mesh to particle system

Blitz3D Forums/Blitz3D Programming/mesh to particle system

Damien Sturdy(Posted 2004) [#1]
Okay you guys/gals. (actually- how many females are here?)

Im quite stuck- and im relying on your extensive knowledge to help me out!! :D

Okay, what i need to do is, by using only one surface and vertex index, create a single triangle. The triangle needs to be textured as the original. Okay, so im struggling to explain, il try again:

what i need, is to copy a mesh, but only have a single triangle copied. the triangle i need to exist is the one connected to the vertice and surface info i have.


Im using it for a damage system, where an object gets smashed and individual triangles of it are copied and used by my particle system (which i can already hand a mesh name to use as the particle)...


So, can anyone here help? any pointers as to how i would go about it? :D


Cheers in advance...


Damien Sturdy(Posted 2004) [#2]
[oops]
[/oops]


big10p(Posted 2004) [#3]
The command you need is TriangleVertex but for this you need to use the triangle index, not the vertex index. So, to get the 3 verts of a given triangle, you use something like:

v0 = TriangleVertex(surf,tri_index,0)
v1 = TriangleVertex(surf,tri_index,1)
v2 = TriangleVertex(surf,tri_index,2)


Also, maybe this demo I did a ways back might be of interest?
http://www.blitzbasic.com/codearcs/codearcs.php?code=680


Damien Sturdy(Posted 2004) [#4]
I will take a look, thanks :D

hmm, i have a vertex..
Do i have to go through all triangles finding one that has my vertice index somewhere involved?

[edit]

WOW, that effect is exactly what i need to acheive! pitty i dont want the whole mesh to explode at once :(


big10p(Posted 2004) [#5]
Well, that's the problem - the vertex could belong to many different triangles. Why do you only have the vertex and surface of the triangle? How are you selecting the triangle in code?


Damien Sturdy(Posted 2004) [#6]
im not selecting a triangle yet- at the moment its just "denting" the mesh by moving the vertex.I will however be using the vertice info to select multiple triangles and export "one" of the list connected.

Im almost done coding it now, i hope it works *fingers crossed*

I took a lesson from your code :D


Damien Sturdy(Posted 2004) [#7]
Okay, right... i got it to half work. i have my triangle created, but copymesh and clearsurface, followed by adding the single triangle seem to loose texturing. Any ideas?

Change the media used below to see what i mean :(




big10p(Posted 2004) [#8]
I wasn't able to run the code but it seems you're not getting texture coords because you're copying them into integer variables - cu1, cv1 instead of cu1#, cv1# etc.

You don't need to bother with the W coords - they're not used. I know my demo does but I wrote that back when I didn't know what a W coord was. :)

Also, be careful using CopyMesh as it will attempt to combine surfaces where it can. i.e. CopyMesh may produce a mesh with fewer surfaces that the original.


Damien Sturdy(Posted 2004) [#9]
I sorted this out.. yeah, i fixed my UV coords almost immediately after posting.

My major issue was that it was only copying the mesh, not the texture- but it worked out OK, because i had my textures stored..

Cheers for the help :D