コード例 #1
0
ファイル: PathShape.cs プロジェクト: bgarrels/projectanarchy
        /// <summary>
        /// Overridden function to create the shape instance
        /// </summary>
        /// <returns></returns>
        public override ShapeBase CreateShapeInstance()
        {
            PathShape shape = new PathShape("Path");
              shape.Position = EditorManager.Scene.CurrentShapeSpawnPosition;

              PathNodeShape node;

              for (int i=0;i<4;i++)
              {
            node = new PathNodeShape();
            node.Position = shape.Position;
            node.y += ((float)i - 1.5f) * 200.0f * EditorManager.Settings.GlobalUnitScaling;
            node.ShapeName = "node" + i;
            node.SetParent(shape);
              }
              shape.SmoothAll(false);
              return shape;
        }
コード例 #2
0
ファイル: PathShape.cs プロジェクト: bgarrels/projectanarchy
        /// <summary>
        /// Overridden function to create the shape instance
        /// </summary>
        /// <returns></returns>
        public override ShapeBase CreateShapeInstance()
        {
            PathShape shape = new PathShape("Circle Path");
              shape.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
              shape.Closed = true;

              // Magic number: http://www.tinaja.com/glib/ellipse4.pdf
              float fMagic = 0.551784f;
              float fRadius = 200.0f * EditorManager.Settings.GlobalUnitScaling;

              Vector3F rotCenter = shape.Position;
              Vector3F rotAngle = new Vector3F(0.0f, 0.0f, 0.0f);
              Matrix3F rotMatrix = new Matrix3F();
              rotMatrix.FromEuler(rotAngle.X, rotAngle.Y, rotAngle.Z);
              PathNodeShape node;

              for (int i = 0; i < 4; i++)
              {
            node = new PathNodeShape();
            node.Position = shape.Position;
            node.y -= fRadius;

            node.TangentIn = new Vector3F(node.TangentIn.X - fRadius * fMagic, 0.0f, 0.0f);
            node.TangentOut = new Vector3F(node.TangentOut.X + fRadius * fMagic, 0.0f, 0.0f);

            node.Position = shape.Position + rotMatrix * (node.Position - rotCenter);
            node.TangentIn = rotMatrix * (node.TangentIn);
            node.TangentOut = rotMatrix * (node.TangentOut);

            node.InType = PathNodeShape.PathNodeInOutType.Custom;
            node.OutType = PathNodeShape.PathNodeInOutType.Custom;

            node.ShapeName = "node" + i;

            node.SetParent(shape);

            rotAngle.X += 90.0f;
            rotMatrix.FromEuler(rotAngle.X, rotAngle.Y, rotAngle.Z);
              }

              return shape;
        }