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 .NET / Memblock Mesh, Indices, Primitives, Triangle Strip, Triangle Fan

Author
Message
PeteyM5
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 7th Nov 2013 22:03
I am attempting to create a set of master meshes for a program and running into a problem with the objects flat square sides only ending up being half of the triangle rather than the full square. I was able to work around this in another 3D engine by setting the primitives to "Triangle Strip" rather than "Triangle Fan". I had been searching through these forms but no one seems to come up with a strait answer.



I know this is not the full source code because the program is huge and is in the process of being ported over the DarkGDK.NET, but I keep hitting little snags like this.

Is there a way to set Primitves to Triangle Strip?

Is there a way to set Indices?
PeteyM5
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 9th Nov 2013 16:26
I created a patch to get around it and treat it as a "Triangle List" rather than "Triangle Strip". Seems to be something lacking in Dark Basic / Dark GDK. Did find a few posts relating to the matter. We all know this is probably not the most efficient way to handle this, but no one got back to me on how to set Meshes to use Triangle Strip, Triangle Fan, etc. This will have to do until I or someone else finds a better solution.




If some of you probably see some of my prior posts, this is for my Role Playing and Adventure Game construction software that I chosen to port over to DarkGDK.NET.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 12th Nov 2013 14:25
I'm fairly certain DGDK by default only handles triangle lists.


"Why do programmers get Halloween and Christmas mixed up?"
PeteyM5
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 15th Nov 2013 05:37
Yeah, took some extensive research and appears other people discovered the same problem. I created a work around that treats each square as 2 triangles so it has extra vertexes that may slow down the game if there are many vertexes present.
The Tall Man
10
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 8th Dec 2013 02:48 Edited at: 18th Dec 2013 13:53
As coincidence would have it, I just modified this in the open-source code (my own copy) for DarkGDK/DBPro earlier today, and then happened across your thread here. I converted the function that creates planes from doing a 6 vertex triangle list to a 4 vertex triangle strip. According to MSDN, triangle fans are deprecated in DirectX 10, so I went with the strip. And the planes are created correctly with this code (I tested it in DarkGDK).

Here's the new function (with the old code commented-out). It is located in the source file is DBOMesh.cpp



P.S. fWidth and fHeight were halved prior to this function call.
(they've used lots of wrapper functions - no doubt from doing a quick merging of the DarkGDK with the DBPro code).

For Reference on triangles/primitives (visit the links in the Remarks section):
http://msdn.microsoft.com/en-us/library/windows/desktop/bb172589%28v=vs.85%29.aspx

Edit - December 18, 2013: I just made a modification to the 4-vertex plane creation function. There's been a bug since forever where planes rendered textures backwards. So I inverted the tu values to correct it. The tu values are the second float value from the end.

Q: ...you mean computer imagery was still based on the paradigm that the world was flat? Even into the 21st century??? Talk about doing something the hard way!

A: Yep! Back then people would render simple shapes with complex meshes of thousands of flat little triangles. Next to the bottleneck processors they used, it's the main reason why their computers were so slow. In the last days of the religious atmosphere of centralization and trade, corporate dogmas had people believing that flat was faster.
The Tall Man
10
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 8th Dec 2013 05:09 Edited at: 31st Dec 2013 07:03
If modifying a function like I mentioned above is beyond the scope of how you wish to keep your project, I've found another way for you to accomplish the same while staying with the DarkGDK commands. DarkGDK has many undocumented commands you can find in the #include files. One is:



This command was present even in the initial release of DarkGDK.

What you can do is create your 4-vertex mesh with a memblock. And after you create your object with that mesh, this little block of code will change the primitive type to a triangle strip:



I tested this, and it does take effect.

By the way, there's no guarantee that using a triangle strip instead of list won't break something down the road. For example, I noticed in CCompiler.cpp this little piece of code from the function cCompiler::CompileScene.



Edit - December 31, 2013: In the second code segment above, I just added that the iDrawPrimitives must be set to 2. To be more accurate, for a triangle strip, this value must be set to the number of vertices minus 2. The MakeMeshFromMemblock command sets this value to the vertex count / 3, which is for triangle lists, and inappropriate here.

Q: ...you mean computer imagery was still based on the paradigm that the world was flat? Even into the 21st century??? Talk about doing something the hard way!

A: Yep! Back then people would render simple shapes with complex meshes of thousands of flat little triangles. Next to the bottleneck processors they used, it's the main reason why their computers were so slow. In the last days of the religious atmosphere of centralization and trade, corporate dogmas had people believing that flat was faster.

Login to post a reply

Server time is: 2024-03-28 18:37:16
Your offset time is: 2024-03-28 18:37:16