Hi I am working though this book in my free time "Introduction to Game Development" by Steve Rabin and I hit a snag. Well on pg 402 there is aome psudo code that I cant understand what some of if means.
So I have this coded and I dont know where to go from here. This is prety much all I can get from this. What it supposed to do is a collection of N particals that move with out colideing, and then add some collition detection into this code later.
- import java.lang.Math;
-
-
public class Euler {
-
-
public static void main(String[] args) {
-
//data needed
-
float mass[];
-
float t;
-
float delta_t;
-
Vector3D cur_S[];
-
Vector3D prior_S[];
-
Vector3D S_derives[];
-
boolean gameOn = true; //keep game sim going
-
-
//set current state to initial conditions
-
for(int i = 0, i < N; i++){
-
mass[i] = mass of particle i;
-
cur_S[2*i] = particle i initial linear momentum;
-
sur_S[2*i+1] = particle i initial position;
-
}
-
-
while(gameOn == true){
-
delta_t.physicSim;
-
for (i = 0; i < N; i ++){
-
Render particle i at postion cur_S[2*i +1];
-
}
-
}
-
-
//do physic method
-
public void physicSim(delta_t){
-
prior_s = cur_S;
-
//calculate the staet derivative vector
-
for(i = 0; i < N; i++){
-
S_derivs = CalcForce(i);
-
S_derivs = prior_S[2*i] / mass[i];
-
}
-
}
-
-
ExplicitEuler(2*N, cur_S, prior_S, S_derivs, delta_t);
-
-
t = t+ delta_t;
-
}
-
}