本文整理汇总了C#中DwarfCorp.Voxel.GetBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C# Voxel.GetBoundingBox方法的具体用法?C# Voxel.GetBoundingBox怎么用?C# Voxel.GetBoundingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DwarfCorp.Voxel
的用法示例。
在下文中一共展示了Voxel.GetBoundingBox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMostLikelyDesignation
public BuildRoomOrder GetMostLikelyDesignation(Voxel v)
{
BoundingBox larger = new BoundingBox(v.GetBoundingBox().Min - new Vector3(0.5f, 0.5f, 0.5f), v.GetBoundingBox().Max + new Vector3(0.5f, 0.5f, 0.5f));
return (from room in BuildDesignations
from buildDesignation in room.VoxelOrders
where larger.Intersects(buildDesignation.Voxel.GetBoundingBox())
select room).FirstOrDefault();
}
示例2: GetMostLikelyRoom
public Room GetMostLikelyRoom(Voxel v)
{
Voxel vRef = v;
foreach(Room r in DesignatedRooms.Where(r => r.ContainsVoxel(vRef)))
{
return r;
}
BoundingBox larger = new BoundingBox(v.GetBoundingBox().Min - new Vector3(0.5f, 0.5f, 0.5f), v.GetBoundingBox().Max + new Vector3(0.5f, 0.5f, 0.5f));
return (from room in BuildDesignations
from buildDesignation in room.VoxelOrders
where larger.Intersects(buildDesignation.Voxel.GetBoundingBox())
select buildDesignation.ToBuild).FirstOrDefault();
}
示例3: Update
public override void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
{
ParticleEmitter._camera = camera;
List<Particle> toRemove = new List<Particle>();
TriggerTimer.Update(gameTime);
if(TriggerTimer.HasTriggered && Data.ParticlesPerFrame > 0)
{
Trigger(Data.ParticlesPerFrame, Vector3.Zero, Tint);
}
bool particlePhysics = GameSettings.Default.ParticlePhysics;
Voxel v = new Voxel();
foreach(Particle p in Particles)
{
float vel = p.Velocity.LengthSquared();
if(!Data.Sleeps || vel > 0.2f)
{
if (Data.EmitsLight && p.Scale > 0.1f)
{
DynamicLight.TempLights.Add(new DynamicLight(10.0f, 255.0f, false) { Position = p.Position});
}
p.Position += p.Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
if (Data.RotatesWithVelocity)
{
Vector3 cameraVel = camera.Project(p.Velocity + camera.Position);
float projectionX = cameraVel.X;
float projectionY = cameraVel.Y;
p.Angle = (float)Math.Atan2(projectionY, projectionX);
}
else
{
p.Angle += (float)(p.AngularVelocity * gameTime.ElapsedGameTime.TotalSeconds);
}
p.Velocity += Data.ConstantAccel * (float)gameTime.ElapsedGameTime.TotalSeconds;
p.Velocity *= Data.LinearDamping;
p.AngularVelocity *= Data.AngularDamping;
}
else if (Data.Sleeps && vel < 0.2f)
{
p.Velocity = Vector3.Zero;
}
p.LifeRemaining -= Data.ParticleDecay * (float)gameTime.ElapsedGameTime.TotalSeconds;
p.Scale += Data.GrowthSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
p.Scale = Math.Max(p.Scale, 0.0f);
bool success = false;
if (Data.HasLighting)
{
success = chunks.ChunkData.GetVoxel(p.Position, ref v);
if (success && v.IsEmpty)
{
p.Tint = new Color(v.SunColor, 255, 0);
}
}
if(Data.CollidesWorld && particlePhysics && vel > 0.2f)
{
if (!Data.HasLighting)
{
success = chunks.ChunkData.GetVoxel(p.Position, ref v);
}
BoundingBox b = new BoundingBox(p.Position - Vector3.One * p.Scale * 0.5f, p.Position + Vector3.One * p.Scale * 0.5f);
if(success && !v.IsEmpty)
{
Physics.Contact contact = new Physics.Contact();
if(Physics.TestStaticAABBAABB(b, v.GetBoundingBox(), ref contact))
{
p.Position += contact.NEnter * contact.Penetration;
Vector3 newVelocity = Vector3.Reflect(p.Velocity, -contact.NEnter);
p.Velocity = newVelocity * Data.Damping;
p.AngularVelocity *= 0.5f;
}
}
}
if(p.LifeRemaining < 0)
{
if(p.InstanceData != null)
{//
p.InstanceData.ShouldDraw = false;
p.InstanceData.Transform = Matrix.CreateTranslation(camera.Position + new Vector3(-1000, -1000, -1000));
Sprites.Remove(p.InstanceData);
}
toRemove.Add(p);
}
else if(p.InstanceData != null)
{
p.InstanceData.ShouldDraw = true;
p.InstanceData.Transform = MatrixFromParticle(p);
p.InstanceData.Color = p.Tint;
}
//.........这里部分代码省略.........