Author Topic: How rotate object around pivot?  (Read 5464 times)

Offline ggp

  • byte
  • *
  • Posts: 39
    • View Profile
How rotate object around pivot?
« on: February 18, 2012, 09:27:32 pm »
How rotate object around pivot?
example:  earth=obj , Sun=pivot.

Offline ggp

  • byte
  • *
  • Posts: 39
    • View Profile
Re: How rotate object around pivot?
« Reply #1 on: February 18, 2012, 09:36:19 pm »
or example "Multiple light sources".

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How rotate object around pivot?
« Reply #2 on: February 18, 2012, 10:19:30 pm »
By setting a rotation pivot using Object3D.setRotationPivot()...

Offline ggp

  • byte
  • *
  • Posts: 39
    • View Profile
Re: How rotate object around pivot?
« Reply #3 on: February 18, 2012, 10:27:33 pm »

earth.setRotationPivot(pivotsun);

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


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How rotate object around pivot?
« Reply #4 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.

Offline ggp

  • byte
  • *
  • Posts: 39
    • View Profile
Re: How rotate object around pivot?
« Reply #5 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);

}
             
« Last Edit: February 19, 2012, 02:22:00 pm by ggp »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How rotate object around pivot?
« Reply #6 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());

Offline ggp

  • byte
  • *
  • Posts: 39
    • View Profile
Re: How rotate object around pivot?
« Reply #7 on: February 24, 2012, 08:35:40 pm »
Thank You EgonOlsen, Worked perfect. But,is possible attach light to Dummy?.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How rotate object around pivot?
« Reply #8 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.