Advertisement

How to scale?

Started by December 27, 2004 03:29 PM
2 comments, last by dawidjoubert 19 years, 10 months ago
Hello, in my latest programming I tried to implement a kind of scale. Objects have a new attribute, the scale factor. By this factor, their size should be setted. For example, if the scale factor is 2.0, the object should be drawn twice bigger than originally. I tried to use glScalef, but it didn' work for me... perhaps you can give me a hint? Thanks in advance, Marco
What I do is to scale my objects independently of the scene, I don't use the GL matrices to scale my stuff, I use a vector lib instead with it's own matrices.

Same goes for rotation and translation, I keep the overall scene seperate from the objects, at least with the stuff I want to keep dynamic.

Now if all you want to do is zoom, you can scale up or move your camera closer to the object you're zooming on, but if you exceed your view-frustum limits, your scene will 'tear'.

If you use your own matrices for translate, scale and rotate (or concat your own special pupose matrices,) you'll have independent control over each object you want to keep dynamic in your scene - you can send any bunch of vertices through your matrices or through opengl's matrices for the final scene, doesn't change anything as far as normal rendering goes, just gives you another option.

I do it like this for CAD objects that I build parametrically in 3D and then generate a 'flat' pattern-development from so they can be built on the shop-floor.

Not fancy, but it works.

Tony
Advertisement
Why didn't glScalef work? To use it, do all the translations and rotations, then glScalef right before putting the vertices with glBegin or displaylist or whatever. It should work. If it doesn't work like that, put up the code and I'll help.


What you could also do is create a type of weight setting which by default = 0

so what you do is you scale each verts position by the weight setting but not like normal do it like this

newvert = oldvert + oldvertNormal * weight

in this why you would get the fat boy effect used in ut(2003+2004).....

i havent tried it yet though its only theory and it only works if you have each verts normal...

Now remember a vert normal is the average normal of all the sharing polies ie

vert normal = (poly1.normal + poly2.normal + poly3.normal) / 3.0
----------------------------

http://djoubert.co.uk

This topic is closed to new replies.

Advertisement