PDA

View Full Version : OpenGL and Builder C++ How to move a model with widgets



johnstonsk
05-14-2003, 11:56 AM
I have created a 3D model of a F-16. I want to have the plane pitch, roll, yaw respectivly when a widget is moved or pressed.

I have a openGL vcl component that allows me to use OpenGL in the app.

How can I bring the model into the window?

How would I go about moving the box.

thanks,
sj

starman
05-15-2003, 03:23 AM
Try this: store the rotations in some kind of global variables (more on this below). Then code event handlers for the widgets you want to use to control roll, pitch, and yaw. In those handlers, update the global variables so that your rendering code will rotate the plane correctly.

As far as how you store your rotations, I would suggest looking at a couple articles on rotations:
http://www.sjbaker.org/steve/omniv/eulers_are_evil.html http://www.sjbaker.org/steve/omniv/matrices_can_be_your_friends.html

Cheers.

[This message has been edited by starman (edited 05-15-2003).]

johnstonsk
05-15-2003, 04:39 AM
Very helpful.
How can I import the rendered 3D model into a matrix one with camera angles and views from all directions?

I think once I get the model in the scene I will be able to manipulate the movement

thanks for the help

sj

starman
05-15-2003, 04:59 AM
I think you're confusing your model (the F-16) with the transformations (rotations, translations, etc.). The transformations go in the modelview matrix. The model data that you import can be stored however you like. Typically, you'll draw a scene like this:

- place "camera" with view transformations (rotate, translate)
- position model with model transformations (rotate, translate, scale)
- draw model by sending the model vertices (and textures, etc.) to OpenGL

I'm relatively new to GL, so I'm sure one of the experts here can answer you better. I'd check out the OpenGL Programming Guide (the red book) chapter 3 on this stuff.

johnstonsk
05-15-2003, 05:34 AM
Reading the "red Book" was very helpful. I was a bit confused about the cameras. I am going to export my model as an ascii file and render it with OpenGL.
THen I am going to use the gl_modelview() to view from different angles.

Thanks starman for pointing me in the right direction

sj

biot023
05-20-2003, 07:28 AM
Johnstonsk - you mentioned a component for BCB & OpenGL?
Could you post a link to this?
Cheers,
doug