Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / rotation using matrix Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
devil20

April 19, 2005, 01:18 AM

Hi
I am not well experinced in 3d graphics but trying to learn everyday new things so guys please help me. I doing simple rotation using matrix of 3d object in 180*180 = 32400 iteration . I am rotating object total 32400 times
in each & everydegree in 2 axis and rendering precalucalted data on render screen. But problem is it is taking 2.9 minutes to complete all loops.

  1.  
  2.     for(int i=0; i<180; ++i)
  3.       for(int j=0; j<180; ++j)
  4.        {
  5.          Object.Rotate(degree,Axis); //rotate object
  6.          Render(); // render precalculated data
  7.        }
  8.  




So how can i do rotation fast ???
Matrix is using lot of memory ??? How can i optimize it ???

I had done all test on p3-1 ghz with 256 mb ram & Nvidia Riva TNT2 32 MB that takes 2.9 minutes.
I had also tested on p4-1.7 ghz cpu with same ram & 64 radeon that is taking aprox 20 sec.
But i want to still need optimazation. Can anyone suggest me what to do ???


 
juhnu

April 19, 2005, 01:28 AM

It's NOT the rotation which is taking time but rendering the object on the screen. You are basicly drawing 32400 frames which takes time, even with the newest graphics cards you can get.

For rotating the object you need to set its' transformation matrix. For that you need a one 4x4 matrix which can be allocated from the stack. That is 16 floats only. So the memory is hardly concern here nor it is the performance bottleneck.

take off the Render() call and watch it fly.




juhani

 
RAZORUNREAL

April 19, 2005, 06:36 AM

You sure you didn't want to render 32400 different frames not 32400 objects onto 1 frame? You want it to spin or what?

 
Chris

April 19, 2005, 10:20 AM

  1.  
  2. So how can i do rotation fast ???
  3. Matrix is using lot of memory ??? How can i optimize it ???
  4.  
  5. I had done all test on p3-1 ghz with 256 mb ram & Nvidia Riva TNT2 32 MB that takes 2.9 minutes.
  6. I had also tested on p4-1.7 ghz cpu with same ram & 64 radeon that is taking aprox 20 sec.
  7.  


And this should already tell you that the problem is your gfx card, not the matrix taking to much memory.

That's a ridiculous statement BTW, a matrix is 4*4 floats or doubles, e.g. no more than 128 bytes. No matter how many rotation matrices you multiply upon it.

Think about it. You render 32400 frames, and even if you could render at 100fps that would take more than half a minute.
If your old TNT2 rendered at (say) 10 fps, that'd make over 5 minutes.

So what you want to do is render less frames, by rotating the object by more than 1 degree. If you rotated by 5 degrees between frames, you'd come out with
36*36 = 1296 frames, and rendering those will obviously be less work.

 
Aaron Wirtz

April 19, 2005, 07:48 PM

just a thought about using pre-rendered views of a 3-D object:

you could in theory render an object from every possible angle to a resolution of 1 degree, which it seems is what you are attempting. This would be time consuming and the resultant set of images would be huge, but this might be a viable option if the 3D object is so complex that you cannot render it in real-time or if you intend to render huge numbers of this object at the same time. You could then simply insert prerendered images into an otherwise 3-D scene as billboarded sprites. (taking into account the viewing angle and using the appropriate prerendered image)

Unfortunately things are rarely entirely that simple. Because of perspective and parallax, your prerendered object will appear distorted compared to the surrounding real 3-D geometry if you view it from a different distance or with a different field of view than you used when you prerendered it. In theory, if you used a parallel-ray camera (a camera with no perspective correction) both for the prerendering and the final demo, the perspective would be correct from any angle or distance (since there would be no perspective), unfortunately, the image from a parallel-ray camera looks very unnatural in the first place and would require some heavy distance-fog to give any sense of depth.

I seem to recall a plugin for 3DSMAX that essentially used this prerendering technique to insert photos of real objects into a scene. (trees, people, etc) They have, for example, a photo of a person from every possible angle, then they use the correct one for the viewing angle in each frame of the final composition. It works fairly well from a distance, but things look really weird if they have a lot of depth (trees for example) or if you get close enough to see the depth distortion (people).

 
Rui Martins

April 20, 2005, 08:13 AM

That's a ridiculous statement BTW, a matrix is 4*4 floats or doubles, e.g. no more than 128 bytes. No matter how many rotation matrices you multiply upon it.


I believe he is calculating the rotated object (vertexes) himself, and keeping the result !
That is why it is huge.

 
Chris

April 20, 2005, 09:26 AM

That'd be a most unclever solution.

 
Rui Martins

April 20, 2005, 12:53 PM

What made me infer that was his own code !

  1. Object.Rotate(degree,Axis); //rotate object

 
This thread contains 8 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.