Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scenegraph branch
05-20-2007, 12:51 PM,
#4
 
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 game.graphics.GetScene().GetRoot().AddNode(); 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.
Reply


Messages In This Thread
Scenegraph branch - by thelusiv - 05-17-2007, 07:23 PM
[No subject] - by joevenzon_phpbb2_import3 - 05-17-2007, 11:56 PM
[No subject] - by rookie1 - 05-20-2007, 07:18 AM
[No subject] - by joevenzon_phpbb2_import3 - 05-20-2007, 12:51 PM
[No subject] - by rookie1 - 05-21-2007, 07:33 AM
[No subject] - by joevenzon_phpbb2_import3 - 05-30-2007, 02:08 AM
[No subject] - by rookie1 - 05-30-2007, 07:10 AM
[No subject] - by joevenzon_phpbb2_import3 - 06-07-2007, 09:40 PM
[No subject] - by thelusiv - 06-07-2007, 10:48 PM
[No subject] - by joevenzon_phpbb2_import3 - 06-09-2007, 01:23 AM
[No subject] - by joevenzon_phpbb2_import3 - 06-10-2007, 09:56 PM
[No subject] - by joevenzon_phpbb2_import3 - 06-20-2007, 11:31 PM
[No subject] - by thelusiv - 07-04-2007, 04:25 AM
[No subject] - by rookie1 - 07-04-2007, 06:08 AM
[No subject] - by rookie1 - 07-04-2007, 09:19 AM
[No subject] - by joevenzon_phpbb2_import3 - 07-04-2007, 12:51 PM
[No subject] - by rookie1 - 07-05-2007, 07:33 AM
[No subject] - by thelusiv - 07-06-2007, 02:12 AM
[No subject] - by rookie1 - 07-06-2007, 06:57 AM
[No subject] - by joevenzon_phpbb2_import3 - 07-06-2007, 11:41 AM
[No subject] - by thelusiv - 07-06-2007, 01:29 PM
[No subject] - by rookie1 - 07-06-2007, 11:37 PM
[No subject] - by joevenzon_phpbb2_import3 - 07-07-2007, 01:00 AM
[No subject] - by joevenzon_phpbb2_import3 - 07-07-2007, 02:35 AM
[No subject] - by thelusiv - 07-07-2007, 03:18 AM
[No subject] - by joevenzon_phpbb2_import3 - 07-07-2007, 12:48 PM
[No subject] - by thelusiv - 07-07-2007, 01:07 PM
[No subject] - by charlieg - 07-08-2007, 01:50 PM
[No subject] - by thelusiv - 07-08-2007, 09:42 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)