Jump to content
  • Advertisement


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


Scaling 3D models

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been making a .3ds viewer and have run into a little problem when it comes to files I havn''t modeled myself. Basically if I use a model that has point coordinates that are very far about like in the hundreds then before I can display the model I have to move away from it. I tryed normalizing the vertices like you would a vector but that then makes the model distorted. Is there anyway I could make all models that I load a certain size regardless to how big they are when I load them? I''m sure there''s probably a way to do it I''m just not sure what it is. Thanks for your help G-Force

Share this post

Link to post
Share on other sites
Transform the vertices with a uniform scale matrix...

s 0 0 0
0 s 0 0
0 0 s 0
0 0 0 1

When s = 0.5 and your model will be scaled to half the size, s = 2 is double the size, and so on. If you're using OpenGL use glScalef(s, s, s)...

The nag is that using glScalef() you'll have to do that once per frame before you draw your model so what you might want to do is use the matrix and apply it to your vertices in memory once with your own matrix*vector routine (maybe at startup) and then just draw them regularly afterwards.

Forgot to mention, when using glScalef if you're also passing normals for lighting they will be scaled too, which is a no-no since normals have to be unit-length. There's 2 gl calls for fixing that, which will either re-normalize the normals (slower) or scale them with the inverse of the modelview matrix (faster), can't remember what they are, try MSDN or google. But really your best bet is to scale the vertices yourself once before you draw them, that way normals aren't affected either.

- outRider -

[edited by - outRider on July 18, 2002 8:27:55 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!