/// <summary> /// Initializes a new instance of the <see cref="CylinderColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cylinder</param> /// <param name="height">The height of the cylinder</param> public CylinderColliderShape(float height, float radius, ShapeOrientation orientation) { Type = ColliderShapeTypes.Cylinder; Is2D = false; //always false for cylinders Matrix rotation; switch (orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.CylinderShapeX(new Vector3(height/2, radius, 0)); rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.CylinderShape(new Vector3(radius, height/2, 0)); rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.CylinderShapeZ(new Vector3(radius, 0, height/2)); rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException("orientation"); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(2*radius, height, 2*radius) * 1.01f) * rotation; }
/// <summary> /// Initializes a new instance of the <see cref="CylinderColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cylinder</param> /// <param name="height">The height of the cylinder</param> public CylinderColliderShape(float height, float radius, ShapeOrientation orientation) { Type = ColliderShapeTypes.Cylinder; Is2D = false; //always false for cylinders Matrix rotation; switch (orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.CylinderShapeX(new Vector3(height / 2, radius, 0)); rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.CylinderShape(new Vector3(radius, height / 2, 0)); rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.CylinderShapeZ(new Vector3(radius, 0, height / 2)); rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException("orientation"); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(2 * radius, height, 2 * radius) * 1.01f) * rotation; }
/// <summary> /// Initializes a new instance of the <see cref="CapsuleColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> /// <param name="length">The length of the capsule.</param> /// <param name="orientation">Up axis.</param> public CapsuleColliderShape(bool is2D, float radius, float length, ShapeOrientation orientation) { Type = ColliderShapeTypes.Capsule; Is2D = is2D; capsuleLength = length; capsuleRadius = radius; Matrix rotation; CapsuleShape shape; switch (orientation) { case ShapeOrientation.UpX: shape = new CapsuleShapeZ(radius, length); rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: shape = new CapsuleShape(radius, length); rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: shape = new CapsuleShapeX(radius, length); rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException("orientation"); } InternalShape = Is2D ? (CollisionShape)new Convex2DShape(shape) { LocalScaling = new Vector3(1, 1, 0) }: shape; DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(1.01f)) * rotation; }
public Player1PlaceArmy() { for (var i = 0; i < 8; i++) { this[i] = new ShapeOrientation(Shape.None, Orientation.Original); } }
/// <summary> /// Initializes a new instance of the <see cref="CapsuleColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> /// <param name="length">The length of the capsule.</param> /// <param name="orientation">Up axis.</param> public CapsuleColliderShape(bool is2D, float radius, float length, ShapeOrientation orientation, Vector3?offset = null, Quaternion?localrot = null) { Type = ColliderShapeTypes.Capsule; Is2D = is2D; Length = length; Radius = radius; Orientation = orientation; Matrix rotation; CapsuleShape shape; cachedScaling = Is2D ? new Vector3(1, 1, 0) : Vector3.One; switch (orientation) { case ShapeOrientation.UpZ: shape = new CapsuleShapeZ(radius, length) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: shape = new CapsuleShape(radius, length) { LocalScaling = cachedScaling, }; rotation = Matrix.Identity; break; case ShapeOrientation.UpX: shape = new CapsuleShapeX(radius, length) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException("orientation"); } InternalShape = Is2D ? (CollisionShape) new Convex2DShape(shape) { LocalScaling = cachedScaling } : shape; DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(DebugScaling)) * rotation; if (offset.HasValue || localrot.HasValue) { LocalOffset = offset ?? Vector3.Zero; LocalRotation = localrot ?? Quaternion.Identity; UpdateLocalTransformations(); } }
/// <summary> /// Initializes a new instance of the <see cref="CapsuleColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> /// <param name="length">The length of the capsule.</param> /// <param name="orientation">Up axis.</param> public CapsuleColliderShape(bool is2D, float radius, float length, ShapeOrientation orientation) { Type = ColliderShapeTypes.Capsule; Is2D = is2D; capsuleLength = length; capsuleRadius = radius; shapeOrientation = orientation; Matrix rotation; CapsuleShape shape; cachedScaling = Is2D ? new Vector3(1, 1, 0) : Vector3.One; switch (orientation) { case ShapeOrientation.UpZ: shape = new CapsuleShapeZ(radius, length) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: shape = new CapsuleShape(radius, length) { LocalScaling = cachedScaling, }; rotation = Matrix.Identity; break; case ShapeOrientation.UpX: shape = new CapsuleShapeX(radius, length) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException("orientation"); } InternalShape = Is2D ? (CollisionShape) new Convex2DShape(shape) { LocalScaling = cachedScaling } : shape; DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(DebugScaling)) * rotation; }
/// <summary> /// Initializes a new instance of the <see cref="ConeColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cone</param> /// <param name="height">The height of the cone</param> public ConeColliderShape(float heightParam, float radiusParam, ShapeOrientation orientationParam, Vector3?offset = null, Quaternion?localrot = null) { Type = ColliderShapeTypes.Cone; Is2D = false; //always false for cone Height = heightParam; Radius = radiusParam; Orientation = orientationParam; Matrix rotation; cachedScaling = Vector3.One; switch (Orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.ConeShapeX(Radius, Height) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.ConeShape(Radius, Height) { LocalScaling = cachedScaling, }; rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.ConeShapeZ(Radius, Height) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException(nameof(Orientation)); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(Radius * 2, Height, Radius * 2) * DebugScaling) * rotation; if (offset.HasValue || localrot.HasValue) { LocalOffset = offset ?? Vector3.Zero; LocalRotation = localrot ?? Quaternion.Identity; UpdateLocalTransformations(); } }
public Player1PlaceArmy(ShapeOrientation frontCenter, ShapeOrientation frontLeft, ShapeOrientation frontRight, ShapeOrientation middleLeft, ShapeOrientation middleRight, ShapeOrientation backCenter, ShapeOrientation backLeft, ShapeOrientation backRight) { FrontCenter = frontCenter; FrontLeft = frontLeft; FrontRight = frontRight; MiddleLeft = middleLeft; MiddleRight = middleRight; BackCenter = backCenter; BackLeft = backLeft; BackRight = backRight; }
public ShapeOrientation this[int index] { get { switch (index) { case 0: return(FrontCenter); case 1: return(FrontLeft); case 2: return(FrontRight); case 3: return(MiddleLeft); case 4: return(MiddleRight); case 5: return(BackCenter); case 6: return(BackLeft); case 7: return(BackRight); default: throw new IndexOutOfRangeException("Valid range is 0-7"); } } set { switch (index) { case 0: FrontCenter = value; break; case 1: FrontLeft = value; break; case 2: FrontRight = value; break; case 3: MiddleLeft = value; break; case 4: MiddleRight = value; break; case 5: BackCenter = value; break; case 6: BackLeft = value; break; case 7: BackRight = value; break; default: throw new IndexOutOfRangeException("Valid range is 0-7"); } } }
public Shape(Type type, ShapeOrientation orientation, ConsoleColor color = ConsoleColor.DarkGray) { ShapeType = type; Orientation = orientation; Color = color; UpdateBits(); for (int x = 0; x <= Bits.GetUpperBound(0); x++) { for (int y = 0; y <= Bits.GetUpperBound(1); y++) { if (Bits[x, y]) { Score++; } } } }
/// <summary> /// Initializes a new instance of the <see cref="CylinderColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cylinder</param> /// <param name="height">The height of the cylinder</param> public CylinderColliderShape(float heightParam, float radiusParam, ShapeOrientation orientationParam) { Type = ColliderShapeTypes.Cylinder; Is2D = false; //always false for cylinders Height = heightParam; Radius = radiusParam; Matrix rotation; cachedScaling = Vector3.One; Orientation = orientationParam; switch (Orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.CylinderShapeX(new Vector3(Height / 2, Radius, Radius)) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationZ(MathF.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.CylinderShape(new Vector3(Radius, Height / 2, Radius)) { LocalScaling = cachedScaling, }; rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.CylinderShapeZ(new Vector3(Radius, Radius, Height / 2)) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationX(MathF.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException(nameof(Orientation)); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(Radius * 2, Height, Radius * 2) * DebugScaling) * rotation; }
/// <summary> /// Initializes a new instance of the <see cref="CylinderColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cylinder</param> /// <param name="height">The height of the cylinder</param> public CylinderColliderShape(float height, float radius, ShapeOrientation orientation) { Type = ColliderShapeTypes.Cylinder; Is2D = false; //always false for cylinders Matrix rotation; CachedScaling = Vector3.One; shapeOrientation = orientation; switch (orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.CylinderShapeX(new Vector3(height / 2, radius, radius)) { LocalScaling = CachedScaling }; rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.CylinderShape(new Vector3(radius, height / 2, radius)) { LocalScaling = CachedScaling }; rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.CylinderShapeZ(new Vector3(radius, radius, height / 2)) { LocalScaling = CachedScaling }; rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException(nameof(orientation)); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(radius * 2, height, radius * 2) * DebugScaling) * rotation; }
/// <summary> /// Initializes a new instance of the <see cref="CylinderColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cylinder</param> /// <param name="height">The height of the cylinder</param> public CylinderColliderShape(float height, float radius, ShapeOrientation orientation) { Type = ColliderShapeTypes.Cylinder; Is2D = false; //always false for cylinders Matrix rotation; CachedScaling = Vector3.One; shapeOrientation = orientation; switch (orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.CylinderShapeX(new Vector3(height/2, radius, radius)) { LocalScaling = CachedScaling }; rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.CylinderShape(new Vector3(radius, height/2, radius)) { LocalScaling = CachedScaling }; rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.CylinderShapeZ(new Vector3(radius, radius, height/2)) { LocalScaling = CachedScaling }; rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException(nameof(orientation)); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(radius * 2, height, radius * 2) * DebugScaling) * rotation; }
public void clearArrayIn2d(float[] array, uint arrayLength, Vector3 position, Vector2 size, ShapeDirection dir, ShapeFront front, ShapeOrientation orientation, bool explode) { generateArrayIn2d(array, arrayLength, position, size, dir, front, orientation, TransparentColor, explode); }
public void generateArrayIn2d(float[] array, uint arrayLength, Vector3 position, Vector2 size, ShapeDirection dir, ShapeFront front, ShapeOrientation orientation, QuantizedColor color, bool explode) { int y0 = 0; int xMin = 0; int y = 0; int x = 0; int idx = 0; //plane we're drawing on: int pos = 0; //how many voxels we need for each value in the array: int voxelsPerValue = Mathf.FloorToInt(size.x / arrayLength); //if we end up getting 0, then just round up to 1. if (voxelsPerValue <= 0) { voxelsPerValue++; } float val = 0.0f; switch (dir) { case ShapeDirection.UP: y0 = Mathf.FloorToInt(position.x); xMin = Mathf.FloorToInt(position.z - size.x / 2); pos = Mathf.FloorToInt(position.y); break; case ShapeDirection.FRONT: y0 = Mathf.FloorToInt(position.y); xMin = Mathf.FloorToInt(position.x - size.x / 2); pos = Mathf.FloorToInt(position.z); break; case ShapeDirection.SIDE: y0 = Mathf.FloorToInt(position.y); xMin = Mathf.FloorToInt(position.z - size.x / 2); pos = Mathf.FloorToInt(position.x); break; default: break; } y = y0; x = xMin; //draw array: for (idx = 0; idx < arrayLength; idx++) { //if we are rendering facing the back or left, we reverse the draw. if (front == ShapeFront.DOWN_BACK_OR_LEFT && (dir == ShapeDirection.FRONT || dir == ShapeDirection.SIDE)) { val = array[arrayLength - idx]; } else { val = array[idx]; } //if we are rendering facing downwards, we just negate the array: if (front == ShapeFront.DOWN_BACK_OR_LEFT && dir == ShapeDirection.FRONT) { y = y0 - Mathf.FloorToInt(val * size.y); } else { y = y0 + Mathf.FloorToInt(val * size.y); } //to do: if voxels per value is more than 1, draw squares rather than single voxels //Debug.Log("Drawing value " + val + " at x: " + x + " y: " + y); if (orientation == ShapeOrientation.HORIZONTAL) { switch (dir) { case ShapeDirection.UP: drawVoxel(y, pos, x, color, explode); break; case ShapeDirection.FRONT: drawVoxel(x, y, pos, color, explode); break; case ShapeDirection.SIDE: drawVoxel(pos, y, x, color, explode); break; default: break; } } else { switch (dir) { case ShapeDirection.UP: drawVoxel(x, pos, y, color, explode); break; case ShapeDirection.FRONT: drawVoxel(y, x, pos, color, explode); break; case ShapeDirection.SIDE: drawVoxel(pos, x, y, color, explode); break; default: break; } } x += voxelsPerValue; } }
internal static extern Seq cvConvexHull2(CVHandle input, CVHandle hull_storage, ShapeOrientation orientation, int return_points);