public void Draw(Effect effect, HxCamera camera) { foreach (HxGameObject gameObject in Objects) { if (gameObject.Has <HxMeshRenderer>()) { HxMeshRenderer meshRenderer = gameObject.Get <HxMeshRenderer>(); meshRenderer.Render(Hx.GraphicsDevice, camera); } /*if (gameObject is HxMesh mesh) * { * mesh.Draw(Hx.GraphicsDevice, effect, camera); * }*/ } }
public void Draw(GraphicsDevice graphicsDevice, Effect effect, HxCamera hxCamera) { if (HxMeshData.VertexCount < 3) { return; } Matrix translationMatrix = Matrix.CreateTranslation(Get <HxTransform>().Position); Matrix rotationMatrix = Matrix.CreateRotationX(MathHelper.ToRadians(Get <HxTransform>().Rotation.X)) * Matrix.CreateRotationY(MathHelper.ToRadians(Get <HxTransform>().Rotation.Y)) * Matrix.CreateRotationZ(MathHelper.ToRadians(Get <HxTransform>().Rotation.Z)); Matrix world = rotationMatrix * translationMatrix; effect.Parameters["WorldViewProjection"].SetValue(world * hxCamera.ViewMatrix * hxCamera.ProjectionMatrix); foreach (EffectPass effectPass in effect.CurrentTechnique.Passes) { effectPass.Apply(); graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, HxMeshData.VertexData, 0, HxMeshData.VertexCount / 3); } }