private void InitializeParametricMeshDrawingData() { _listOfShapeMeshes = new List<LCC3ParametricMeshes>(); LCC3ParametricMeshes mesh = new LCC3ParametricMeshes(0, "sphere"); mesh.PopulateAsSphere(3.0f, new LCC3Tessellation(50,50)); _listOfShapeMeshes.Add(mesh); mesh = new LCC3ParametricMeshes(1, "cone"); mesh.PopulateAsHollowCone(3.0f, 5.0f, new LCC3Tessellation(50, 50)); _listOfShapeMeshes.Add(mesh); mesh = new LCC3ParametricMeshes(2, "box"); mesh.PopulateAsSolidBox(new LCC3BoundingBox(0.0f, 0.0f, 0.0f, 5.0f, 5.0f, 5.0f), false); _listOfShapeMeshes.Add(mesh); mesh = new LCC3ParametricMeshes(3, "plane"); mesh.PopulateAsRectangle(new CCSize(7.0f, 7.0f)); _listOfShapeMeshes.Add(mesh); LCC3Scene scene = new LCC3Scene(); scene.AmbientLight = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f); 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, 1.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.4f, -0.3f, -0.2f)).NormalizedVector(); lights[i].AmbientColor = new CCColor4F(0.2f, 0.5f, 0.2f, 1.0f); lights[i].DiffuseColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f); lights[i].SpecularColor = new CCColor4F(0.9f, 0.9f, 0.9f, 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); }
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(); }