Inheritance: LoadableModel, IDisposable
Exemplo n.º 1
0
        /// <summary>
        /// Creates the cube.
        /// </summary>
        /// <param name="size">The size (1 by default).</param>
        /// <returns>A <see cref="Model"/> representing a cube.</returns>
        public static Model CreateCube(float size = 1.0f)
        {
            Model cube = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            cube.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Cube(size));
            cube.isPrimitive = true;

            return cube;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new Model
        /// </summary>
        /// <param name="position">model initial position</param>
        /// <param name="model">the model mesh</param>
        /// <param name="collider">the model collider</param>
        private void CreateModel(Vector3 position, Model model, Collider3D collider)
        {
            Entity primitive = new Entity()
               .AddComponent(new Transform3D() { Position = position })
               .AddComponent(collider)
               .AddComponent(model)
               .AddComponent(new RigidBody3D())
               .AddComponent(new MaterialsMap() { DefaultMaterialPath = WaveContent.Assets.basicMaterial })
               .AddComponent(new ModelRenderer());

            this.EntityManager.Add(primitive);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the capsule.
        /// </summary>
        /// <param name="height">The height (1 by default).</param>
        /// <param name="radius">The radius (0.5f by default).</param>
        /// <param name="tessellation">The tessellation (16 by default).</param>
        /// <returns>A <see cref="Model"/> representing a capsule.</returns>
        public static Model CreateCapsule(float height = 1f, float radius = 0.5f, int tessellation = 16)
        {
            Model capsule = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            capsule.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Capsule(height, radius, tessellation));
            capsule.isPrimitive = true;

            return capsule;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the torus.
        /// </summary>
        /// <param name="diameter">The diameter (1 by default).</param>
        /// <param name="thickness">The thickness (0.333f by default).</param>
        /// <param name="tessellation">The tessellation (16 by default).</param>
        /// <returns>A <see cref="Model"/> representing a torus</returns>
        public static Model CreateTorus(float diameter = 1.0f, float thickness = 0.333f, int tessellation = 16)
        {
            Model torus = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            torus.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Torus(diameter, thickness, tessellation));
            torus.isPrimitive = true;

            return torus;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the teapot.
        /// </summary>
        /// <param name="size">The size.</param>
        /// <param name="tessellation">The tessellation.</param>
        /// <returns>A <see cref="Model"/> representing a teapot.</returns>
        public static Model CreateTeapot(float size = 1.0f, int tessellation = 8)
        {
            Model teapot = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            teapot.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Teapot(size, tessellation));
            teapot.isPrimitive = true;

            return teapot;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates the sphere.
        /// </summary>
        /// <param name="diameter">The diameter (1 by default).</param>
        /// <param name="tessellation">The tessellation (8 by default).</param>
        /// <returns>A <see cref="Model"/> representing a sphere.</returns>
        public static Model CreateSphere(float diameter = 1.0f, int tessellation = 8)
        {
            Model sphere = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            sphere.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Sphere(diameter, tessellation));
            sphere.isPrimitive = true;

            return sphere;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates the pyramid.
        /// </summary>
        /// <param name="size">The size (1 by default).</param>
        /// <returns>A <see cref="Model"/> representing a pyramid.</returns>
        public static Model CreatePyramid(float size = 1.0f)
        {
            Model pyramid = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            pyramid.InternalModel.FromPrimitive(WaveServices.GetService<GraphicsDevice>(), new Pyramid(size));
            pyramid.isPrimitive = true;

            return pyramid;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates the plane.
        /// </summary>
        /// <param name="normal">The normal ( [0, 1, 0] by default).</param>
        /// <param name="size">The size (1 by default).</param>
        /// <returns>
        /// A <see cref="Model" /> representing a plane.
        /// </returns>
        public static Model CreatePlane(Vector3? normal = null, float size = 1.0f)
        {
            if (!normal.HasValue)
            {
                normal = Vector3.Up;
            }

            Model plane = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            plane.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Primitives.Plane(normal.Value, size));
            plane.isPrimitive = true;

            return plane;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates the cylinder.
        /// </summary>
        /// <param name="height">The height (1 by default).</param>
        /// <param name="diameter">The diameter (1 by default).</param>
        /// <param name="tessellation">The tessellation (16 by default).</param>
        /// <returns>A <see cref="Model"/> representing a cylinder.</returns>
        public static Model CreateCylinder(float height = 1.0f, float diameter = 1.0f, int tessellation = 16)
        {
            Model cylinder = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            cylinder.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Cylinder(height, diameter, tessellation));
            cylinder.isPrimitive = true;

            return cylinder;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates the cone.
        /// </summary>
        /// <param name="height">The height (1 by default).</param>
        /// <param name="diameter">The diameter (1 by default).</param>
        /// <param name="tessellation">The tessellation (16 by default).</param>
        /// <returns>A <see cref="Model"/> representing a cone.</returns>
        public static Model CreateCone(float height = 1.0f, float diameter = 1.0f, int tessellation = 16)
        {
            Model cone = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            cone.InternalModel.FromPrimitive(WaveServices.GraphicsDevice, new Cone(height, diameter, tessellation));
            cone.isPrimitive = true;
            cone.modelType = ModelType.Cone;

            return cone;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Create a random model
        /// </summary>
        /// <param name="name">The name of the model</param>
        /// <param name="model">The model to create</param>
        private void CreateRandomModel(string name, Model model)
        {
            Entity entity = new Entity(name)
                         .AddComponent(new Transform3D() { Position = GetRandomVector(), Scale = new Vector3(1.5f, 1.5f, 1.5f) })
                         .AddComponent(new BoxCollider())
                         .AddComponent(model)
                         .AddComponent(new MaterialsMap(new BasicMaterial(GetRandomColor())))
                         .AddComponent(new ModelRenderer());

            EntityManager.Add(entity);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Creates the cube.
        /// </summary>
        /// <param name="mesh">The mesh</param>
        /// <param name="boundingBox">The mesh bounding box</param>
        /// <returns>A <see cref="Model"/> representing a cube.</returns>
        public static Model CreateFromMesh(Mesh mesh, BoundingBox boundingBox)
        {
            Model model = new Model(string.Empty) { InternalModel = new InternalStaticModel() };
            model.InternalModel.FromMesh(WaveServices.GraphicsDevice, mesh, boundingBox);
            model.modelType = ModelType.Custom;

            return model;
        }