   [SOLVED] How can we do this transformation ?
  Hi, I am using SetTransform(D3DTS_WORLD,&mat) to transform any mesh. I think it just transforms whole world space before rendering a particular mesh.So we have to apply this transformation again and again on each frame render.Is there any way to transform a mesh parmanently to a location say (5.0f,0.0f,0.0f) so that we can apply transforation just once instead of applying transformation each frame ?????????One way i figured is by locking the vertex buffer and applying D3DXVec3TransformCoord  to all the vertices, but this may be a affect performence as locking vertex buffer etc takes time.So is there any other way to achieve this ?[Edited by - Chetanhl on February 22, 2010 4:30:25 AM]
  To move the mesh "permanently", you would really have to lock the vertex buffer and modify all the vertices. But as you would do this only once, at the beginning of the application, I don't see how this could affect the performance.I don't know what exactly you are trying to achieve, but the transformations (world in this case) are very fast, you normally don't have to worry about doing them every frame for multiple individual objects.   ;  Actually what i want to render say 20 meshes and frequency of change of their locations is different eg 10 meshes changes locations every second but other 10 changes location say once in 1 minute.So i just wanted to know if its good to transform meshes each frame even if there number is high say 100 or 200 meshes  ??or Is there any other way to do that ?(Other than vertex locking i have read that will take even more time than transformations)But if these transformation are that fast as you said and dont affect performence that much its more appropriate to use transformations only.   ;  I would rather use the transformations, because even if I lock() the vertex buffer and pretransform the vertices in object space at the init part of the application, I still need to set the identity transform to the device, prior to render that pretransformed mesh, if there are any transform calls in the main loop. If there aren't transform calls in the main loop, consider switching to static mesh with groups.   ;  It's perfectly normal to do the transformations each frame. Graphics cards are built to be able to do a lot of these transformations, and the draw call overhead is much higher than setting the transformation and doing it, so you'll gain little from not doing it.In general I'd suggest not to try to optimise things up front, certainly not at your level of knowledge. Try to get things working, and if they then work slowly, learn to use profiling tools to find out where the bottleneck is.   ;  thanks for all your replies it really helped me to choose the right path.   ;  I think you should learn what a matrix is.  It's just a simple math structure-- it has nothing to do with your actual mesh other than determining where you draw it.How long does it take to multiply out a few numbers to get your final matrix?  Almost 0.  Like, it will take a million times more processing power to actually render a single frame of video than to calculate all the the matrices of your mesh.Of course, I'm just a n00b-- anyway want to tell me I'm wrong on this one? :)   ;  Well, creating the transformation matrix and setting it to the device is one thing. Another thing is that this matrix has to be aplied to all the vertices of the mesh, which is done by multiplying every vertex (its vector of position, normal) with the matrix. But this is done "automatically" and since GC's with HW T&L it's HW accelerated, Chetanhl really shouldn't worry about doing it (We are all doing it btw. Somebody just by setting the matrix, somebody by vertex shaders, but this doesn't matter) ;)   ;Quote:Chetanhl really shouldn't worry about doing it (We are all doing it btw. Somebody just by setting the matrix, somebody by vertex shaders, but this doesn't matter) ;)ya i got it from your previous post only and am continuing with transformations only.   