Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scenegraph branch
05-17-2007, 07:23 PM,
Scenegraph branch
Lately Joe has been working on a new branch for refactoring the game's drawing code. It's in our SVN repository here:

You can check it out like this:
svn co vdrift-scenegraph-branch

So far things are starting to work well again but there are still some problems. Most of the 2D drawing code seems to work. 3D is not so good, in fact, none of the 3D stuff seems to work at all... Smile
05-17-2007, 11:56 PM,
As of R1726, all 3D drawing is completely disabled, but I now have the 2D drawing perfected with all of the bugs stamped out. 2D drawing is now faster than the trunk! I know it doesn't mean much to the average user to get 240fps in the menu screen instead of 210fps, but I'm pleased. :-)

I'd say this branch is about 80% of the way to being playable. The 2D stuff was the hard bit. Wrapping the basic 3D drawing with the scenegraph should be relatively easy (that's what it was meant for). After that I'd like to merge back into the trunk (or at least get some people to try the scenegraph branch) to stomp out remaining bugs. Then I can start playing around with the fun stuff... new graphical effects, new ways to enhance performance.
05-20-2007, 07:18 AM,
Hi Joe, the auto-x track layout designer i'm playing with is based on your scenegraph branch. I have some questions on the drawing code. Hope you can answer them.

In the designer, I need to draw quads defined by 4 cones at the corner. So i've added a function in utility.cpp called DrawQuad(). It's similar to DrawButton() but with 4 pairs of (x,y) instead of 2.

Look at the code, it seems to me if a particular ELEMENT2D is already in UTILITY::draw2d map, it will not be added again. So,

1. If i want a particular shape to be drawn in front of another (z-order), how do i specify that?

2. How do i remove a shape from the draw2d map? Looks to me the map is not cleared every frame. Or is my understanding wrong?

Should I commit my changes so you can have a look?
05-20-2007, 12:51 PM,
I recommend not basing your code on the utility:Big Grinraw functions. They're a hack to try to get the old 2D draw functions to work with the new scenegraph code (with reasonable performance). Instead, you should try to work directly with the scenegraph. Here's how:

You should create a scenegraph node under the root node and store a handle to it (via a pointer or reference or BIPOINTER or whatever you prefer). You do this with; which returns a SCENENODE & reference to the created scenenode. Then, when you want to add an object to draw, you'll add a drawable to the node with scenenodereference.AddDrawable(); which returns a DRAWABLE & reference to the created drawable. You can then use this reference to set the properties of the drawable (more about that in the next paragraph). These objects are stored in the scenegraph. The GRAPHICS class draws the scenegraph once every frame, and that's where the code lives that will draw your drawables. So, you don't do any draw call or anything for each frame... your class just sets up the drawable ONCE and then drawing for each frame is taken care of elsewhere. If you need to change the drawable properties later, you just use your reference to do so. If you want to delete a drawable you call scenenodereference.Delete(&drawablereference);

So how do you make sure that your drawable gets drawn the way you want? Well, the drawable is a general object that is supposed to handle any possible drawing that you'd want to do. It may not do that yet, but that's the intent. To draw a quad without a texture but with color, you'd probably want to set the drawable type to vertex array (drawable.SetToVertexArray()). You get a reference to a VERTEXARRAY object, which you can fill with vertices and normals and texture coordinates and faces. For your purposes, you'll just want to add vertices and faces (4 verts, 3 faces). You can use UTILITY::SetVertexData2DQuad to make generating a vertex array for a quad a bit easier. After you get the vertex array set up, you should set the other properties of the drawable. So do a Set2D(true) and a SetColor(r,g,b,a) and a SetLit(false) and a SetPartialTransparency(true). The defaults for all other properties should be fine. At this point your drawable is set up and will be drawn this way each frame. You can use the DRAWABLE public interface to make other changes later if you want.

This might not get drawn exactly how you want it at the moment, and if it doesn't turn out right, check it in and I'll look at it. The GRAPHICS:Big GrinrawList function does all of the actual drawing and I'm still in the process of getting it set up the way I want. Currently there's no good way to z-order objects, but I'll work on adding this now as a DRAWABLE property. Let me know if you have any other questions.
05-21-2007, 07:33 AM,
Thanks for your explanation Joe. Now it's becoming clearer. I'll look at how to use the new way to draw. In the meantime, I've committed my code into the scenegraph branch for others to take a look.
05-30-2007, 02:08 AM,
rookie1: I haven't forgotten about the request for layers (or some sort of ordering) for the scenegraph drawable class... I've just been busy with other things. I'll add it in soon, I promise....

By the way, the branch now uses ODE for collisions. It's not perfect yet, but is more or less working. Just a few bugs to work out. I also checked in a NaN fix to both the scenegraph branch and the trunk, and I haven't gotten any NaNs yet! Hopefully that bug is dead and gone....

Anyway, if anyone gets a chance try out the scenegraph branch and let me know if ODE collision is working for you all. I'm using version 0.6-rc1 of ODE (an older version, I know). I included all of the ODE headers in the project include/ dir, and I'm not sure if that's a good idea or not... but there you are. Try it!
05-30-2007, 07:10 AM,
I'm using ODE 0.8 to test (self compiled since Ubuntu only has version 0.5). If I chose Monza, the game throws below exception and end immediately.

EXCEPTION: src/3dmath.cpp, line 769: vertex length is negative..??: nan
06-07-2007, 09:40 PM,
My newer 3dmath code throws exceptions when it encounters NaNs. Before, if the NaN was in something that wasn't important and went away next frame, VDrift would keep on cruising along. However, I don't want any NaNs anymore, so now I throw exceptions all over the place for NaN values. I fixed a big NaN issue, perhaps *THE* NaN issue, in my scenegraph branch. Once the repository is up I'll check in my code.

Also, I added fragment shaders and motion blur. It looks awesome.
06-07-2007, 10:48 PM,
Yes, it looks so awesome. Big Grin No joke, the blur really makes a big difference.
06-09-2007, 01:23 AM,
Here are some screenshots for the curious:

Yes, the performance is poor at the moment... don't worry, it's not optimized at all, yet.
06-10-2007, 09:56 PM,
SVN is back up and I checked everything in. I've been doing a lot of optimization and profiling, and my FPS is up to 115 or so on leguna seca with blur and bloom turned off. With blur turned on it's about 37.
06-20-2007, 11:31 PM,

I need to work on them quite a bit still, but it's just tweaking, now.
07-04-2007, 04:25 AM,
I've updated a few things in the scenegraph branch...I modified the logging classes a little to remove the dependence on shared pointers, and then set up a few basic logs using it. They don't seem to be working yet, perhaps it's because of my modifications...

I also set up the control class write function to use the configfile format instead of the old format. I haven't rewritten the read function yet, just because I want to first make sure the game will figure out if the new file exists, and if it doesn't, try to fall back to the old format. This way everyone won't have to re-input all their controls, but the game will always write in the new format, so they'll be automatically upgraded.
07-04-2007, 06:08 AM,
My poor Geforce 4200 does not support the shaders recently added in. Sad What is the minimum shader version support required? Is there a switch to disable shaders if my card does not support it?
07-04-2007, 09:19 AM,
Ok. Guess I posted too soon. After getting the latest revision (r1743), I'm able to play now. Still having some graphics glitch though, not sure whether it's shader related.

Forum Jump:

Users browsing this thread: 1 Guest(s)