[MDX] Sphere-Plane Collision
Im getting a weird collision, but it might have something to do with the mesh itself. Im going to make a new mesh and see what happens...
Ive come to the conclusion that everything works except for the last test:
if (s >= 0 && t >= 0 && s + t <= 1)
My s + t is NOT <= 1!
if (s >= 0 && t >= 0 && s + t <= 1)
My s + t is NOT <= 1!
but it must be. If s+t > 1 the point is outside the triangle. Look at this . it works as a vector summing:
if s+t = 1, doesn't matter the values of s and t, the point will be on the segment v1 - v2
v1+ +v0+(v1-v0)+(v2-v0)-> so, s = 1 and t = 1, s+t > 1...point is outside | / | / | / | / |/vo+--------+v2
if s+t = 1, doesn't matter the values of s and t, the point will be on the segment v1 - v2
Right now Im really worried about one thing
I made two test meshes: one with textures and one without
To make my textures tile I apply a UWV map modifier
The mesh without textures had very good collision except i had to change the equation to >= instead of <=
The mesh with textures had no sense of collision detection whatsoever (however, i did not fully test it)
Could the UWV mapping somehow be interfearing with my vertex positions? :S
I made two test meshes: one with textures and one without
To make my textures tile I apply a UWV map modifier
The mesh without textures had very good collision except i had to change the equation to >= instead of <=
The mesh with textures had no sense of collision detection whatsoever (however, i did not fully test it)
Could the UWV mapping somehow be interfearing with my vertex positions? :S
WooW lol :p
I really dont know...I dont use this method to get the triangles from my mesh :P...well, textures dont change the positions of the vertices...maybe there's something wrong in your code. an the UVW map modifier(are you using 3dsmax?!? :P) usually doesnt change anything on the vertex positions....
I really dont know...I dont use this method to get the triangles from my mesh :P...well, textures dont change the positions of the vertices...maybe there's something wrong in your code. an the UVW map modifier(are you using 3dsmax?!? :P) usually doesnt change anything on the vertex positions....
I am very close to achieving succesfull collision detection now, however, there is some slight error in the method. Since I hardly have any experience in this I am not able to figure out where exactly the error lies or in what context and cases the error occurs. However, I did manage to come to one conclusion: In a square room collusion only occurs when I hit the walls with a positive X or Z normal. There is most likely some typo in the vector manipulation in the algorithm :p
Could you please have a look :)
Thank you so much for your help!
(btw, I am now using s + t <= 1 and there was no interference with the verticies :P)
Could you please have a look :)
Thank you so much for your help!
(btw, I am now using s + t <= 1 and there was no interference with the verticies :P)
to collide with walls, you could check the y component of the normal of the triangle your sphere is penetrating(since earth gravity is (0.f, 9.81f, 0.f)...).
It the most simple method. for example, normal with a y component lower than 0.5. if the intersecting triangle has a normal with this property, you'll not be able to climb that triangle...something like that. I never developped a serious 1st person camera walking system, so I dont have many ideas about :/ ...I think, just think, that a good method would be using forces and friction but its more complex and large...
and one detail: I dont know if you are doing it but you can intersect more than one triangle at time, so pay attention to your code.
It the most simple method. for example, normal with a y component lower than 0.5. if the intersecting triangle has a normal with this property, you'll not be able to climb that triangle...something like that. I never developped a serious 1st person camera walking system, so I dont have many ideas about :/ ...I think, just think, that a good method would be using forces and friction but its more complex and large...
and one detail: I dont know if you are doing it but you can intersect more than one triangle at time, so pay attention to your code.
Hey...sorry!!
I've given you a wrong method to compute s and t!!confused with computing the distance between a point and a line :P...:(...I'll fix this now ;)
create two new vectors: uP which is perpendicular to both u and the triangle normal and vP which is perpendicular to both v and the triangle normal. To compute them:
uP = Vec3Cross(&u, &triangleNormal)
vP = Vec3Cross(&v, &triangleNormal)
Now, s and t will be:
s = Vec3Dot(&w, &uP) / Vec3Dot(&u, &uP);
t = Vec3Dot(&w, &vP) / Vec3Dot(&v, &vP);
Its just check if s>=0 && t>=1 && s+t<=1 is true and if yes the point is inside...
I hope theres nothing else wrong now :P...
I've given you a wrong method to compute s and t!!confused with computing the distance between a point and a line :P...:(...I'll fix this now ;)
create two new vectors: uP which is perpendicular to both u and the triangle normal and vP which is perpendicular to both v and the triangle normal. To compute them:
uP = Vec3Cross(&u, &triangleNormal)
vP = Vec3Cross(&v, &triangleNormal)
Now, s and t will be:
s = Vec3Dot(&w, &uP) / Vec3Dot(&u, &uP);
t = Vec3Dot(&w, &vP) / Vec3Dot(&v, &vP);
Its just check if s>=0 && t>=1 && s+t<=1 is true and if yes the point is inside...
I hope theres nothing else wrong now :P...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement