public bool PopulateUniformWithVisitor(LCC3ShaderUniform uniform, LCC3NodeDrawingVisitor visitor) { if (uniform.Program != _program) { return false; } foreach(LCC3ShaderUniform currentUniform in _uniforms) { if (currentUniform.Location == uniform.Location) { uniform.SetValueFromUniform(currentUniform); return true; } } return false; }
public void DrawVerticesWithVisitor(uint vertexIndex, uint count, LCC3NodeDrawingVisitor visitor) { visitor.CurrentShaderProgram.PopulateDrawScopeUniformsWithVisitor(visitor); if (_vertexIndices != null) { _vertexIndices.DrawFromIndexWithVisitor(vertexIndex, count, visitor); } else { _vertexLocations.DrawFromIndexWithVisitor(vertexIndex, count, visitor); } }
public void DrawWithVisitor(LCC3NodeDrawingVisitor visitor) { if (this.SwitchingMaterial()) { this.ApplyAlphaTestWithVisitor(visitor); this.ApplyBlendWithVisitor(visitor); this.ApplyColorsWithVisitor(visitor); this.DrawTexturesWithVisitor(visitor); } }
public void ApplyColorsWithVisitor(LCC3NodeDrawingVisitor visitor) { visitor.CurrentColor = this.EffectiveDiffuseColor; }
public void ApplyAlphaTestWithVisitor(LCC3NodeDrawingVisitor visitor) { // Using progammable pipeline so don't do anything here }
public virtual void DrawFromIndexWithVisitor(uint vertexIndex, uint vertexCount, LCC3NodeDrawingVisitor visitor) { // Subclasses to implement }
public void BindTextureParametersWithVisitor(LCC3NodeDrawingVisitor visitor) { LCC3ProgPipeline progPipeline = visitor.ProgramPipeline; uint tuIndex = visitor.CurrentTextureUnitIndex; progPipeline.SetTextureMinifyFuncAtIndex(this.MinifyingFunction, tuIndex); progPipeline.SetTextureMagnifyFuncAtIndex(this.MagnifyingFunction, tuIndex); progPipeline.SetTextureHorizWrapFuncAtIndex(this.HorizontalWrappingFunction, tuIndex); progPipeline.SetTextureVertWrapFuncAtIndex(this.VerticalWrappingFunction, tuIndex); _texParametersAreDirty = false; }
public void DrawWithVisitor(LCC3NodeDrawingVisitor visitor) { if (_graphicsTexture != null) { this.BindGraphicsTextureWithVisitor(visitor); visitor.CurrentTextureUnitIndex += 1; } }
public void BindWithVisitor(LCC3NodeDrawingVisitor visitor) { visitor.CurrentShaderProgram = this; LCC3ProgPipeline.SharedPipeline().CurrentlyActiveShader = this; }
public override void DrawFromIndexWithVisitor(uint vertexIndex, uint vertexCount, LCC3NodeDrawingVisitor visitor) { base.DrawFromIndexWithVisitor(vertexIndex, vertexCount, visitor); visitor.ProgramPipeline.DrawVertices(this.DrawingMode, (int)(_firstVertex + vertexIndex), (int)vertexCount); }
protected virtual void BindContentToAttributeAtIndexWithVisitor(object[] vertexData, LCC3VertexAttrIndex vaIdx, LCC3NodeDrawingVisitor visitor) { visitor.ProgramPipeline.BindVertexContentToAttributeAtIndex(vertexData, _elementType, _shouldNormalizeContent, vaIdx); }
public void BindContentToAttributeAtIndexWithVisitor(LCC3VertexAttrIndex vaIdx, LCC3NodeDrawingVisitor visitor) { if (_vertices != null && _vertexCount > 0) { this.BindContentToAttributeAtIndexWithVisitor(_vertices, vaIdx, visitor); } }
public void DrawWithVisitor(uint vertexIndex, uint count, LCC3NodeDrawingVisitor visitor) { this.BindWithVisitor(visitor); this.DrawVerticesWithVisitor(vertexIndex, count, visitor); }
public void DrawWithVisitor(LCC3NodeDrawingVisitor visitor) { this.BindWithVisitor(visitor); this.DrawVerticesWithVisitor(visitor); }
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); }
public void PopulateDrawScopeUniformsWithVisitor(LCC3NodeDrawingVisitor visitor) { this.PopulateUniformsWithVisitor(_uniformsDrawScope, visitor); }
public void BindGraphicsTextureWithVisitor(LCC3NodeDrawingVisitor visitor) { _graphicsTexture.BindWithVisitor(visitor); }
public void PopulateNodeScopeUniformsWithVisitor(LCC3NodeDrawingVisitor visitor) { this.PopulateSceneScopeUniformsWithVisitor(visitor); this.PopulateUniformsWithVisitor(_uniformsNodeScope, visitor); }
public bool PopulateUniformWithVisitor(LCC3ShaderUniform uniform, LCC3NodeDrawingVisitor visitor) { LCC3Semantic semantic = uniform.Semantic; uint semanticIndex = uniform.SemanticIndex; LCC3Material material; uint numOfTextures = (uint)visitor.CurrentMaterial.TextureCount(); bool isInverted; switch (semantic) { #region Attribute Qualifiers case LCC3Semantic.SemanticVertexNormal: uniform.SetValue(visitor.CurrentMesh.HasVertexNormals); return true; case LCC3Semantic.SemanticShouldNormalizeVertexNormal: uniform.SetValue(visitor.CurrentMeshNode.EffectiveNormalScalingMethod == LCC3NormalScaling.CC3NormalScalingNormalize); return true; case LCC3Semantic.SemanticShouldRescaleVertexNormal: uniform.SetValue(visitor.CurrentMeshNode.EffectiveNormalScalingMethod == LCC3NormalScaling.CC3NormalScalingRescale); return true; case LCC3Semantic.SemanticHasVertexTangent: uniform.SetValue(visitor.CurrentMesh.HasVertexTangents); return true; case LCC3Semantic.SemanticHasVertexBitangent: uniform.SetValue(visitor.CurrentMesh.HasVertexBitangents); return true; case LCC3Semantic.SemanticHasVertexColor: uniform.SetValue(visitor.CurrentMesh.HasVertexColors); return true; case LCC3Semantic.SemanticHasVertexWeight: uniform.SetValue(visitor.CurrentMesh.HasVertexWeights); return true; case LCC3Semantic.SemanticHasVertexMatrixIndex: uniform.SetValue(visitor.CurrentMesh.HasVertexMatrixIndices); return true; case LCC3Semantic.SemanticHasVertexTextureCoordinate: uniform.SetValue(visitor.CurrentMesh.HasVertexTextureCoordinates); return true; case LCC3Semantic.SemanticHasVertexPointSize: uniform.SetValue(visitor.CurrentMesh.HasVertexPointSizes); return true; case LCC3Semantic.SemanticIsDrawingPoints: uniform.SetValue(false); // XNA doesn't support drawing mode by points return true; #endregion Attribute Qualifiers #region Environment semantics case LCC3Semantic.SemanticEyePosition: uniform.SetValue(visitor.ViewMatrix.Inverse().TranslationOfTransformMatrix()); return true; case LCC3Semantic.SemanticModelMatrix: uniform.SetValue(visitor.ModelMatrix); return true; case LCC3Semantic.SemanticModelViewMatrix: uniform.SetValue(visitor.ModelViewMatrix); return true; case LCC3Semantic.SemanticModelViewProjMatrix: uniform.SetValue(visitor.ModelViewProjMatrix); return true; case LCC3Semantic.SemanticViewMatrix: uniform.SetValue(visitor.ViewMatrix); return true; case LCC3Semantic.SemanticProjMatrix: uniform.SetValue(visitor.ProjMatrix); return true; case LCC3Semantic.SemanticModelViewMatrixInvTran: uniform.SetValue(visitor.ModelViewMatrix.InverseAdjointTranspose()); return true; case LCC3Semantic.SemanticModelMatrixInvTran: uniform.SetValue(visitor.ModelMatrix.Transpose().Inverse()); return true; #endregion Environment semantics #region Setting material semantics case LCC3Semantic.SemanticColor: uniform.SetValue(visitor.CurrentColor.ToVector4()); return true; case LCC3Semantic.SemanticMaterialColorAmbient: uniform.SetValue(visitor.CurrentMaterial.EffectiveAmbientColor.ToVector4()); return true; case LCC3Semantic.SemanticMaterialColorDiffuse: uniform.SetValue(visitor.CurrentMaterial.EffectiveDiffuseColor.ToVector4()); return true; case LCC3Semantic.SemanticMaterialColorSpecular: uniform.SetValue(visitor.CurrentMaterial.EffectiveSpecularColor.ToVector4()); return true; case LCC3Semantic.SemanticMaterialColorEmission: uniform.SetValue(visitor.CurrentMaterial.EffectiveEmissionColor.ToVector4()); return true; case LCC3Semantic.SemanticMaterialOpacity: uniform.SetValue(visitor.CurrentMaterial.EffectiveDiffuseColor.A); return true; case LCC3Semantic.SemanticMaterialShininess: uniform.SetValue(visitor.CurrentMaterial.Shininess); return true; case LCC3Semantic.SemanticMaterialReflectivity: uniform.SetValue(visitor.CurrentMaterial.Reflectivity); return true; case LCC3Semantic.SemanticMinimumDrawnAlpha: material = visitor.CurrentMaterial; uniform.SetValue(material.ShouldDrawLowAlpha ? 0.0f : material.AlphaTestReference); return true; #endregion Setting material semantics #region Textures case LCC3Semantic.SemanticTextureCount: uniform.SetValue(visitor.CurrentMaterial.TextureCount()); return true; case LCC3Semantic.SemanticTexUnitMode: if(semanticIndex < numOfTextures) { LCC3TextureUnitMode texUnitMode = visitor.CurrentMaterial.TextureForTextureUnit(semanticIndex).TextureUnitMode; uniform.SetValue((int)texUnitMode); } else { uniform.SetValue(0); } return true; case LCC3Semantic.SemanticVertexTexture: if(semanticIndex < numOfTextures) { LCC3Texture texture = visitor.CurrentMaterial.TextureForTextureUnit(semanticIndex); LCC3GraphicsTexture2D tex2D = texture.GraphicsTexture as LCC3GraphicsTexture2D; uniform.SetValue(tex2D); } else { uniform.SetValue(null); } return true; case LCC3Semantic.SemanticTexUnitConstantColor: if(semanticIndex < numOfTextures) { LCC3Texture texture = visitor.CurrentMaterial.TextureForTextureUnit(semanticIndex); uniform.SetValue(texture.TextureUnitConstantColor.ToVector4()); } else { uniform.SetValue(LCC3Vector4.CC3Vector4One); } return true; #endregion Textures #region Light semantics case LCC3Semantic.SemanticIsUsingLighting: uniform.SetValue(visitor.CurrentNode.ShouldUseLighting); return true; case LCC3Semantic.SemanticSceneLightColorAmbient: uniform.SetValue(visitor.Scene.AmbientLight.ToVector4()); return true; case LCC3Semantic.SemanticLightIsEnabled: for (uint i = 0; i < uniform.Size; i++) { LCC3Light light = visitor.LightAtIndex(uniform.SemanticIndex + i); uniform.SetValueAtIndex(light.Visible, i); } return true; case LCC3Semantic.SemanticLightInvertedPositionEyeSpace: isInverted = true; goto case LCC3Semantic.SemanticLightPositionEyeSpace; case LCC3Semantic.SemanticLightPositionEyeSpace: for (uint i = 0; i < uniform.Size; i++) { LCC3Light light = visitor.LightAtIndex(uniform.SemanticIndex + i); LCC3Vector4 ltPos = light.GlobalHomogeneousPosition; if (isInverted == true) { ltPos = ltPos.HomogeneousNegate(); } // Transform global position/direction to eye space and normalize if direction ltPos = visitor.ViewMatrix.TransformCC3Vector4(ltPos); if (light.IsDirectionalOnly == true) { ltPos = ltPos.NormalizedVector(); } uniform.SetValueAtIndex(ltPos, i); } return true; case LCC3Semantic.SemanticLightDirection: for (uint i = 0; i < uniform.Size; i++) { LCC3Light light = visitor.LightAtIndex(uniform.SemanticIndex + i); uniform.SetValueAtIndex(light.Location, i); } return true; case LCC3Semantic.SemanticLightColorDiffuse: for (uint i = 0; i < uniform.Size; i++) { LCC3Light light = visitor.LightAtIndex(uniform.SemanticIndex + i); CCColor4F ltColor = light.Visible ? light.DiffuseColor : LCC3ColorUtil.CCC4FBlackTransparent; uniform.SetValueAtIndex(ltColor.ToVector4(), i); } return true; case LCC3Semantic.SemanticLightColorAmbient: for (uint i = 0; i < uniform.Size; i++) { LCC3Light light = visitor.LightAtIndex(uniform.SemanticIndex + i); CCColor4F ltColor = light.Visible ? light.AmbientColor : LCC3ColorUtil.CCC4FBlackTransparent; uniform.SetValueAtIndex(ltColor.ToVector4(), i); } return true; case LCC3Semantic.SemanticLightColorSpecular: for (uint i = 0; i < uniform.Size; i++) { LCC3Light light = visitor.LightAtIndex(uniform.SemanticIndex + i); CCColor4F ltColor = light.Visible ? light.SpecularColor : LCC3ColorUtil.CCC4FBlackTransparent; uniform.SetValueAtIndex(ltColor.ToVector4(), i); } return true; #endregion Light semantics } return false; }
public void PopulateSceneScopeUniformsWithVisitor(LCC3NodeDrawingVisitor visitor) { if (_isSceneScopeDirty == true) { this.PopulateUniformsWithVisitor(_uniformsSceneScope, visitor); _isSceneScopeDirty = false; } }
public void BindWithVisitor(LCC3NodeDrawingVisitor visitor) { LCC3ProgPipeline progPipeline = visitor.ProgramPipeline; uint texUnitIndex = visitor.CurrentTextureUnitIndex; LCC3GraphicsTextureTarget texTarget = this.TextureTarget; progPipeline.BindTextureToTargetAtIndex(this, texTarget, texUnitIndex); }
public void PopulateUniformsWithVisitor(List<LCC3ShaderUniform> uniforms, LCC3NodeDrawingVisitor visitor) { LCC3ShaderProgramContext progCtx = visitor.CurrentMaterial.ShaderContext; for (int i=0; i < uniforms.Count; i++) { if (progCtx.PopulateUniformWithVisitor(uniforms[i], visitor) || _semanticDelegate.PopulateUniformWithVisitor(uniforms[i], visitor)) { uniforms[i].UpdateShaderValue(); } } }
public void DrawWithVisitor(LCC3NodeDrawingVisitor visitor) { if (this.StripCount > 0) { uint startOfStrip = 0; foreach (uint stripLen in _stripLengths) { this.DrawFromIndexWithVisitor(startOfStrip, stripLen, visitor); startOfStrip += stripLen; } } else { this.DrawFromIndexWithVisitor(0, this.VertexCount, visitor); } }
public void PopulateVertexAttributesWithVisitor(LCC3NodeDrawingVisitor visitor) { LCC3ProgPipeline pipeline = LCC3ProgPipeline.SharedPipeline(); foreach (LCC3ShaderAttribute attribute in _attributes) { pipeline.BindVertexAttributeWithVisitor(attribute, visitor); } }
public void ApplyBlendWithVisitor(LCC3NodeDrawingVisitor visitor) { LCC3ProgPipeline progPipeline = visitor.ProgramPipeline; bool shouldBlend = !this.IsOpaque; progPipeline.EnableBlend(shouldBlend); if(shouldBlend == true) { visitor.ProgramPipeline.SetBlendFuncSrcAndDst(_srcBlendType, _dstBlendType); } }
public bool PopulateUniformWithVisitor(LCC3ShaderUniform uniform, LCC3NodeDrawingVisitor visitor) { return false; }
public void DrawTexturesWithVisitor(LCC3NodeDrawingVisitor visitor) { visitor.CurrentTextureUnitIndex = 0U; _texture.DrawWithVisitor(visitor); foreach (LCC3Texture texture in _textureOverlays) { texture.DrawWithVisitor(visitor); } visitor.DisableUnusedTextureUnits(); }
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(); }
public void UnbindWithVisitor(LCC3NodeDrawingVisitor visitor) { LCC3Material.ResetSwitching(); }
public void BindWithVisitor(LCC3NodeDrawingVisitor visitor) { if (this.SwitchingMesh == true) { visitor.ProgramPipeline.BindMeshWithVisitor(this, visitor); } }