本文整理汇总了C#中Camera.Project方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.Project方法的具体用法?C# Camera.Project怎么用?C# Camera.Project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.Project方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(GraphicsDevice device, Camera camera)
{
PhysicsRenderer physicsrenderer = PhysicsRenderer.GetInstance(device);
physicsrenderer.Draw(body, camera);
SpriteRenderer spriterenderer = SpriteRenderer.GetInstance(device);
spriterenderer.Begin(null);
Vector3 proj = camera.Project(new Vector3(target, 0));
spriterenderer.AddString(Resources.arial10px_font, "x", proj.X, proj.Y);
spriterenderer.End();
}
示例2: Draw
public void Draw(Physics physics, Camera camera, bool shapes, bool outlines, bool normals, bool points, bool chains, bool tags)
{
material.Projection = camera.projection;
material.View = camera.view;
material.World = Matrix.Identity;
material.CurrentTechnique.Passes[0].Apply();
PrimitiveBatch instance = PrimitiveBatch.GetInstance(device);
instance.Begin(Primitive.Line);
for (int i = 0; i < physics.body_list.Count; i++)
{
Body body = physics.body_list[i];
if (shapes)
{
instance.SetColor(Color.Yellow);
for (int p = 1; p < body.curr_shape.count; p++)
{
instance.AddVertex(body.curr_shape.points[p - 1]);
instance.AddVertex(body.curr_shape.points[p - 0]);
}
instance.AddVertex(body.curr_shape.points[body.curr_shape.count - 1]);
instance.AddVertex(body.curr_shape.points[0]);
}
if (outlines)
{
instance.SetColor(Color.White);
for (int p = 1; p < body.pointmass_list.Length; p++)
{
instance.AddVertex(body.pointmass_list[p - 1].position);
instance.AddVertex(body.pointmass_list[p - 0].position);
}
instance.AddVertex(body.pointmass_list[body.pointmass_list.Length - 1].position);
instance.AddVertex(body.pointmass_list[0].position);
}
if (normals)
{
instance.SetColor(Color.Purple);
for (int p = 0; p < body.pointmass_list.Length; p++)
{
Vector2 pt = body.pointmass_list[p].position;
int prevPt = (p > 0) ? p - 1 : body.pointmass_list.Length - 1;
int nextPt = (p < body.pointmass_list.Length - 1) ? p + 1 : 0;
Vector2 prev = body.pointmass_list[prevPt].position;
Vector2 next = body.pointmass_list[nextPt].position;
Vector2 fromPrev = new Vector2();
fromPrev.X = pt.X - prev.X;
fromPrev.Y = pt.Y - prev.Y;
Vector2 toNext = new Vector2();
toNext.X = next.X - pt.X;
toNext.Y = next.Y - pt.Y;
Vector2 ptNorm = new Vector2();
ptNorm.X = fromPrev.X + toNext.X;
ptNorm.Y = fromPrev.Y + toNext.Y;
VectorHelper.Perpendicular(ref ptNorm);
ptNorm = Vector2.Normalize(ptNorm)*(camera.position.Z * 0.03f);
instance.AddVertex(pt);
instance.AddVertex(pt + ptNorm);
}
}
/*
if (body is SpringBody)
{
SpringBody sbody = body as SpringBody;
instance.SetColor(Color.Green);
for (int s = 0; s < sbody.spring_list.Count; s++)
{
instance.AddVertex(sbody.spring_list[s].pointmass_a.position);
instance.AddVertex(sbody.spring_list[s].pointmass_b.position);
}
}*/
}
if (chains)
{
for (int i = 0; i < physics.chain_list.Count; i++)
{
Chain chain = physics.chain_list[i];
instance.SetColor(Color.Green);
for (int s = 0; s < chain.spring_list.Count; s++)
{
instance.AddVertex(chain.spring_list[s].pointmass_a.position);
instance.AddVertex(chain.spring_list[s].pointmass_b.position);
//.........这里部分代码省略.........