• Advertisement
Sign in to follow this  

Kyretzn's Scenegraph!

This topic is 4237 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
On the bright side, Ive got Movement working fine.
I will always move towards the point in space wher ethe camera is facing.
Which, is atleast a plus! :)

Just, rotating the camera properly is what im havnig difficulty doing.

I intend to make a Space Shooter game as a test.
~Black.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
probably adding a collision query system is next,
it would probably be integrated into the scenegraph, with each node containing the bounding volumes of its children etc. that also adds certain problems like
dirty flag propagation and recomputation of child bounding volumes when objects move in relation to each other.

fun stuff

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
oops....forgot to mention you could go down another path and integrate physics engines like ODE. Then you can piggy back your collision/picking via ode :)

Share this post


Link to post
Share on other sites
Alrighty, Well ive got camera rotation and movement working.
Although, not precisely how I wanted it.
*sigh*

I can move left and right, and move in whatever direction im facing.
I can also look up and down, hwoever it doesnt 'rotate' around if I look up high enough.

Like, I have enough to make a basic FPS now.
But, I do not have enough to make a space sim.

In space, you can look around 360 directions in all directions. Hmm.
I suppose Ill keep playing with it, hopefully Ill have what I want soon enough! :).

I shall post the source soon, should anyone be interested.

~Black.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kyretzn
Alrighty, Well ive got camera rotation and movement working.
Although, not precisely how I wanted it.
*sigh*

I can move left and right, and move in whatever direction im facing.
I can also look up and down, hwoever it doesnt 'rotate' around if I look up high enough.

Like, I have enough to make a basic FPS now.
But, I do not have enough to make a space sim.

In space, you can look around 360 directions in all directions. Hmm.
I suppose Ill keep playing with it, hopefully Ill have what I want soon enough! :).

I shall post the source soon, should anyone be interested.

~Black.



I'm interested!

Share this post


Link to post
Share on other sites
Can't help beyound saying that you should look into Quaternions for camera operations. I've used some tutorial as basis to set mine up, and it works, though I still have no idea why ^_^;;;.

Share this post


Link to post
Share on other sites
As of yet, Wraith SG is *not* commented, maybe one file out of the 26+ are commented.

Would you rather me spend a couple hours commenting all of the code? or upload it as is?

~Black

Share this post


Link to post
Share on other sites
I wonder how people have implemented like, a roaming galaxy in other games.

So it seems like the Universe is MASSIVE and... never ending.
Any tips people?

~Black

Share this post


Link to post
Share on other sites
Hey all! I think ive decided on what kind of game I would like to develop.

A close friend and I are both ... avid fans of games like Arcanum, Fallout 1/2 and Morrowind, and I have old sourcecode lying around that implements a Morrowindish Skill system (albeit in my opinion, a slightly better skill system than Morrowind).

Anywho, The question is, quite simply - Is there a way to make a Isometric view in OpenGL, using completely 3D Objects?

Ie, Instead of writing a true Isometric engine, that utilizes Tiles and the like, The graphics you see are rendered on the fly, the World (Cell you are in) is just a bunch of texture mapped Verts, etc.

The problem? OpenGL seeems to have a Perspective view of everything, thus ruining the Isometricness.

I have heard of Orthographic, but I dont suppose I can use Orthographic view to make a true Isometric view? Without having to code a Tile system?

:) Any insights would be greatly appreciated!.
Also, Any graphics wizzes would interested, Give me a yell!

~Black, the Bit Wizard.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kyretzn
I wonder how people have implemented like, a roaming galaxy in other games.

So it seems like the Universe is MASSIVE and... never ending.
Any tips people?


First, Space is vast, but mostly empty. Second, galaxies can be generated on-the-fly with procedural methods. (This is the only way to do it, actually).

Share this post


Link to post
Share on other sites
Quote:
Original post by Kyretzn
Anywho, The question is, quite simply - Is there a way to make a Isometric view in OpenGL, using completely 3D Objects?

Of course.

Quote:
Original post by Kyretzn
The problem? OpenGL seeems to have a Perspective view of everything, thus ruining the Isometricness.

E.g. glOrtho sets up orthographics projection. An orthographics projection is a special kind of parallel projection, what means that the projectors are all in parallel. Being orthographic means additionally that the projectors hit the projection plane in a 90 degree angle. Now, isometric projection means additionally that the distances along all 3 principal directions are shortened the same amount when being projected. This is yielded by orienting the camera so that the line of view hits the world's principal planes all in the same angle. For this purpose, rotate the camera heading to 45° and do a pitching by 35.3°.

Notice that most games that are called "isometric" are in fact dimetric. That means that only 2 of the 3 principal directions are shortened the same amount. Kinds typically used in computer games are the so-called 1:2 and 3:4 projections, where the former one sees more "from below" while the latter one sees more "from above".

[Edited by - haegarr on July 6, 2006 12:23:21 PM]

Share this post


Link to post
Share on other sites
Hey again all!

A small group of friendly Mesh artists and myself have started a little group called Cure.

Anywho, a couple new pictures from the engine.





Anywho, I fixed a crapload of freaking bugs in the Scenegraph, and made a lot of little tweaks, so it works better and seems more organized.

I have a question!
You can see that Smooth shading of the Model is infact, NOT working.
I figure this is because the Normals arent being calculated.

Now, the question is - Is there a function that you can call built into GL, that calculates the normals for you so Smooth shading works correctly?

OR... Do I have to normalize the Mesh, every frame myself?
And would that fix the Smooth shading issue?

:) Enjoy.
Also, we have a website.
Its not a fancy website, but its a website none the less.

It has the sourcecode for the Wraith Scenegraph as of yet... but the Main.cpp is a messy hack of gloom, I put it together for a quick dirty demo.

Also, its stress testing. Loading 8x 3776 Poly models, I was curious to see what would happen :P.

the results were the pictures.

Anywho, link to the site....

: Cure Entertainment :
: Cure Forums :

Any help would be appreciated.

~Black

Share this post


Link to post
Share on other sites
More tweaking and bughunting.
Found a stupid mistake in the Blending Node, aswell as a couple more in the Mesh Loader.

Anywho, Ive implemented a slightly different Lighting method.
:) Shading looks like it should now!.
Tell me what you think!

Better or worse? :)





:) Im happy about it, so far.

~Black.

Share this post


Link to post
Share on other sites
Yay! New screenshot!.

Testing my new Mesh loading system (Im going to tweak the OBJ Format, Mannnn! Its a test file, its big... A byte per digit. ;) Lets make it Binary! and maybe compress it with ZLIB. :)

Anywho, Here is the test. Ive also implemented a simple Skydome! Low resolution texture, but I think it looks neat.

Also, sorry about the Image size. Its about 1.92MB PNG, I havent got GIMP installed as of yet, so many appologies.



:) Tell me what you think!
;) Its getting a little lonely being the only one in here.

~Kyretzn.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kyretzn
Also, sorry about the Image size. Its about 1.92MB PNG, I havent got GIMP installed as of yet, so many appologies.


Who needs GIMP when there's convert? [grin]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement