jPCT-AE - a 3d engine for Android > Support
Object3D rotation around another object
aerosolswe:
Hello.
So I am really new with jpct-ae (and only been programming for 1yr). I am currently working on my first app with it, so far loving it. But I've struggled with this task all night and I cant seem to get it work.
The game plays out in the solar system and atm I am making the planets orbit around the sun but I cant find a good way to do this. Tried some with sin and cos but nothing really worked.
So I am wondering if anyone else got some tips for me how I am suppose to do this.
Appreciate all the help and tips. Thanks.
EgonOlsen:
You can set a dummy object (http://www.jpct.net/doc/com/threed/jpct/Object3D.html#createDummyObj()) in the sun's center (or one for each planet), make it a child of the planet and rotate the dummy around Y to make the planet orbit the sun.
aerosolswe:
Thank you egon, I will have a go with that
phmenard:
I took your advice and its not working ... I do this in
onSurfaceChanged()
--- Code: ---center = Object3D.createDummyObj();
center.translate(sol[0].getTransformedCenter());
center.build();
earth[0].translate(0, 50, 0);
earth[0].setTexture("texture");
earth[0].addChild(center);
--- End code ---
and in onDrawFrame()
--- Code: ---center.rotateY(1f);
--- End code ---
but nothing happends ... whats am I doing wrong?? the sol and earth objects are loaded obj models.
EgonOlsen:
The earth should be the child of the center to make this work, not the other way.
Navigation
[0] Message Index
[#] Next page
Go to full version