Animate a cube to rotate around x axis!!!

Hi! I'm trying to animate a cube to rotate around x axis using RotationInterpolator object.
Can anyone kindly tell me how I can do that? I've seen the example at Sun's 3d tutorial but they use the default behavior which is rotating around y axis.
Thanks in advance.
--DM

lol
in fact the axis used in the RotationInterpolator is the one which is on the y axis in the local coordinates system obtained after the Transform3D is performed
for example:
- if you use only new Transform3D(), which does nothing, the axis will be y
- but if you use rotz(), this transform3D transforms the old x axis into the new y one, the old y axis into the new -x one and the old z axis into the new z one. Thus in the new local coordinates system obtained, the new y axis matches the old x axis, so this x axis is used for the interpolator
I don't know if I'm very clear, it's difficult to explain and I'm French ;)
see the java 3D API :
http://java.sun.com/products/java-media/3D/forDevelopers/J3D_1_3_API/j3dapi/javax/media/j3d/RotationInterpolator.html#RotationInterpolator(javax.media.j3d.Alpha, javax.media.j3d.TransformGroup, javax.media.j3d.Transform3D, float, float)

Similar Messages

  • How to limit rotation around an axis

    Hello!
    I am using Mouse Rotate to rotate an object around it's axis:
    MouseRotate mouseRotate = new MouseRotate();
    mouseRotate.setTransformGroup( sectionTransform );
    mouseRotate.setSchedulingBounds( new BoundingSphere() );
    mouseRotate.setFactor( 0, 0.3 );
    Currently it rotates 360 degrees, but I would like to be able to limit the rotation angle to say 180. Could you please help me out?
    Thanks!
    Anna.

    You might want to consider creating your own behaviour. It depends on your implementation, but if you have a Transform group above the object, you can get the transform and get the rotation values from that transform. It will take a bit of math, but here's a primer to get you started...
    http://www.martinb.com/maths/geometry/rotations/conversions/index.htm
    http://www.martinb.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm
    so if you calculate the angle around a particular axis from that transform and it is "greater" than the limit, then you can just set the transform's rotation angle to the limit by reconstructing a new transform and placing that transform in the transform group.
    Anyway, I dont know if that helps. It really depends on what you have as far as implementation thus far. My best suggestion is to try to create your own rotation behaviour.
    Cheers,
    Greg

  • Having trouble with multiple rotations around an objects poles

    Hey all, i am new to java 3d (only started coding today) but i have been coding in Java for a while..
    I am having a problem understanding how to perform the rotations i want to. I have read the majority of the literature i can find on performing these kinds of rotations. I realise that i need to have correctly linked nodes in the graph so that i am rotating around the correct points and i think i have accomplished this. However, i cannot get the system to rotate around the objects poles. To clarify, i can get the object to rotate around one of its poles (x , y, z) in some cases but trying to do multiple rotations causes problems.
    import javax.media.j3d.Appearance;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.ColoringAttributes;
    import javax.media.j3d.PolygonAttributes;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import javax.vecmath.Color3f;
    import javax.vecmath.Vector3f;
    import com.sun.j3d.utils.geometry.ColorCube;
    import com.sun.j3d.utils.geometry.Cylinder;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    public class TestRotation
         private TransformGroup objectTranslateGroup, objectRotationGroup;
         private Transform3D translate = new Transform3D(); private Transform3D  rotX = new Transform3D();
    private Transform3D rotY = new Transform3D()
    private Transform3D rotZ = new Transform3D();
         private double rotationX, rotationY, rotationZ, newRot = 10;
         private SimpleUniverse u;
         public TestRotation()
              // Create the root of the branch graph
              BranchGroup objRoot = new BranchGroup();
              rotationX = 0; //init rotations
              rotationY = 0;
              rotationZ = 0;
              ColorCube cube = new ColorCube(0.25f);
              Appearance x = new Appearance();
              Appearance y = new Appearance();
              Appearance z = new Appearance();
              x.setColoringAttributes(new ColoringAttributes(new Color3f(1,0,0),ColoringAttributes.SHADE_GOURAUD));
              y.setColoringAttributes(new ColoringAttributes(new Color3f(0,1,0),ColoringAttributes.SHADE_GOURAUD));
              z.setColoringAttributes(new ColoringAttributes(new Color3f(0,0,1),ColoringAttributes.SHADE_GOURAUD));
              Cylinder poleX = new Cylinder(0.02f, .75f, x); //RED
              Cylinder poleY = new Cylinder(0.02f, .75f, y); //BLUE
              Cylinder poleZ = new Cylinder(0.02f, .75f, z); //GREEN
              Transform3D poleXTransform = new Transform3D();
              Transform3D poleYTransform = new Transform3D();
              Transform3D poleZTransform = new Transform3D();
              poleXTransform.rotZ(Math.toRadians(90));
              poleZTransform.rotX(Math.toRadians(90));
              TransformGroup poleXTransformGroup = new TransformGroup(poleXTransform);
              TransformGroup poleYTransformGroup = new TransformGroup(poleYTransform);
              TransformGroup poleZTransformGroup = new TransformGroup(poleZTransform);
              poleXTransformGroup.addChild(poleX);
              poleYTransformGroup.addChild(poleY);
              poleZTransformGroup.addChild(poleZ);
              translate = new Transform3D();
              translate.setTranslation(new Vector3f(0,0,0)); //init position
              rotX.rotX(Math.toRadians(rotationX));
              rotY.rotY(Math.toRadians(rotationY));
              rotZ.rotZ(Math.toRadians(rotationZ));
              objectTranslateGroup = new TransformGroup();
              objectTranslateGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              objectRotationGroup = new TransformGroup();
              objectRotationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              objectRotationGroup.addChild(cube); //add the object to the rotation group
              objectRotationGroup.addChild(poleXTransformGroup); //add the object to the rotation group
              objectRotationGroup.addChild(poleYTransformGroup); //add the object to the rotation group
              objectRotationGroup.addChild(poleZTransformGroup); //add the object to the rotation group
              objectTranslateGroup.addChild(objectRotationGroup); //add the rot group to translate group
              objRoot.addChild(objectTranslateGroup); //add to root
              u = new SimpleUniverse();
              u.getViewingPlatform().setNominalViewingTransform();
              u.addBranchGraph(objRoot);
              this.begin();
         private void begin()
              while(true)
                   //rotationX += newRot; //rotate slightly
                   rotationY += newRot;
                   rotationX += 0; //rotate slightly
                   //rotationY += 0;
                   rotX.rotX(Math.toRadians(rotationX));
                   rotY.rotY(Math.toRadians(rotationY));
                   rotZ.rotZ(Math.toRadians(rotationZ));
                   rotY.mul(rotX); //multiply rotations
                   rotZ.mul(rotY);
                   objectRotationGroup.setTransform(rotZ); //update
                   try {
                        Thread.sleep(300);
                   } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              new TestRotation();
    }As you can see the code is a full class so you can copy and paste it to run it... In the 'begin' method you will notice the variables that update the rotation, currently when the cube rotates on the y axis the cube is rotating around the viewers Y axis and not around the objects y pole. However, if you change the values so the cube is set to rotate around the X axis then it will treat the x axis as the objects x pole and not the viewers x axis. I presume this is because of the multiplication of the matrices.
    What i want to know is how can i set it so that if i say rotate around the y axis it rotates the cube around its y axis (as in the y pole) regardless of where the y pole is. Not only that but i need to be able to rotate around multiple axis ensuring that it is rotating around the objects poles correctly.
    The reason for this is that the object will be turned into an auv (underwater vehicle) fitted with thrusters which are going to turn the vehicle so no matter how the vehicle is positioned (facing up, upside down etc) the thruster always rotate around the same axis on the block.
    Hope this makes sense, sorry for the long post!!
    edd
    Message was edited by:
    edwardr

    Since the 2-Wire gateway is providing both modem and DHCP services, you would want to insure that the Time Capsule is not also configured to provide DHCP services as well.  If this were the case, that would mean two routers are trying to do the same thing on the same network. You only want one device on a network performing as a router.
    The reason for this is that a two router setup is likey to create IP address conflicts on the network, which likely may be your issue.
    To check, open Macintosh HD > Applications > Utiltiies > AirPort Utility
    Click on the Time Capsule icon, then click Edit
    Click the Network tab at the top of the next window
    Insure that the setting for Router Mode is set to Off (Bridge Mode)
    Click Update to save the correct setting
    Then power cycle the entire network by powering off all devices in any order that you want
    Wait a minute
    Start the 2-Wire gateway first and let it run a minute by itself
    Start the Time Capsule next the same way
    Continue starting devices the same way until everything is powered back up.
    Power off the entire network...all devices...and wait a minute

  • Rotation about ANY axis

    Hi all !!!
    I am a novice to 3d programming but i have done some JAVA programming earlier.
    The problem i am finding is that I do not know how to rotate any geometric object (say, a cylinder or a cone) about any arbitrary axis, say ax+by+c=0.
    Can anybodyhelp me ???
    Thanks in advance.
    Ajay

    I am pretty sure I know what you are talking about.
    //Create the Object
    //Create a transform group for your object
    TransformGroup tg = new TransformGroup();
    // Now you need to make a Transform3D to do the rotational work
    Transform3D tr = new Transform3D();
    //To rotate around any axis use setRotation and pass
    // is a Quat4D (or f,i)
    // Quat takes 4 arguments x,y,z,w use the x,y and z to
    // create a vector to rotate around. i.e. (0,1,0,.4) would
    // rotate arount the Y axis, (1,1,0, .4) would rotate
    // around a line between x,y.
    // The W in the Quat is the angle to rotate (in Radian 0-2Pi);
    //So ...
    tr.setRotation( new Quat4d(1,1,0,.4));
    tg.setTransform(tr);
    //Add your object to your transform group
    tg.addChild(your_object);
    //Add your TRansformGroup to the world
    root.addChild(tg); //or whatever your BranchGroup is called
    I hope that is what you wanted. And does what you need.

  • How to make a still picture rotate around a vertical axis ?

    H there,
    Can I know how do I make a still picture rotate around a vertical axis ?
    Thanks

    Thanks MTD,
    It is indeed one good trick ...
    From your timeline, it seems that you applied a transition after each clip. Can I know why & what transition you applied ?
    Can you please elaborate what you meant by "I changed the last keyframe in the last clip to a Smooth" ?
    Thanks again ...
    Cheers
    Meg The Dog wrote:
    Hi -
    While Mr. Wolsky is absolutely correct that you need the other software to do the effect you describe correctly, I believe you can make an approximation of what you want using FCE. Whether or not it passes the smell test is up to you.
    You can see a clip I made [HERE|http://www.spotsbeforeyoureyes.com/3DTurn_Example.mov]
    Because when you rotate the frame 360 degrees using the Y-axis, the image always comes back to the same position - which gives you a handy place to match cut to the next implementation of the rotation at a slightly slower pace. The last rotation was smoothed to a stop by modifying the filter keyframe to "Smooth".
    So (not acounting for the pad video at the head and tail of the clip, a 1 second clip, followed by a 2 second clip, followed by a 4 second clip to give me a 7 second move.
    !http://www.spotsbeforeyoureyes.com/3dTurnTimeline.jpg!
    I applied the filter to the first clip, and set it so that it went from -360 to 360 in Y axis rotation. I then copied that clip and used Command -V to apply the same effect to the next to clips via paste attributes, UNCHECKING the Scale Attribute Times so that the spinning would slow down as the clips lengthened.
    Lastly, I changed the last keyframe in the last clip to a "Smooth" , and added head and tail trim to the entire effect so the bars would start static, spin and the end static.
    Like I say, it's far from perfect but may either point you toward a solution or trigger ideas of your own.
    MTD

  • Javascript function to rotate an object around its axis

    Hello,
    I wonder if it is possible to rotate an object around its axis (eg 45 ° rotation)?
    I want to make this rotation with a button and a Javascript code!
    Is it possible? if so, have a track for me to start?
    thank you

    Possible, yes - but you will need some basic knowledge of how 3D matrix transformations work if you want to do anything complex.
    The code to rotate a node in a 3D scene by 45 degrees on the X axis is
    myNode.transform.rotateAboutXInPlace(Math.PI/4)

  • Model rotation about multiple axis

    Can anyone tell me how I can limit the rotation of a model to
    a specific angle without using camera rotation?
    I do know how to limit the rotation when the model has only
    been rotated in one axis (simple maths comparison of either x, y,
    or z depending on which axis I've rotated the model about).
    But, how do you limit rotation when the model has already
    been rotated about 1 or 2 of the other axes given that x, y, and z
    keep changing their values and axisAngle doesn't always give
    appropriate values?

    Using parent/childs is one way to work around relative
    rotation problems. Parent the model you are trying to limit
    rotation on to a dummy model (or group). Keep the dummy at
    rotation(0, 0, 0), and rotate the target model to its correct
    orientation in your scene. Then monitor the dummy's rotation to
    keep it within your limits.

  • How do you rotate around a local point?

    Hi,
    I'm having problems using RotationInterpolators.
    I'm trying to build a 3d figure and animate it. I can use pickRotate behaviours to rotate the different limbs around their local centres, but I'm now trying to do it via the RotationInterpolator and every time they get moved to the central point of the whole scene, and rotated around this, rather than that of their own TransformGroup.
    I have a BranchGroup (objRoot), and a TransformGroup for the entire figure (figTrnsGrp), which is the child of objRoot, and is centred. The children of figTrnsGp are a cylinder (the figure's upper chest), and four TransformGroups - one each for the neck, pelvis, left shoulder, and right shoulder. These in turn have their own TransformGroup children which deal with the other parts of the body. I added the RotationInterpolator as a child of the TransformGroup I want it to rotate.
    So, for example, I want the pelvis to rotate around its own centre (taking the legs with it, which it does, but it gets moved up and rotated around the centre of the figure!). Actually, i can't work out if it's being rotated round the figure centre, or the scene centre, but anyway it's not doing what i want it to and I've been trying different things for days, and none of them work, so if anyone can PLEASE help, i'd really appreciate it!
    I think the problem may be that the Transform3D which is passed to the RotationInterpolator is somehow being reset in the process, but I still can't work it out.
    Here is some of the code:
    pelvisT3D = new Transform3D();
    pelvisT3D.setTranslation(new Vector3f(0.0f, -0.4f, 0.0f));
    pelvisTrnsGrp = new TransformGroup(transformPelvis);
    pelvisTrnsGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    pelvisTrnsGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    figTrnsGrp.addChild(pelvisTrnsGrp);
    Sphere pelvis = new Sphere(pelvissize);
    pelvisTrnsGrp.addChild(pelvis);
    Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 7000, 0, 0, 0, 0, 0);
    pelvisTrnsGrp.getTransform(pelvisT3D);
    RotationInterpolator r = new RotationInterpolator(alpha,
    pelvisTrnsGrp, pelvisT3D, 0.0f, 3.0f);
    r.setSchedulingBounds(behaveBounds);
    pelvisTrnsGrp.addChild(r);
    many thanks to anyone who can help...

    Hi
    The problem is indeed that the RotationInterpolater will reset the transform to the identity before adding the rotation. The solution is to have your pre-animation transforms in one TransformGroup, and have another TransformGroup below that the interpolater acts on.
    BranchGroup-TransformGroup-TransformGroup-Shape3D
    ^ ^
    Your translations Attach the
    go here Interpolator here
    B.D.

  • Rotation around global coordinates?

    hey, i wanna to make an animation of camera. the situation looks in this way:
    i have a box in center of global coordinates and i want to make a rotation of camera around y axis (y of global coord.). when i use setOrientation(...) it makes a rotation around local coordinates of camera. how change it if i want to rotate it with global coordinates? im completly new in 3dmobile, i tried to found any solutions with api documenation but i couldnt :(. i have to make it quickly so i dont have time to read all spec.
    please help me!
    thanks in advance

    ok nevermind :]

  • Rotation around a different point

    I have a geometry that I am scaling and translating to appear in the center of my screen. It is still rotating around the original 0,0 axis. How can I change where the rotation center point is

    Rotations in 3D graphics is a bit weird. Help me explain...
    Take a blank piece of paper, and draw a little dot on it, roughly in the middle.
    Put the page down in front of you on a flat surface.
    The dot represents 0, 0, 0
    Take a small object (I took a memory stick) and place it anywhere on the piece of paper. This represents your 3D object.
    Now, in real life, if you want to have your object spin around in place, you'd simply turn it with your finger. On the other hand, to have your 3D model spin like that, things work a bit differently.
    Close your eyes.
    Remember where on the paper your object is, and its orientation. Pick it up and place it down on the dot (at 0, 0, 0), but keep it facing in exactly the same way it was when you picked it up. This is step 1 of your rotation sequence.
    Next, turn it a little bit in any direction. This is step 2 of the sequence.
    Now, place it back where it was on the page, but now facing in the "new" direction. Step 3.
    Finally, open your eyes. Step 4. You have now rendered the rotated object and it appears to have spinned in place.
    Repeat steps 1 - 4 and you'll have an animated 3D object.
    Now, to have that object orbit an arbitrary point in space, the same sequence as above must be followed, except for one modification to the first step. In stead of the center of rotation coinciding with the center of the object, it now lies some distance off in some direction.
    That new center of rotation is the point which must be moved (translated) to the dot (origin). When you perform your rotation, the object will "swing" around the new point (which now lies at 0, 0, 0). When you translate the point back to where it came from, and then display that frame, it will appear as if the 3D object's rotation had taken place around your intended center of rotation, or as you call it, your "different point".
    I hope you now understand the most basic concept of 3D rotation, and that you will be able to translate these thoughts into working code :)

  • How can I get an object to rotate around another object in Motion 5? Also, can I export on a transparent background to FCPX?

    Attempting to make one .png (its and arrow) rotate around a circlular logo which is also a .png. I need to them come out of Motion 5 for FCPX on a transpartent background. Anyone have any help for me. Stuck on this for hours now.

    Thanks Russ...
    I spend severale hours (new to Motion) trying to figure out how to set the orbit around the cicular logo. I was able to finally get it. I was missing the square under the orbit behavior that I could plug in the circular logo. lol... Once I got that set, I added to the align to motion behavior and set the drag to that behavior to get it all to rotate and work right. I then published as a generator to FCPX. After setting the background to transparent.
    Works like a charm. Just took most of my day trying to figure it out. lol.. But thats how you learn I guess.
    Thanks for the reply!

  • Wind Shake Effect Around Z Axis

    I would like to create a "Wind Shake Effect Around Z Axis". I have a image of the leave in vertical position standing on its stem and would like it to have an appearance as if it trembles in the wind.
    I applied Wiggle effect. However it wiggles/distorts in all possible directions but the Z axis. What would be my course of actions/direction to try to emulate a slight rapid shake around the Z axis in the front veiew.
    In other words you look at the leave and see its right edge coming at you and left edge away of you and then in reverse. Pritty much like skewing in 3D with exception of X and Y axis.
    I use AE CS6 on Windows.

    Thank you for your reply.
    Looks like I will need step by step direction as I was not able to successfully implement your suggestion.
    Here is what I tried.
    1. With the Wiggle Gelatin effect applied to my "Leaf" layer and 3D turned on I clicked "P" on the keyboard which opened Position in under layer's "Transform". Holding down "Alt" I pressed stop watch on the Position and entered your code:
        seedRandom(index, true)
        leafJitter=wiggle(3,30);
        leafJitterZ=leafJitter[2];
    I got this error message:
         After Effects warning: Class'Array" has no property or methid named '2'
        Expression disabled.
        Error occured at line 3.
        Comp:'shake leave test'
        Layer:1 ('Green2')
        Property;'Position'
    2. Same as all of the above, but I selected "Position" under "Effects" of the layer and got this error message:
         After Effects warning: expression result must be of demension 3, not 1
        Expression disabled.
        Error occured at line 0.
        Comp:'shake leave test'
        Layer:1 ('Green2')
        Property;'Position'
    3. I deleted the Wiggle Effect all together and applied you three lines of code ot Position. This produced no results.
    Please let me know where I messed up or you need more specific info on my set up?

  • Rotation and Z axis tracking

    Here's my test:
    http://media.putfile.com/shaketrack
    As you can see, X and Y tracking work fine.
    However, how can I do rotation and Z axis tracking?

    You need a two point track and you need to tell Shake to interpret the information as rotation, size, or both...
    Patrick

  • Rotate to z axis

    How to use Behavior to rotate to z axis?

    You are so brief, this is the best I can tell you:
    Use a Transform3D that you put into a TransformGroup node placed over the brach that has to be rotated, and make your behaviour create a new Transform3D o change the already existing one and then set whichever of both you choose, again in the TransformGroup. This basically descrives the general method to change a trasnformation, just make your behaviour do it on your own criteria (on key presses, mouse movement, time, etc.)
    Anyway there are some predefined behaviours you could benefit from, check the tutorials.
    Regards

  • 3D rotate around a circle preset ae6

    Hello thanks for looking in..
    I am messing with the (3D rotate around a circle) preset in AE6 and if you notice that the Browse Preset feature shows the 3D text completing a circle.. Yet, When I create a text layer, apply the preset effect there is a gap from the end of my last word typed to the start of the word typed.
    IE: TV Bug TV Bug TV Bug TV Bug  (space) beginning of TV Bug instead of looking as the preset does in Browse Presets. TV Bug in a complete circle and spaced evenly.
    I hope this is making sense...I want the "g" in Bug to be spaced as a contiunued circle, so that Last "g" in Bug should butt up to the first "T" in TV. As it stands now I type it out and apply the preset and there is a huge space between the last "g" in Bug and the first "T" in TV.
    What do I need to mess with too get the ends to meet?
    I added a couple of pics to help describe:
    First one is the preset
    2nd one is my challnege of the ends not meeting
    Thanks again
    NC

    RG thanks again for hopping in here. You are a great help and I am thankful to have you perusing these forums.  I did get it to work. Although I do have a question or two about adding one keyframe to create a seemless loop.
    1. I add one frame via End > Page Down. However, I am unclear on where to park the last keyframe to make it a seemless loop? I ended up adjusting the First Margin on that effect to get it to start at the point I desire and then hit END to place the last KeyFrame. I of course made my last keyframe spot on where it starts as to not have a "Jump" in text when it restarts.....
    2. The other thing is the effect on that goes from one speed and slows to a stop and then of course starts again when going back to the beginning. I used Ease In and Ease out however I do not have control over the speed. IE: One speed throughout... Any suggestions on that one RG?
    Regards
    NC

Maybe you are looking for