2 of 4
2
Touchlib rotate scale bug
Posted: 17 June 2008 06:43 PM   [ Ignore ]   [ # 16 ]
New Member
Rank
Total Posts:  87
Joined  2007-10-23

Wow...well when trying to alter the dynamic registration class to use a matrix method I came across an anoying bug in flash. Once you apply certain transformations using a transform matrix some of the normal properties of a display object, in my particular case scaleY, returned 0 or a wrong value. Hmm....I’m not sure if this bug will reappear when the rotate scale class is modified. It sure is a pain!

Profile
 
 
Posted: 17 June 2008 07:19 PM   [ Ignore ]   [ # 17 ]
New Member
Rank
Total Posts:  31
Joined  2007-07-10
weyforth - 17 June 2008 06:43 PM

Once you apply certain transformations using a transform matrix some of the normal properties of a display object, in my particular case scaleY, returned 0 or a wrong value.

I’m developing on flex and the scaleX and scaleY maintain the asigned value regardless the transformation aplied with the transform matrix. Instead, rotation change with the transformation.

Profile
 
 
Posted: 18 June 2008 10:29 AM   [ Ignore ]   [ # 18 ]
New Member
Rank
Total Posts:  87
Joined  2007-10-23

Hey I implemented the matrix methods into the dynamic registration class so I could do some accurate testing. I spend all day yesterday and half of today trying my best to get the best performance out of each method, and the results can be seen below. It turns out the matrix methods are slightly slower than the methods used in the original dynamic registration class, which I wasn’t really expecting, but the difference is very slight as I had to increase the number of tests to identify it. So if you are only performing a few operations the difference should be negligible. Anyway I hope these test results are of some use. If anyone wants the modified dynamic registration class or the test fla just say smile

DYNAMIC REGISTRATION METHOD TEST
------------------------------------------------------------------
10 identical transformations, scaling rotating and moving, performed on two sprites using different dynamic registration classes. Set of transformations repeated 10000 times on each sprite

TEST #1
original class:  625 ms
matrix class:  670 ms

TEST #2
original class:  624 ms
matrix class:  672 ms

TEST #3
original class:  624 ms
matrix class:  678 ms

TEST #4
original class:  618 ms
matrix class:  672 ms

TEST #5
original class:  658 ms
matrix class:  677 ms

TEST #6
original class:  621 ms
matrix class:  680 ms

TEST #7
original class:  600 ms
matrix class:  689 ms

TEST #8
original class:  598 ms
matrix class:  694 ms

TEST #9
original class:  612 ms
matrix class:  698 ms

TEST #10
original class:  594 ms
matrix class:  699 ms

RESULTS (AVERAGE OVER 10 TESTS)
------------------------------------------------------------------
original class:  617.4 ms
matrix class:  682.9 ms

Profile
 
 
Posted: 18 June 2008 12:22 PM   [ Ignore ]   [ # 19 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  1356
Joined  2007-04-08

Of course we would like the class/fla. I haven’t had time to test this yet, but by the end of next week I hope to have a version commited to the svn. So if one of you already have a whole class that just needs to be tested/committed without changes, please post it so I can test and commit ASAP.

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 18 June 2008 01:06 PM   [ Ignore ]   [ # 20 ]
New Member
Rank
Total Posts:  87
Joined  2007-10-23

Attached are the two classes, old and new, along with the fla I used to test them. I also included the Consts class as I think I put it in a different location to the original in the SVN. Sorry about the state of the modified class, I optimized it so that it runs as quick s possible, so If you need any help understanding or commenting it just say. There are alos a few extra features in the classes that aren’t in the original dynamic registration class, such as the centreRegistration function. enjoy

File Attachments
Dynamic Reg Test.zip  (File Size: 9KB - Downloads: 62)
Profile
 
 
Posted: 18 June 2008 01:45 PM   [ Ignore ]   [ # 21 ]
New Member
Rank
Total Posts:  31
Joined  2007-07-10

There is a problem with the matrix transform method. When used, the scaleX, scaleY, width and height remain unchanged and in certain cases we need to know the changed width and height. This is due to the design of DisplayObject and UIComponent (I’m working in flex, so Multitouchable extends UIComponent and UIComponent extend DisplayObject). DisplayObject have the properties transform, scaleX, scaleY, width, height and rotation and UIComponent have the same properties but transform and rotation. When we change the transform property, this change the DisplayObjetc.scaleX, DisplayObject.scaleY, DisplayObjetc.width, DisplayObjetc.height and DisplayObjetc.rotation. UIComponent only extend rotation and the other properties are reimplemented in UIComponent, so any change to DisplayObject.scaleX doen’t reflect on UIComponent.scaleX.

This is my changed code. You can add this function to the dynamic registration class:

public function doTransform(dx:Numberdy:Numberda:Numberds:Number):void
{
    this
.+= dx;
    
this.+= dy;
    
    var 
rp:Point = new Point(this._x2this._y2);
    var 
a:Point this.parent.globalToLocal(this.localToGlobal(rp));
    
    
this.scaleX *= ds;
    
this.scaleY *= ds;
    
    
callLater(finishDoTransform[rpada]);
}

private function finishDoTransform(rp:Pointa:Pointda:Number):void
{
    this
.rotation += da;
    
    var 
b:Point this.parent.globalToLocal(this.localToGlobal(rp));
    
    
this.-= b.a.x;
    
this.-= b.a.y;
}

The finishDoTransform is only needed in flex if extend UIComponent.

Profile
 
 
Posted: 19 June 2008 03:46 AM   [ Ignore ]   [ # 22 ]
Administrator
Avatar
RankRank
Total Posts:  204
Joined  2007-04-03

*bookmark*

looks very interesting smile

 Signature 

My multitouch blog: http://www.multigesture.net
Howto: Compile touchlib on windows XP/Vista
Howto: Compile touchlib on Ubuntu Linux
Downloads: Touchlib SVN builds

Profile
 
 
Posted: 19 June 2008 10:53 AM   [ Ignore ]   [ # 23 ]
New Member
Rank
Total Posts:  24
Joined  2008-04-01

Indeed! I agree with the Falcon.

 Signature 

canTouch tangible interfaces - Amsterdam - http://www.cantouch.nl

Profile
 
 
Posted: 20 June 2008 12:45 PM   [ Ignore ]   [ # 24 ]
New Member
Rank
Total Posts:  87
Joined  2007-10-23

Just a quick note about the two different methods, I’m kinda leaning more towards the matrix method. I don’t really like the way the original method works, as it is tranforming the object and then afterwards translating it to the position it SHOULD be in. The matrix method makes all these adjustments using a matrix before it uses it to transform the object itself. Much cleaner and less clumsey in my opinion. What about everyone else?

Profile
 
 
Posted: 20 June 2008 12:54 PM   [ Ignore ]   [ # 25 ]
Sr. Member
Avatar
RankRankRank
Total Posts:  265
Joined  2007-09-22

Really funny is that MS’s Surface has the same problem with rotation and zooming out smile) , you can see it in the Live Labs demo video (the Seadragon one with Shadowbox at the end)
When the guy uses the picture app rotating and zooming out , he has the same bug smile) , really funny.

Profile
 
 
Posted: 14 July 2008 02:18 PM   [ Ignore ]   [ # 26 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  537
Joined  2006-11-09

Related Blog Post: http://gasi.ch/blog/zooming-in-flash-flex/

File Attachments
Zooming.zip  (File Size: 5KB - Downloads: 48)
 Signature 

~

Profile
 
 
Posted: 14 July 2008 08:56 PM   [ Ignore ]   [ # 27 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  599
Joined  2008-02-12

Nice find nuiman

Taha

 Signature 

My MultiTouch Blog

Profile
 
 
Posted: 17 July 2008 05:31 PM   [ Ignore ]   [ # 28 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  509
Joined  2008-02-22

I can’t seem it get this to work. weyforth can u help or anyone?

 Signature 

http://www.justinriggio.com cool mad
http://www.niceminds.com My blog

Profile
 
 
Posted: 18 July 2008 07:11 AM   [ Ignore ]   [ # 29 ]
New Member
Rank
Total Posts:  8
Joined  2008-05-24

we took a similar approach to fix the rotate bug using matrix transformations, but are using the TouchLibrary from Mark as a base.
rotating looks way better now *smile*

btw: it’s quite exhausting to read the svn code of touchlib with all these cc-fixes, dead code blocks and no doc.
any chance of getting someone to clean up a little? smile

Profile
 
 
Posted: 18 July 2008 10:23 AM   [ Ignore ]   [ # 30 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  509
Joined  2008-02-22

Do you have a class for marks libary?

 Signature 

http://www.justinriggio.com cool mad
http://www.niceminds.com My blog

Profile
 
 
   
2 of 4
2