directx - C# Direct X 9.0c - Mesh Intersect -
i want collide vector of mesh using up-vector.
i have position , vector.. booth calculate far vector
public vector3 setplayertoground(matrix object, matrix player, mesh groundobject) { vector3 intersectvector = new vector3(0, 0, 0); if (groundobject != null) { vector3 player_up = new vector3(player.m12, player.m22, player.m32); vector3 playerpos = new vector3(player.m14, player.m24, player.m34); vector3 playerpos_far = playerpos - player_up ; gameengine.m_device.transform.world = object; intersectinformation closestintersection; if (groundobject.intersect(playerpos, playerpos_far, out closestintersection)) { intersectvector = player_up + (playerpos_far * closestintersection.dist); } } return intersectvector; }
well if
vector3 playerpos_far = playerpos + player_up;
he intersect nothing... object wich want intersect under "position - upvector"
so think
vector3 playerpos_far = playerpos - player_up ;
is rigth
why cant intersect?
here better description:
here player , ship. player alway @ 0,0,0 because move world around player. if move player forward chance playerposition vector wich chance positions of other objects. think player has nothing intersect.. ship itself. use position 0,0,0 , upvector direction intersectvector of ground ship. matrix of ship (matrix object):
vector3 com = ship.position - gamemanager.player.position; matrix world; world = matrix.identity * matrix.scaling(0.001f, 0.001f, 0.001f) * matrix.translation(com); m_device.transform.world = world;
i tryed , think wont use translated matrix of ship...
you have provide ray defined position , direction. not have specify 2 points. pass -player_up
instead of playerpos_far
.
furthermore, intersect
method not care transformations. have pretransform ray. transform both ray position , direction inverse world matrix (transform world space model's space) , should fine.
vector3 raystart = playerpos; vector3 raydir = -player_up; matrix world; //the ship's world matrix world = matrix.invert(matrix); raystart = vector3.transformcoordinate(raystart, world); //you may need add out parameter raydir = vector3.transformnormal(raydir, world); groundobject.intersect(raystart, raydir, ...
Comments
Post a Comment