/// 指定 BasicProgram を必ず利用して描画する /** * Material は、BasicModel に設定された Material を利用する */ public void Draw(GraphicsContext graphics, BasicProgram program, Matrix4 viewProj, Vector4 eye) { List <LocalPart> localPartList = updateLocalPart(); // パーツを DrawOrder 順にソート localPartList.Sort(); // パーツの描画 foreach (LocalPart localPart in localPartList) { if (localPart.material != null) { setPolygonMode(graphics, localPart.material); // [note] local 参照なしの変数(だが、debug用途に残しておきたい) /* * int worldCount = localPart.worldCount; * bool texAnim = localPart.material.UseTexAnim; * int texCount = (localPart.material.Layers.Length <= 3) ? localPart.material.Layers.Length : 3; */ graphics.SetShaderProgram(program); program.SetViewProj(viewProj); program.SetMaterial(ref localPart.material); if (localPart.material.LightEnable != 0) { program.SetLightCount(lightCount); program.SetLights(ref localPart.matrixPalette[0], ref eye, ref lights); } else { program.SetLightCount(0); } setLayers(graphics, program, localPart.material); program.SetMatrixPalette(localPart.worldCount, ref localPart.matrixPalette); program.Update(); } graphics.SetVertexBuffer(0, localPart.vertexBuffer); graphics.DrawArrays(localPart.primitives); } }
/// 指定 BasicProgram を必ず利用して描画する /** * Material は、BasicModel に設定された Material を利用する */ public void Draw( GraphicsContext graphics, BasicProgram program, Matrix4 viewProj, Vector4 eye ) { List< LocalPart > localPartList = updateLocalPart(); // パーツを DrawOrder 順にソート localPartList.Sort(); // パーツの描画 foreach( LocalPart localPart in localPartList ){ if( localPart.material != null ){ setPolygonMode( graphics, localPart.material ); // [note] local 参照なしの変数(だが、debug用途に残しておきたい) /* * int worldCount = localPart.worldCount; * bool texAnim = localPart.material.UseTexAnim; *int texCount = (localPart.material.Layers.Length <= 3) ? localPart.material.Layers.Length : 3; */ graphics.SetShaderProgram( program ); program.SetViewProj( viewProj ); program.SetMaterial( ref localPart.material ); if( localPart.material.LightEnable != 0 ){ program.SetLightCount( lightCount ); program.SetLights( ref localPart.matrixPalette[ 0 ], ref eye, ref lights ); }else{ program.SetLightCount( 0 ); } setLayers( graphics, program, localPart.material ); program.SetMatrixPalette( localPart.worldCount, ref localPart.matrixPalette ); program.Update(); } graphics.SetVertexBuffer( 0, localPart.vertexBuffer ) ; graphics.DrawArrays( localPart.primitives ) ; } }
/// 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); } } } }