Advertisement

Collisions and optimizations

Started by April 30, 2003 02:23 PM
5 comments, last by Slickfty2 21 years, 10 months ago
Simple optimization question first. Is it better to scale the model coordinates as they''re being loaded (ie xcoord *= 0.05) than to use glScale*() when rendering each model? And as this applies to collision detection, is it better to do it that way and calculate the bounding box proportions with the scaled coordinates? Thanks
Appended question... I''m using the MD2 loader from lesson 7 (Model Mania), and it''s loading "glCommands". Where from this would I even get the coordinates to scale, and calculate the bounding volume from?
Advertisement
its faster to do everything when loading rather than each frame. So, yes scale when loading. for collision, calculate with the same data you draw with, or it might not match in size.
Remember to scale your normals as well...

And you''ll need to calculate the BB after you''ve scaled everything...
I''m still not clear how, since the tutorial model loader loads the "glCommands", to get the vertices to scale when loading. Does anyone have an example of how to do that during model loading?

Thanks
Is your model loading routine a seperate function?

If not, it should be.

Then once you''ve seperated off this code, you''ll basically read in each piece of data, scaling it as you go, including calculating/scaling any normals you need. Then as I''m assuming you''re doing so now, you will store the newly scaled vertex/normal data in an array for drawing later on (in the main drawing loop).

HTH
I like pie! - weebl.
Oneiric - Another graphics engine in the works.
Advertisement
Ok. I think I see what you''re saying. I''m using NeHe''s Tutorial 7 which has a MD2 class (I''ve modified it to fit my needs, but the structure is essentially the same). The MD2 class has a routine to load the model into an array of glCommands. Then the rendering function uses those glCommands. You would suggest instead of using them to render, maybe build some vertex arrays from then (scaling as I go) in the loading routine and then render with the vertex arrays in the rendering routine? If I''m rendering with vertex arrays, would I have to use a vertex program to do cel-shading?

This topic is closed to new replies.

Advertisement