#### Archived

This topic is now archived and is closed to further replies.

# world space

This topic is 6069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, If I have an object, say a cube for example defined in object space, how do I define world space - do I need to have x,y,z offsets within the cube object and use the world transformation matrix to put it into world space - I just can''t seem to get it into my head how you position objects in a ''big world''. Any help on this subject would be much appreciated. Thanks, Steve

##### Share on other sites
If you have a cube defined in object space (sometimes called local space) then you need to apply a world transform to this cube to get it into world space. (The cube''s object space will be, typically, with respect to it''s own local origin).

To transform the cube into world space you will need to build the relevant transform - which typically comprises of translations, rotations and scaling operations. So, your cube would have a variable somewhere in it''s definition that indicates it''s position in world space. From this value you can determine the translation portion of the overall world transformation. It is also likely that your cube will have a rotation about the x,y and z axes. These values can be used to create your local->world portion of the overall world transformation for your cube. Likewise with scaling.

I know I haven''t explained this too clearly... let''s try something else...

[Cube]
xPos = 10
yPos = 20
zPos = 30

xRot = 0
yRot = 1
zRot = 0

Here the cube has a position (10,20,30) - which is it''s position in WORLD space. So you would call a function along the lines of...
Cube->SetTranslation(transMatrix,Cube.xPos,Cube.yPos,Cube.zPos)

(and likewise with rotation)

Cube->SetRotation(rotMatrix,Cube.xRot.... etc.

These matrices (transMatrix and rotMatrix) can be concatenated to create your overall transformation matrix. This resulting matrix is your cube''s world matrix and will place the cube in world space.

SetTransform(resultingMatrix)
Cube->Render()

I was never too good at explaining things - hope it helps a little!

Cheers,
Sharky

##### Share on other sites
Thanks Sharky, you have explained that perfectly - I thought
the object did need to have world x,y and z positions and you
have now convinced it does!

Cheers,
Steve

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631782
• Total Posts
3002338
×