Example #1
0
        public override void UpdatePosition(ref CustomVertex.TransformedColored vt, ref myownvertexformat Particle,int i)
        {
            vt.X += Particle.speed.X + this.world.gravityX;
                vt.Y += Particle.speed.Y + (this.world.gravityY * Particle.lifecount/5f);

                Particle.lifecount++;
                if (Particle.lifecount >= Particle.lifetime )
                {
                    this.remove_particle(i);

                }
        }
        private void button16_Click(object sender, EventArgs e)
        {
            // Initialize
            pictureBox1.Width = 640; pictureBox1.Height = 480;

            PresentParameters presentParams = new PresentParameters();

            presentParams.Windowed   = true;
            presentParams.SwapEffect = SwapEffect.Discard;
            device = new Device(0, DeviceType.Hardware, pictureBox1, CreateFlags.SoftwareVertexProcessing, presentParams);
            AllocateResources();


            device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, pictureBox1.Width / pictureBox1.Height, 1f, 50f);
            device.Transform.View       = Matrix.LookAtLH(new Vector3(0, 0, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            device.RenderState.Lighting = false;
            device.RenderState.CullMode = Cull.None;

            vertices             = new CustomVertex.PositionColored[3];
            vertices[0].Position = new Vector3(0f, 0f, 0f);
            vertices[0].Color    = Color.Red.ToArgb();
            vertices[1].Position = new Vector3(10f, 0f, 0f);
            vertices[1].Color    = Color.Green.ToArgb();
            vertices[2].Position = new Vector3(5f, 10f, 0f);
            vertices[2].Color    = Color.Yellow.ToArgb();


            verticesT[0] = new myownvertexformat(new Vector3(2, -2, -2), 0.0f, 0.0f);
            verticesT[1] = new myownvertexformat(new Vector3(0, 2, 0), 0.125f, 1.0f);
            verticesT[2] = new myownvertexformat(new Vector3(-2, -2, 2), 0.25f, 0.0f);

            vb.SetData(verticesT, 0, LockFlags.None);

            VertexElement[] velements = new VertexElement[]
            {
                new VertexElement(0, 0, DeclarationType.Float3,
                                  DeclarationMethod.Default,
                                  DeclarationUsage.Position, 0),

                new VertexElement(0, 12, DeclarationType.Float2,
                                  DeclarationMethod.Default,
                                  DeclarationUsage.TextureCoordinate, 0),

                VertexElement.VertexDeclarationEnd
            };
            vd = new VertexDeclaration(device, velements);

            myTiff.Image.Save("C:\\ISO\\Dumps\\CA\\Texture.bmp");
            testTexture = TextureLoader.FromFile(device, "C:\\ISO\\Dumps\\CA\\Texture.bmp");

            dxTimer.Enabled = true;
        }
Example #3
0
 public virtual void UpdatePosition(ref CustomVertex.TransformedColored vt, ref myownvertexformat Particle, int i)
 {
     //dummy hier kommt die animation rein
 }
Example #4
0
        public void remove_particle(int index)
        {
            if (this.count <= 1)
                this.alive = false;
            this.count--;
            if (this.count - 1 >= 0)
            {

                if (index == -1) index = count-1;
                if (index >= 0)
                {
                    ParticleInfo[index] = new myownvertexformat();
                    vert[index] = new CustomVertex.TransformedColored();

                    //for (int i = index; i < count; i++)
                    //{
                    //    ParticleInfo[i] = ParticleInfo[i + 1];
                    //    vert[i] = vert[i + 1];
                    //}
                }
            }
        }
Example #5
0
 public void add_particle(float X, float Y, int color, Vector2 speed,int lifetime)
 {
     if (count + 1 < ParticleInfo.Length)
     {
         count++;
         ParticleInfo[count] = new myownvertexformat();
         ParticleInfo[count].speed = speed;
         ParticleInfo[count].lifetime = lifetime;
         ParticleInfo[count].lifecount = 0;
         vert[count]                       = new CustomVertex.TransformedColored(X, Y, 0, 0, color);
     }
 }