Beispiel #1
0
        public void Draw(int timeLastFrame)
        {
            if (!Enable)
            {
                return;
            }

            ModelComponent modelComponent = (ModelComponent)m_gameObject.GetComponent(typeof(ModelComponent).ToString());

            Mgr <GraphicsDevice> .Singleton.SetVertexBuffer(m_vertexBuffer);

            // configure effect

            Effect effect = null;

            if (modelComponent != null && modelComponent.Model != null)
            {
                CatMaterial material = modelComponent.GetCatModelInstance().GetMaterial();
                material.SetParameter("World", new CatMatrix(m_gameObject.AbsTransform));
                material.SetParameter("View", new CatMatrix(Mgr <Camera> .Singleton.View));
                material.SetParameter("Projection", new CatMatrix(Mgr <Camera> .Singleton.m_projection));
                if (material.HasParameter("LightMap") && Mgr <Scene> .Singleton.m_shadowSystem != null)
                {
                    material.SetParameter("LightMap", new CatTexture(Mgr <Scene> .Singleton.m_shadowSystem.AccumulateLight));
                }
                effect = material.ApplyMaterial();
            }
            else
            {
                effect = Mgr <DebugTools> .Singleton.DrawEffect;
                ((BasicEffect)effect).Alpha              = 1.0f;
                ((BasicEffect)effect).DiffuseColor       = new Vector3(1.0f, 0.0f, 1.0f);
                ((BasicEffect)effect).View               = Mgr <Camera> .Singleton.View;
                ((BasicEffect)effect).Projection         = Mgr <Camera> .Singleton.m_projection;
                ((BasicEffect)effect).VertexColorEnabled = false;
                ((BasicEffect)effect).World              = m_gameObject.AbsTransform;
            }
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                Mgr <GraphicsDevice> .Singleton.DrawUserPrimitives <VertexPositionColorTexture>(
                    PrimitiveType.TriangleStrip, m_vertex, 0, 2);
            }
        }
Beispiel #2
0
        public void Draw(int timeLastFrame)
        {
            if (m_lifeInMS <= 0)
            {
                return;
            }

            // now just take it as basic effect
            Mgr <GraphicsDevice> .Singleton.SetVertexBuffer(m_emitter.m_vertexBuffer);

            ModelComponent modelComponent = (ModelComponent)m_emitter.GameObject.
                                            GetComponent(typeof(ModelComponent));
            Effect effect      = null;
            Matrix matPosition = Matrix.CreateTranslation(position);
            Matrix matRotation = Matrix.CreateRotationZ(m_rotationZ);
            Matrix matScale    = Matrix.CreateScale(m_size.X, m_size.Y, 1.0f);
            Matrix transform   = Matrix.Multiply(Matrix.Multiply(matScale, matRotation), matPosition);

            if (modelComponent != null && modelComponent.Model != null)
            {
                CatMaterial material = modelComponent.GetCatModelInstance().GetMaterial();
                material.SetParameter("Alpha", new CatFloat((float)m_lifeInMS / m_emitter.ParticleLifetimeInMS));
                material.SetParameter("World", new CatMatrix(transform));
                material.SetParameter("View", new CatMatrix(Mgr <Camera> .Singleton.View));
                material.SetParameter("Projection", new CatMatrix(Mgr <Camera> .Singleton.m_projection));
                effect = material.ApplyMaterial();
            }
            else
            {
                effect = Mgr <DebugTools> .Singleton.DrawEffect;
                ((BasicEffect)effect).Alpha              = (float)m_lifeInMS / m_emitter.ParticleLifetimeInMS;
                ((BasicEffect)effect).DiffuseColor       = new Vector3(1.0f, 0.0f, 1.0f);
                ((BasicEffect)effect).View               = Mgr <Camera> .Singleton.View;
                ((BasicEffect)effect).Projection         = Mgr <Camera> .Singleton.m_projection;
                ((BasicEffect)effect).VertexColorEnabled = false;
                ((BasicEffect)effect).World              = transform;
            }
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                Mgr <GraphicsDevice> .Singleton.DrawUserPrimitives <VertexPositionTexture>(
                    PrimitiveType.TriangleStrip, m_emitter.m_vertex, 0, 2);
            }
        }
Beispiel #3
0
        public void Draw(int timeLastFrame)
        {
            if (!Enable)
            {
                return;
            }

            ModelComponent modelComponent = m_gameObject.GetComponent(
                typeof(ModelComponent).ToString()) as ModelComponent;
            GraphicsDevice gd = Mgr <GraphicsDevice> .Singleton;

            gd.SetVertexBuffer(m_vertexBuffer);
            Effect  effect        = null;
            Vector3 finalPosition = new Vector3(m_position.X - m_offset.X,
                                                m_position.Y - m_offset.Y,
                                                m_depth);

            if (modelComponent != null && modelComponent.Model != null)
            {
                CatMaterial material = modelComponent.GetCatModelInstance().GetMaterial();
                material.SetParameter("World", new CatMatrix(Matrix.CreateTranslation(
                                                                 finalPosition)));
                material.SetParameter("View", new CatMatrix(Matrix.Identity));
                material.SetParameter("Projection", new CatMatrix(Matrix.Identity));
                effect = material.ApplyMaterial();
            }
            else
            {
                effect = Mgr <DebugTools> .Singleton.DrawEffect;
                ((BasicEffect)effect).Alpha              = 1.0f;
                ((BasicEffect)effect).DiffuseColor       = new Vector3(1.0f, 0.0f, 1.0f);
                ((BasicEffect)effect).View               = Matrix.Identity;
                ((BasicEffect)effect).Projection         = Matrix.Identity;
                ((BasicEffect)effect).VertexColorEnabled = false;
                ((BasicEffect)effect).World              = Matrix.CreateTranslation(finalPosition);
            }
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                gd.DrawUserPrimitives <VertexPositionTexture>(
                    PrimitiveType.TriangleStrip, m_vertex, 0, 2);
            }
        }