could someone please help, i am finding it difficult to work around moving individual models, i can only move the whole scene. i cant seem to work around moving models that have been selected....Any ideas please
this is my display method....the translate enable me to drag the whole scene(which is not exactly what i want...which is moving a selected object)....seems placing a translate in this function moves the camera instead of the selected models....
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This clear the background color to dark blue
glMatrixMode(GL_MODELVIEW); // Modeling transformation
glPushMatrix(); glLoadIdentity(); // Initialize the model matrix as identity
glTranslatef(mouse1.GetX(), mouse1.GetY(), 0.0);
drawModel(GL_RENDER);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
this is where the selection is done,i have tried every scenario i could but i cant get the selected model to move individually, or how i could include the pushMatrix,gltranslate and popmatrix....to achieve what i want....thank you.
mouse(int button, int state, int x, int y)
{
GLuint selectBuf[SIZE];
GLint hits;
GLint viewport[4];
could someone please help, i am finding it difficult to work around moving individual models, i can only move the whole scene. i cant seem to work around moving models that have been selected....Any ideas please
this is my display method....the translate enable me to drag the whole scene(which is not exactly what i want...which is moving a selected object)....seems placing a translate in this function moves the camera instead of the selected models....
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This clear the background color to dark blue
glMatrixMode(GL_MODELVIEW); // Modeling transformation
glPushMatrix(); glLoadIdentity(); // Initialize the model matrix as identity
glTranslatef(mouse1.GetX(), mouse1.GetY(), 0.0);
drawModel(GL_RENDER);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
this is where the selection is done,i have tried every scenario i could but i cant get the selected model to move individually, or how i could include the pushMatrix,gltranslate and popmatrix....to achieve what i want....thank you.
mouse(int button, int state, int x, int y)
{
GLuint selectBuf[SIZE];
GLint hits;
GLint viewport[4];
That should be fine as long as the matrices for the selected object is different from the rest, like the rest has a transform of identity and the selected one has a different one.
thanks alot i did see some improved changes, i am trying to achieve a drag object property in my program, i had in place of gltranslate used ObjTranslate(&object[obj_control],mouse1.GetX(), mouse1.GetY(), 0.0); in my program earlier to help me achieve dragging....only for my objects to disappear (probably translating the selected objects to locations not in the scene).......which brought me to feel my algorithm was wrong....i tested it with the function (without using my drag algorithm)ObjTranslate(&object[obj_control],0.0, 0.0, -1); the model moved a step on each click.
could you please give me an idea how i could incorporate dragging of objects in my program or an algorithm i could use...i am really bad at maths
I don't know GL as well as I should anymore but what you would like to do is the following.
Setup Projection and view matrices
Foreach model in modelsList
{
setup the world matrix of this model
draw the model itself
}
I have no idea what your object and all the arrays stand for keep your code simple it will help you understand what you are doing or trying to do without seeing the code for it.