Jump to content
  • Advertisement
Sign in to follow this  
Geometrian

Two+ Objects

This topic is 4152 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 [edit: want to] have one object which will always be in the center of view, and other objects which will be moving around in the background. For example, a similar situation would be a tailplane view of an airplane- the airplane would remain in the center of the view, while the ground and other objects moved. I already checked the documentation. Geometrian [Edited by - Geometrian on April 22, 2007 7:58:45 PM]

Share this post


Link to post
Share on other sites
Advertisement
If what you're going for is as simple as a crosshair sort of display, then you'll want to look into orthographic projections. gluOrtho2D is the magic call to get started.

However, for a fixed view of a plane, as you described, you'll want some sort of a formal camera system. You would still be using a perspective projection, the camera would follow at a fixed distance behind the plane and be constantly aimed at the tail. For more information on that, googling and looking around gamedev for a "3d camera" should get you on the way.

Share this post


Link to post
Share on other sites
No, it's definitely 3D, think 'flight-simulator'. See here:

http://img149.imageshack.us/my.php?image=fokkertriplane6rw4.png

I probably should have been more specific. I am trying to make a flight simulator type game. I just wanted to see if there was a generic answer before concerning anyone with specifics. But there it is. Go to the link. Ignore the ad on the top, I only have other pictures of triplanes. As you can see, this is a tail view of the plane. As the plane flies, the camera should move with it. The ground below should be moving too, as you fly over it. I have everything for the ground, but how do I make it so it can move? Do I have to change where I draw it? That seems a bit crude. I'm thinking along the lines of changing where I draw the ground as an object- not redefining each point of the ground. In a basic version of this program, a single plane, you, would fly over a landscape. I think there would be two objects, the plane and the ground. OpenGL would draw the resulting relative motion as the plane moved over the ground.

So, to rephrase as a final question: Is it possible to make 3D multitextural objects such as the triplane or the ground into one thing which I can call to tell OpenGL where and how to draw?

I suspect the answer is yes, though I'm not certain. I think this is what I'm looking for: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=12
But, it's written in C++ so I don't understand what it's doing. What I really need help with is figuring out what it's doing. I don't know, and I can't figure it out.

I need the relevant code from there that actually makes the display list and draws it. I can figure out where to draw it, provided that I knew which functions to use. Either that or I'm trying the completely wrong thing.

Thanks,
Geometrian

Share this post


Link to post
Share on other sites
It's not hard to find explanations of openGL calls in python -- here's one for glNewList, an important part of display lists. It links to the other functions you'll need to use them.

As far as actually using them goes, the theory is the same for C++ is the same for python is the same for Basic is the same for Assembly.... You politely ask for a new display list, build the display list, then use it whenever you feel the urge. When you're done, you kindly give it back so that it can be used again.

Your overall approach sounds correct - make a plane and a ground, and draw them where they should be -- as separate entities.

Share this post


Link to post
Share on other sites
I see how to compile them into display lists, and yes, that link was perfect, (I'm editing a copy of my code now), but I don't understand how to draw them, either how to call them or how to orient them.

[edit: ok, there's links at the bottom. I'll check out those and get back to you a little later]

[reedit: None of the links seem to work! I've finished editing my code to use the functions in that page, so I just need to know how to call the list, (including positioning it in the proper orientation, position, etc.)]

[reedit: Even though the ones in the bottom don't work, the links in the body of the paper do. I now know how to call a display list, just not how to orient it or place it at a point in space. Is it possible to save display lists to a file?]

[reedit: Ok, so by definition, display lists are drawn where their constituent polygons' vertices lie. Right? Is there any way to translate the place where the display list is drawn without translating the camera?

G

[Edited by - Geometrian on April 22, 2007 9:49:08 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Geometrian
I now know how to call a display list, just not how to orient it or place it at a point in space. Is it possible to save display lists to a file?

To situate a display list, simply use the usual glTranslate/glRotate calls before the rendering, not before compiling the list. As far as files go, no, you can't really save a display list to a file. You can, though, look into saving a loading different model formats, such as .obj and .3ds. You can load these models, then choose how you want to display them (one such method is a display list, though there are others.) There is no native way to save and load display lists, as they reside in video memory.

Share this post


Link to post
Share on other sites
But... Using those functions will move the camera too, won't it?
Thanks for that page! Using display lists almost doubled my fps!

Share this post


Link to post
Share on other sites
Quote:
Original post by Geometrian
But... Using those functions will move the camera too, won't it?

Sure they will. You can then un-move it with glLoadIdentity. It resets the transformation matrix back to the identity matrix (no transforms). Clean slate! Then, move your camera/plane and render it, since they'll most likely be in the same space.

So,
RenderLoop:
glLoadIdentity( ); // start afresh

MoveToGround( );
DrawGround( );

glLoadIdentity( ); // start afresh again

MoveToPlane( );
DrawPlane( );
EndLoop;

Something along those lines.

Share this post


Link to post
Share on other sites
Ok, thanks! I'll try that.

[edit: I just finished changing my program to load the display list from a subprogram that will load a display list. This way I don't have to look at 500 lines of code in my main program (seriously, about 500). I have not yet tried any functions to move stuff yet but it looks promising! I'll post something if I get it to work.]

[Edited by - Geometrian on April 22, 2007 10:13:05 PM]

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!