/// <summary> /// コンストラクター /// </summary> /// <remarks> /// メモ:法線はここで正規化した方が良い? /// 現状では何もしていない。 /// </remarks> /// <param name="collidee">衝突した相手(<see cref="PhysicsBody"/> オブジェクト)</param> /// <param name="point">衝突地点(ローカル座標)</param> /// <param name="normal">法線(ローカル座標)</param> internal ContactPoint(PhysicsBody collidee, Vector3 point, Vector3 normal) : this() { this.Normal = normal; this.Point = point; this.Collidee = collidee; }
public static Node Create(Vector3 pos) { var cmp = new MyDeadBox (); var spr = new Sprite (128, 128); spr.AddTexture (new Texture ("media/Image128x128(Red).png")); spr.Color = Color.Gray; var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0); col.SetOffset (spr.Width / 2, spr.Height / 2, 0); var body = new PhysicsBody (); body.Shape = col; body.IsTrigger = true; var node = new Node ("DeadBox"); node.Attach (cmp); node.Attach (spr); node.Attach (col); node.Attach (body); node.Translation = pos; return node; }
private Node CreateBall(Vector3 pos) { var cmp = new MyBall (); var spr = new Sprite (Resource.GetTexture ("media/Earth-32x32.png"), 32, 32); var col = new SphereCollision (16); col.SetOffset (col.Radius, col.Radius, 0); var body = new PhysicsBody (); body.Type = ColliderType.Dynamic; body.SetShape (col); body.SetMaterial (new PhysicsMaterial ()); body.ApplyForce (50000, 0, 0); var node = new Node ("Ball " + ballIndex++); node.Attach (spr); node.Attach (cmp); node.Attach (col); node.Attach (body); node.Translation = pos; return node; }
private static Node CreateFloor(string name, int x, int y, int width, int height, Quaternion rot) { var spr = new Sprite (width, height); spr.AddTexture (Resource.GetTexture ("media/Rectangle-160x40.png")); var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0); col.SetOffset (spr.Width / 2, spr.Height / 2, 0); var body = new PhysicsBody (); var mat = new PhysicsMaterial (); body.Shape = col; body.Material = mat; var node = new Node (name); node.SetTranslation (x, y, 0); node.SetRotation (rot); node.Attach (spr); node.Attach (col); node.Attach (body); return node; }