Archived

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

HaywireGuy

Callin' SetWorldTransform( ) each frame

Recommended Posts

Hello guys, I was lookin'' at the Inside DirectX book yesterday and came up with this question hope to get some ideas from you guys.. Say for example Quake, each of the objects in the game environment has its own "Object space", and lookin'' into the game, there are lots and lots of these objects visible. So it''s said that you have to make up a world transformation matrix and transform the object into "World coordinate system". And my guess is that you''ll need to have one world matrix for each object if they do not transform into the same spot in the "world coordinate". And here comes my question: If I were to render many of these objects in each frame, wouldn''t it be very slow if I were to repeatedly call the "SetWorldTransform()" function? Just wonderin''... thanks in advanced if anyone would be replyin'' to me

Share this post


Link to post
Share on other sites
my engine is setup for outdoor and indoor levels containing hundreds of objects and I usually end up calling SetWorldTransform() for every object each frame. Its not slow at all! You can also use RHW(transformed) cordinates instead, if I remember correctly RHW are not local, there world cordinates but its harder to control objects that way. Its much better using a matrix to control your world tanform...You can easily perform scaling, rotating, translating. D3DX also makes it incredibly easy.

SetWorldTransform() = Device->SetTransform( D3DTS_WORLD, &mat );

[edited by - nickvbs on March 3, 2003 1:33:30 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by nickvbs
my engine is setup for outdoor and indoor levels containing hundreds of objects and I usually end up calling SetWorldTransform() for every object each frame. Its not slow at all! You can also use RHW(transformed) cordinates instead, if I remember correctly RHW are not local, there world cordinates but its harder to control objects that way. Its much better using a matrix to control your world tanform...You can easily perform scaling, rotating, translating. D3DX also makes it incredibly easy.

SetWorldTransform() = Device->SetTransform( D3DTS_WORLD, &mat );

[edited by - nickvbs on March 3, 2003 1:33:30 AM]


RHW means that the vertex position described has been transformed - thus Direct3D does not carry out any extra transformations on it. RHW is often found in vertex format definitions when rendering 2D primitives (such as sprites) to the display (where you specify the actual screen coordinates rather than a ''true'' position in 3D space).

As for setting the world matrix... this is a very, very fast operation and it is normal to see the SetTransform(WORLD...) function called many times per frame.

Regards,
Sharky

Share this post


Link to post
Share on other sites
Here is one thing you might want to look into if your models dont move (like a tree for example, or a house).

Lets say you have 20 houses in a general area, and each house is 200 vertices.

If you make 1 vertex buffer and 1 index buffer for all the houses, this will greatly speed up rendering!

Instead of 20 calls to SetMatrix, and 20 calls to DrawIndexedPrimitive, you now can render ALL 20 houses with 1 call to DrawIndexedPrimitive, and 1 call to set matrix.

Share this post


Link to post
Share on other sites
Thanks for all the replies, now I feel OK if I were to repeatedly call the SetTransform() function. I think it will never be a reason that slows down my renderin''.

"One VB" way of implementin'' will be best for now I can see, because say for a 3D tetris game, those blocks at the bottoms are not movin'', you only change the transform matrix for those blocks that are droppin'' from the top. Right?

Thanks again guys!

Share this post


Link to post
Share on other sites
One last thing, if you are worried about the SetTransform function


DrawIndexedPrimitive is about 34 times slower than SetTransform. (on an ''average'' primitive of 500 triangles)

One if the things I do in my engine is constantly look for ways to lower the calls to DrawPrimitive.

Share this post


Link to post
Share on other sites