/// <summary> /// Carga el contenido gráfico del componente /// </summary> protected override void LoadContent() { Vector3 halfSize = (this.Max - this.Min) / 2f; this.m_Box = new CollisionBox(halfSize, this.Mass); VertexPositionNormalTexture[] buffer = null; PolyGenerator.InitializeCube(out buffer, this.Min, this.Max); int primitiveCount = buffer.Length / 3; this.m_Geometry = new BufferedGeometryInfo() { FillMode = this.FillMode, Indexed = false, PrimitiveType = PrimitiveType.TriangleList, PrimitiveCount = primitiveCount, Vertices = buffer, VertexDeclaration = new VertexDeclaration(this.GraphicsDevice, VertexPositionNormalTexture.VertexElements), Texture = this.Game.Content.Load <Texture2D>(@"Content/crate"), }; this.m_BasicEffect = new BasicEffect(this.GraphicsDevice, null); this.m_BasicEffect.EnableDefaultLighting(); base.LoadContent(); }
/// <summary> /// Constructor /// </summary> public CubeGameComponent(Game game, Vector3 min, Vector3 max) : base(game) { Vector3 halfSize = (max - min) / 2f; this.m_Box = new CollisionBox(halfSize, halfSize.X * halfSize.Y * halfSize.Z * 20f); PolyGenerator.InitializeCube(out m_Vertices, min, max); this.m_PrimitiveCount = m_Vertices.Length / 3; }