我想使用 Up-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;
}
好吧,如果我这样做
Vector3 PlayerPos_Far = PlayerPos + Player_UP;
它总是与任何东西相交......但我想要相交的对象总是在“位置 - UpVector”下
所以我认为
Vector3 PlayerPos_Far = PlayerPos - Player_UP ;
是正确的
为什么我不能相交?
这是一个更好的描述:
这是玩家,他在一艘船上。玩家总是在 0,0,0,因为我在玩家周围移动世界。如果我将玩家向前移动,我会选择玩家位置向量,它只会影响所有其他对象的位置。但我认为玩家与 Intersect 无关……而是船本身。我使用位置 0,0,0 和上向量作为方向来从船中获取地面的相交向量。船的矩阵是(矩阵对象):
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;
我尝试了一些东西,我认为他不会使用我翻译的飞船矩阵......