private void DrawModel(RenderEffectTechniques technique, Model model, Matrix world, IViewPoint viewPoint) { var bones = model.Bones.Count; if (SharedBoneMatrix is null || SharedBoneMatrix.Length < bones) { SharedBoneMatrix = new Matrix[bones]; } model.CopyAbsoluteBoneTransformsTo(SharedBoneMatrix); for (var iMesh = 0; iMesh < model.Meshes.Count; iMesh++) { var mesh = model.Meshes[iMesh]; for (var iEffect = 0; iEffect < mesh.Effects.Count; iEffect++) { var effect = mesh.Effects[iEffect]; this.Effect.Wrap(effect); this.Effect.World = SharedBoneMatrix[mesh.ParentBone.Index] * world; this.Effect.View = viewPoint.View; this.Effect.Projection = viewPoint.Projection; this.Effect.Apply(technique); } mesh.Draw(); } }
public void Draw(RenderEffectTechniques technique) { for (var i = 0; i < this.Models.Count; i++) { var modelPose = this.Models[i]; this.DrawModel(technique, modelPose.Model, modelPose.Pose.Matrix, this.ViewPoint); } }
private void DrawModel(RenderEffectTechniques technique, AModel modelPose, Matrix world, IViewPoint viewPoint) { var model = modelPose.Model; var bones = model.Bones.Count; if (SharedBoneMatrix is null || SharedBoneMatrix.Length < bones) { SharedBoneMatrix = new Matrix[bones]; } model.CopyAbsoluteBoneTransformsTo(SharedBoneMatrix); for (var iMesh = 0; iMesh < model.Meshes.Count; iMesh++) { var mesh = model.Meshes[iMesh]; for (var iEffect = 0; iEffect < mesh.Effects.Count; iEffect++) { var effect = mesh.Effects[iEffect]; this.Effect.Wrap(effect); if (modelPose.HasAnimations && RenderEffect.TechniqueSupportsSkinning(technique)) { technique = RenderEffect.GetSkinnedTechnique(technique); this.Effect.BoneTransforms = modelPose.SkinTransforms; } this.Effect.TextureOffset = modelPose.UVOffsets[iMesh]; this.Effect.World = SharedBoneMatrix[mesh.ParentBone.Index] * world; this.Effect.View = viewPoint.View; this.Effect.Projection = viewPoint.Projection; this.Effect.InverseViewProjection = this.InverseViewProjection; this.Effect.Skybox = this.Skybox; this.Effect.CameraPosition = viewPoint.Position; this.Effect.TextureScale = modelPose.TextureScale; this.Effect.Apply(technique); } mesh.Draw(); } }