C
C#2mo ago
:', ryte ,':

Right-Hand Model on Left-Hand Engine with Right-Hand physics engine

Heya- this is more of a math problem than coding specific but it's related to my implementation and i'm kind of stumped. So I'm working on a tool that's supposed to work with the XNA framework specifically, limitation wise I can't edit the culling direction. To create a map, I need to embed 3 things into a file, a VertexBuffer & an IndexBuffer, which are rendered by DirectX 9; and a CollisionMesh which is a triangle mesh (so vertexes and indices) which are processed by the physics engine. (jigLibX) Thus far I've been using glTf to create the buffers because the data is stored in a way that makes it far easier to convert to a VertexBuffer with the caveat that glTfs are right-handed, requiring me to invert the Z axis to have it render properly on direct X's left handed system. Now the problem arises in the fact that to create the triangle mesh, I have to flip it back around so that it matches XNA's right handed coordinate system or else my collisions become internal (Ex: you can enter a cube but you can't leave it) This system works dandy and all for symmetrical objects but now i'm finding that my collision and graphic model are rendered in a opposite pattern from the Z axis (1 is at 1 for collisions while 1 is at -1 for graphics), and i'm as to how to rotate them into the right position without triggering the physics fallthrough / the graphics failing to render because now everything is being rendered in the wrong order. There's some simplified code below, i wonder if it has to do with my vertex order / index order but i don't really know, i've tried making v0, v1, v2 go to v0, v2, v1 but in that case it doesn't render anything useful at all
//Load to vertex buffer
for (var i = 0; i < _vertices.Length; i++)
{
_vertices[i] = new Vector3()
{
X = binaryReader.ReadSingle(),
Y = binaryReader.ReadSingle(),
Z = binaryReader.ReadSingle() * -1,
};
}
//To Triangle mesh
for (var i = 0; i < _vertices.Length; i++)
{
Vector3 vector = _vertices[i];
vector.Z *= -1;
mesh.vertices[i] = vector;
}
//Load to vertex buffer
for (var i = 0; i < _vertices.Length; i++)
{
_vertices[i] = new Vector3()
{
X = binaryReader.ReadSingle(),
Y = binaryReader.ReadSingle(),
Z = binaryReader.ReadSingle() * -1,
};
}
//To Triangle mesh
for (var i = 0; i < _vertices.Length; i++)
{
Vector3 vector = _vertices[i];
vector.Z *= -1;
mesh.vertices[i] = vector;
}
No description
1 Reply
:', ryte ,':
:', ryte ,':OP2mo ago
i think i have an idea one second
Want results from more Discord servers?
Add your server