gs384

03-12-2005, 11:01 AM

can anyone please point me to a tut or explain how to move a 2d coloured polygon across the screen and stop at a given point

:)

:)

View Full Version : how move 2d polygon across screen ?

gs384

03-12-2005, 11:01 AM

can anyone please point me to a tut or explain how to move a 2d coloured polygon across the screen and stop at a given point

:)

:)

ce110ut

03-12-2005, 01:39 PM

try http://nehe.gamedev.net/ - plenty of useful tutorials.

:regards:

:regards:

gs384

03-12-2005, 11:26 PM

Had a look at nehe's site but none of the examples deal specificly with what i want to do. All beginners tutorials seem to deal with movement by using glRotatef(). Is glTranslatef() able to move objects across the screen if so how does it work? If not then how is it done?

A basic explanation would be helpfull.

:)

A basic explanation would be helpfull.

:)

Silkut

03-13-2005, 01:42 AM

Hm, hope a very basic explanation helps you... ;)

Ok so, you can use 3 modelisation transformations:

_glRotate[ type ]( angle , x, y, z);

where type is d (for double), i(for int), f(for float), and angle is your angle of rotation, because this function is used for rotating objects. x, y and z are your coords in 3D space (x axis, y axis, z axis...)

in theory: This function multiply the active matrix by a rotation about an object.

_glTranslate[ type ](x, y, z);

where type is d (for double), i(for int), f(for float), this function is used for translate objects in 3D space (left or right, up or down, far or near).

in theory: This function multiply the active matrix by a matrix that move an object (moving the local coords system).

_glScale[ type ](x, y, z);

where type is d (for double), i(for int), f(for float), this function is used to modify how your object look like, at every coords (x, y or z) if you specify a value < 1, the object appear more little, if the value is > 1, the object appear bigger.

in theory: This function multiply the active matrix by a matrix that modify the appearence (more little, more big, more deep...)

Tricks and counter traps:

_Don't forget that if you want to translate and rotate an object, the result is not the same if you translate before rotate or rotate before translate !

There is no "good" order, because you can use this little trap such as a bonus to facilitate your transformations

_Don't forget, angle is in degree (:

_You must use glLoadIdentity() function very often, i.e. between 2 transformations, because if you don't, the current transformation willbe affected by the older transformation, note: such as rotate and translate, this traps can be used like a bonus...

_all transformation are multiplications of matrix by other matrix in reality, so check your math out !

(note that your transformations may look like

( 1 0 0 )

( 0 1 0 ) <-- erks ! (i.e. an identity matrix)

( 0 0 1 ) If you want to move an object from a point to another point you can try something like that:

// globals

GLfloat myXmove;

....

// renderer

glTranslatef( myXmove, y, z);

glBegin();

glVertex....

...

glEnd();

if(myXmove < 10.0f)

{

myxmove += 0.001f;

}

else

{

another_transformations...

} (don't hurt, this is an example (: )

Hope that helps, don't forget to check the OpenGL RedBook out (this is the official bible)

Gollum :p

Ok so, you can use 3 modelisation transformations:

_glRotate[ type ]( angle , x, y, z);

where type is d (for double), i(for int), f(for float), and angle is your angle of rotation, because this function is used for rotating objects. x, y and z are your coords in 3D space (x axis, y axis, z axis...)

in theory: This function multiply the active matrix by a rotation about an object.

_glTranslate[ type ](x, y, z);

where type is d (for double), i(for int), f(for float), this function is used for translate objects in 3D space (left or right, up or down, far or near).

in theory: This function multiply the active matrix by a matrix that move an object (moving the local coords system).

_glScale[ type ](x, y, z);

where type is d (for double), i(for int), f(for float), this function is used to modify how your object look like, at every coords (x, y or z) if you specify a value < 1, the object appear more little, if the value is > 1, the object appear bigger.

in theory: This function multiply the active matrix by a matrix that modify the appearence (more little, more big, more deep...)

Tricks and counter traps:

_Don't forget that if you want to translate and rotate an object, the result is not the same if you translate before rotate or rotate before translate !

There is no "good" order, because you can use this little trap such as a bonus to facilitate your transformations

_Don't forget, angle is in degree (:

_You must use glLoadIdentity() function very often, i.e. between 2 transformations, because if you don't, the current transformation willbe affected by the older transformation, note: such as rotate and translate, this traps can be used like a bonus...

_all transformation are multiplications of matrix by other matrix in reality, so check your math out !

(note that your transformations may look like

( 1 0 0 )

( 0 1 0 ) <-- erks ! (i.e. an identity matrix)

( 0 0 1 ) If you want to move an object from a point to another point you can try something like that:

// globals

GLfloat myXmove;

....

// renderer

glTranslatef( myXmove, y, z);

glBegin();

glVertex....

...

glEnd();

if(myXmove < 10.0f)

{

myxmove += 0.001f;

}

else

{

another_transformations...

} (don't hurt, this is an example (: )

Hope that helps, don't forget to check the OpenGL RedBook out (this is the official bible)

Gollum :p

Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.