How can I ensure my Collada model fits on an iPhone screen?

Hi I am new to game development. I see many examples and tried myself like displaying triangle, cube etc. Now I am looking to render a Collada object. So I created a Collada object using Google Sketch up and trying to render that now. But the thing I am not understanding is, in all examples the vertices are between -1.0 and +1.0 values. But when I looked into that Collada file, the vertices were ranging from -30.0 to 90.0. I know any vertices greater than 1.0 will not display on iPhone. So can you pleas tell my the secret behind converting Object coordinate to normalized vector coordinate?

My previous triangle defined as

``````struct Vertex{

float Position[3];
float Color[4];
};
const Vertex Vertices[] = {
{{-0.5, -0.866}, {1, 1, 0.5f, 1}},
{{0.5, -0.866}, {1, 1, 0.5, 1}},
{{0, 1}, {1, 1, 0.5, 1}},
{{-0.5, -0.866}, {0.5f, 0.5f, 0.5f}},
{{0.5, -0.866}, {0.5f, 0.5f, 0.5f}},
{{0, -0.4f}, {0.5f, 0.5f, 0.5f}},
};
``````

And now triangle from collada is

``````const Vertex Vertices[] = {
{{39.4202092, 90.1263924, 0.0000000}, {1, 1, 0.5f, 1}},
{{-20.2205588, 90.1263924, 0.0000000}, {1, 1, 0.5, 1}},
{{-20.2205588, 176.3763924, 0.0000000}, {1, 1, 0.5, 1}},
{{-20.2205588, 176.3763924, 0.0000000}, {1, 1, 0.5, 1}},
{{-20.2205588, 90.1263924, 0.0000000}, {1, 1, 0.5, 1}},
{{39.4202092, 90.1263924, 0.0000000}, {1, 1, 0.5, 1}},
};
``````
-
the units depend on how you export or scale your collada object, and how your renderer interprets those values. what values do you expect, or what were the values for our cube for example? – cppanda Dec 22 '12 at 17:50
@cppanda I updated my question – rakeshNS Dec 22 '12 at 19:13
it seems to me that you simply made a larger triangle in Google SketchUp. You can just scale it down and export it again to receive smaller values. I think your last sentence about normalizing is just a misunderstanding. Normalizing any object coordinates to be between 0 and 1 is not something you have to do. depending on the view and perspective setup a different range of coordinates will be shown on screen, those could be from -1 to 1, from -30 to 100, this really depends on your "camera" – cppanda Dec 22 '12 at 23:50

1 Answer

By default, if you simply pass untransformed vertex data directly to the GPU via OpenGL, the visible extents of the screen are from -1 to 1 along both axes. This is true of any OpenGL device, not just the iPhone. Also true of any OpenGL device (including the iPhone) is that you can then adjust OpenGL state (the viewport, the transformation matrices, et cetera) to allow you to see any range of vertex coordinates just fine.

Your statement that "any vertices greater than 1.0 will not display on iPhone" is quite false.

You should familiarize yourself with the OpenGL transformation pipeline and configure your viewport and projection matrices accordingly to allow you to see what you need to see in your scene. You probably want to configure your view matrix such that your camera is pulled back at least 90 units from the origin, though, since that appears to be the largest extent of your model.

-
you are right. Only in recent days I got little bit knowledge about OpenGL transformations and now I can load this kind of objects now. Thanks for your answer. – rakeshNS Feb 24 '15 at 13:22