PDA

View Full Version : Trying to translate a specific vertex help! :(



noobscratcher
04-03-2012, 06:36 AM
Hey all trying to translate a vertex but I'm having problems with specifying a quad to move.

I can move everything in the frustum using a translation matrix and then sending it up the vertex shader and * by the position like so


#version 330
//Position Container
in vec4 position;

//Container for TexCoords
in vec4 Texcoord0;



// THIS IS OUT VEC2 TEXCOORD IN OTHER CODE
smooth out vec2 Texcoord_VSPS;


//Translation Matrix
uniform mat4x4 myMatrix;



//out vec2 ex_texcoord;
//TO USE A DIFFERENT COORDINATE SYSTEM JUST MULTIPLY THE MATRIX YOU WANT


//mat4 = projection mat4{

//1.0, 0.0, 0.0, 0.0,
//0.0, 1.0, 0.0, 0.0,
//0.0, 0.0, -2.0, 0.0,
//0.0, 0.0, 0.0, 1.0


//};

//Main Entry Point
void main(void)
{
//Translations and w Cordinates stuff
gl_Position = myMatrix * position;
Texcoord_VSPS = Texcoord0.st;

}




/// //Translations and w Cordinates stuff
// gl_Position = vec4(position.xyz, 1.0);




But how too specify a specific quad to move ?

I was thinking I would put the translation matrix next to the binding of the vbo being used at that current time but that didn't return valid results I craved.

anyways
thanks in advance

Aleksandar
04-03-2012, 02:31 PM
This is not an advance topic by any means.
You have a problem with understanding basic transformations.
Setting a transformation matrix next to binding a VBO means nothing. It should be set before an actual drawing. And since you want to move a particular object, after its drawing the matrix have to be set to its previous state (or like it should be for other objects). In the legacy OpenGL it was elegantly done by glPushMatrix/glPopMatrix. Now, you have to implement it on your own.

I hope I got the point, since you have not published the actual drawing code.