0
votes

I have been going over tutorials but i have hit some quesitons.

  1. when the positions for a certain object/polygon are made, they are stored as floats (how many pixels wide is 1.0f)

  2. When i color a polygon, with shades of colors, what is method used (ie.

    // R, G, B, A final float[] cubeColorData = {
    // Front face (red) 1.0f, 0.0f, 0.0f, 1.0f,
    1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
    1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,

            // Right face (green)
            0.0f, 1.0f, 0.0f, 1.0f,             
            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,             
            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
    

3.What is a matrix and its purpose? 4. What about the buffers that are created from the positions? Are changes applied to buffers on every frame step or the direct vector positions?

1

1 Answers

2
votes
  1. Depends. If you are viewing an object in 3D in the real world--for example your house--how many "pixels wide" your eyes perceive your house depends on how far you are from it! 1.0f is unity, a single unit. So whatever you elect your scale to be, 1.0f will be a single unit of that.

  2. You can use glColor3f or glColor3vf if you wish to pass in a vertex array. This also depends on if you are using OpenGL ES 1.1 or 2. You can also use glColor4x if you want to specify your values in Hex and I think they even have glColor3fi for ints. Take a look at your OpenGL header file (or I guess .class definition since this is Android/Java you're talking about: android.opengl.GLU)+++

  3. A matrix is a 2d array of floats. When you multiply a vector by a matrix, you get a transformed vector. Thus, you can use a matrix to transform vectors (which are object orientations and positions) from one coordinate system to another. For example the local coordinate system used to describe an object can be transformed into the world coordinate system (where the object exists in your world). Having a local coordinate system is useful because it makes it easy to rotate an object about itself. Having a world coordinate system is useful when many objects interact with each other. You can also transform to, say, a 'camera' coordinate system. Just like how each object in our real world looks different form various camera angle views, the computer also needs to know how to transform the object to be presented in those views. Each camera would have its own transformation matrix defined and when the vectors, or vertices rather, of an object are multiplied by said matrix, the result is the transformed object in the view of the camera. Slight simplification.

Some suggested reading:

  • Tricks of the 3D Game Programming Gurus by Andre LaMothe. It's old and talks about software rasterization instead of hardware, but it'll teach you about all the math necessary for you to understand 3D graphics and then some.

  • Any Linear Algebra academic book

  • NeHe Game Programming, just google it


+++Note: For your purposes, the way you have your colors defined, it looks to me like you would probably want to instantiate a Float Buffer, store those color values in it, and utilize the glColorPointer function.