本文整理汇总了C#中Quad类的典型用法代码示例。如果您正苦于以下问题:C# Quad类的具体用法?C# Quad怎么用?C# Quad使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Quad类属于命名空间,在下文中一共展示了Quad类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected override void Initialize()
{
quad = new Quad[6];
quad[0] = new Quad(Vector3.Backward, Vector3.Backward, Vector3.Up, 2, 2);
quad[1] = new Quad(Vector3.Left, Vector3.Left, Vector3.Up, 2, 2);
quad[2] = new Quad(Vector3.Right, Vector3.Right, Vector3.Up, 2, 2);
quad[3] = new Quad(Vector3.Forward, Vector3.Forward, Vector3.Up, 2, 2);
quad[4] = new Quad(Vector3.Down, Vector3.Down, Vector3.Right, 2, 2);
quad[5] = new Quad(Vector3.Up, Vector3.Up, Vector3.Left, 2, 2);
nh = new NodeHandle();
imgSub = nh.subscribe<Messages.sensor_msgs.Image>("/camera/rgb/image_rect_color", 1, (img) =>
{
if (padlock.WaitOne(10))
{
if (next_texture == null)
{
next_texture = new Texture2D(GraphicsDevice, (int) img.width, (int) img.height);
}
util.UpdateImage(GraphicsDevice, img.data, new Size((int)img.width, (int)img.height), ref next_texture, img.encoding.data);
padlock.ReleaseMutex();
}
});
base.Initialize();
}
示例2: OverlapQuads
public static bool OverlapQuads(Quad quad1, Quad quad2) {
bool triIntersect1 = TriTriIntersection.TriTriOverlap.TriTriIntersect(quad1.GetTri1(), quad2.GetTri1());
bool triIntersect2 = TriTriIntersection.TriTriOverlap.TriTriIntersect(quad1.GetTri1(), quad2.GetTri2());
bool triIntersect3 = TriTriIntersection.TriTriOverlap.TriTriIntersect(quad1.GetTri2(), quad2.GetTri1());
bool triIntersect4 = TriTriIntersection.TriTriOverlap.TriTriIntersect(quad1.GetTri2(), quad2.GetTri2());
return triIntersect1 || triIntersect2 || triIntersect3 || triIntersect4;
}
示例3: Render
public void Render(GraphicsDeviceManager graphics, Matrix cameraViewMatrix, Matrix cameraProjectionMatrix, ParticleSystem system, Entity camera)
{
// TODO: Fix.
Vector3 ps = new Vector3(pos.X, pos.Y, pos.Z);
if (relativePosition)
{
ps += system.position;
}
Matrix billboardMatrix = Matrix.CreateBillboard(pos, camera.position, camera.getUpVector(), camera.getForwardVector());
if (quad == null)
{
}
quad = new Quad(ps, Vector3.Backward, Vector3.Up, size, size);
quadVertexDeclaration = new VertexDeclaration(graphics.GraphicsDevice, VertexPositionNormalTexture.VertexElements);
foreach (VertexPositionNormalTexture v in quad.Vertices)
{
Vector3.Transform(v.Position, billboardMatrix);
}
graphics.GraphicsDevice.VertexDeclaration = quadVertexDeclaration;
graphics.GraphicsDevice.DrawUserIndexedPrimitives
<VertexPositionNormalTexture>(
PrimitiveType.TriangleList,
quad.Vertices, 0, 4,
quad.Indexes, 0, 2);
}
示例4: Player
public Player(GraphicsDeviceManager _graphics )
{
graphics = _graphics;
spriteEffect = new BasicEffect(graphics.GraphicsDevice);
Position = new Quad(new Vector3(0, 50, 0), Vector3.Backward, Vector3.Up, 100, 100);
}
示例5: Main
static void Main(string[] args)
{
Vector v1 = new Vector(0F, 5F, 0F);
Vector v2 = new Vector(5F, 5F, 0F);
Vector v3 = new Vector(0F, 5F, 5F);
Vector v4 = new Vector(5F, 5F, 5F);
Quad quad = new Quad(v1, v2, v3, v4, new MyColor(0F, 0F, 0F));
List<Quad> quads = new List<Quad>();
quads.Add(quad);
Vector observer = new Vector(2F, 6.5F, 3F);
float distanceToGround = MovingTools.DistanceToGround(observer, quads);
/*
float Distance = MovingTools.PointToPlaneDistance(observer, v1, v2, v3);
Console.WriteLine("distance: " + Distance.ToString());
bool intersectWithWall = MovingTools.PointIsWithinRangeOfTriangle(10F, observer, v1, v2, v3);
Console.WriteLine("intersection?: " + intersectWithWall);
v1 = new Vertex(10F, 0F, 0F);
v2 = new Vertex(10F, 3F, 0F);
v3 = new Vertex(0F, 3F, 0F);
observer = new Vertex(8F, 0.1F, 0.1F);
intersectWithWall = MovingTools.PointIsWithinRangeOfTriangle(1F, observer, v1, v2, v3);
Console.WriteLine("intersection?: " + intersectWithWall);
*/
Console.ReadKey();
}
示例6: AdjustPointToNotGoThroughQuad
public static bool AdjustPointToNotGoThroughQuad(float MinDistance, ref Vector observer, Quad quad)
{
Vector ab = quad.vertices[0].Difference(quad.vertices[1]);
Vector ad = quad.vertices[0].Difference(quad.vertices[3]);
Vector N = ab.CrossProduct(ad);
float d = -N.DotProduct(quad.vertices[0]);
float t = -(d + observer.DotProduct(N)) / (N.DotProduct(N));
float Distance = (float)Math.Abs(t * N.Length());
if (Distance > MinDistance)
return false; //too far away, regardless of where you are relative to the wall
Vector projectionOntoTriangle = new Vector(observer.x + t * N.x, observer.y + t * N.y, observer.z + t * N.z);
if (!PointIsInQuad(projectionOntoTriangle, quad))
return false; //outside the quad
//the point needs to be moved
float NormalMultiplier = MinDistance / N.Length();
if (N.x / (observer.x - projectionOntoTriangle.x) < 0
|| N.y / (observer.y - projectionOntoTriangle.y) < 0
|| N.z / (observer.z - projectionOntoTriangle.z) < 0)
NormalMultiplier *= -1.0F;
observer = new Vector(projectionOntoTriangle.x + N.x * NormalMultiplier, projectionOntoTriangle.y + N.y * NormalMultiplier, projectionOntoTriangle.z + N.z * NormalMultiplier);
return true;
}
示例7: SLQuad
/// <summary>
/// Init SLQuad with Custom Quad Parameters
/// </summary>
/// <param name="gd"></param>
/// <param name="service"></param>
/// <param name="path"></param>
/// <param name="quad"></param>
public SLQuad(GraphicsDevice gd, IServiceProvider service, string path, Quad quad)
: base(gd)
{
Para = quad;
LoadContent(service, path, quad.BasePara.contentname);
Init(gd);
}
示例8: HitTestQuadSegment
/// <summary>
/// This is a specialized version of HitTestPolygonSegment that takes
/// a Quad for a polygon. This method is called very intensively by
/// hit-testing API and we don't want to create Vector[] for every quad it hit-tests.
/// </summary>
/// <param name="quad">the connecting quad to test against</param>
/// <param name="hitBegin">begin point of the hitting segment</param>
/// <param name="hitEnd">end point of the hitting segment</param>
/// <returns>true if hit, false otherwise</returns>
internal static bool HitTestQuadSegment(Quad quad, Point hitBegin, Point hitEnd)
{
System.Diagnostics.Debug.Assert(quad.IsEmpty == false);
HitResult hitResult = HitResult.Right, firstResult = HitResult.Right, prevResult = HitResult.Right;
int count = 4;
Vector zeroVector = new Vector(0, 0);
Vector hitVector = hitEnd - hitBegin;
Vector vertex = quad[count - 1] - hitBegin;
for (int i = 0; i < count; i++)
{
Vector nextVertex = quad[i] - hitBegin;
hitResult = WhereIsSegmentAboutSegment(zeroVector, hitVector, vertex, nextVertex);
if (HitResult.Hit == hitResult)
{
return true;
}
if (true == IsOutside(hitResult, prevResult))
{
return false;
}
if (i == 0)
{
firstResult = hitResult;
}
prevResult = hitResult;
vertex = nextVertex;
}
return (false == IsOutside(firstResult, hitResult));
}
示例9: Gen
public void Gen()
{
Vector3D[] verts = Verts( m_m, m_k );
Sphere[] tet = Tetrahedron( verts );
Quad quad = new Quad() { Verts = verts };
// We need to avoid infinities.
//tet = tet.Select( s => H3Models.UHSToBall( s ) ).ToArray();
//for( int i=0; i<quad.Verts.Length; i++ )
// quad.Verts[i] = H3Models.UHSToBall( quad.Verts[i] );
// Reflect it around.
//Quad[] quads = new Quad[] { quad };
Quad[] quads = CalcQuads( tet, quad );
List<H3.Cell.Edge> edges = new List<H3.Cell.Edge>();
foreach( Quad q in quads )
{
q.R3toS3();
edges.AddRange( q.GenEdges() );
}
string filename = string.Format( "lawson_{0}_{1}.pov", m_m, m_k );
PovRay.WriteEdges( new PovRay.Parameters() { AngularThickness = 0.01 },
Geometry.Spherical, edges.ToArray(), filename, append: false );
}
示例10: Beacon
public Beacon( int index, Vector3 position, bool active )
{
rotationScale = Matrix.CreateScale( .5f );
Position = position;
Active = active;
ContentManager content = ZombieCraft.Instance.Content;
model = content.Load<StillModel>( "Models/beacon" );
Texture2D haloTexture = content.Load<Texture2D>( "Textures/halo" );
Vector3[] verts =
{
new Vector3(-1f, 0f,-1f ),
new Vector3( 1f, 0f,-1f ),
new Vector3( 1f, 0f, 1f ),
new Vector3(-1f, 0f, 1f ),
};
halo = new Quad( verts, Position, haloTexture );
switch ( index )
{
case 0:
label = content.Load<Texture2D>( "Textures/beaconLabelA" );
break;
case 1:
label = content.Load<Texture2D>( "Textures/beaconLabelB" );
break;
case 2:
label = content.Load<Texture2D>( "Textures/beaconLabelX" );
break;
}
}
示例11: Initialise
public override void Initialise(Renderer renderer, ResourceContext context)
{
_quad = new Quad(renderer.Device);
//Create geometry management objects
_geometryProviders = renderer.Scene.FindManagers<IGeometryProvider>();
_depthPeeler = new DepthPeel();
var settings = renderer.Settings;
// 1 - Min
// 5 - Default
// 10 - Extreme
settings.Add("transparency_deferred_layers", "the max number of depth peeled layers to use for deferred transparency", 5);
//Make sure deferred lighting is enabled
LightingComponent.SetupScene(renderer.Scene, out _directLights, out _indirectLights);
// define inputs
context.DefineInput("gbuffer_depth");
context.DefineInput("gbuffer_normals");
context.DefineInput("gbuffer_diffuse");
context.DefineInput("lightbuffer");
//define outputs
context.DefineOutput("gbuffer_depth");
context.DefineOutput("lightbuffer", isLeftSet: true, surfaceFormat: SurfaceFormat.HdrBlendable, depthFormat: DepthFormat.Depth24Stencil8);
base.Initialise(renderer, context);
}
示例12: Snowflake
public Snowflake(Vector3 position, float snowflakeTemperature)
{
float diameter = Snowflake.CalculateDiameter(snowflakeTemperature);
this.mass = Snowflake.CalculateMass (snowflakeTemperature, diameter);
this.basicEffect = new BasicEffect(this.graphicsDevice);
this.basicEffect.World = this.camera.World;
this.basicEffect.View = this.camera.View;
this.basicEffect.Projection = this.camera.Projection;
this.basicEffect.TextureEnabled = true;
if (this.showLeaf)
{
this.quad = new Quad(diameter * 2);
Texture2D texture = this.contentManager.Load<Texture2D>("leaf_" + (int)(Snowflake.random.NextDouble() * numTextures));
this.basicEffect.Texture = texture;
}
else
{
this.quad = new Quad(diameter);
Texture2D texture = this.contentManager.Load<Texture2D>("flake_" + (int)(Snowflake.random.NextDouble() * numTextures));
this.basicEffect.Texture = texture;
}
this.Position = position;
this.velocity = new Vector3(0f, -0.1f, 0f);
}
示例13: GetGeom
protected override DX11IndexedGeometry GetGeom(DX11RenderContext context, int slice)
{
Quad quad = new Quad();
quad.Size = this.FSize[slice];
return context.Primitives.QuadCross(quad);
}
示例14: GetSortingOrder
private int GetSortingOrder(Quad newQuad, List<Building> buildings) {
int numberToCheck = Mathf.Min(buildings.Count, numBuildingsToCheck);
int sortingOrder;
int? sortingOrderUpperLimit = null;
int? sortingOrderLowerLimit = null;
for (int i = 1; i <= numberToCheck; i++) {
int index = buildings.Count - i;
Building otherBuilding = buildings[index];
Quad otherQuad = otherBuilding.attributes.quad;
if (!Quad.OverlapQuads(newQuad, otherQuad)) continue;
if (newQuad.ContainsTopPointsFromOtherQuad(otherQuad)) {
if (sortingOrderUpperLimit != null) sortingOrderUpperLimit = Mathf.Min((int)sortingOrderUpperLimit, otherBuilding.attributes.sortingOrder);
else sortingOrderUpperLimit = otherBuilding.attributes.sortingOrder;
}
else if (otherQuad.ContainsTopPointsFromOtherQuad(newQuad)) {
if (sortingOrderLowerLimit != null) sortingOrderLowerLimit = Mathf.Max((int)sortingOrderLowerLimit, otherBuilding.attributes.sortingOrder);
else sortingOrderLowerLimit = otherBuilding.attributes.sortingOrder;
}
}
if (sortingOrderLowerLimit == null && sortingOrderUpperLimit == null) sortingOrder = baseSortingOrder;
else if (sortingOrderLowerLimit == null) sortingOrder = (int)sortingOrderUpperLimit - 10;
else if (sortingOrderUpperLimit == null) sortingOrder = (int)sortingOrderLowerLimit + 10;
else sortingOrder = ((int)sortingOrderUpperLimit + (int)sortingOrderLowerLimit) / 2;
return sortingOrder;
}
示例15: Initialize
public void Initialize()
{
// TODO: Add your initialization logic here
quad = new Quad( Vector3.Zero, Vector3.Backward, Vector3.Up, 1, 1 );
View = Matrix.CreateLookAt( new Vector3( 0, 0, 2 ), Vector3.Zero, Vector3.Up );
Projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, 4.0f / 3.0f, 1, 500 );
}