3D need help with 3d instance orbiting around another, like Earth and Moon

T

tiestolord

Guest
hi everyone,

I manage to make a lot 3D stuff as newbie, but i didn't manage to make a moon or another 3d object to orbiter around any given object. I would be grateful for any good tip. :D

I now it has something to do with d3d_translation, every time i do something my self, it spins only. -.-
 
The easiest way is to just offset the drawing portion. For example,

d3d_transform_set_rotation_z(rot);
d3d_transform_add_translation(x,y,z);
d3d_model_draw(moon,0,0,0,tex);

will spin the moon around in one spot, but

d3d_transform_set_rotation_z(rot);
d3d_transform_add_translation(x,y,z);
d3d_model_draw(moon,100,0,0,tex);

will orbit it around x, y, and z.
 
T

tiestolord

Guest
im at the work now, il test later. So what im understandig here is, that model draw is where he gona be, and when i put in steps code, he will automatically orbit around x,y,z. no need for extra radius or distance code for that?
 
The translation handles where an object's drawing position will originate from. The actual drawing position is the offset from that translation origin. You could also just use math in the translation part to offset it from a different place (the lengthdir functions, for example) but it depends on the final effect you're looking for.
 
T

tiestolord

Guest
i still cant get it, here is my code, i dont use 3D camera, just normal 2d camera. That means when Z is -360 its in front of Planet. how to make moon to circle around the planet?


EDIT: i manage to make it circle around planet, but its now perfect 360 around planet.

EDIT 2: i manage to make it, it works like charm. Thank you very much BattleRifle, i lost 1h just to make it perfect circle and i saw then lengthdir_y and put it on Z axis and voila. It circle full 360 around planet.
:D:D:D:D:D:D:D:D:D:D:D:D


d3d_transform_add_translation( Planet.x+lengthdir_x(360,rot), Planet.y,
lengthdir_y(-360,rot));
 
Last edited by a moderator:
Top