سؤال

Let's say I have an element with the following two triangles:

<triangle A="1018;655;0" B="1018;655;61,5" C="1030;655;61,5" />
<triangle A="1030;655;0" B="1077;655;0" C="1030;655;61,5" />

Each triangle has 3 vertices which consist of values between 0 and 1200.

Now I like to visualize this element in OpenGL ES 2.

What I'm currently doing is, to look for the biggest value and divide all of the elements through this value to get a new value between 0 and 1. With this value of each triangle my renderer is able to visualize the object.

I don't think this is the correct way to go.

I got the following matrices: Model, View, Projection. My computer graphics course was a bit ago but isn't it possible to use the default triangle-values and do a specific transformation from the object-space to the view-/world space?

Is there any good solution available? Or do I have to provide objects with values between 0 and 1 and my approach is the correct way to go.

هل كانت مفيدة؟

المحلول

This depends a bit on what you are using. If you use glOrtho (opposed to glFrustum) all you need to do is insert larger values as parameters, screen coordinates are commonly used.

As for the frustum (more likely in your case) you could still do the same but then you will change the field of view (you will increase its angle). So to keep it all together you should either scale the model or simply put it far away. Note that by putting it far away you might need to increase zFar parameter in frustum call.

In general it is common that models you get are either to large or too small for your scene but that is nothing a simple matrix call can't handle. All you have to do is push the model matrix and scale (glScalef) it down just before drawing the model and popping it just after the draw call. This way you should get the desired effect and rest of the code is intact.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top