protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList <Light.ILight> lights) { AnimatedModel modelo = obj.Modelo as AnimatedModel; for (int i = 0; i < modelo.GetAnimatedModel().Meshes.Count; i++) { ModelMesh modelMesh = modelo.GetAnimatedModel().Meshes[i]; for (int j = 0; j < modelMesh.MeshParts.Count; j++) { SkinnedEffect basicEffect = (SkinnedEffect)modelMesh.MeshParts[j].Effect; if (EnableTexture) { basicEffect.Texture = modelo.getTexture(TextureType.DIFFUSE, i, j); } if (followBone) { basicEffect.World = Followed.GetBoneAbsoluteTransform(boneName) * Followobj.WorldMatrix; basicEffect.SetBoneTransforms(modelo.getBonesTransformation()); } else { basicEffect.World = WorldMatrix; basicEffect.SetBoneTransforms(ac.GetBoneTransformations()); } basicEffect.View = cam.View; basicEffect.Projection = cam.Projection; } modelMesh.Draw(); } }
public void Draw(BasicEffect effect, GameTime gametime) { List <ulong> models = ComponentManager.GetAllEntitiesWithComp <ModelComponent>(); foreach (ulong mC in models) { ModelComponent m = ComponentManager.GetComponent <ModelComponent>(mC); CameraComponent camera = ComponentManager.GetComponent <CameraComponent>(mC); TransformComponent transform = ComponentManager.GetComponent <TransformComponent>(mC); Matrix[] transforms = new Matrix[m.model.Bones.Count]; Matrix worldMatrix = Matrix.CreateScale(0.05f, 0.05f, 0.05f) * Matrix.CreateFromQuaternion(transform.qRot) * Matrix.CreateTranslation(transform.position); m.model.CopyAbsoluteBoneTransformsTo(transforms); for (int index = 0; index < m.model.Meshes.Count; index++) { ModelMesh mesh = m.model.Meshes[index]; foreach (BasicEffect be in mesh.Effects) { be.EnableDefaultLighting(); be.PreferPerPixelLighting = true; be.World = mesh.ParentBone.Transform * m.chopperMeshWorldMatrices[index] * worldMatrix; be.View = camera.viewMatrix; be.Projection = camera.projectionMatrix; } mesh.Draw(); } } }
private void DrawMeshShadow(Matrix transform, ModelMesh mesh, float alpha) { // Store original effects for mesh parts, before substituting them for shadow rendering var originalEffects = new Dictionary <ModelMeshPart, Effect>(); foreach (ModelMeshPart part in mesh.MeshParts) { originalEffects[part] = part.Effect; part.Effect = _basicEffect; } foreach (BasicEffect effect in mesh.Effects) { effect.AmbientLightColor = Vector3.Zero; effect.Alpha = alpha; effect.DirectionalLight0.Enabled = false; effect.DirectionalLight1.Enabled = false; effect.DirectionalLight2.Enabled = false; // effect.View = _basicEffect.View; // effect.Projection = _basicEffect.Projection; effect.World = transform * _shadowTransform; } mesh.Draw(); // Restore former effects for mesh parts foreach (ModelMeshPart part in mesh.MeshParts) { part.Effect = originalEffects[part]; } }
private void DrawBoxBody(RigidBody body) { // We know that the shape is a boxShape BoxShape shape = body.Shape as BoxShape; // Create the 4x4 xna matrix, containing the orientation // (represented in jitter by a 3x3 matrix) and the position. Matrix matrix = Conversion.ToXNAMatrix(body.Orientation); matrix.Translation = Conversion.ToXNAVector(body.Position); // We have a (1,1,1) box so packing the box size // information into the the "scale" part of the xna // matrix is a good idea. Matrix scaleMatrix = Matrix.CreateScale(shape.Size.X, shape.Size.Y, shape.Size.Z); // the next lines of code draw the boxModel using the matrix. ModelMesh mesh = boxModel.Meshes[0]; foreach (BasicEffect effect in mesh.Effects) { effect.DiffuseColor = ((Color)body.Tag).ToVector3(); effect.EnableDefaultLighting(); effect.World = scaleMatrix * matrix; effect.View = viewMatrix; effect.Projection = projectionMatrix; } mesh.Draw(); }
protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList <Light.ILight> lights) { AnimatedModel modelo = obj.Modelo as AnimatedModel; for (int i = 0; i < modelo.GetAnimatedModel().Meshes.Count; i++) { ModelMesh modelMesh = modelo.GetAnimatedModel().Meshes[i]; for (int j = 0; j < modelMesh.MeshParts.Count; j++) { SkinnedModelBasicEffect basicEffect = (SkinnedModelBasicEffect)modelMesh.MeshParts[j].Effect; basicEffect.CurrentTechnique = basicEffect.Techniques["FORWARD"]; basicEffect.Parameters["diffuseMap0"].SetValue(modelo.getTexture(TextureType.DIFFUSE, i, j)); basicEffect.Parameters["diffuseMapEnabled"].SetValue(true); if (followBone) { basicEffect.World = Followed.GetBoneAbsoluteTransform(boneName) * Followobj.WorldMatrix; basicEffect.Bones = ac.GetBoneTransformations(); } else { basicEffect.World = WorldMatrix; basicEffect.Bones = ac.GetBoneTransformations(); } basicEffect.View = cam.View; basicEffect.Projection = cam.Projection; } modelMesh.Draw(); } }
private void DrawMesh(Matrix transform, ModelMesh mesh, float alpha) { GraphicsDevice.RenderState.AlphaBlendEnable = true; GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha; GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha; // GraphicsDevice.RenderState.AlphaBlendOperation = BlendFunction.Add; // foreach (BasicEffect effect in mesh.Effects) foreach (SunlightEffect effect in mesh.Effects) { // effect.EnableDefaultLighting(); effect.Alpha = alpha; effect.View = Camera.View; effect.Projection = Camera.Projection; effect.World = transform; effect.ApplyParameters(); // SunlightEffect sunlight = effect; // if (sunlight != null) // { // } } mesh.Draw(); GraphicsDevice.RenderState.AlphaBlendEnable = false; }
public override void Render() { DirectXDevice device = DeviceService.DirectXDevice; foreach (Shader shader in Technique) { shader.Apply(Technique.Name, UpdateType.SceneFrame); } foreach (Shader shader in Technique) { shader.Apply(Technique.Name, entity.Id, UpdateType.InstanceStatic); shader.Apply(Technique.Name, entity.Id, UpdateType.InstanceFrame); } quad.Draw(device); device.SetPixelShaderSampler(0, null); var inputs = Inputs.ToArray(); for (int i = 0; i < inputs.Length; i++) { device.SetPixelShaderShaderResourceView(i, null); } }
/// <summary> /// This method draws a model mesh, with the given worldMatrix as viewed by the camera. /// </summary> /// <param name="mesh">The mesh to draw</param> /// <param name="worldMatrix">The matrix holding the position, rotation and scale of the mesh</param> /// <param name="camera">The camera which represents the user's current view</param> public void DrawModelMesh(ModelMesh mesh, Matrix worldMatrix, bool applyCustomEffects) { Cameras.Camera currentCamera = DisplayController.Display.CurrentView.Camera; // setup effect parameters for each effect foreach (BasicEffect effect in mesh.Effects) { // use default settings for now. effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; // the view, projection and world matrices must be setup for each effect, each frame. effect.View = currentCamera.ViewMatrix; effect.Projection = currentCamera.ProjectionMatrix; effect.World = worldMatrix; // apply custom effects (if any): if (applyCustomEffects) { this.ApplyCustomEffects(effect); } // propagate changes. Any changes to parameters are not applied until CommitChanges() is called. effect.CommitChanges(); } // actually draw the model, now that all effects have been setup: mesh.Draw(); }
private static void drawMesh(ModelMesh mesh, GameModel model, string tech, Plane?clipPlane, Matrix view) { Matrix entityWorld = ConversionHelper.MathConverter.Convert(model.Entity.CollisionInformation.WorldTransform.Matrix); foreach (Effect currentEffect in mesh.Effects) { currentEffect.CurrentTechnique = currentEffect.Techniques[tech]; currentEffect.Parameters["Texture"].SetValue(model.Texture.ActualTexture); currentEffect.Parameters["xCamerasViewProjection"].SetValue(view * MathConverter.Convert(Camera.ProjectionMatrix)); currentEffect.Parameters["xWorld"].SetValue(mesh.ParentBone.Transform * model.Transform * entityWorld);// * Camera.World); currentEffect.Parameters["xPassThroughLighting"].SetValue(true); //currentEffect.Parameters["xLightPos"].SetValue(lights.LightPosition); //currentEffect.Parameters["xLightPower"].SetValue(0.4f); //currentEffect.Parameters["xAmbient"].SetValue(lights.AmbientPower); //currentEffect.Parameters["xLightDir"].SetValue(lights.LightDirection); if (clipPlane.HasValue) { currentEffect.Parameters["xEnableClipping"].SetValue(true); currentEffect.Parameters["xClipPlane"].SetValue(new Vector4(clipPlane.Value.Normal, clipPlane.Value.D)); } else { currentEffect.Parameters["xEnableClipping"].SetValue(false); } } mesh.Draw(); }
public void Draw(Matrix view, Matrix projection) { //foreach (ModelMesh mesh in model.Meshes) for (int i = 0; i < model.Meshes.Count; i++) { ModelMesh mesh = model.Meshes[i]; foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.GraphicsDevice.DepthStencilState = DepthStencilState.Default; if (i == 1 || i == 3) { effect.World = Matrix.CreateRotationY(WheelAngle) * mesh.ParentBone.Transform * Matrix.CreateRotationZ(Body.Rotation) * Matrix.CreateTranslation(new Vector3(Body.Position, 0f)); } else { effect.World = mesh.ParentBone.Transform * Matrix.CreateRotationZ(Body.Rotation) * Matrix.CreateTranslation(new Vector3(Body.Position, 0f)); } effect.View = view; effect.Projection = projection; } mesh.Draw(); } }
public static void DrawWithTextureBumpShader(ModelMesh mesh, Effect shader, Vector3 cameraPosition, Matrix world, Matrix view, Matrix projection, Texture2D texture, Texture2D normalMap) { foreach (ModelMeshPart part in mesh.MeshParts) { part.Effect = shader; shader.Parameters["World"].SetValue(world); shader.Parameters["View"].SetValue(view); shader.Parameters["Projection"].SetValue(projection); shader.Parameters["WorldInverseTranspose"].SetValue(Matrix.Transpose(Matrix.Invert(world))); shader.Parameters["ModelTexture"].SetValue(texture); shader.Parameters["AmbientColor"].SetValue(Color.White.ToVector4()); shader.Parameters["AmbientIntensity"].SetValue(0.1f); shader.Parameters["DiffuseLightDirection"].SetValue(new Vector3(0.0f, 1000.0f, 1000.0f)); //shader.Parameters["DiffuseColor"].SetValue(Color.White.ToVector4()); //shader.Parameters["DiffuseIntensity"].SetValue(1.0f); shader.Parameters["Shininess"].SetValue(20.0f); shader.Parameters["SpecularColor"].SetValue(Color.White.ToVector4()); shader.Parameters["SpecularIntensity"].SetValue(0.8f); shader.Parameters["NormalMap"].SetValue(normalMap); } mesh.Draw(); }
public static void DrawModelMesh(this Model model, ModelMesh mesh) { Matrix mat = Matrix.Identity; GetModelMeshTransform(mesh.ParentBone, ref mat); Matrix View = Utility.Camera.View; Matrix Projection = Utility.Camera.Projection; for (int x = 0; x < mesh.Effects.Count; x++) { BasicEffect eff = mesh.Effects[x] as BasicEffect; if (eff != null) { eff.World = mat; eff.View = View; eff.Projection = Projection; eff.LightingEnabled = true; eff.EnableDefaultLighting(); eff.TextureEnabled = true; eff.VertexColorEnabled = true; } } mesh.Draw(); }
public void Draw(BaseCamera camera) { if (Active) { if (HitTest) { world = lastWorld; } // Copy any parent transforms. // Draw the model. A model can have multiple meshes, so loop. for (int meshIndex = 0; meshIndex < mesh.Meshes.Count; meshIndex++) { meshM = mesh.Meshes[meshIndex]; // This is where the mesh orientation is set, as well // as our camera and projection. foreach (BasicEffect effect in meshM.Effects) { effect.EnableDefaultLighting(); if (elementsWorldMatrix.Length == 0) { effect.World = transforms[meshM.ParentBone.Index] * world; } else { effect.World = transforms[meshM.ParentBone.Index] * elementsWorldMatrix[meshIndex] * world; } effect.View = camera.GetViewMatrix(); effect.Projection = camera.GetProjectionMatrix(); } // Draw the mesh, using the effects set above. meshM.Draw(); } } }
private void Draw(ModelMesh mesh, Matrix projectionXform, Matrix viewXform, Matrix worldXform, Transforms.IGeometryTransform modelXform) { if (modelXform is Transforms.SkinnedTransform skinXform) { var skinTransforms = skinXform.SkinMatrices.Select(item => item.ToXna()).ToArray(); foreach (var effect in mesh.Effects) { UpdateTransforms(effect, projectionXform, viewXform, worldXform, skinTransforms); } } if (modelXform is Transforms.RigidTransform statXform) { var statTransform = statXform.WorldMatrix.ToXna(); worldXform = Matrix.Multiply(statTransform, worldXform); foreach (var effect in mesh.Effects) { UpdateTransforms(effect, projectionXform, viewXform, worldXform); } } mesh.Draw(); }
private void DrawMesh(ModelMesh mesh, Matrix matrix) { Matrix worldMatrix = mesh.ParentBone.Transform * matrix; Effect.Parameters["World"].SetValue(worldMatrix); Effect.Parameters["InverseTransposeWorld"].SetValue(Matrix.Transpose(Matrix.Invert(worldMatrix))); mesh.Draw(); }
public override void Draw(ref GameTime gameTime, ref XCamera Camera) { if (!loaded) { return; } //X.GraphicsDevice.RenderState.DepthBufferWriteEnable = false; //X.GraphicsDevice.RenderState.DepthBufferEnable = false; X.GraphicsDevice.RenderState.DepthBufferEnable = true; X.GraphicsDevice.RenderState.DepthBufferWriteEnable = true; X.GraphicsDevice.RenderState.AlphaBlendEnable = false; Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); if (Filenames.Count == 1) { effect.Parameters["Projection"].SetValue(Camera.Projection); effect.Parameters["View"].SetValue(Camera.View); if (Filenames.Count == 1) { effect.Parameters["EyePosition"].SetValue(Camera.Position); effect.Parameters["skyCubeTexture"].SetValue(cube); } for (int pass = 0; pass < effect.CurrentTechnique.Passes.Count; pass++) { for (int msh = 0; msh < model.Meshes.Count; msh++) { ModelMesh mesh = model.Meshes[msh]; effect.Parameters["World"].SetValue(transforms[mesh.ParentBone.Index] * Matrix.CreateScale(100) * Matrix.CreateTranslation(Camera.Position)); for (int prt = 0; prt < mesh.MeshParts.Count; prt++) { mesh.MeshParts[prt].Effect = effect; } mesh.Draw(); } } } else {//render our other method foreach (ModelMesh mesh in model.Meshes) { foreach (Effect effect in mesh.Effects) { effect.Parameters["World"].SetValue(transforms[mesh.ParentBone.Index] * Matrix.CreateScale(100) * Matrix.CreateTranslation(Camera.Position)); effect.Parameters["Projection"].SetValue(Camera.Projection); effect.Parameters["View"].SetValue(Camera.View); } mesh.Draw(); } } }
// Token: 0x0600013D RID: 317 RVA: 0x00012388 File Offset: 0x00010588 public override void Draw() { bool flag = !this.eType.IsPlayer; checked { if (flag) { Vector3 AmbColor = new Vector3(0f); int i = 0; do { ModelMesh mesh = this.eType.Model.Meshes[i]; Matrix World = Matrix.Multiply(Matrix.Multiply(this.eType.Transforms, this.BodyParts[i].Rotation), Matrix.CreateTranslation(this.BodyParts[i].RelativePosition + this.Position)); AmbColor.X = (float)((double)this.BodyParts[i].Hurt / 25.0); this.BodyParts[i].Hurten(-1f); foreach (Effect effect3 in mesh.Effects) { BasicEffect effect = (BasicEffect)effect3; effect.AmbientLightColor = AmbColor; effect.Projection = Main.projectionMatrix; effect.View = Main.viewMatrix; effect.World = World; } mesh.Draw(); i++; }while (i <= 7); bool flag2 = !Information.IsNothing(this.CTool); if (flag2) { foreach (ModelMesh mesh2 in this.CTool.Model.Meshes) { Matrix World2 = this.CTool.Transforms[mesh2.ParentBone.Index] * this.CTool.Rotation * Matrix.CreateTranslation(this.CTool.RelativePosition + this.Position); foreach (Effect effect4 in mesh2.Effects) { BasicEffect effect2 = (BasicEffect)effect4; effect2.Projection = Main.projectionMatrix; effect2.View = Main.viewMatrix; effect2.World = World2; } mesh2.Draw(); } } } } }
public void Draw(Shader ef) { for (int i = 0; i < model.Meshes.Count; i++) { ModelMesh mesh = model.Meshes[i]; foreach (var part in mesh.MeshParts) { part.Effect = ef.efekt; } mesh.Draw(); } }
public void Draw() { for (int i = 0; i < model.Meshes.Count; i++) { ModelMesh mesh = model.Meshes[i]; foreach (var part in mesh.MeshParts) { //shader.efekt.CurrentTechnique = shader.efekt.Techniques["Tex"]; part.Effect = shader.efekt; mesh.Draw(); } } }
public static void DrawAsBasicEffect(ModelMesh mesh, Matrix world, Matrix view, Matrix projection, Color color) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = world; effect.View = view; effect.Projection = projection; effect.AmbientLightColor = new Vector3(0.01f, 0.01f, 0.01f); effect.DiffuseColor = color.ToVector3(); } mesh.Draw(); }
protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList <Light.ILight> lights) { AnimatedModel modelo = obj.Modelo as AnimatedModel; for (int i = 0; i < modelo.GetAnimatedModel().Meshes.Count; i++) { ModelMesh modelMesh = modelo.GetAnimatedModel().Meshes[i]; for (int j = 0; j < modelMesh.MeshParts.Count; j++) { SkinnedModelBasicEffect basicEffect = (SkinnedModelBasicEffect)modelMesh.MeshParts[j].Effect; basicEffect.CurrentTechnique = basicEffect.Techniques["DEFERREDCUSTOM"]; basicEffect.Parameters["diffuseMap0"].SetValue(modelo.getTexture(TextureType.DIFFUSE, i, j)); basicEffect.Parameters["diffuseMapEnabled"].SetValue(true); basicEffect.Parameters["normalMapEnabled"].SetValue(useBump); basicEffect.Parameters["glowMapEnabled"].SetValue(useGlow); basicEffect.Parameters["specularMapEnabled"].SetValue(useSpecular); if (useGlow) { basicEffect.Parameters["glowMap0"].SetValue(modelo.getTexture(TextureType.GLOW, i, j)); } if (useBump) { basicEffect.Parameters["normalMap0"].SetValue(modelo.getTexture(TextureType.BUMP, i, j)); } if (useSpecular) { basicEffect.Parameters["specularMap0"].SetValue(modelo.getTexture(TextureType.SPECULAR, i, j)); } if (followBone) { basicEffect.World = Followed.GetBoneAbsoluteTransform(boneName) * Followobj.WorldMatrix; basicEffect.Bones = modelo.getBonesTransformation(); } else { basicEffect.World = WorldMatrix; basicEffect.Bones = ac.GetBoneTransformations(); } basicEffect.View = cam.View; basicEffect.Projection = cam.Projection; } modelMesh.Draw(); } render.SetSamplerStates(ginfo.SamplerState); }
public static void Draw(this ModelMesh mesh, Matrix world, Matrix view, Matrix proj, Vector4 diffuse) { foreach (BasicEffect effect in mesh.Effects) { effect.View = view; effect.Projection = proj; effect.World = world; effect.LightingEnabled = false; effect.DiffuseColor = new Vector3(diffuse.X, diffuse.Y, diffuse.Z); effect.Alpha = diffuse.W; } mesh.Draw(); }
// Draw helper private void DrawModel(Model model, Matrix matrix, Color color) { ModelMesh mesh = boxModel.Meshes[0]; foreach (BasicEffect effect in mesh.Effects) { effect.DiffuseColor = color.ToVector3(); effect.EnableDefaultLighting(); effect.World = matrix; effect.View = viewMatrix; effect.Projection = projectionMatrix; } mesh.Draw(); }
// This gets called on each frame render protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); SolidColorMeshShader shader = SolidColorMeshShader.SharedInstance; shader.Use(); camera.ApplyToShader(shader); sphere.Draw(); SwapBuffers(); }
//private int debug = 0; public void DrawModel(Model model, IEnumerable <Cubie> selectedCubies, Matrix worldMatrix, Matrix[] modelTransforms, Matrix viewMatrix, Matrix projectionMatrix) { model.CopyAbsoluteBoneTransformsTo(modelTransforms); foreach (Cubicle cubicle in _cubeConfiguration.Values) { List <Mesh> meshes = cubicle.Cubie.Meshes; foreach (Mesh mesh in meshes) { ModelMesh modelMesh = mesh.ModelMesh; Matrix transform = modelTransforms[modelMesh.ParentBone.Index] * worldMatrix; foreach (BasicEffect effect in modelMesh.Effects) { if (selectedCubies != null && selectedCubies.Contains(cubicle.Cubie)) //if(meshIndex == selectedMesh[0]) { effect.AmbientLightColor = Vector3.One; } else { effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; } effect.World = transform; effect.View = viewMatrix; effect.Projection = projectionMatrix; } modelMesh.Draw(); } } if (_nonCubeMeshs != null) { foreach (ModelMesh mesh in _nonCubeMeshs) { Matrix transform = modelTransforms[mesh.ParentBone.Index] * worldMatrix; foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; effect.World = transform; effect.View = viewMatrix; effect.Projection = projectionMatrix; } mesh.Draw(); } } }
public void DrawModel(Cube cube, Matrix objectWorldMatrix, Matrix view, Matrix projection, GraphicsDevice GraphicsDevice) { GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.DepthStencilState = DepthStencilState.Default; for (int index = 0; index < cube.Model.Meshes.Count; index++) { ModelMesh mesh = cube.Model.Meshes[index]; foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = mesh.ParentBone.Transform * Matrix.CreateTranslation(Game1.CUBIE_SIZE, -Game1.CUBIE_SIZE, -Game1.CUBIE_SIZE) * cube.MeshTransforms[index] * objectWorldMatrix; effect.View = view; effect.Projection = projection; } mesh.Draw(); } }
/// <summary> /// draws the model given /// </summary> /// <param name="cube"></param> /// <param name="objectWorldMatrix"></param> /// <param name="view"></param> /// <param name="projection"></param> /// <param name="graphicsDevice"></param> public void DrawModel(Cube cube, Matrix objectWorldMatrix, Matrix view, Matrix projection) { graphicsDevice.BlendState = BlendState.Opaque; graphicsDevice.DepthStencilState = DepthStencilState.Default; for (int index = 0; index < cube.Model.Meshes.Count; index++) { ModelMesh mesh = cube.Model.Meshes[index]; foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = Matrix.CreateScale(currentScale) * mesh.ParentBone.Transform * Matrix.CreateTranslation(Main.CubieSize, -Main.CubieSize, -Main.CubieSize) * cube.MeshTransforms[index] * objectWorldMatrix; effect.View = view; effect.Projection = projection; } mesh.Draw(); } }
private void DrawModel(Model model, Matrix objectWorld, Matrix[] meshWorldMatrices, Matrix view, Matrix projection) { for (int index = 0; index < model.Meshes.Count; index++) { ModelMesh mesh = model.Meshes[index]; foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; effect.World = mesh.ParentBone.Transform * meshWorldMatrices[index] * objectWorld; effect.View = view; effect.Projection = projection; } mesh.Draw(); } }
private void DrawModel(ref Model model, ref Matrix world) { model.CopyAbsoluteBoneTransformsTo(transforms); for (int mIndex = 0; mIndex < model.Meshes.Count; mIndex++) { ModelMesh mesh = model.Meshes[mIndex]; for (int eIndex = 0; eIndex < mesh.Effects.Count; eIndex++) { BasicEffect effect = (BasicEffect)mesh.Effects[eIndex]; effect.EnableDefaultLighting(); effect.World = transforms[mesh.ParentBone.Index] * world; effect.View = cameraView; effect.Projection = cameraProjection; } mesh.Draw(); } }
private void DrawMeshGhost(Matrix transform, ModelMesh mesh, float alpha) { GraphicsDevice.RenderState.AlphaBlendEnable = true; GraphicsDevice.RenderState.SourceBlend = Blend.One; GraphicsDevice.RenderState.DestinationBlend = Blend.One; foreach (SunlightEffect effect in mesh.Effects) { effect.Alpha = alpha; effect.View = Camera.View; effect.Projection = Camera.Projection; effect.World = transform; effect.ApplyParameters(); } mesh.Draw(); GraphicsDevice.RenderState.AlphaBlendEnable = false; }