constant scale in viewport

Started by
1 comment, last by V-man 15 years, 11 months ago
How do i make a object of constant size (in viewport) independent of view parameters like distance from camera and fov? For example like the transform gizmo in 3DSMax or Lightwave. I have managed to make it 'almost' independent based on camera distance: scale_xyz = some_constant / distance_from_camera. But how would i do it with fov?
Crush your enemies, see them driven before you, and hear the lamentations of their women!
Advertisement
Sounds like you want an orthographic view, where the objects shown don't decrease in size the further away from the camera they get. Google "glOrtho", and give that a go
You can try glhConstantSizeMatrixf2 or glhConstantSizeMatrixf from my glhlibrary
glhlibrary

It is intended to be used when you use a perspective projection.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement