|
DoomMarine
|
 |
« on: 2007/07/18 14:38:16 » |
|
I recently have integrated a basic physics/collision system into my game engine. At first it was just AABBs and spheres but now i have found a way to integrate actual model-triangle colision, unfortunately if i scale the model, rotate it, or move it i can not get the vertices of the bounds change accordingly, i have tried getting the positions of the vertices and transforming it by the entities world matrix but that doesnt seem to work and when i debug the vertices positions i get values like infinity or -infinity. I got the position of the vertices through my custom model processor and that seems to work fine, so i believe it has to do with the transformation of the vector3's that i use. Are a model's vertices stored an positioned a certain way so that i can transform there coordinates correctly? If you can please help, thank you.
|
|
|
|
|
Logged
|
|
|
|
|
Nemo Krad
|
 |
« Reply #1 on: 2007/07/18 15:16:09 » |
|
I imagine the vert's position is relative to the models position so model.Pos + model.vert.pos should give you the actual position of the vert. Just guessing so I may be well off the mark.
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #2 on: 2007/07/18 15:35:57 » |
|
when you say the model position u mean the root bone's transform correct? or are you referring to the mesh's parent bone's one? and if i need to calculate the positions like that how would i integrate scale and rotation?
|
|
|
|
« Last Edit: 2007/07/18 15:38:03 by DoomMarine »
|
Logged
|
|
|
|
|
Nemo Krad
|
 |
« Reply #3 on: 2007/07/19 00:45:39 » |
|
I presume you are using the HMEngine and the HMModel object to do this, so I am guessing that you can use the HMModel.Position + the HMModel.Mesh.Verts[v].position to get the correct position of the vert.
Having not seen your code I can only make assumptions...
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #4 on: 2007/07/19 14:09:13 » |
|
heres the code i use to move the triangle's vertex's position public void RefreshTris(Matrix world) { Vertex1 = Vector3.Transform(vertstore1, world); Vertex2 = Vector3.Transform(vertstore2, world); Vertex3 = Vector3.Transform(vertstore3, world); }
|
|
|
|
|
Logged
|
|
|
|
|
Nemo Krad
|
 |
« Reply #5 on: 2007/07/19 15:01:12 » |
|
Say you arnt giving much away there.... It looks like you could do with doing this Vertex1 = Vector3.Transform(this.Position + vertstore1, world);
Again, this is an asumption....
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #6 on: 2007/07/19 15:19:45 » |
|
sry bout not giving much away havent decided if i wanted to show everything yet, but the world matrix that i use is made like this RefreshTris( RotationMatrix * Matrix.CreateScale(Scaling) * Matrix.CreateTranslation(position), position);
im wondering if thats how it should have been made
|
|
|
|
|
Logged
|
|
|
|
|
Nemo Krad
|
 |
« Reply #7 on: 2007/07/20 01:18:58 » |
|
hmm the world matrix looks odd to me.
Mike uses Scale * Rotation * Position You are using Rotation * Scale * Position
maybe this is your issue??
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #8 on: 2007/07/20 08:47:45 » |
|
ive tried the scale *rotation * position but that doesnt seem to be making a difference, i wonder if it is how i get the vertices positions that my be the problem. To get the vertices positions i have a binary reader read the models data from a memory stream, should i be using something else?
|
|
|
|
|
Logged
|
|
|
|
|
Nemo Krad
|
 |
« Reply #9 on: 2007/07/20 11:40:32 » |
|
Not that I know where, but in the Refresh don't they give you access to the mesh verts as standard now?
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #10 on: 2007/07/20 12:18:54 » |
|
wow, lol, i did not know that, ill check that out now
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #11 on: 2007/07/20 13:56:10 » |
|
it doesnt seem to make a difference i am still gettin screwed up collision but the tri's points seem to be fine, it might have something to do with my triangles collision so ill check that out next
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #12 on: 2007/07/20 15:11:18 » |
|
not the collision either so it must be the transformation of the vertices, are the vertices already transofrm to the mesh's parent bone transform?
|
|
|
|
|
Logged
|
|
|
|
|
Nemo Krad
|
 |
« Reply #13 on: 2007/07/20 15:41:57 » |
|
I don't know, one way to find out would be to remove the transform code you have and try it with out...
|
|
|
|
|
Logged
|
|
|
|
|
DoomMarine
|
 |
« Reply #14 on: 2007/07/23 10:28:17 » |
|
now the vertices positions seem to screw up the collision, i am getting very strange results from it, how exactly are you supposed to get the vertices data from the model? i used the getdata function for the index and vertex buffers but i wasnt to sure on how to get the total amount for the array that i use to store the data, if you can help with this it will be appreciated
|
|
|
|
|
Logged
|
|
|
|
|