Jump to content
  • Advertisement
Sign in to follow this  
Kyretzn

Kyretzn's Scenegraph!

This topic is 4335 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

Hey all! This past week Ive spent writing a Scenegraph system. Why do I post this? You may ask? Well, simply because I have absolutely no idea what to do with it!. It loads nicely formatted text files for the 'Scene', Stores them in the Scene object structure, which you can use to Render the scene, or get addresses of specific objects in the scene, so you can like manipulate things. Im thinking of adding a scripting system to it. So far the Scenegraph can: - Load .OBJ Meshes with their corresponding .MTL files. - Draw Mesh to screen, with its texture map and correct Ambient/Diffuse/Specular material settings. - Rotation, Translation, Scaling. - Lighting (Basic lighting, eg: Directional and Positional light sources.) - Camera (Where it is, where it is looking at, what its up vector is.) I think its kinda cool, its not terribly optimized though (I think?) and I havent tested it with a great deal of Mesh activity, but it loads my test Meshes fine and does what I ask of it. All the above, are added to the Scene as Scenegraph Nodes, all of which are modifiable, and will effect the next render, so... I can use the Scene object to return a pointer to whatever Node I search for, use that pointer to move something, or rotate something. :) My test was a bunch of Spaceships flying in formation. Any advice? Im not sure what to do next, but like I said - Im thinking of adding Scripting to the mix, so I can have basic things happening automatically in the scene, like... a Ship moving, or a planet rotating or something, all without me having to type a line of C++ in the main game loop of whatever game uses the Scenegraph. A typical Scene Map would be as follows: add Camera at(-7.0, 7.0, 7.0) facing(0.0, 0.0, 0.0) up(0.0, 1.0, 0.0) ; Adds camera. add Light on Camera Light is Directional Light is positioned at -2.0, 2.0, -2.0 Light points at 0.0, 0.0, 0.0 Light's focus is 0.0 Light's Ambient is 0.2, 0.0, 0.0 Light's Diffuse is 1.0, 0.0, 0.0 Light's Specular is 1.0, 1.0, 1.0 ; Adds lightsource object on Camera node. add Rotation on Camera of(90.0) around(-1.0, -1.0, -1.0) ; Adds Rotation object on Camera node, so the Mesh wont be pointing down... add Mesh from file( Spiderbox ) named Mesh1 ; Adds Mesh on its own Node, loading both Spiderbox.obj and Spiderbox.mtl, the Mesh node ; will be named Mesh1. Anywho, if anyone would like the source code to the Scenegraph ive written, Ill post it if requested. Also, Any ideas what I could do next would be appreciated. Thanks! ~Kyretzn, Ze Black Mage.

Share this post


Link to post
Share on other sites
Advertisement
Scenegraph now supports Texture Mapping, Fog, Blending nodes.

Next? I think I shall add a basic particle system, so maybe I can have some fire or something burning behind a spaceship!

Here is a Screenshot of the current test I have performed:


For those who would like to download the demo and run it on their system,
(Windows users, sorry Linux guys! I feel your pain, Ill release the source soon complete with DevC++ Project file and Linux Makefile.)

: Wraith Demo (as of 03/07/06) :

:) My goal is to get graphics as good as Homeworld 1!.

And, this has been completely coded under Slackware Linux. :) Be slack!

~Black.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kyretzn
Why do I post this? You may ask?
Well, simply because I have absolutely no idea what to do with it!.


Why, writing a game using it, of course! [grin]

Screenshot looks nice. Can it texture the objects properly though?

Share this post


Link to post
Share on other sites
Yes, The Scenegraph textures objects correctly.
UV coordinates are mapped directly, and corrected, so the textures arent flipped or skewed.

There is small limitation to how the system works, for example, after every Face list of faces using a certain texture, you need to add 'killmtl'. This is so the SceneObject_Mesh can track what Faces use what Textures.

When I get home, I will post the source code.
Draw Lists have been implemented, so things will draw slightly faster.
Which, is cool.

I think I might make a game on it indeed!.

Any tips on how to translate 2D Screen coordinates to 3D World Coordinates?
I tried Projecting the 3D Scene to glOrtho2D, but I have a slight idea that maybe glProject call will be useful here.

Thanks for the compliment on the screenshot! :).

~Black.

Share this post


Link to post
Share on other sites
Engine doesnt Normalize yet, like...
It doesnt make the Models look all smooth all over.
Ill add a Normalizing routine sometime.

~Black.

Share this post


Link to post
Share on other sites
You could also implement bump maps, if you haven't yet. Maybe decals. Or a particle system, like you mentioned. And maybe shaders later on.

As for the question you asked, it's a case of picking, I believe. Check the part about transforming an eye coordinate pick ray into object coordinates, something like that is probably what you are looking for (if you weren't looking for picking to begin with).

Share this post


Link to post
Share on other sites
Bump Mapping sounds tasty.
Although, I still want to keep the engine relatively simple.
A slightly more advanced Homeworldesque engine sounds ok.

Im thinking of a game design, and I was thinking of maybe a Freelancer type game, but way deeper, free and multiplayer.

And... Maybe instead of space, its done in some other otherworldly seeming place, like... maybe Under water.

Im not so good at Texturing though :(.
Im going to do a google search on Bump Mapping on OpenGL, Just curious- is that built into GL, or will I need to use Extensions?

~Black

Share this post


Link to post
Share on other sites
Generally speaking you need multi-texturing for it, so that means OpenGL 1.4 at least, iirc. You could check out NeHe's tutorials, there's a couple on various bump mapping techniques.

Share this post


Link to post
Share on other sites
Ive been toying with Camera control and movement in code.

You know, so I can have FPS View.

so far, I have Left and Right camera rotation working, but Up and Down isnt working correctly, and... if I rotate left and right, looking slight up or down, things change.

Here are my calculations:

degreex += 1.0; // Increment Degree for X
XD = sin(degreex*M_PI/180.0) * 5.0; // Workout the Vector needed to place LookAt X
// At the right place.
ZD = cos(degreex*M_PI/180.0) * 5.0; // Workout the Vector needed to place LookAt Z
// at the right place.
pC->LookAtVector[0] = (XD); // Make Camera LookAt X = XD
pC->LookAtVector[2] = (ZD); // Make Camera lookAt Z = ZD

This seems to work fine, when I am looking completely level, however when the Y is changed, things get all not rotating FPS style.

Any tips?
~Black

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!