public IStack initialise(Vector3 centroid, Vector3 stackTwist, float scale, Color stackColour)
    {
        stack = new GameObject("Torus");
        torus = stack.AddComponent<TorusPrimitive>();

        torus.OuterRadius = scale;
        torus.InnerRadius = 0.2f * scale;
        //torus.Sides = 32;
        //torus.Segments = 32;

        torus.UpdatePrimitive ();

        stackRigidBody = stack.AddComponent<Rigidbody>();
        stackRigidBody.useGravity = false;
        stackRigidBody.detectCollisions = false;

        stack.transform.position = centroid;

        currentRotationX = stackTwist.x;
        currentRotationY = stackTwist.y;
        currentRotationZ = stackTwist.z;
        stack.transform.Rotate (stackTwist);

        stack.transform.localScale = new Vector3(scale, scale, scale);

        stack.GetComponent<Renderer>().material.color = stackColour;
        return this;
    }
Beispiel #2
0
    public IStack initialise(Vector3 centroid, Vector3 stackTwist, float scale, Color stackColour)
    {
        stack = new GameObject("Torus");
        torus = stack.AddComponent <TorusPrimitive>();

        torus.OuterRadius = scale;
        torus.InnerRadius = 0.2f * scale;
        //torus.Sides = 32;
        //torus.Segments = 32;

        torus.UpdatePrimitive();

        stackRigidBody                  = stack.AddComponent <Rigidbody>();
        stackRigidBody.useGravity       = false;
        stackRigidBody.detectCollisions = false;

        stack.transform.position = centroid;

        currentRotationX = stackTwist.x;
        currentRotationY = stackTwist.y;
        currentRotationZ = stackTwist.z;
        stack.transform.Rotate(stackTwist);

        stack.transform.localScale = new Vector3(scale, scale, scale);

        stack.GetComponent <Renderer>().material.color = stackColour;
        return(this);
    }
Beispiel #3
0
        // Token: 0x06004268 RID: 17000 RVA: 0x00151718 File Offset: 0x0014FB18
        public override void GenerateColliderGeometry()
        {
            Mesh colliderMesh = base.GetColliderMesh();

            if (colliderMesh)
            {
                colliderMesh.Clear();
                TorusPrimitive.GenerateGeometry(colliderMesh, this.radius0, this.radius1, this.torusSegments, this.coneSegments, this.slice, this.normalsType, this.pivotPosition);
                base.RefreshMeshCollider();
            }
            base.GenerateColliderGeometry();
        }
Beispiel #4
0
        // Token: 0x06004266 RID: 16998 RVA: 0x00151654 File Offset: 0x0014FA54
        public void GenerateGeometry(float radius0, float radius1, int torusSegments, int coneSegments, float slice, NormalsType normalsType, PivotPosition pivotPosition)
        {
            MeshFilter component = base.GetComponent <MeshFilter>();

            if (component.sharedMesh == null)
            {
                component.sharedMesh = new Mesh();
            }
            Mesh sharedMesh = component.sharedMesh;

            base.GenerationTimeMS = TorusPrimitive.GenerateGeometry(sharedMesh, radius0, radius1, torusSegments, coneSegments, slice, normalsType, pivotPosition);
            this.radius0          = radius0;
            this.radius1          = radius1;
            this.torusSegments    = torusSegments;
            this.coneSegments     = coneSegments;
            this.normalsType      = normalsType;
            this.slice            = slice;
            this.flipNormals      = false;
            this.pivotPosition    = pivotPosition;
        }
        /// <inheritdoc />
        public override void Initialize()
        {
            Game.Background = Color.CornflowerBlue;
            Camera          = new TargetCamera(GraphicsDevice.Viewport.AspectRatio, new Vector3(0, 20, 60), Vector3.Zero);

            Box = new CubePrimitive(GraphicsDevice, 10, Color.DarkCyan, Color.DarkMagenta, Color.DarkGreen,
                                    Color.MonoGameOrange, Color.Black, Color.DarkGray);
            BoxPosition      = Vector3.Zero;
            Cylinder         = new CylinderPrimitive(GraphicsDevice, 20, 10, 16);
            CylinderPosition = new Vector3(-20, 0, 0);
            Sphere           = new SpherePrimitive(GraphicsDevice, 10);
            SpherePosition   = new Vector3(0, -15, 0);
            Teapot           = new TeapotPrimitive(GraphicsDevice, 10);
            TeapotPosition   = new Vector3(20, 0, 0);
            Torus            = new TorusPrimitive(GraphicsDevice, 10, 1, 16);
            TorusPosition    = new Vector3(-20, 15, 0);
            Triangle         = new TrianglePrimitive(GraphicsDevice, new Vector3(-10f, 10f, 0f), new Vector3(0f, 20f, 0f),
                                                     new Vector3(10f, 10f, 0f), Color.Black, Color.Cyan, Color.Magenta);

            base.Initialize();
        }
Beispiel #6
0
        /// <summary>
        /// Creates a StaticModel from a GeometricPrimitive and specified dimensions.
        /// </summary>
        /// <param name="primitiveType">Type of primitive to create</param>
        /// <param name="height">Height of primitive, used by cubes and cylinders.</param>
        /// <param name="width">Width of primitive, used by cubes.</param>
        /// <param name="depth">Depth of primitive, used by cubes.</param>
        /// <param name="diameter">Diameter of primitive, used by cylinders, spheres, toruses, and teapots.</param>
        private void LoadModelFromPrimitive(GeometricPrimitiveType primitiveType, float height, float width, float depth, float diameter)
        {
            GeometricPrimitive primitive;

            switch (primitiveType)
            {
            case GeometricPrimitiveType.Box:
                primitive = new CubePrimitive(this.parentEntity.Game.GraphicsDevice, height, width, depth);
                break;

            case GeometricPrimitiveType.Sphere:
                primitive = new SpherePrimitive(this.parentEntity.Game.GraphicsDevice, diameter, 16);
                break;

            case GeometricPrimitiveType.Cylinder:
                primitive = new CylinderPrimitive(this.parentEntity.Game.GraphicsDevice, height, diameter, 16);
                break;

            case GeometricPrimitiveType.Cone:
                primitive = new ConePrimitive(this.parentEntity.Game.GraphicsDevice, height, diameter, 16);
                break;

            case GeometricPrimitiveType.Torus:
                primitive = new TorusPrimitive(this.parentEntity.Game.GraphicsDevice, diameter, 0.3333f, 16);
                break;

            case GeometricPrimitiveType.Teapot:
                primitive = new TeapotPrimitive(this.parentEntity.Game.GraphicsDevice, diameter, 8);
                break;

            default:
                throw new Exception("LoadPrimitive does not handle this type of GeometricPrimitive. Was a new primitive type made and not handled here?");
            }

            if (null != primitive)
            {
                model = new StaticModel(primitive, this.parentEntity.Game.GraphicsDevice);
            }
        }