/// BasicMaterial に設定された ShaderName から、ShaderProgram を探して描画する public void Draw( GraphicsContext graphics, ShaderContainer shaderContainer, Matrix4 viewProj, Vector4 eye, float Brightness ) { foreach (var bone in Bones) { int worldCount = 0; // sky00_nami; // bone.Name = "sky00_nami"; int[] blendBones = bone.BlendBones; if (blendBones == null) { worldCount = 1; matrixBuffer = new Matrix4[1]; matrixBuffer[0] = bone.WorldMatrix; } else { int blendCount = blendBones.Length; if (blendCount > matrixBuffer.Length) { matrixBuffer = new Matrix4[blendCount]; } for (int i = 0; i < blendCount; i++) { matrixBuffer[i] = Bones[blendBones[i]].WorldMatrix * bone.BlendOffsets[i]; } } int[] blendSubset = defaultBlendSubset; foreach (var index in bone.DrawParts) { BasicPart part = Parts[index]; foreach (var mesh in part.Meshes) { if (blendBones != null && blendSubset != mesh.BlendSubset) { blendSubset = (mesh.BlendSubset != null) ? mesh.BlendSubset : defaultBlendSubset; worldCount = blendSubset.Length; if (worldCount > blendBones.Length) { worldCount = blendBones.Length; } } BasicMaterial material = Materials[mesh.Material]; if (material != null) { setPolygonMode(graphics, material); BasicProgram program = findBasicProgram(shaderContainer, material, worldCount, this.lightCount); graphics.SetShaderProgram(program); program.SetViewProj(viewProj); program.SetMaterial(ref material); if (material.LightEnable != 0) { program.SetLightCount(lightCount); program.SetLights(ref matrixBuffer[0], ref eye, ref lights); } else { program.SetLightCount(0); } program.SetRateLight(Brightness); setLayers(graphics, program, material); program.SetWorldCount(worldCount); for (int i = 0; i < worldCount; i++) { program.SetMatrixPalette(i, ref matrixBuffer[blendSubset[i]]); } program.Update(); } graphics.SetVertexBuffer(0, mesh.VertexBuffer); graphics.DrawArrays(mesh.Primitives); } } } }