# Rotating A Sphere

7 replies to this topic

### #1 JJProductions

JJProductions

Agamma Corpus

• New Member
• 2211 posts

Posted 21 December 2006 - 07:48 PM

I'm kind of lost as to how to roatate a sphere in 3d. I tried setting the transform origin as the x and y of the middle of the sphere, then adding a transform to the z axis and it does rotate, just the center slowly grows off and so the ball will end up rotating through floors and mid-air.
• 0

### #2 ragarnak

ragarnak

GMC Member

• Retired Staff
• 19468 posts
• Version:GM8

Posted 21 December 2006 - 08:12 PM

just the center slowly grows off and so the ball will end up rotating through floors and mid-air.

<{POST_SNAPBACK}>

And you really think we can answer such a question without us being able to look at what you wrote ?

We might be good, but we are no mind-readers.

Edited by ragarnak, 21 December 2006 - 08:13 PM.

• 0

### #3 wioneo

wioneo

The Profet

• New Member
• 526 posts

Posted 21 December 2006 - 10:23 PM

And you really think we can answer such a question without us being able to look at what you wrote ?

We might be good, but we are no mind-readers.

<{POST_SNAPBACK}>

I actually am a mind reader. However, I need to be able to see my subject's in person, and thus I am helpless to help you. I am also very interested in seeing a screenshot of what you described...
• 0

### #4 FredFredrickson

FredFredrickson

Artist

• Global Moderators
• 9196 posts
• Version:GM8

Posted 21 December 2006 - 10:38 PM

You draw the object just the same as normal, but you don't draw it relative to x,y, and z... Save that for transformations.

```d3d_transform_set_identity();
d3d_draw_ellipsoid(-1,-1,1,1,1,-1,-1,0,0,12);
d3d_transform_set_identity();```

You first rotate the object on it's original axis by using rotations first, then you translate the object to where you want it to be drawn. Finally, you include the draw code, which contains coordinates relative to 0,0,0, and without references to where the object actually is in x, y, and z space. This is important, because anything you add here is relative to the translation position.
• 0

### #5 ragarnak

ragarnak

GMC Member

• Retired Staff
• 19468 posts
• Version:GM8

Posted 22 December 2006 - 09:27 AM

You draw the object just the same as normal, but you don't draw it relative to x,y, and z...  Save that for transformations.
<snip>

<{POST_SNAPBACK}>

Spoil-sport ...

Its probably exactly that : incorrect use of the transformation-commands.

But, if he does just copy-and-paste your code, he won't know/realize what his mistake was ...
• 0

### #6 JJProductions

JJProductions

Agamma Corpus

• New Member
• 2211 posts

Posted 22 December 2006 - 05:43 PM

Is the first d3d_set_transform_identity() needed?
• 0

### #7 -0NL1N3-

-0NL1N3-

Network Programmer

• New Member
• 650 posts

Posted 22 December 2006 - 06:42 PM

Is the first d3d_set_transform_identity() needed?

<{POST_SNAPBACK}>

Yes because that makes the transformation area relative to 0,0,0.

Thanks,
-0NL1N3-
• 0

### #8 ragarnak

ragarnak

GMC Member

• Retired Staff
• 19468 posts
• Version:GM8

Posted 23 December 2006 - 01:32 AM

Is the first d3d_set_transform_identity() needed?

<{POST_SNAPBACK}>

Not if you change, of the the first command below it, the "..._add_..." to a "..._set_...".

But yes, you need to reset any rotation/translation/other set by a previous object. That is because those rotation/translation/other 3D transformation commands are global, not local to the object-instance they are used in.

Hope that clarifies it.
• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users