0
103 May 18, 2010 at 11:10

I am rendering box’s which are fired out in the ships direction

first i check is space pressed
if(fire) { //MessageBox(NULL,”Fire”,”“,0); VecStruct vs; vs.Dir = rRotToDir; vs.FPos = FinalPos; Vs.push_back(vs); fire = false; } then here loop on vector size, the trouble is each box spawns at the last distance , so i am stuck with this time thing , like how would you reset it without messing anything up, i know the problem , i need to find how much gTimeDela is incrementing so i can start each box from 0 and increment it, but i dont know how atm for(int i = 0; i < Vs.size(); i++) { D3DXMatrixTranslation(&Vs[i].Pos,Vs[i].Dir.x*gTimeDelta*5.5f, Vs[i].Dir.y*gTimeDelta*5.5f, Vs[i].Dir.z*gTimeDelta*5.5f); d3ddev->SetTransform(D3DTS_WORLD,&Vs[i].Pos); Box->DrawSubset(0); } heres a video of what i mean http://www.youtube.com/watch?v=O30srrLn8IY [code]

if(fire)
{

//MessageBox(NULL,”Fire”,”“,0);
VecStruct vs;
vs.Dir = rRotToDir;
vs.FPos = FinalPos;
Vs.push_back(vs);
fire = false;

}

then here loop on vector size, the trouble is each box spawns at the last distance , so i am stuck with this time thing , like how would you reset it without messing anything up, i know the problem , i need to find how much gTimeDela is incrementing so i can start each box from 0 and increment it, but i dont know how atm

for(int i = 0; i < Vs.size(); i++)
{
D3DXMatrixTranslation(&Vs.Pos,Vs.Dir.x*gTimeDelta*5.5f,
Vs.Dir.y*gTimeDelta*5.5f,
Vs.Dir.z*gTimeDelta*5.5f);
d3ddev->SetTransform(D3DTS_WORLD,&Vs.Pos);
Box->DrawSubset(0);
}

heres a video of what i mean

#### 3 Replies

0
167 May 18, 2010 at 16:34

Make a struct for your particle that contains a position and velocity. When a particle is fired, initialize its position to position of the ship’s guns. Every frame, loop over the particles and update their positions, by adding their velocity multiplied by the time taken to render the last frame.

0
103 May 18, 2010 at 18:37

ive got that sorted now what i want next is a ray to move with the bullet in the pushed back drection but when i fire say in the oposite direction it says intersected , do you know why?

the bullet is intersecting with the wall no matter which rotation i fire from....

short video

D3DXVECTOR3 ObjPos,NormDir;
D3DXMATRIX matWorld;
d3ddev->GetTransform(D3DTS_WORLD,&matWorld);

for(int i = 0; i < Vs.size(); i++)
{
D3DXMatrixTranslation(&Vs[i].Pos,Vs[i].Dir.x*(gTimeDelta-Vs[i].BulletTime)*5.0f,
Vs[i].Dir.y*(gTimeDelta-Vs[i].BulletTime)*5.0f,
Vs[i].Dir.z*(gTimeDelta-Vs[i].BulletTime)*5.0f);
d3ddev->SetTransform(D3DTS_WORLD,&Vs[i].Pos);
D3DXVECTOR3 BPos(Vs[i].Pos._41,Vs[i].Pos._42,Vs[i].Pos._43);
//Vs[i].Pos._43 = -5.0f;
//MadeEffect->Begin(NULL, NULL);    // begin using the effect
Box->DrawSubset(0);
//gotta convert the ray to objectspace same space as the wall
D3DXVec3TransformCoord(&ObjPos,&BPos,D3DXMatrixInverse(NULL,NULL,&(matWorld * matView))); // to object space
D3DXVec3TransformNormal(&NormDir,&Vs[i].Dir,D3DXMatrixInverse(NULL,NULL,&(matWorld * matView))); // to object space
D3DXVec3Normalize(&NormDir,&NormDir);

D3DXIntersect(Wall,&BPos,&NormDir,&Hit,&Face,NULL,NULL,&Dist,NULL,0);
if(Hit)
{
d3ddev->SetRenderState(D3DRS_LIGHTING, TRUE);
d3ddev->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);

}
else
{
d3ddev->SetRenderState(D3DRS_LIGHTING, TRUE);
d3ddev->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
Face = 0;
Hit = false;
}

0
103 May 19, 2010 at 17:30

Got it working