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 / Creating a custom 3D model using undocumented functions...

Author
Message
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Jan 2012 23:12
I found a great tutorial with sample code after searching for "loading custom media" in GDK. So I'm at the point were I've used the tutorials and come up with implementing it into my own code to generate a level from vertices and indices myself.

It's not creating a model... Anybody help out?



Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 18th Jan 2012 01:22
I'm not sure about what you have there but you can create an object like this.



I use it for adding vertices to an existing object, this is why the vertex and index data is not set in the above example, it's pretty easy to do though.

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Jan 2012 01:47
Thanks Matty, implemented that and it now works. Now I've had to reverse my faces orientation. I always thought a face should be clockwise.



Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Jan 2012 18:16
@Matty H - Does this also work by adding an empty plane object as a limb to an object? It's so I can add as many limbs as I need to my base object...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 18th Jan 2012 20:18
Not sure, although I don't see any reason why you could not turn an object into a mesh and then use dbAddLimb() to add it to your original object.

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Jan 2012 21:17
Yeah, I've been trying to figure out if there's a less long winded way of building an object. And also to see if it can be done without shifting data around in memory via meshes. For this current project I'm on I can get away with it but for a later project it'd be good if I could almost instantly throw an object together, a reasonably large one.

I think for the time being I'll go via meshes but I'll still play around with the original code from the old tutorials to see if it is possible...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 19th Jan 2012 20:08 Edited at: 19th Jan 2012 20:12
Hi, WLGfx

I have been working on Mike's tutorial. I’m not sure if any of this will help you. By adding three vertices and one primitive to his M2 – 003 example, I have made a plain object. Beyond this example I am lost. My mind not being what it once was, I don’t fully understand exactly what the indices are. This is my code for that.



While browsing DBPro’s source code, I came across the MakeCone function. Although this is already implemented in DGDK, I added a slightly modified function to my source. This function uses indices, but I still can’t seem to grasp them.

Help, please!

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Jan 2012 22:49
I got that cone code to work just fine, so I'll use that as a basis for what I'm working on. My original code I tried just didn't do anything with the indices list.

The vertex list is just a list of 3D vectors in space. If an object is using an index list then faces are created by the indices. ie. 0,1,2 would point to a triangle made up of vertices 0, 1 and 2. The direction it draws is determined by the clockwise orientation of the vertices. Also using this method you can share vertices.

D3DPT_TRIANGLELIST tells you that an object is using an index list referncing the verts. It's also usually the preferred method because the faces of an object don't have to be attached to one another.

The only thing that needs sussing out now is how to use the same examples and add limbs to an object. I'm sure it's something to do with the pMesh list.

Thanks WickedX for something that you got working...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 19th Jan 2012 23:27
Thanks, so if I have this right. In this SimpleMeshFormat 1 text file for a cube, there are 24 vertices and 12 indices. Am I correct? And if so now I just have to figure out how to implement that.

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Jan 2012 00:56
Basically yes, 12 groups of 3 indices for each triangle. I'm assuming the extra data after the index list is either the face normals or 'more' likely the vertex normals. These normals are usually setup during the creating of a vertex.

I've been recently experimenting with shared vertices, so if you had that list up there with just the coordinates for 8 vertices, the indices list would be the same size but reference just those 8 verts.

However you will notice a big difference when it's displayed, the sharp edges of the original cube go and smoother looking edges appear. Some of us older programmers tend to log these things in our memory (that one cell thats left). They do come in handy a) for faster rendering of very large objects with less verts (less calcs on the gpu I guess) and b) Making sure sharper edges can also be done with a little tweak.

I'm still chuffed that you posted that cone code earlier. Was a jump in the right direction for my next project (which is 99% likely to be done in one fo the GDK's)...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 20th Jan 2012 02:09
chuffed.xD - My new word of the day.

Quote: "I've been recently experimenting with shared vertices, so if you had that list up there with just the coordinates for 8 vertices, the indices list would be the same size but reference just those 8 verts."


I thought as much, that’s just how MilkShape exported it. The extra data appears to be the Normals and UV data for the three vertices respectively.

What’s the difference between Vertex Normals and Face Normals? I’ve always assumed Normals where Normals. The only difference being how there calculated i.e. (Vertex Normal is the average of the sides shared by a vertex).

Glad I could help, although all I did was post the code.
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Jan 2012 14:10
As far as I can tell, the dbo format only uses vertex normals which is annoying because some things would be much faster if you didn't have to go down the route of using more and more vertices to get the corrected normals on a face.

Those tutorials I had a nosey through and my first experiment was just using one of the examples. Which ended up not working for me. The code you posted was from another one but when I tried it, it worked. he he...

As I'm ploughing through this project I'm going to be commenting it as much as I can because I'll be releasing the source. For the main reason that others can learn from it.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 20th Jan 2012 20:55
Thanks WLGfx,

Your help is greatly appreciated, I now have a working example of a plain object both using indices and not using indices. I am also chuffed about these new found functions. Now were free to use the other primitive types.



Experimented with making 3D lines with D3DPT_LINELIST, it worked beautifully. Now to figure out how to add limb and animation to an object. I’ll keep muddling through the DirectX SDK reference document and DBPro source code. If I find anything that may be of use I will post it here.

Looking forward to your, completed project.

Cheers.
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 21st Jan 2012 14:48
Guys, while on the subject of creating an object. Do you guys have any idea how I could retrieve the total number of triangles an object has?
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 21st Jan 2012 16:03
This seems to work. It gave correct results for my plain object and an FPSC character model.

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Jan 2012 16:10
I was just looking up that. Could you not also dbLockVertexDataForLimb()...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 21st Jan 2012 16:36 Edited at: 21st Jan 2012 16:46
Correction, found a flaw in the previous code.



Edit:

Quote: "I was just looking up that. Could you not also dbLockVertexDataForLimb()..."


Gave that a try, seems to work as well.

Edit:

I take that back. dbLockVertexDataForLimb() returned a big zero for the index and vertex count for the animated character.
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 21st Jan 2012 17:06
Quote: "I take that back. dbLockVertexDataForLimb() returned a big zero for the index and vertex count for the animated character. "

which limb number did you check?

WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 21st Jan 2012 17:08
Limb(0) and limb(1), both returned zero.
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Jan 2012 17:32 Edited at: 21st Jan 2012 17:37
I'm looking into the dbo structures today cos I'm sure you can retrieve that data with something like:

sObject* myObj = dbGetObject(ID);

Also, I need to be able to add limbs manually. If not I'll have to do it the long winded way for now...

EDIT: Looks like it might be part of this


Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-11-19 04:31:24
Your offset time is: 2024-11-19 04:31:24