public void PopulateFrom(LCC3FaceArray another)
        {
            _mesh = another.Mesh;
            _shouldCacheFaces = another._shouldCacheFaces;
            _indices = another.Indices;
            _centers = another.Centers;
            _normals = another.Normals;
            _neighbours = another.Neighbours;

            _indicesAreDirty = another._indicesAreDirty;
            _centersAreDirty = another._centersAreDirty;
            _normalsAreDirty = another._normalsAreDirty;
            _neighboursAreDirty = another._neighboursAreDirty;
        }
        private void InitializeMaterialDrawingData()
        {
            uint numOfVertices = 18;
            LCC3Mesh mesh = new LCC3Mesh(0, "mymesh");
            LCC3VertexLocations locations = new LCC3VertexLocations(1, "locations");
            locations.AllocateVertexCapacity(numOfVertices);
            // Top face
            locations.SetLocation(new LCC3Vector(0.0f, 0.0f, 0.0f), 0);
            locations.SetLocation(new LCC3Vector(0.0f, 0.0f, 5.0f), 1);
            locations.SetLocation(new LCC3Vector(5.0f, 0.0f, 0.0f), 2);

            locations.SetLocation(new LCC3Vector(5.0f, 0.0f, 0.0f), 3);
            locations.SetLocation(new LCC3Vector(5.0f, 0.0f, 5.0f), 4);
            locations.SetLocation(new LCC3Vector(0.0f, 0.0f, 5.0f), 5);

            // Side front face
            locations.SetLocation(new LCC3Vector(0.0f, 0.0f, 5.0f), 6);
            locations.SetLocation(new LCC3Vector(0.0f, -5.0f, 5.0f), 7);
            locations.SetLocation(new LCC3Vector(5.0f, 0.0f, 5.0f), 8);

            locations.SetLocation(new LCC3Vector(5.0f, 0.0f, 5.0f), 9);
            locations.SetLocation(new LCC3Vector(5.0f, -5.0f, 5.0f), 10);
            locations.SetLocation(new LCC3Vector(0.0f, -5.0f, 5.0f), 11);

            // Side left face
            locations.SetLocation(new LCC3Vector(0.0f, 0.0f, 0.0f), 12);
            locations.SetLocation(new LCC3Vector(0.0f, -5.0f, 0.0f), 13);
            locations.SetLocation(new LCC3Vector(0.0f, 0.0f, 5.0f), 14);

            locations.SetLocation(new LCC3Vector(0.0f, 0.0f, 5.0f), 15);
            locations.SetLocation(new LCC3Vector(0.0f, -5.0f, 5.0f), 16);
            locations.SetLocation(new LCC3Vector(0.0f, -5.0f, 0.0f), 17);

            LCC3VertexNormals normals = new LCC3VertexNormals(1, "normals");
            normals.AllocateVertexCapacity(numOfVertices);
            // Top face normals
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 1.0f, -1.0f).NormalizedVector(), 0);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 1.0f, 1.0f).NormalizedVector(), 1);
            normals.SetNormalAtIndex(new LCC3Vector(1.0f, 1.0f, -1.0f).NormalizedVector(), 2);

            normals.SetNormalAtIndex(new LCC3Vector(1.0f, 1.0f, -1.0f).NormalizedVector(), 3);
            normals.SetNormalAtIndex(new LCC3Vector(1.0f, 1.0f, 1.0f).NormalizedVector(), 4);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 1.0f, 1.0f).NormalizedVector(), 5);

            // Side front face normals
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 1.0f, 1.0f).NormalizedVector(), 6);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, -1.0f, 1.0f).NormalizedVector(), 7);
            normals.SetNormalAtIndex(new LCC3Vector(1.0f, 1.0f, 1.0f).NormalizedVector(), 8);

            normals.SetNormalAtIndex(new LCC3Vector(1.0f, 1.0f, 1.0f).NormalizedVector(), 9);
            normals.SetNormalAtIndex(new LCC3Vector(1.0f, -1.0f, 1.0f).NormalizedVector(), 10);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, -1.0f, 1.0f).NormalizedVector(), 11);

            // Side left face normals
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 1.0f, -1.0f).NormalizedVector(), 12);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, -1.0f, -1.0f).NormalizedVector(), 13);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 1.0f, 1.0f).NormalizedVector(), 14);

            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 1.0f, 1.0f).NormalizedVector(), 15);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, -1.0f, 1.0f).NormalizedVector(), 16);
            normals.SetNormalAtIndex(new LCC3Vector(-1.0f, -1.0f, -1.0f).NormalizedVector(), 17);

            /*
            for (uint i=0; i < 6; i++)
            {
                normals.SetNormalAtIndex(new LCC3Vector(0.0f, 1.0f, 0.0f).NormalizedVector(), i);
                normals.SetNormalAtIndex(new LCC3Vector(0.0f, 0.0f, 1.0f).NormalizedVector(), i + 6);
                normals.SetNormalAtIndex(new LCC3Vector(-1.0f, 0.0f, 0.0f).NormalizedVector(), i + 12);
            }
            */

            LCC3VertexTextureCoordinates texCoords = new LCC3VertexTextureCoordinates(0, "texCoords");
            texCoords.AllocateVertexCapacity(numOfVertices);
            for (uint i=0; i < numOfVertices / 6; i++)
            {
                uint offset = i * 6;
                texCoords.SetTexCoord2FAtIndex(new CCTex2F(0.0f, 0.0f), 0 + offset);
                texCoords.SetTexCoord2FAtIndex(new CCTex2F(0.0f, 1.0f), 1 + offset);
                texCoords.SetTexCoord2FAtIndex(new CCTex2F(1.0f, 0.0f), 2 + offset);

                texCoords.SetTexCoord2FAtIndex(new CCTex2F(1.0f, 0.0f), 3 + offset);
                texCoords.SetTexCoord2FAtIndex(new CCTex2F(1.0f, 1.0f), 4 + offset);
                texCoords.SetTexCoord2FAtIndex(new CCTex2F(0.0f, 1.0f), 5 + offset);
            }

            LCC3VertexColors colors = new LCC3VertexColors(0, "colors");
            colors.AllocateVertexCapacity(numOfVertices);
            for (uint i=0; i < numOfVertices; i++)
            {
                colors.SetColor4FAtIndex(new CCColor4F(0.2f, 1.0f, 0.0f, 1.0f), i);
            }

            mesh.VertexLocations = locations;
            mesh.VertexNormals = normals;
            mesh.VertexTextureCoords = texCoords;
            //mesh.VertexColors = colors;

            LCC3Scene scene = new LCC3Scene();
            scene.AmbientLight = new CCColor4F(0.5f, 0.5f, 0.0f, 0.5f);

            LCC3Material defaultMaterial = new LCC3Material(0, "Default");
            defaultMaterial.ShaderProgram = _materialShaderProgram;
            defaultMaterial.AmbientColor = new CCColor4F(0.2f, 1.0f, 0.0f, 1.0f);
            defaultMaterial.DiffuseColor = new CCColor4F(0.2f, 1.0f, 0.0f, 0.0f);
            defaultMaterial.SpecularColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f);
            defaultMaterial.EmissionColor = new CCColor4F(0.2f, 1.0f, 0.0f, 1.0f);
            defaultMaterial.Shininess = 0.0f;
            defaultMaterial.ShouldUseLighting = true;

            LCC3MeshNode meshNode = new LCC3MeshNode();
            meshNode.Material = defaultMaterial;
            meshNode.Mesh = mesh;
            meshNode.Parent = scene;

            LCC3Light[] lights = new LCC3Light[(int)LCC3Light.DefaultMaxNumOfLights];
            for (int i = 0; i < LCC3Light.DefaultMaxNumOfLights; i++)
            {
                lights[i] = new LCC3Light();
                lights[i].Visible = true;
                lights[i].Location = (new LCC3Vector(0.0f, -1.0f, -0.2f)).NormalizedVector();
                lights[i].AmbientColor = new CCColor4F(0.0f, 0.5f, 0.0f, 1.0f);
                lights[i].DiffuseColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f);
                lights[i].SpecularColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f);
                }

            scene.Lights = lights;

            _drawingVisitor = new LCC3NodeDrawingVisitor();
            _drawingVisitor.CurrentColor = new CCColor4F(1.0f, 0.0f, 0.0f, 1.0f);
            _drawingVisitor.CurrentNode = meshNode;
            _drawingVisitor.StartingNode = meshNode;

            _drawingVisitor.ModelMatrix = LCC3Matrix4x4.CC3MatrixIdentity;
            _drawingVisitor.ViewMatrix = new LCC3Matrix4x4(_graphicsContext.ViewMatrix.XnaMatrix);
            _drawingVisitor.ProjMatrix = new LCC3Matrix4x4(_graphicsContext.ProjectionMatrix.XnaMatrix);

            _drawingVisitor.ProgramPipeline = _progPipeline;

            _progPipeline.BindProgramWithVisitor(_materialShaderProgram, _drawingVisitor);

            //_progPipeline.GenerateVertexBuffer();
        }
Exemple #3
0
        public void PopulateFrom(LCC3Mesh anotherMesh)
        {
            base.PopulateFrom(anotherMesh);

            this.Faces = anotherMesh.Faces;
            this.VertexLocations = anotherMesh.VertexLocations;
            this.VertexNormals = anotherMesh.VertexNormals;
            this.VertexTangents = anotherMesh.VertexTangents;
            this.VertexBitangents = anotherMesh.VertexBitangents;
            this.VertexColors = anotherMesh.VertexColors;
            this.VertexMatrixIndices = anotherMesh.VertexMatrixIndices;
            this.VertexWeights = anotherMesh.VertexWeights;
            this.VertexPointSizes = anotherMesh.VertexPointSizes;
            this.VertexTextureCoords = anotherMesh.VertexTextureCoords;
        }