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

#### ggp

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

#### ggp

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

#### EgonOlsen

• Posts: 11777
##### Re: How rotate object around pivot?
« Reply #2 on: February 18, 2012, 10:19:30 pm »
By setting a rotation pivot using Object3D.setRotationPivot()...

#### ggp

• byte
• Posts: 39
##### 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);
}

#### EgonOlsen

• Posts: 11777
##### 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.

#### ggp

• byte
• Posts: 39
##### 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.setLighting(Object3D.LIGHTING_NO_LIGHTS);
earthsetTransparency(7);
earth.setBillboarding(true);
earth.shareCompiledData(dummyPlane);
earth.build();
earth.strip();
earth.translate(0.22f,-25, -0.12f);

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 »

#### EgonOlsen

• Posts: 11777
##### 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());`

#### ggp

• byte
• Posts: 39
##### 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?.