#Creating a mesh for a softbody

1 messages · Page 1 of 1 (latest)

split pine
#

Continuing the converaation about how to create a mesh from an array of points to make a background for a softbody

atomic sable
split pine
#

@atomic sable i know your not my personal teacher but i need your help again. youre the only one theat knows the context haha. while i have made progress, i dot know whats wrong with my for loop creating the triangles. i only know that it is wrong

tris = new int[points.Length * 3];

for(int i = 0; i <points.Length-2; i++)
{
        tris[i] = i;
        tris[i + 1] = i + 1;
        tris[i + 2] = points.Length;
}```
atomic sable
#

how does it look in wireframe? depending on the order you specify the verts it will change the "front"

#

i think anti clockwise is what you want

split pine
#

counterclockwise means the face points to me but thats not the problem i think as when looking fromthe other side in scene view it looks the same

atomic sable
#

check it in wireframe mode then to see if triangles are created or not

split pine
#

doesnt look like it

atomic sable
#

Well to do the triangle fan you can start with the center vert and then 2 on the edge in a counter clockwise pattern

#

and the triangle array should be groups of 3 vert indexes in a row

split pine
atomic sable
#

well atm you increment i by 1 which is incorrect

#

so do i += 3

#

and use a new int to track the vert indexes you are using for the triangles

split pine
atomic sable
#

If the center vert is 0 and the rest start from 1 then we want to define triangles like
0,2,1, 0,3,2, 0,4,3 ect...

#

Trying to point out that your logic is just wrong

split pine
atomic sable
#

Build each triangle like this

split pine
#

it has to be clockwise tho

#

i think

atomic sable
#

I think its counter but if im wrong you can correct it

split pine
#

i think i saw it in a breckeys video yesterday but it was really late wait a sec

#

yea its clockwise

atomic sable
#

even direct x docs states counter clock wise is the typical mode

split pine
#

anyways its rendered from both sides right now so idk what to believe

atomic sable
#

your shader/material can change culling to be back, front or both

#

Anyway you should be able to make the fan correctly now and correct the direction quite easily if you desire

split pine
#

nah i still dont get it sadly

#

im completely lost

split pine
atomic sable
#

meshes are built with a list of vertex positions. we then define triangles as a set of 3 vertex indexes so we re use verts for our many triangles.

#

so when building the mesh data you do it with this in mind...