/// <summary> /// Makes primitive into specified type using default values. /// </summary> /// <param name="type">Type of primitive to use.</param> public void MakePrimitive(GeometricPrimitiveType type) { // Create default primitive switch (type) { case GeometricPrimitiveType.Cube: primitive = new CubePrimitive(core.GraphicsDevice); break; case GeometricPrimitiveType.Cylinder: primitive = new CylinderPrimitive(core.GraphicsDevice); break; case GeometricPrimitiveType.Sphere: primitive = new SpherePrimitive(core.GraphicsDevice); break; case GeometricPrimitiveType.Teapot: primitive = new TeapotPrimitive(core.GraphicsDevice); break; case GeometricPrimitiveType.Torus: primitive = new TorusPrimitive(core.GraphicsDevice); break; default: return; } this.type = type; this.BoundingSphere = primitive.BoundingSphere; }
/// <summary> /// Makes primitive a teaport. /// </summary> /// <param name="size">Size of teapot.</param> /// <param name="tessellation">Tessellation of teapot.</param> public void MakeTeapot(float size, int tessellation) { // Create primitive primitive = new TeapotPrimitive(core.GraphicsDevice, size, tessellation); type = GeometricPrimitiveType.Teapot; BoundingSphere = primitive.BoundingSphere; }
/// <summary> /// Makes primitive a torus. /// </summary> /// <param name="diameter">Diameter of torus.</param> /// <param name="radius">Radius of torus.</param> /// <param name="tessellation">Tessellation of torus.</param> public void MakeTorus(float radius, float thickness, int tessellation) { // Create primitive primitive = new TorusPrimitive(core.GraphicsDevice, radius * 2, thickness, tessellation); type = GeometricPrimitiveType.Torus; BoundingSphere = primitive.BoundingSphere; }
/// <summary> /// Makes primitive a cylinder. /// </summary> /// <param name="height">Height of cylinder.</param> /// <param name="diameter">Diameter of cylinder.</param> /// <param name="tessellation">Tessellation of cylinder.</param> public void MakeCylinder(float height, float diameter, int tessellation) { // Create primitive primitive = new CylinderPrimitive(core.GraphicsDevice, height, diameter, tessellation); type = GeometricPrimitiveType.Cylinder; BoundingSphere = primitive.BoundingSphere; }
/// <summary> /// Makes primitive a sphere. /// </summary> /// <param name="radius">Radius of sphere.</param> /// <param name="tessellation">Tessellation of sphere.</param> public void MakeSphere(float radius, int tessellation) { // Create primitive primitive = new SpherePrimitive(core.GraphicsDevice, radius * 2, tessellation); type = GeometricPrimitiveType.Cube; BoundingSphere = primitive.BoundingSphere; }
/// <summary> /// Makes primitive a cube. /// </summary> /// <param name="size">Size of cube.</param> public void MakeCube(float size) { // Create primitive primitive = new CubePrimitive(core.GraphicsDevice, size); type = GeometricPrimitiveType.Cube; BoundingSphere = primitive.BoundingSphere; }
/// <summary> /// Create a render component. All rendering info for an entity comes from here. /// </summary> /// <param name="parent">Entity this component will be attached to</param> public RenderComponent(BaseEntity parent, string materialPath, GeometricPrimitiveType primitiveType) : base(parent) { ActivateComponent(); LoadModelFromPrimitive(primitiveType); LoadMaterial(materialPath); }
public static void AddTestComponent( Entity entity, GeometricPrimitiveType primitiveType, float size ) { Transform transform = new Transform(); entity.AddAttribute( Attributes.TRANSFORM, transform ); PrimitiveRenderComponent renderComponent = new PrimitiveRenderComponent( entity ); renderComponent.GeometricPrimitiveType = primitiveType; renderComponent.Color = Color.LimeGreen; renderComponent.Wireframe = false; renderComponent.m_size = size; entity.AddComponent( renderComponent ); }
public static GeometricPrimitive Factory( GeometricPrimitiveType type, float size ) { GeometricPrimitive result = null; switch ( type ) { case GeometricPrimitiveType.Cube: result = new Cube( size ); break; case GeometricPrimitiveType.Sphere: result = new Sphere( size, 10 ); break; } result.GenerateGeometry(); return result; }
/// <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); } }
/// <summary> /// Creates a StaticModel from a GeometricPrimitive. /// </summary> /// <param name="primitiveType">Type of primitive to create</param> private void LoadModelFromPrimitive(GeometricPrimitiveType primitiveType) { LoadModelFromPrimitive(primitiveType, 1.0f, 1.0f, 1.0f, 1.0f); }