Example #1
0
 public LCC3Node()
 {
     _transformMatrix = LCC3Matrix4x4.CC3MatrixIdentity;
     _children = new List<LCC3Node>();
 }
        public void DrawTextureTest()
        {
            _progPipeline.SetClearColor(new CCColor4F(0.2f, 0.5f, 0.8f, 1.0f));
            _progPipeline.SetClearDepth(100.0f);
            _progPipeline.ClearBuffers(LCC3BufferMask.ColorBuffer | LCC3BufferMask.DepthBuffer);

            _progPipeline.EnableBlend(false);
            _progPipeline.EnableDepthTest(true);
            _progPipeline.SetDepthMask(true);
            _progPipeline.SetDepthFunc(LCC3DepthStencilFuncMode.LessOrEqual);
            _progPipeline.EnableCullFace(true);

            _progPipeline.CurrentlyActiveShader = _tankShader;

            foreach (ModelMesh mesh in _tankModel.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {

                    LCC3ShaderUniform worldViewProjUniform = _tankShader.UniformNamed("WorldViewProj");
                    LCC3Matrix4x4 worldViewProjMatrix
                        = new LCC3Matrix4x4(_tankTransforms[mesh.ParentBone.Index] * _graphicsContext.ViewMatrix.XnaMatrix * _graphicsContext.ProjectionMatrix.XnaMatrix);
                    worldViewProjUniform.SetValue(worldViewProjMatrix);
                    worldViewProjUniform.UpdateShaderValue();

                    LCC3ShaderUniform eyePositionUniform = _tankShader.UniformNamed("EyePosition");
                    LCC3Vector eyePosition = new LCC3Vector(Matrix.Invert(_graphicsContext.ViewMatrix.XnaMatrix).Translation);
                    eyePositionUniform.SetValue(eyePosition);
                    eyePositionUniform.UpdateShaderValue();

                    LCC3ShaderUniform worldUniform = _tankShader.UniformNamed("World");
                    LCC3Matrix4x4 worldMatrix = new LCC3Matrix4x4(_tankTransforms[mesh.ParentBone.Index]);
                    worldUniform.SetValue(worldMatrix);
                    worldUniform.UpdateShaderValue();

                    LCC3ShaderUniform worldInvTransUniform = _tankShader.UniformNamed("WorldInverseTranspose");
                    LCC3Matrix4x4 worldInvTransMatrix = new LCC3Matrix4x4(Matrix.Invert(Matrix.Transpose(_tankTransforms[mesh.ParentBone.Index])));
                    worldInvTransUniform.SetValue(worldInvTransMatrix);
                    worldInvTransUniform.UpdateShaderValue();

                    _progPipeline.XnaVertexBuffer = part.VertexBuffer;
                    _progPipeline.XnaIndexBuffer = part.IndexBuffer;

                    //_progPipeline.DrawIndices(LCC3DrawMode.TriangleList, part.VertexOffset, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount);
                }
            }
        }
Example #3
0
 private void ApplyTranslation()
 {
     _transformMatrix *= LCC3Matrix4x4.CreateTranslationMatrix(_location);
     this.UpdateGlobalLocation();
 }