|
| boogie |
Post
#1
|
|
Newbie Group: Members Posts: 9 Joined: 12-July 07 Member No.: 1,319 |
Hi,
I'm trying to rotate a cube in two ways, first I rotate from rigth to left (no problem with that) but when I try to rotate from up to down I just can't get it right. I'm posting an example (test.zip) of what I want to do with Sandy (This example is not done with Sandy), and also I'm posting what I'm getting with sandy sandy_tes.swf. To rotate the cube in sandy i'm using these two methods: public function rotateRight(){ _iniHAng = _endHAng _endHAng += 60 _rotint = new RotationInterpolator( _myEase.create(), 50 ,_iniHAng,_endHAng); _rotint.setAxisOfRotation(new Vector(0,-1,0)); _cubo.setTransform( _rotint ); } // THIS IS WHAT I'M NOT GETTING RIGHT public function rotateDown(){ _iniVAng = _endVAng _endVAng += 90 _rotint = new RotationInterpolator( _myEase.create(), 50 ,_iniVAng,_endVAng); _rotint.setAxisOfRotation(new Vector(-1,0,0)); _cubo.setTransform( _rotint ); } Any help will be apreciated, thanks (IMG:style_emoticons/default/biggrin.gif) Attached File(s) |
| Petit |
Post
#2
|
|
Advanced Member Group: Moderator Posts: 587 Joined: 21-June 06 From: Borgholm, Sweden Member No.: 38 |
Hi, I'm trying to rotate a cube in two ways, first I rotate from rigth to left (no problem with that) but when I try to rotate from up to down I just can't get it right. I I'm not at all certain about this, but I think it may be because your'e using the same RotationInterpolator for both rotations. Maybe you should add your cube to a TransformGroup and set one RotationInterpolator to that, add it to another TransformGroup and let it have another RotationInterpolator, one for each direction. |
| boogie |
Post
#3
|
|
Newbie Group: Members Posts: 9 Joined: 12-July 07 Member No.: 1,319 |
I'm not at all certain about this, but I think it may be because your'e using the same RotationInterpolator for both rotations. Maybe you should add your cube to a TransformGroup and set one RotationInterpolator to that, add it to another TransformGroup and let it have another RotationInterpolator, one for each direction. Hi Petit, You were right (as allways (IMG:style_emoticons/default/tongue.gif) ) I need to add one Transf. into the other transf. Any way hereare the two moves (just in case any body is interested on it) CODE var trans1:Transform3D = new Transform3D(); var tg1:TransformGroup = new TransformGroup(); var trans2:Transform3D = new Transform3D(); var tg2:TransformGroup = new TransformGroup(); tg1.addChild( cube ); tg2.addChild( tg1 ); bg.addChild( tg2 ); ..... // first I rotate 60 degrees from left to right function rotateLeft(){ y+=60 trans1.rotAxis(new Vector(0,-1,0),y); // this is the same as ==> trans1.rotY(y) tg1.setTransform(trans1); } // then I start moving the cuber down by 15 degrees function rotateDown(){ x+=15 trans2.rotAxis(new Vector(Math.sin(Math.PI/3),0,Math.sin(Math.PI/6)),x) // vector(sin(60º),0,sin(30º)) tg2.setTransform(trans2); } |
| boogie |
Post
#4
|
|
Newbie Group: Members Posts: 9 Joined: 12-July 07 Member No.: 1,319 |
CODE // then I start moving the cuber down by 15 degrees function rotateDown(){ x+=15 trans2.rotAxis(new Vector(Math.sin([b]Math.PI/6[/b]),0,-Math.sin([b]Math.PI/3[/b])),x) // vector(sin([b]30º[/b]),0,sin([b]60º[/b])) tg2.setTransform(trans2); } |
| Petit |
Post
#5
|
|
Advanced Member Group: Moderator Posts: 587 Joined: 21-June 06 From: Borgholm, Sweden Member No.: 38 |
Hi Petit, You were right (as allways (IMG:style_emoticons/default/tongue.gif) ) I need to add one Transf. into the other transf. Happy you solved the problem. Always is too often (IMG:style_emoticons/default/cool.gif) [ Two things about the forum: You *can* edit your own post ( I did that ) By enclosing code in code tags, you separate code from other text - you do that by selection the code and pressing the # button. ] Cheers! /Petit |
| Lo-Fi Version | Time is now: 10th August 2007 - 02:54 AM |