本文整理汇总了C#中Decal.ApplyToActor方法的典型用法代码示例。如果您正苦于以下问题:C# Decal.ApplyToActor方法的具体用法?C# Decal.ApplyToActor怎么用?C# Decal.ApplyToActor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Decal
的用法示例。
在下文中一共展示了Decal.ApplyToActor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDecal
public void CreateDecal(Vector3 decalPosition, BoundingBox area, string textureName, float lifetime, float size, DecalLayers layer)
{
Texture2D texture = Renderer.Instance.LookupTexture(textureName);
Decal decal = new Decal(ref decalPosition, texture, lifetime, size, layer);
Vector3 difference = area.Max - area.Min;
float length = difference.Z;
float height = difference.Y;
float width = difference.X;
BEPUphysics.CollisionShapes.ConvexShapes.SphereShape sphereShape = new BEPUphysics.CollisionShapes.ConvexShapes.SphereShape(width);
//BEPUphysics.CollisionShapes.ConvexShapes.BoxShape boxShape = new BEPUphysics.CollisionShapes.ConvexShapes.BoxShape(width, height, length);
BEPUphysics.MathExtensions.RigidTransform startingTransform = new BEPUphysics.MathExtensions.RigidTransform(decalPosition);
Vector3 sweep = Vector3.Zero;
// area is is local space, transform to world space
area.Min += decalPosition;
area.Max += decalPosition;
// use the broad phase's acceleration structure to find all the objects which are in the decal area
var candidates = BEPUphysics.ResourceManagement.Resources.GetBroadPhaseEntryList();
decalsWorld.BroadPhase.QueryAccelerator.GetEntries(area, candidates);
foreach (BEPUphysics.BroadPhaseEntries.BroadPhaseEntry candidate in candidates)
{
if (candidate.OwningActor != null)
{
BEPUphysics.RayHit rayHit;
bool gotHit = false;
Vector3 location = Vector3.Zero;
Vector3 up = Vector3.Up;
for(int i = 0; i < cardinalRays.Count; i++)
{
Ray ray = cardinalRays[i];
ray.Position = decalPosition;
if (candidate.RayCast(ray, width, out rayHit))
{
gotHit = true;
location = rayHit.Location;
up = ups[i];
break;
}
}
if (!gotHit)
{
gotHit = true;
Actor actor = (Actor)candidate.OwningActor;
location = actor.PhysicsObject.Position;
//if (candidate.ConvexCast(sphereShape, ref startingTransform, ref sweep, out rayHit))
//{
// gotHit = true;
// location = rayHit.Location;
//}
}
if (gotHit)
{
// apply the decal
Actor actor = (Actor)candidate.OwningActor;
if (!decal.ApplyToActor(actor, location, up))
break;
}
}
}
AddDecal(decal);
}