Rarrgh rant mode on! Please help with Torques messed up vertex system!
by Lukas Joergensen · in Torque 3D Professional · 07/17/2012 (2:07 pm) · 4 replies
Okay, theres gonna sneak in a little bit of rant here.
Why the **** is T3D's vertex system so ****** up?? O.o
Skinmeshes is easy enough to work with, their vertexes represent the ingame vertexes and they are scaled, deformed etc etc.. They work perfectly.
Then there is the non-skinmeshes, half of my model is not a skinmesh for some reason.
What defines a skinmesh?
Furthermore why is:
Mesh->verts
undefined while Mesh->mVertexData
Contains all the vertexdata?
And not only that, if the Mesh isn't a skin mesh, the VertexData in mVertexData is not scaled. Meaning if you scaled your model when you imported from dae down with a factor of 100 this scaling is not represented in non-skinmeshes data while it is represented in skinmeshes data?
How do i get this collada to dae scale?
I'm not sure if this is bugs or just me not getting the system, but it sure as hell is confusing!
Why the **** is T3D's vertex system so ****** up?? O.o
Skinmeshes is easy enough to work with, their vertexes represent the ingame vertexes and they are scaled, deformed etc etc.. They work perfectly.
Then there is the non-skinmeshes, half of my model is not a skinmesh for some reason.
What defines a skinmesh?
Furthermore why is:
Mesh->verts
undefined while Mesh->mVertexData
Contains all the vertexdata?
And not only that, if the Mesh isn't a skin mesh, the VertexData in mVertexData is not scaled. Meaning if you scaled your model when you imported from dae down with a factor of 100 this scaling is not represented in non-skinmeshes data while it is represented in skinmeshes data?
How do i get this collada to dae scale?
I'm not sure if this is bugs or just me not getting the system, but it sure as hell is confusing!
About the author
IPS Bundle available at: https://www.winterleafentertainment.com/Products/IPS.aspx
#2
Moreover, the skinning information can be divided into groups (vertex groups). So as to avoid influencing the matrices of an adjacent vertex. So for example you can have several groups of vertices to different parts of an object and animate only the interested party.
Now i do not know exactly how your code works, but i suggest you to give a checked, to the updateSkin method of the class TSSkinMesh.
07/17/2012 (6:30 pm)
The difference between the two types of meshes is simple. The SkinMesh include additional information on the transformations of the vertices. Information such as influencing weight, and references to connecting bones. This information is saved along with those of the vertices, faces and UVs.Moreover, the skinning information can be divided into groups (vertex groups). So as to avoid influencing the matrices of an adjacent vertex. So for example you can have several groups of vertices to different parts of an object and animate only the interested party.
Now i do not know exactly how your code works, but i suggest you to give a checked, to the updateSkin method of the class TSSkinMesh.
#3
Now I have come to believe that the model might have some loose floating vertices flying around far away from the model ( the mVertexData returned points at around 100 in both x y and z coordinates ).
But generally the static meshes are acting weird.
This is something I have complained about earlier in another thread, the transform on the static meshes is acting weird, I believe the vertex data is wrong in static meshes:
Here the model is not rotated:

This is what the transform matrix returned:
[0]=1
[1]=0
[2]=0
[3]=243.864
[4]=0
[5]=1
[6]=0
[7]=86.902802
[8]=0
[9]=0
[10]=1
[11]=185.737
[12]=0
[13]=0
[14]=0
[15]=1
Now here the model is rotated:

And this is the transform matrix:
[0]=1
[1]=0
[2]=0
[3]=243.864
[4]=0
[5]=0
[6]=1
[7]=86.902802
[8]=0
[9]=-1
[10]=0
[11]=185.737
[12]=0
[13]=0
[14]=0
[15]=1
Unfortunately, I can't read a transform matrix so I don't know if it is right or wrong :/
But I believe either the vertexData or the transform data is wrong on staticmeshes. I use identical code both when handling skinmeshes and when handling staticmeshes and the skinmeshes work just fine but the staticmeshes is not working properly, the only difference is whether I get the vertexData from the skinmesh or the static mesh.
07/18/2012 (7:13 am)
@Alfio, the skinmeshes are working just fine. But the non-skinmeshes are giving some weird outputs.Now I have come to believe that the model might have some loose floating vertices flying around far away from the model ( the mVertexData returned points at around 100 in both x y and z coordinates ).
But generally the static meshes are acting weird.
This is something I have complained about earlier in another thread, the transform on the static meshes is acting weird, I believe the vertex data is wrong in static meshes:
Here the model is not rotated:

