[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-svn] r147 - trunk/skorpion
From: |
will |
Subject: |
[cinvoke-svn] r147 - trunk/skorpion |
Date: |
24 Mar 2007 02:04:59 -0400 |
Author: vmy
Date: 2007-03-24 02:04:59 -0400 (Sat, 24 Mar 2007)
New Revision: 147
Modified:
trunk/skorpion/ParticleSystem.cs
trunk/skorpion/skorpion.cs
Log:
add Atomos bodies, a harmonic oscillator implemented with ParticleSystem
Modified: trunk/skorpion/ParticleSystem.cs
===================================================================
--- trunk/skorpion/ParticleSystem.cs 2007-03-22 05:47:49 UTC (rev 146)
+++ trunk/skorpion/ParticleSystem.cs 2007-03-24 06:04:59 UTC (rev 147)
@@ -15,7 +15,7 @@
public static readonly VertexFormats Format =
VertexFormats.Position | VertexFormats.Diffuse;
};
- public struct Particle
+ public class Particle
{
public bool isSpark;
@@ -562,26 +562,25 @@
{
_time += fSecsPerFrame;
-
for(int ii = _particlesList.Count-1; ii >= 0; ii--)
{
Particle p = (Particle)_particlesList[ii];
-
+
float fT = _time - p.creationTime;
- // compute gravitational force and apply that
acceleration to velocity
- float g = .0000000000667f;
- float force = g * 99999.0f * 90.0f /
(float)Math.Pow((vPosition - p.positionVector).Length(), 2.0f);
+ // compute attractive force and apply that
acceleration to velocity
Vector3 r = vPosition - p.positionVector;
- r.Scale(-1 * force / 10000000);
+ float force = .000001f
*(float)Math.Pow(r.Length(), 2.0f);
+ r.Scale(force/2.0f); // f = ma, f/m = a
p.velocityVector += r;
- p.positionVector += p.velocityVector;
-
//System.Console.Out.WriteLine(p.positionVector);
+ p.positionVector.X += p.velocityVector.X;
+ p.positionVector.Y += p.velocityVector.Y;
+ p.positionVector.Z += p.velocityVector.Z;
}
// emit NumParticlesToEmit new particles, but dont
exceed _particlesLimit
int particlesEmit = _particleCount +
_numParticlesToEmit;
- while(_particlesList.Count < 1)
+ while(_particlesList.Count < 10)
{
Particle particle;
@@ -597,28 +596,22 @@
// Emit new particle
float fRand1 =
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 2.0f;
- float fRand2 =
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 0.25f;
- float fRand3 =
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 0.25f;
+ float fRand2 =
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 2.0f;
+ float fRand3 =
((float)_rand.Next(int.MaxValue)/(float)int.MaxValue) * (float)Math.PI * 2.0f;
particle.isSpark = false;
particle.initialPosition = vPosition;
-
particle.initialVelocity = vVelocity;
- particle.initialVelocity.X +=
(float)Math.Cos(fRand1) * (float)Math.Sin(fRand2) * 2.5f;
- particle.initialVelocity.Z +=
(float)Math.Sin(fRand1) * (float)Math.Sin(fRand2) * 2.5f;
- particle.initialVelocity.Y +=
(float)Math.Cos(fRand2);
- particle.initialVelocity.X +=
(float)Math.Cos(fRand1) * (float)Math.Sin(fRand2) * .5f;
- particle.initialVelocity.Y +=
(float)Math.Sin(fRand1) * (float)Math.Sin(fRand2) * .5f;
- particle.initialVelocity.Z +=
(float)Math.Sin(fRand1) * (float)Math.Cos(fRand2) * .5f;
- particle.initialVelocity.Scale(90);
- particle.positionVector =
particle.initialPosition;
- particle.velocityVector =
particle.initialVelocity;
- particle.velocityVector.X += fRand1;
- particle.velocityVector.Y += fRand2;
- particle.velocityVector.Z += fRand3;
+ particle.positionVector.X = 0.0f;
+ particle.positionVector.Y = 0.0f;
+ particle.positionVector.Z = 0.0f;
+ particle.velocityVector.X = fRand1 * .05f;
+ particle.velocityVector.Y = fRand2 * .05f;
+ particle.velocityVector.Z = fRand3 * .05f;
+
particle.diffuseColor = clrEmitColor;
particle.fadeColor = clrFadeColor;
particle.fadeProgression = 1.0f;
@@ -628,6 +621,5 @@
_particleCount++;
}
}
-
}
}
\ No newline at end of file
Modified: trunk/skorpion/skorpion.cs
===================================================================
--- trunk/skorpion/skorpion.cs 2007-03-22 05:47:49 UTC (rev 146)
+++ trunk/skorpion/skorpion.cs 2007-03-24 06:04:59 UTC (rev 147)
@@ -146,6 +146,12 @@
ParticleSystem iBallParticleSystem = null;
Texture iBallParticleTexture = null;
ParticleColors iBallParticleColor = ParticleColors.White;
+
+ // an atomos body
+ ParticleSystem iAtomosParticleSystem = null;
+ Texture iAtomosParticleTexture = null;
+ ParticleColors iAtomosParticleColor = ParticleColors.White;
+
public System.Drawing.Color[] g_clrColor =
{
System.Drawing.Color.White,
@@ -322,6 +328,24 @@
drawingFont.InitializeDeviceObjects(iDevice);
sprite = new Sprite(iDevice);
+ iAtomosParticleSystem = new
AtomosBodyParticleSystem(20f, 512, 2048);
+ iAtomosParticleSystem.Radius = .1f;
+ iAtomosParticleSystem.ParticlesLimit = 512;
+ iAtomosParticleSystem.NumParticlesToEmit = 1;
+ iAtomosParticleSystem.EmitVelocity = 100;
+ iAtomosParticleTexture = TextureLoader.FromFile(
iDevice,
+ System.IO.Directory.GetCurrentDirectory() +
"\\assets\\Particle.bmp",
+ D3DX.Default,
+ D3DX.Default,
+ D3DX.Default,
+ 0,
+ Format.Unknown,
+ Pool.Managed,
+ Filter.Triangle|Filter.Mirror,
+ Filter.Triangle|Filter.Mirror,
+ 0);
+ iAtomosParticleSystem.RestoreDeviceObjects(iDevice);
+
// thrusters
if(ClientConfig.Thrusters)
{
@@ -749,6 +773,20 @@
iDevice.RenderState.ZBufferEnable = true;
iDevice.RenderState.Wrap0 = 0;
+ // draw atomos body
+ iDevice.Transform.World = Matrix.Translation(0,0,0);
+ iAtomosParticleSystem.Update(.03F,
g_clrColor[(int)iAtomosParticleColor],
+
g_clrColorFade[(int)iAtomosParticleColor],
+ new Vector3(0.0f, 0.0f, 0.0f),
new Vector3(0.0f, 0.0f, 0.0f));
+ iDevice.RenderState.ZBufferWriteEnable = false;
+ iDevice.RenderState.AlphaBlendEnable = true;
+ iDevice.RenderState.SourceBlend = Blend.One;
+ iDevice.RenderState.DestinationBlend = Blend.One;
+ iDevice.SetTexture(0, iBallParticleTexture);
+ iAtomosParticleSystem.Render(iDevice);
+ iDevice.RenderState.ZBufferWriteEnable = true;
+ iDevice.RenderState.AlphaBlendEnable = false;
+
// draw sparks erupting from the ball
foreach(Entity e2 in
GlobalState.Client.ThisFrame.Values)
//foreach(Entity e in
(Entity)GlobalState.Client.Universe.Entities[2])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cinvoke-svn] r147 - trunk/skorpion,
will <=