Very urgent questions
First of all, can someone tell me how to use the glScale function. I want to use it to scale a loaded Milkshape3D model.
Then, after loading a milkshape3d model, the texture-mapping is done upside down! I have no idea why. Can someone tell me how I can modify the texture coordinates so that the texture-mapping is done properly. Pls, don''t tell me to invert the images; I just won''t do that!!!
simple example for glScale:
glLoadIdentity();
glScale( 1, 2, 3 );
now you calls to ploting vertices will be something like
glVertex3f( 2, 2, 2) --> after scaling this will be ( 2, 4, 6 )
...understand?
about textures upside down... just cahnge u (or v)texture coordinate to 1-u (or 1-v)
You should never let your fears become the boundaries of your dreams.
glLoadIdentity();
glScale( 1, 2, 3 );
now you calls to ploting vertices will be something like
glVertex3f( 2, 2, 2) --> after scaling this will be ( 2, 4, 6 )
...understand?
about textures upside down... just cahnge u (or v)texture coordinate to 1-u (or 1-v)
You should never let your fears become the boundaries of your dreams.
You''re loading milkshape models and you don''t know how glScale works? That seems rather odd, not trying to be a smartass or anything, but shouldn''t you learn the basics first? Anyways, the function glScale*(x, y, z) works like this.
x - how much to scale in x. say 2 for example. That would make everythin twice as large.
y - how much to scale in y.
z - how much to scale in z.
the scaling is accomplished through the matrix
|sx 0 0 0|
|0 sy 0 0|
|0 0 sz 0|
|0 0 0 1|
if you multiply this matrix by a point p{transpose} = (x, y, z, 1};
then you get
|sx * x|
|sy * y|
|sz * z|
| 1 |
you may also want to look into how to push and pop the matrix stack so that you only scale the things you wish to scale (also, translate, rotate, and shear).
Hope my answer helps.
x - how much to scale in x. say 2 for example. That would make everythin twice as large.
y - how much to scale in y.
z - how much to scale in z.
the scaling is accomplished through the matrix
|sx 0 0 0|
|0 sy 0 0|
|0 0 sz 0|
|0 0 0 1|
if you multiply this matrix by a point p{transpose} = (x, y, z, 1};
then you get
|sx * x|
|sy * y|
|sz * z|
| 1 |
you may also want to look into how to push and pop the matrix stack so that you only scale the things you wish to scale (also, translate, rotate, and shear).
Hope my answer helps.
I think what he wants to know that it applies to everything that uses the current matrix mode (e.g. MODELVIEW matrix would be used by verticies and normals) would be scaled after applying glScale() to that matrix. That's where glPushMatrix and glPopMatrix come into play, allowing you to save and restore the matrix something like this:
Something to be wary of though is that if you must use glScalef() instead of scaling your model in your editor (advisable) then make sure to enable GL_NORMALIZE, otherwise your normals will get scaled as well and cause weird stuff to happen to your lighting. The problem with GL_NORMALIZE is that I _think_ you take a performance hit for using it. I'm not sure though since I haven't really bothered looking into if it's done in hardware or software (I don't use it). Anyone feel free to correct me if I'm wrong on this.
Joanus D'Mentia
---------------
The three phases of me...
The twit, the tool and the lonely fool.
[edited by - joanusdmentia on December 26, 2002 3:53:01 PM]
...do stuff...glPushMatrix();glScalef(sx,sy,sz);...draw your milkshape model...glPopMatrix();...do stuff, the scale will no longer affect anything
Something to be wary of though is that if you must use glScalef() instead of scaling your model in your editor (advisable) then make sure to enable GL_NORMALIZE, otherwise your normals will get scaled as well and cause weird stuff to happen to your lighting. The problem with GL_NORMALIZE is that I _think_ you take a performance hit for using it. I'm not sure though since I haven't really bothered looking into if it's done in hardware or software (I don't use it). Anyone feel free to correct me if I'm wrong on this.
Joanus D'Mentia
---------------
The three phases of me...
The twit, the tool and the lonely fool.
[edited by - joanusdmentia on December 26, 2002 3:53:01 PM]
I read that you do take a performance hit for enabling GL_NORMALIZE or GL_AUTO_NORMAL so I believe you are correct. You are also correct in stating that he should scale his model before loading into his program, as using glScale will mess up his lighting (messes up all the normals), at least that''s what I''ve read.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement