Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Merging Meshes

Author
Message
Elenesski
17
Years of Service
User Offline
Joined: 21st Sep 2007
Location: Calgary, AB
Posted: 24th Sep 2007 03:34
I need to know whether Dark GDK has the ability to merge meshes together so that a new mesh is created as a result. For example, suppose I want to form a 3D "I" shape. I could do this with three boxes. Two laying horizontal and the other vertical.

Now, I want is to take these three meshes and merge them together so that instead of "remembering" that the shape consisted of three meshes, only one mesh is required to represent the composite shape. Furthermore, the mesh takes into consideration that it doesn't need to represent or show the interior of the result, just the exterior parts.

Once finished the merge, I want to save it as an "X" mesh so that I can use it at a later stage in the software.

Fundamentally, the GDK may not be able to do this (would be great it if could), so my question is, do the Game Creators and/or the GDK have such a library to merge meshes, and if not where could I find one? Is this a really unique request?

Thanks,
- El
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 24th Sep 2007 06:22
You can link various meshes by creating one Object and then linking other meshes as limbs.

The final result can be saved, as far as I know, as a .DBO file to be used later. Dunno if can be converted to .X

I think these are correct, maybe somebody else can reafirm this.

Best regards,
Thiago
Elenesski
17
Years of Service
User Offline
Joined: 21st Sep 2007
Location: Calgary, AB
Posted: 24th Sep 2007 07:26
Just to clarify, want a single consolidated mesh, not a list of linked meshes. Linked meshes would overload the graphics engine by asking it to load tens of thousands of meshes. I only want one ...

Simple Example: I want to form the letter "I" in 3D. I could do this by taking three boxes, 2 horizontal and one vertical and merging them together. The result is a new shape. I want to then create a new mesh which is the amalgamated version of the three shapes so that I do not have to remember that this new shape was a composite of other shapes.

Complex Example: I want to build a complex machine (as part of a game) which has dozens of parts. Once the machine has been certified (that it works), I want to form the outer shell of the machine and only render (in the game) the outer shape of the machine. Getting more complex, I want to use this new machine with several other machines to build a more complicated machine. Once again, I want to form the outer shell of the machine so that I only render the outer shape of the machine.

Ramping Up the Sophistication: Continuing this process through multiple iterations, it would be possible to build a really big machine consisting of hundreds of thousands of parts. A graphics engine would get overwhelmed if it had to draw all of the parts of the machine. Instead, by simply rendering the outer shape of the final machine, it would be possible to draw dozens of copies of the machine in a scene, even though the underlying machine is extremely complicated because of the number of parts involved.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Sep 2007 12:21
The function names are mis-spelt, but they are there:
void dbPeformCSGUnion ( int iObjectA, int iObjectB );
void dbPeformCSGDifference ( int iObjectA, int iObjectB );
void dbPeformCSGIntersection ( int iObjectA, int iObjectB );
void dbPeformCSGClip ( int iObjectA, int iObjectB );
void dbPeformCSGUnionOnVertexData ( int iBrushMeshID );
void dbPeformCSGDifferenceOnVertexData ( int iBrushMeshID );
void dbPeformCSGIntersectionOnVertexData ( int iBrushMeshID );

Remember that CSG does nothing with textures, so if you join two meshes with two different textures you are liable to get a mess.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 24th Sep 2007 12:26
Quote: "Linked meshes would overload the graphics engine by asking it to load tens of thousands of meshes. I only want one ...
"


i'm kinda assuming... and this is just an assumtion, mind you... that either one, if it contains that much geometry, would over load many aspects of the 'engine'...

good luck though...

--Mike
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 24th Sep 2007 20:18
Quote: "
void dbPeformCSGUnion ( int iObjectA, int iObjectB );
void dbPeformCSGDifference ( int iObjectA, int iObjectB );
void dbPeformCSGIntersection ( int iObjectA, int iObjectB );
void dbPeformCSGClip ( int iObjectA, int iObjectB );
void dbPeformCSGUnionOnVertexData ( int iBrushMeshID );
void dbPeformCSGDifferenceOnVertexData ( int iBrushMeshID );
void dbPeformCSGIntersectionOnVertexData ( int iBrushMeshID );
"


Those are Stock Commands Eh? Cool! All this under-the-hood vertice stuff is starting to make sense. How do you tell DarkGDK what is a surface and what isn't? (Like how could you make a "Cube" and remove one face?)

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Sep 2007 21:24
If you want low-level stuff like that then you wouldn't use the CSG functions, and you probably wouldn't use the vertexdata commands (unless porting from DBPro, or maybe when using .NET) - you'd access the object meshes directly.

Most objects are set up as lists of vertex positions. If there is no index buffer then each 3 vertices make up one poly. If there is an index buffer, then each 3 indices make up one poly and each one is an index into the vertex buffer. Both of these methods are forms of triangle lists (or tri-lists for short)

You'd also need to take into account that some of the stock objects aren't set up in this way - they'll use tri-strips (1st three vertices make a poly, then the next vertex plus the last 2 make the next poly etc) or tri-fans (1st three vertices make a poly, then the next vertex plus the last and first make the next poly).

Oh, and IIRC, the CSG functions only work on tri-lists.

It can be complicated.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 24th Sep 2007 22:37
Good Stuff - Where are the "lists"? Where are these data structures?

struct Vertice{
float x;float y; float z;
};

??

(appreciate the brain dump) Not even sure I'll use it right away but being able to essentially do what a modeling program does programatically seems like it could be useful. make dot make another dot, make another dot... then make three dots into a poly face.. then weld to another etc.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Sep 2007 23:55
You can get the internal point to an objects data by calling dbGetObject(ObjNum) - it returns an sObject*.

The structures for the internal data are in '.../Dark Game SDK/Include/DBO Format/DBOData.h'.

In the sObject structure is an item 'ppFrameList', which is an array of sFrame structures (frames are the internal equivalent of limbs).
Each frame can have a mesh attached (pMesh).
Each mesh has a vertex buffer (pVertexData), and may have an index buffer (pIndices). You'll notice the pVertexData is a BYTE* - because the format varies depending on the value of dwFVF, the size of each vertex can vary.
The type of mesh it is is held in iPrimitiveType, and contains one of the following values:

If you lock the vertexbuffer, make your changes to these structures are the limb level, then unlock the vertexbuffer, the D3D structures will be correctly updated so that you can see the effects.


Hope that hasn't confused you too much, but you did ask

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Sep 2007 00:52
Nope - I'm very grateful you did post that bounty of info. Now I know in short what to do - BEFORE - and I know where to look in the headers etc with some "primer" knowledge for the DURING and I know what to do AFTER so I can see the changes "accepted". Way Cool.

I Guess - making these from scratch is tricky! hehee... There must be a way to swap the pointer from one object to another - that would complete the circle... One could totally design an object at the tri-coordinate level up that way - pick a "link" method - start plotting - connecting dots and whella!

Not a 1 hour task that is for certain!

Login to post a reply

Server time is: 2024-11-19 16:33:06
Your offset time is: 2024-11-19 16:33:06