This is what the transform matrix returned:
[0]=1
[1]=0
[2]=0
[3]=243.864
[4]=0
[5]=1
[6]=0
[7]=86.902802
[8]=0
[9]=0
[10]=1
[11]=185.737
[12]=0
[13]=0
[14]=0
[15]=1
Now here the model is rotated:

And this is the transform matrix:
[0]=1
[1]=0
[2]=0
[3]=243.864
[4]=0
[5]=0
[6]=1
[7]=86.902802
[8]=0
[9]=-1
[10]=0
[11]=185.737
[12]=0
[13]=0
[14]=0
[15]=1
Unfortunately, I can't read a transform matrix so I don't know if it is right or wrong :/
But I believe either the vertexData or the transform data is wrong on staticmeshes. I use identical code both when handling skinmeshes and when handling staticmeshes and the skinmeshes work just fine but the staticmeshes is not working properly, the only difference is whether I get the vertexData from the skinmesh or the static mesh.
#4
07/18/2012 (7:38 am)
Btw, I'm gonna release this as a resource later anw so I might aswell post the code I am using atm:if(emitfaces.size())
{
S32 faceIndex = rand() % emitfaces.size();
face tris = emitfaces[faceIndex];
Mesh = shape->getShape()->meshes[tris.meshIndex];
TSMesh::__TSMeshVertexBase v1, v2, v3;
Point3F p1, p2, p3;
if(tris.skinMesh)
{
sMesh = dynamic_cast<TSSkinMesh*>(Mesh);
vertexList = sMesh->mVertexData;
U8 indiceBool = tris.triStart % 2;
if(indiceBool = 0)
{
v1 = vertexList[sMesh->indices[tris.triStart]];
v2 = vertexList[sMesh->indices[tris.triStart + 1]];
v3 = vertexList[sMesh->indices[tris.triStart + 2]];
}
else
{
v3 = vertexList[sMesh->indices[tris.triStart]];
v2 = vertexList[sMesh->indices[tris.triStart + 1]];
v1 = vertexList[sMesh->indices[tris.triStart + 2]];
/*
v1
v3
v2??
*/
}
p1 = v1.vert();
p2 = v2.vert();
p3 = v3.vert();
}
else{
vertexList = Mesh->mVertexData;
U8 indiceBool = tris.triStart % 2;
if(indiceBool = 0)
{
v1 = vertexList[Mesh->indices[tris.triStart]];
v2 = vertexList[Mesh->indices[tris.triStart + 1]];
v3 = vertexList[Mesh->indices[tris.triStart + 2]];
}
else
{
v3 = vertexList[Mesh->indices[tris.triStart]];
v2 = vertexList[Mesh->indices[tris.triStart + 1]];
v1 = vertexList[Mesh->indices[tris.triStart + 2]];
/*
v1
v3
v2??
*/
}
p1 = v1.vert();
p2 = v2.vert();
p3 = v3.vert();
}
Point3F vec1;
Point3F vec2;
mainP = p1;
vec1 = p2-p1;
vec2 = p3-p2;
F32 K1 = rand() % 1000 + 1;
F32 K2 = rand() % U32(K1) + 1;
Point3F planeVec = p1 + (vec1 * (K1 / 1000)) + (vec2 * (K2 / 1000));
const Point3F *vertPos = new const Point3F(planeVec);
MatrixF trans;
// Get the transform of the node to get the rotation matrix
if(SS)
trans = SS->getTransform();
else
trans = (dynamic_cast<TSStatic*>(SB))->getTransform();
// Rotate our point by the rotation matrix
const Point3F* p = rotate(trans, *vertPos);
Point3F* normalV = new Point3F((v1.normal()+v2.normal()+v3.normal())/3);
normalV->normalize();
if(SS)
pNew->pos = SS->getPosition() + *p + (*normalV * ejectionOffset);
else
pNew->pos = (dynamic_cast<TSStatic*>(SB))->getPosition() + (*p * (dynamic_cast<TSStatic*>(SB))->getScale()) + (*normalV * ejectionOffset);
pNew->relPos = *p +(*normalV * ejectionOffset);
pNew->vel = *normalV * initialVel;
pNew->orientDir = *normalV;
delete(*p);
delete(*vertPos);
delete(*normalV);
}{Edited before posted, might have made some mistakes when editing but tell me anw}
Torque Owner Lukas Joergensen
WinterLeaf Entertainment