public static float[] AreCollideWithStatic(Bullet bullet, RigidShape staticBody) { switch (staticBody) { case RigidAABB aabb: return(AreCollide(bullet.Position, bullet.Velocity, aabb)); case RigidCircle circle: return(AreCollide(bullet.Position, bullet.Velocity, circle)); default: return(null); } }
private static void ResolveCollisionStatically(CollisionInfo info, RigidShape first, RigidShape second) { if (second.IsStatic) { first.MoveBy(info.Normal * info.Depth); } else if (first.IsStatic) { second.MoveBy(info.Normal * info.Depth); } else { first.MoveBy(info.Normal * info.Depth); } }
/// <summary> /// Draws the shapeObject. Coordinates are took in camera axis. /// </summary> /// <param name="shapeObject"></param> /// <param name="strokePen"></param> /// <param name="g"></param> public static void Draw(RigidShape shapeObject, Pen strokePen, Graphics g) { switch (shapeObject) { case RigidCircle circle: DrawCircle(circle, strokePen, g); break; case RigidAABB aabb: DrawAABB(aabb, strokePen, g); break; case RigidTriangle triangle: DrawTriangle(triangle, strokePen, g); break; case RigidCircleQuarter circleQuarter: DrawCircleQuarter(circleQuarter, strokePen, g); break; } }
public static CollisionInfo GetCollisionInfo(RigidShape first, RigidShape second) { switch (first) { case RigidCircle firstCircle when second is RigidCircle secondCircle: return(GetCollisionInfo(firstCircle, secondCircle)); case RigidAABB aabb when second is RigidCircle circle: return(GetCollisionInfo(aabb, circle)); case RigidCircle circle when second is RigidAABB aabb: return(GetCollisionInfo(aabb, circle)); case RigidCircle circle when second is RigidCircleQuarter quarter: return(GetCollisionInfo(circle, quarter)); case RigidCircleQuarter quarter when second is RigidCircle circle: return(GetCollisionInfo(circle, quarter)); case RigidCircle circle when second is RigidTriangle triangle: return(GetCollisionInfo(circle, triangle)); case RigidTriangle triangle when second is RigidCircle circle: return(GetCollisionInfo(circle, triangle)); default: return(null); } }
public void Read(BinaryReader reader, PmxHeaderData header) { RigidName = reader.ReadText(header.Encoding); RigidNameE = reader.ReadText(header.Encoding); BoneId = reader.ReadPmxId(header.BoneIndexSize); Group = reader.ReadByte(); GroupFlag = reader.ReadUInt16(); Shape = (RigidShape)reader.ReadByte(); Size = reader.ReadVector3(); Pos = reader.ReadVector3(); Rot = reader.ReadVector3(); Mass = reader.ReadSingle(); MovingAttenuation = reader.ReadSingle(); RotationAttenuation = reader.ReadSingle(); Repulsive = reader.ReadSingle(); Frictional = reader.ReadSingle(); RigidType = (RigidType)reader.ReadByte(); }
public static void RenderShapeOnCamera(RigidShape shape, Vector cameraPosition) { RigidBodyRenderer.Draw(shape, cameraPosition, ShapePen, gfxCamera); }
public static float[] AreCollideWithStatic(Vector objectPosition, Vector objectVelocity, RigidShape staticBody) { switch (staticBody) { case RigidAABB aabb: return(AreCollide(objectPosition, objectVelocity, aabb)); case RigidCircle circle: return(AreCollide(objectPosition, objectVelocity, circle)); default: return(null); } }
public CollectableWeapon(Weapon item, RigidShape collisionShape, SpriteContainer spriteContainer) { this.item = item; CollisionShape = collisionShape; SpriteContainer = spriteContainer; }