Log in or register to post comments

Second Object is a different Size

June 17, 2011 - 5:14am #1

Hi,

I've been working from the ImageTargets and have used the obj2opengl.pl script to get two of my own models in. The models are displaying but for some reason they arent appearing at the same scale and I don't know why!

this code I'm trying is:


        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, 1);

		
        SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                                     &modelViewMatrix.data[0]);
		
		SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
                                    &modelViewMatrix.data[0],
                                    &modelViewProjection.data[0]);

        glUseProgram(shaderProgramID);
        glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
                           (GLfloat*)&modelViewProjection.data[0] );


	    glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
	                          (const GLvoid*) &model1Verts[0]);
	    glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
	                          (const GLvoid*) &model1Normals[0]);
	    glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
	                          (const GLvoid*) &model1TexCoords[0]);

        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        glEnableVertexAttribArray(textureCoordHandle);

	    glDrawArrays(GL_TRIANGLES, 0, model1NumVerts);

		
        SampleUtils::translatePoseMatrix(0.2f, 0.2f, 0.2f,
                                     &modelViewMatrix.data[0]);
		
		SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
                                    &modelViewMatrix.data[0],
                                    &modelViewProjection.data[0]);

        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &model2Verts[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &model2Normals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &model2TexCoords[0]);

        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        glEnableVertexAttribArray(textureCoordHandle);

	    glDrawArrays(GL_TRIANGLES, 0, model2NumVerts);

any thoughts of what I'm doing wrong?

Cheers

Re: Second Object is a different Size

June 17, 2011 - 7:08am #2

Maybe because the two original objects don't have the same size...

For my apps, I use a different scale constant for each object.

Log in or register to post comments