Directx模型包含Vector3吗? -非游戏引擎 [英] Directx model contains Vector3? - NOT GAME ENGINE

查看:146
本文介绍了Directx模型包含Vector3吗? -非游戏引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个函数,如果某个点在DirectX 3D模型(.x)中,则返回该函数...

我已经尝试过,但是我无法使它正常工作,所以我需要一些帮助.

像这样的东西:

I need a function that return if a certain point is inside a directx 3d model(.x)...

I have tried but i can´t get it to work so i need some help.

Something like this:

public bool IsInsideModel(Vector3 point, Model model)
{
    //This would of course be nice but i don''t think such function exists...
    //return model.Contains(point);
}



任何建议将不胜感激.


这不是用于游戏引擎或实时渲染,因此计算时间不是问题.
请提供一些示例.



Any suggestions will be appreciated.


This is not for a game engine or realtime rendering so the computing time is not an issue.
Please provide some examples.

推荐答案

好消息:可以做到.坏消息:精确的测试在计算上很昂贵,因此可能太慢而无法在实时渲染中使用.

首先,它仅适用于凸面对象.凹形对象必须分解为两个或多个凸形对象,然后分别进行测试.

http://en.wikipedia.org/wiki/Concave_polygon [
The good news: it can be done. The bad news: A precise test is computationally expensive and therefore probably too slow to be of any use in real time rendering.

First off, it works only on convex objects. Concave objects would have to be broken down into two or more convex objects and then tested individually.

http://en.wikipedia.org/wiki/Concave_polygon[^]

Let''s call the point you want to test P, the verices of the object VX and their normals NX. Then you will have to compute the cross product between the NX and (VX - P). The cross product will tell you wether P is inside the object or not and this must be true for every VX of the object.


Seriously, you are probably trying to program a collision test for some 3D engine, right? In this case The test is usually done against a much simpler object as a substitute for the real 3D object, usually those are boxes or spheres which approximate the space filled by the real 3D object and are far easier to test. It''s very common in graphics to sacrifice some precision in order to gain performance.


这篇关于Directx模型包含Vector3吗? -非游戏引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