Jump to content
  • Advertisement
Sign in to follow this  
hury

Move single Objects

This topic is 3814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i´ve got several objects on screen --> www.captured-dreams.de/temp/1.jpg Now i want to move only one of these red squares. I´ve got all squares in a List, so i can access these objects, but I dont know how to move them. Rotating with glRotatef(rtri2, 1.0f,0.0f,0.0f); works, but thats not exactly what i need. Anyone any ideas? Alex

Share this post


Link to post
Share on other sites
Advertisement
well.....

you could dictate which squares are selected (using a bool).... and if it is selected rotate it.

if glRotatef is not exactly what you want.... what DO you want?

do all of your squares have their own matrix info?

Share this post


Link to post
Share on other sites
My squares are drawn in class IconDrawer.cpp:

void IconDrawer::draw() {

glRotatef(_rtri, 1.0f,0.0f,0.0f);

glColor3f(0.5f,0.5f,1.0f);

glBegin(GL_QUADS);

glVertex3f( 0.08f, 0.08f,-0.02f);
glVertex3f(-0.08f, 0.08f,-0.02f);
glVertex3f(-0.08f, 0.08f, 0.02f);
glVertex3f( 0.08f, 0.08f, 0.02f);

glColor3f(0.5f,0.6f,1.0f);
glVertex3f( 0.08f,-0.08f, 0.02f);
glVertex3f(-0.08f,-0.08f, 0.02f);
glVertex3f(-0.08f,-0.08f,-0.02f);
glVertex3f( 0.08f,-0.08f,-0.02f);

glColor3f(0.5f,0.7f,1.0f);
glVertex3f( 0.08f, 0.08f, 0.02f);
glVertex3f(-0.08f, 0.08f, 0.02f);
glVertex3f(-0.08f,-0.08f, 0.02f);
glVertex3f( 0.08f,-0.08f, 0.02f);

glColor3f(0.5f,0.8f,1.0f);
glVertex3f( 0.08f,-0.08f,-0.02f);
glVertex3f(-0.08f,-0.08f,-0.02f);
glVertex3f(-0.08f, 0.08f,-0.02f);
glVertex3f( 0.08f, 0.08f,-0.02f);

glColor3f(0.5f,0.9f,1.0f);
glVertex3f(-0.08f, 0.08f, 0.02f);
glVertex3f(-0.08f, 0.08f,-0.02f);
glVertex3f(-0.08f,-0.08f,-0.02f);
glVertex3f(-0.08f,-0.08f, 0.02f);

glColor3f(0.5f,1.0f,1.0f);
glVertex3f( 0.08f, 0.08f,-0.02f);
glVertex3f( 0.08f, 0.08f, 0.02f);
glVertex3f( 0.08f,-0.08f, 0.02f);
glVertex3f( 0.08f,-0.08f,-0.02f);
glEnd();

}

then they are drawn from the main class:

for(int i=0; i<myVec.size();i++) {
glLoadIdentity();
glPushMatrix();
glTranslatef(x ,y, -5.0f);

myVec.at(i)->draw();
if (y > -1.5f)
y -= 0.3f;
else {
x += 0.3f;
y = 1.86f;
}

glPopMatrix();

myVec is the vector with the Icon Objects.
What i need now, is after i selected one object (dont care about the selection), to move this objects on the screen. So i dont need to rotate, but just to move it left or/and right or into the screen

Share this post


Link to post
Share on other sites
you wanna do a translate...

gltranslate

hmm... and your main function is rendering them weird... you only have 1 matrix for all the squares.

review object space and world space matrices... and that will solve your problem

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!