www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: ggp on February 18, 2012, 09:27:32 pm

Title: How rotate object around pivot?
Post by: ggp on February 18, 2012, 09:27:32 pm
How rotate object around pivot?
example:  earth=obj , Sun=pivot.
Title: Re: How rotate object around pivot?
Post by: ggp on February 18, 2012, 09:36:19 pm
or example "Multiple light sources".
Title: Re: How rotate object around pivot?
Post by: EgonOlsen on February 18, 2012, 10:19:30 pm
By setting a rotation pivot using Object3D.setRotationPivot()...
Title: Re: How rotate object around pivot?
Post by: ggp on February 18, 2012, 10:27:33 pm

earth.setRotationPivot(pivotsun);

//no rotate
onDrawFrame(GL10 gl) {
   earth.rotateY(2);
}

Title: Re: How rotate object around pivot?
Post by: EgonOlsen on February 18, 2012, 11:21:56 pm
??? And the question is...??? That's not the complete code, isn't it? What do you expect it to do, what does it do? You can be sure that a call to rotateY(...) DOES rotate the object.
Title: Re: How rotate object around pivot?
Post by: ggp on February 19, 2012, 02:13:30 pm
With  earth.setBillboarding(true); not working,  without  earth.setBillboarding(true);  works!!!

Here the code:

                                earth= new Object3D(dummyPlane, true);
            earth.setTexture("glow");
            earth.setAdditionalColor(RGBColor.WHITE);
            earth.setLighting(Object3D.LIGHTING_NO_LIGHTS);
            earth.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
            earthsetTransparency(7);
            earth.setBillboarding(true);
            earth.shareCompiledData(dummyPlane);
            earth.build();
            earth.strip();
                                earth.translate(0.22f,-25, -0.12f);

                                world.addObject(earth);
                                 
                             


            public void onDrawFrame(GL10 gl) {
         try {
            
         
            SimpleVector pivotsun= new SimpleVector();
         
            pivotsun.x = -20;
            pivotsun.y = -25;
            pivotsun.z = -13;
            
            earth.setRotationPivot(pivotsun);
            //earth.getTransformedCenter(pivotsun);
            //earth.translate(pivotsun);
            earth.rotateY(0.05f);

}
             
Title: Re: How rotate object around pivot?
Post by: EgonOlsen on February 19, 2012, 10:05:31 pm
That's because bill boarding replaces the actual rotation matrix...hmmm...try to use dummy objects instead. Object3D has a static method to create a dummy object. Place dummies with the correct rotation pivot at the location where you want the bill boards to be rendered and then do something like:

Code: [Select]
bill.clearTranslation();
bill.translate(dummy.getTranslation());
Title: Re: How rotate object around pivot?
Post by: ggp on February 24, 2012, 08:35:40 pm
Thank You EgonOlsen, Worked perfect. But,is possible attach light to Dummy?.
Title: Re: How rotate object around pivot?
Post by: EgonOlsen on February 24, 2012, 10:08:35 pm
No, not directly. You have to set the light's position to the dummy's translation in code.