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.

DarkBASIC Professional Discussion / Make high poly model into triangle objects

Author
Message
Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 28th Feb 2009 03:28 Edited at: 27th Oct 2009 20:12
New Question:

I figured out how to do this with spheres in this example:



This doesn't work for plain objects.

Replace:


with:


The object wasn't constructed successfully. Try using a box instead of a plain and you end up with something close but not quite what I am trying to do.

I have tried using Lock VertexData For Mesh and it doesn't seem to work.

Another idea is to use memblocks, but idk if it will work with plains.



Old:
What I am trying to do is to take a high poly model and break it up into separate triangle objects.

This isn't easy as it sounds. I have tried about 5-6 times and wasn't able to get it.

Basically what needs to be done is:
- Use vertex data to get vertex positions
- Convert them into world positions by adding the objects position to the vertexes position

The part I can't figure out is figuring what vertexes will form the triangle.

It has to do with Index data, but I haven't really figured out how it works quite yet.

I will post my attempts here soon.

- How to make the triangles (X,Y) into Pyramids (X,Y,Z).
- How to fill these pyramids in the sphere to make the object full with pyramids.

Dark Fire

My future self met up with one day to teach me what I know today.
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 28th Feb 2009 13:21
Hi Dark Fire

Try looking at this post in code snippets from [ Mr Tank ]
Exploding Sphere using vertex data commands
could be what you are looking for...

http://forum.thegamecreators.com/?m=forum_view&t=141809&b=6
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 28th Feb 2009 13:25
sorry that link is wrong... don't know how to add link..
just go to code snippets [ My Tank ] 9 Jan 2009.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 28th Feb 2009 15:04
This might be along the lines you are think, there a command in the GameFX called reduce mesh look it up and see if it will help.

Even if does not worth knowing about.

Dark Physics makes any hot drink go cold.
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 28th Feb 2009 15:24
Or just use make mesh from object and it will triangulate it for you. Just go through all the verts in order. Each 3 makes up a triangle.

Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 1st Mar 2009 05:18
@Lost in Thought - I have tried that.

- Converted object to mesh
- Get VertexData from the mesh
- Create a triangle 3 vertexes at a time

Visually got nothing. I will post code to show what I mean soon.

@J_C - I don't think he has converted a mesh to triangles.

An example of this working would be great. I will post code here as soon.

Thanks,

Dark Fire

My future self met up with one day to teach me what I know today.
Mr Tank
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 1st Mar 2009 21:19
If i remember right, make mesh from object does not change the model into the format you want - a series of sets of 3 vertices, each describing a triangle polygon. Make memblock from mesh does though. You can then make a mesh from that memblock, and make an object from this mesh.

This is what happens at the start of my code snippet. The explosion keeps a single model, rather than a separate one for each triangle. That was basically the main point of the snippet- using separate objects would run much slower.

If you just want to access the triangle information from your mesh/object, you can do so without using the memblock trick. Check out the indexdata commands. Should be in the help file listed next to the vertexdata ones.

Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 2nd Mar 2009 20:25 Edited at: 2nd Mar 2009 21:41
I figured it out! Index Data taken in threes gives you the vertex indexes for the triangle. Use the vertex data to get the positions and it works.

Thanks. I was able to figure it out my-self. Just took a bit to figure how index data works.

Dark Fire

My future self met up with one day to teach me what I know today.
Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 2nd Apr 2009 18:42 Edited at: 2nd Apr 2009 20:21
Though I figured it out. I have holes that I need to fill for this mesh. Try this code snippet and let me know what I did wrong.



Thanks,

Dark Fire

My future self met up with one day to teach me what I know today.
Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 14th Jun 2009 22:59
I am still having problems getting it to work. I forgot to delete the sphere I was making into triangles so it looked like I have made all the triangles. If you try the code in the post above it shows how there are still holes in the mesh.

I still need some help with this one. Check the above post.

Thanks,

Dark Fire

My future self met up with one day to teach me what I know today.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Jun 2009 00:33


DBPro spheres are made from triangle strips rather than triangle lists. In triangle strips the last two vertices of the last triangle make up the first two of the next, so the total number of triangles is the number of indices minus two.

Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 18th Jun 2009 22:51
@Diggsey - Thanks, that did it.

I now have to make these X, Y triangles into X, Y, Z triangles. (Meaning they have depth)

Question:
Any way of making a pyramid object and then applying it to my example so the pyramid triangles fill the object? (What I am trying to accomplish is some fake DMM effect.

Thanks,

Dark Fire

My future self met up with one day to teach me what I know today.
Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 8th Jul 2009 00:58
How can you make a triangle, but with more depth?

Thanks,

Dark Fire

My future self met up with one day to teach me what I know today.
qwe
20
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 8th Jul 2009 12:01
take the triangle you have made,

add another vertex at point XYZ,

connect that vertex to the already existing 3 vertices with three triangles and you have a pyramid.

the trick is to find the XYZ coordinates

the three existing points making the triangle (which will be the base of your pyramid) form a plane. you want to find the center of the plane, then point a vector, from the center of the plain, "inward" into the object. the new vertex to add in order to complete the pyramid will be along this vector

btw, you aren't taking a XY triangle to a XYZ pyramid, you're taking an XYZ triangle (with 3 vertices and 1 triangle) to an XYZ pyramid (with 4 vertices and 4 triangles)
Image All
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 8th Jul 2009 21:05
to get the xyz for the fourth vertex, you should get the negative cross product of the two vectors [a,b] and [a,c] where a, b and c are the vertices of the polygon. normalize that cross product vector and multiply it by the average length of all three edges of the polygon, and the x,y,z lengths of the resulting vector will be the x,y,z coordinates from the center of the polygon.




Remember those old guys? They made epic renders, I think one of them was called DaVinci, and all they used was MS Paint. Sometimes it's just skill....
qwe
20
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 9th Jul 2009 05:11
he remembers his math courses
Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 9th Jul 2009 21:44 Edited at: 9th Jul 2009 21:48
@Image All - Thanks. I don't really know how to use what you gave me to make a thicker triangle. What you showed me was more of a pyramid. (Although the code was very good. Calculating the normals is always a hassle)

Here is a picture to show what I am looking for:


I have a triangle that I just want to make thicker. Think of pieces of glass. The triangle has a thickness of .1 and I want to make it have a thickness of about 2.

After I do this, I want the triangles it creates to be different. In the object they are all the same size and shape. (Most of them) I want to have the plain object be highly detailed and have different sized triangles to make up the plain.

Thanks,

Dark Fire

My future self met up with one day to teach me what I know today.

Attachments

Login to view attachments
Image All
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 9th Jul 2009 23:22
then all you have to do is take the normal (same as it is in the above code snippet), multiply it by your thickness, and add that vector to the position of all three vertices (one by one) and you have the positions for the three new ones; all six vertices that make up the thick triangle are found.


Remember those old guys? They made epic renders, I think one of them was called DaVinci, and all they used was MS Paint. Sometimes it's just skill....
Dark Fire
15
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 27th Oct 2009 20:14
I figured out how to do this with spheres in this example:



This doesn't work for plain objects.

Replace:


with:


The object wasn't constructed successfully. Try using a box instead of a plain and you end up with something close but not quite what I am trying to do.

I have tried using Lock VertexData For Mesh and it doesn't seem to work.

Another idea is to use memblocks, but idk if it will work with plains.

Thanks for any help,

Dark Fire

(re-posted on the first post)

My future self met up with one day to teach me what I know today.

Login to post a reply

Server time is: 2024-05-04 13:27:26
Your offset time is: 2024-05-04 13:27:26