Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public override void PreUpdate(IObject ent, IList <Light.ILight> lights)
        {
            this.ent = ent;
            base.PreUpdate(ent, lights);

            AnimatedModel modelo = ent.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++)
                {
                    modelMesh.MeshParts[j].Effect = SkinnedEffect;
                }
            }
        }
        public override void DepthExtractor(GameTime gt, IObject obj, ref Matrix View, ref Matrix projection, RenderHelper render)
        {
            AnimatedModel modelo = obj.Modelo as AnimatedModel;

            foreach (ModelMesh modelMesh in modelo.GetAnimatedModel().Meshes)
            {
                foreach (ModelMeshPart meshPart in modelMesh.MeshParts)
                {
                    SkinnedModelBasicEffect basicEffect = (SkinnedModelBasicEffect)meshPart.Effect;
                    basicEffect.CurrentTechnique = basicEffect.Techniques["DEPTH"];
                    if (followBone)
                    {
                        basicEffect.World = Followed.GetBoneAbsoluteTransform(boneName) * Followobj.WorldMatrix;
                        basicEffect.Bones = modelo.getBonesTransformation();
                    }
                    else
                    {
                        basicEffect.World = WorldMatrix;
                        basicEffect.Bones = ac.GetBoneTransformations();
                    }
                    basicEffect.View       = View;
                    basicEffect.Projection = projection;
                }

                modelMesh.Draw();
            }
            render.SetSamplerStates(ginfo.SamplerState);
        }
        public override void BasicDraw(GameTime gt, IObject obj, ref Matrix view, ref Matrix projection, IList <Light.ILight> lights, RenderHelper render, Plane?clippingPlane, bool useAlphaBlending = false)
        {
            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;
                    if (clippingPlane != null)
                    {
                        basicEffect.Parameters["clipenabled"].SetValue(true);
                        basicEffect.Parameters["plane"].SetValue(new Vector4(clippingPlane.Value.Normal, clippingPlane.Value.D));
                    }
                    else
                    {
                        basicEffect.Parameters["clipenabled"].SetValue(false);
                    }
                    basicEffect.DiffuseMapEnabled = true;
                    basicEffect.CurrentTechnique  = basicEffect.Techniques["FORWARDCLIP"];
                    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 = modelo.getBonesTransformation();
                    }
                    else
                    {
                        basicEffect.World = WorldMatrix;
                        basicEffect.Bones = ac.GetBoneTransformations();
                    }
                    basicEffect.View       = view;
                    basicEffect.Projection = projection;
                }

                modelMesh.Draw();
            }
            render.SetSamplerStates(ginfo.SamplerState);
        }