169 lines
7.1 KiB
C#
169 lines
7.1 KiB
C#
|
/****************************************************************************
|
|||
|
Copyright (c) 2011-2013,WebJet Business Division,CYOU
|
|||
|
|
|||
|
http://www.genesis-3d.com.cn
|
|||
|
|
|||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
of this software and associated documentation files (the "Software"), to deal
|
|||
|
in the Software without restriction, including without limitation the rights
|
|||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
copies of the Software, and to permit persons to whom the Software is
|
|||
|
furnished to do so, subject to the following conditions:
|
|||
|
|
|||
|
The above copyright notice and this permission notice shall be included in
|
|||
|
all copies or substantial portions of the Software.
|
|||
|
|
|||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
|
THE SOFTWARE.
|
|||
|
****************************************************************************/
|
|||
|
using System;
|
|||
|
using System.Runtime.CompilerServices;
|
|||
|
using ScriptRuntime;
|
|||
|
|
|||
|
namespace ScriptRuntime
|
|||
|
{
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
public static class IntersectWorld// : Base
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ӵ<EFBFBD>ǰĬ<C7B0><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="screenPos"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>ȡֵ<C8A1><D6B5>Χ<EFBFBD><CEA7>[0,1]</param>
|
|||
|
/// <param name="outRay"><3E><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD></param>
|
|||
|
static public void IntersectWorld_ComputeRay(ref Vector2 screenPos, out Ray outRay)
|
|||
|
{
|
|||
|
ICall_IntersectWorld_ComputeRay(ref screenPos,out outRay);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><DFBC><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Actor
|
|||
|
/// </summary>
|
|||
|
/// <param name="act">Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor</param>
|
|||
|
/// <param name="ray"><3E><><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="layerid"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD></param>
|
|||
|
/// <param name="pos"><3E><><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD>Actor<6F>ϵĵ<CFB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Actor</returns>
|
|||
|
static public bool IntersectActor(Actor act, ref Ray ray, LayerID layerid, out Vector3 pos)
|
|||
|
{
|
|||
|
if (LayerID.Min <= layerid && layerid < LayerID.Max && act != null)
|
|||
|
{
|
|||
|
return ICall_IntersectWorld_IntersectActor(act, ref ray, LayerMark.LayerIDToUINTMark(layerid), out pos);
|
|||
|
}
|
|||
|
pos = Vector3.Zero;
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>(<28><><EFBFBD><EFBFBD>)Actor<6F>Ľ<EFBFBD><C4BD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="act">Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor</param>
|
|||
|
/// <param name="ray">Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="mark">Actor<6F>Ĺ<EFBFBD><C4B9>˲<EFBFBD>(ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD>)</param>
|
|||
|
/// <param name="pos"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor<6F>Ľ<EFBFBD><C4BD><EFBFBD></param>
|
|||
|
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor<6F>Ƿ<EFBFBD><C7B7>н<EFBFBD><D0BD><EFBFBD></returns>
|
|||
|
static public bool IntersectActor(Actor act, ref Ray ray, LayerMark mark, out Vector3 pos)
|
|||
|
{
|
|||
|
if (act != null)
|
|||
|
{
|
|||
|
return ICall_IntersectWorld_IntersectActor(act, ref ray, mark.MarkAsUINT, out pos);
|
|||
|
}
|
|||
|
pos = Vector3.Zero;
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><DFBC><EFBFBD>Actor
|
|||
|
/// </summary>
|
|||
|
/// <param name="ray">ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="layerid"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD></param>
|
|||
|
/// <returns><3E><><EFBFBD><EFBFBD><DFBC>Actor<6F><72><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD><EFBFBD>㷢<EFBFBD><E3B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B5BD>Actor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>м<EFBFBD><D0BC><EFBFBD>κ<EFBFBD>Actor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NULL</returns>
|
|||
|
static public Actor IntersectWorld_Actor(ref Ray ray, LayerID layerid)
|
|||
|
{
|
|||
|
if (LayerID.Min <= layerid && layerid < LayerID.Max)
|
|||
|
{
|
|||
|
return ICall_IntersectWorld_Actor(ref ray, LayerMark.LayerIDToUINTMark(layerid));
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><DFBC><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)Actor<6F>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="ray">ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="layerid"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD></param>
|
|||
|
/// <param name="outPoint"><3E><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣩</param>
|
|||
|
static public void IntersectWorld_Point(ref Ray ray, LayerID layerid, out Vector3 outPoint)
|
|||
|
{
|
|||
|
if (LayerID.Min <= layerid && layerid < LayerID.Max)
|
|||
|
{
|
|||
|
ICall_IntersectWorld_Point(ref ray, LayerMark.LayerIDToUINTMark(layerid), out outPoint);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
outPoint = Vector3.Zero;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ߴ<EFBFBD><DFB4>еĵ<D0B5>һ<EFBFBD><D2BB>(<28><><EFBFBD><EFBFBD>)Actor
|
|||
|
/// </summary>
|
|||
|
/// <param name="ray">ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="mark">Actor<6F>Ĺ<EFBFBD><C4B9>˲<EFBFBD>(ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD>)</param>
|
|||
|
/// <returns></returns>
|
|||
|
static public Actor IntersectWorld_Actor(ref Ray ray, LayerMark mark)
|
|||
|
{
|
|||
|
return ICall_IntersectWorld_Actor(ref ray, mark.MarkAsUINT);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ߴ<EFBFBD><DFB4>еĵ<D0B5>һ<EFBFBD><D2BB>(<28><><EFBFBD><EFBFBD>)Actor<6F>Ľ<EFBFBD><C4BD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="ray">ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="mark">Actor<6F>Ĺ<EFBFBD><C4B9>˲<EFBFBD>(ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD>)</param>
|
|||
|
/// <param name="outPoint"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Actor<6F>Ľ<EFBFBD><C4BD><EFBFBD></param>
|
|||
|
static public void IntersectWorld_Point(ref Ray ray, LayerMark mark, out Vector3 outPoint)
|
|||
|
{
|
|||
|
ICall_IntersectWorld_Point(ref ray, mark.MarkAsUINT, out outPoint);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ߴ<EFBFBD><DFB4>еĵ<D0B5>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="ray">ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="mark">Actor<6F>Ĺ<EFBFBD><C4B9>˲<EFBFBD>(ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Actor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD>)</param>
|
|||
|
/// <param name="outPoint1"><3E><><EFBFBD><EFBFBD><EFBFBD>εĵ<CEB5>һ<EFBFBD><D2BB><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="outPoint2"><3E><><EFBFBD><EFBFBD><EFBFBD>εĵڶ<C4B5><DAB6><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="outPoint3"><3E><><EFBFBD><EFBFBD><EFBFBD>εĵ<CEB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
static public void IntersectWorld_Triangle(ref Ray ray, LayerMark mark, out Vector3 outPoint1, out Vector3 outPoint2, out Vector3 outPoint3)
|
|||
|
{
|
|||
|
ICall_IntersectWorld_Triangle(ref ray, mark.MarkAsUINT, out outPoint1, out outPoint2, out outPoint3);
|
|||
|
}
|
|||
|
|
|||
|
// - internal call declare
|
|||
|
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
|||
|
extern private static void ICall_IntersectWorld_ComputeRay(ref Vector2 screenPos, out Ray outRay);
|
|||
|
|
|||
|
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
|||
|
extern private static bool ICall_IntersectWorld_IntersectActor(Actor act, ref Ray ray, uint selectMark, out Vector3 pos);
|
|||
|
|
|||
|
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
|||
|
extern private static Actor ICall_IntersectWorld_Actor(ref Ray ray, uint selectMark);
|
|||
|
|
|||
|
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
|||
|
extern private static void ICall_IntersectWorld_Point(ref Ray ray, uint selectMark, out Vector3 outFloat3);
|
|||
|
|
|||
|
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
|||
|
extern private static void ICall_IntersectWorld_Triangle(ref Ray ray, uint selectMark, out Vector3 outPoint1, out Vector3 outPoint2, out Vector3 outPoint3);
|
|||
|
}
|
|||
|
}
|