Advertisement

How to make an OpenGL demo...!?!

Started by May 20, 2002 04:02 AM
9 comments, last by Halloko 22 years, 9 months ago
Hi.. After having been programming for some while now and having seen a lot of COOL 3D-demos I''ve finally decided to try myself..;-) BUT.. I have a little question: How do you make your 3D world move around all by itself?? For example in 3D Mark''s benchmark demo the camera just moves through the world and kind of a "story" is being told WITHOUT ANY user input..!?! Sooo.. how do u make a "story" in your demo which the appplication can understand and execute?? I''m very excited and hope somebody has some good answers or tips..;-) Halloko Denmark
if that is a serious question for u, go home and learn more - becouse making flights without user input is just like with it, but much more easy. - well, maybe read some tutors from here
Advertisement
Uhmm.. I see.. Or maybe I don''t!!!

Of course it''s easier to make something without the user input but I still can''t figure out if you will have to hardcode where every object goes after another object has moved to a certain place and so on..

It''s easy to make objects do things in circles so they will always return to the same place again.. but to move them to certain places and create the ability of a 3D world in which objects can move FREELY around.. that''s what I''m looking for..

All the tuts I''ve seen so far is about small demos with only one purpose: to show one specific aspect of a OpenGL command in a relatively SIMPLE scene...;-)

Hope you still have some advise (or maybe some links)..

Halloko
Okay, are you asking how to move the "camera" in 3D space? If so, think about it this way: By translating and rotation the matrix according to the camera position and angle before any of your other drawing code, you effectively move the camera (although it''s more like moving the whole world, but that''s only an abstract difference) ... if none of that made sense, look at lesson 10 or look up the gluLookAt() function.

If you''re asking how to script camera movement, try making a file which lists camera positions and camera angles, and have the program read the values from the file, then move to each point and each angle in sequence, at a constant rate (or you can specify it in the file) ... it''s really not that complex if you just give it some thought.
The question is not "why a talking monkey," but rather, "why not a talking monkey." -Monkey Island 4
Hey..

Thanx for the reply.. The problem wasn''t how to rotate and translate the camera. It was the way of scripting a camera..

I think I''ll gonna try your approach by making a file and then load the values..

BTW in another forum a friendly guy advised me to use bezier curves to move the camera.. a really good approach too I think..;-)

Thanx..

Halloko
ok , sorry i misunderstanded u.
now i know u rn''t so newbie as i firstly thought.
for me the easiest way is to mekae something like "keyframes" for objects - u know the positions are beeing kept in some vector-like what u want and after getting a time which elapsed from last frame u interpolate position and animation frame of an object. if u would like u might try to make some "modifier functions" which would aply to object position coordinates - when i programmed a first demo in 2d i used it so u might try to make functions which modify the x+z coords , maybe an object representing a visula should contain a pointer to modifier , hope i could be helpfull, sorry about my first post , good luck
Advertisement
Hey..

Thanx for the tip.. and it''s ok.. u couldn''t know that I wasn''t "so newbie"..;-)
It sounds like a very robust and great method.. I think I''m gonna check it out..;-)

Halloko
Hmmm I have never thought about this much but my guess is that the things that are used to make the camera make smooth round translations are curves. For example think of a sin (or cos) curve. You could use this to make the camera move round an object (or something) in a smooth way.
A really good thing would be to know how to make Bezier curves, thanks to this the only thing you would need to do is to tell your program to go from point A to point B and then your program would do this in a smooth and rounded way like you see in most demos.
In my recent LOTR entry FellowshipZ, I used a simple camera scripter. I designed it from the user-back, i.e. my first design criteria was that it would behave like a simple tape recorder. I setup keys to trigger recording (alt-r), playback (alt-p), saving (alt-s) and loading (alt-l).

Then I simply setup my app''s viewcamera mode (v) to MANUAL, moved to where I wanted the script to start, then started recording. It snaps the camera''s position and orientation once per second (variable), while I lazily move the camera the way I want it to move. When I finished a "loop" I stopped recording, and saved. It goes to a simple ascii file in an easy to edit format if required.

Then, I loaded the script file in init, and triggered playback when in the selected scene (Rivendell).

The script can use either bspline or catmullrom technique for interpolation, and playback can be speed-controlled (+-).

Check the camerascript class if interested.

Otherwise, my motion controller class can move/orient the camera/any object in programmable orbits if I don''t care what I run into.

zin

zintel.com - 3d graphics & more or less
zintel.com - 3d graphics & more or less
Yeah, bezier curves are all pretty and such.

Here''s an article that might help: http://www.pixelate.co.za/issues/9/articles/bezier/article.html
The question is not "why a talking monkey," but rather, "why not a talking monkey." -Monkey Island 4

This topic is closed to new replies.

Advertisement