hBool CollideEntity(pEntity EntA, pEntity EntB, float factor) { vect_t vD; vect_t radius; float D; float A; float B; if(!EntA || !EntB) return false; vD.X = EntA->ent_anim.Pos.X - EntB->ent_anim.Pos.X; vD.Y = EntA->ent_anim.Pos.Y - EntB->ent_anim.Pos.Y; vD.Z = EntA->ent_anim.Pos.Z - EntB->ent_anim.Pos.Z; D = (float)Norme(vD); radius.X = EntA->Radius.X * EntA->ent_anim.Siz.X; radius.Y = EntA->Radius.Y * EntA->ent_anim.Siz.Y; radius.Z = EntA->Radius.Z * EntA->ent_anim.Siz.Z; A = (float)Norme(radius) * factor; radius.X = EntB->Radius.X * EntB->ent_anim.Siz.X; radius.Y = EntB->Radius.Y * EntB->ent_anim.Siz.Y; radius.Z = EntB->Radius.Z * EntB->ent_anim.Siz.Z; B = (float)Norme(radius) * factor; if(D < A+B) return true; return false; }
void Vector::Normalize(){ double n = Norme(); if(n != 0){ componantX /= n; componantY /= n; componantZ /= n; } }
bool Normalize(vect_t *pVect) { float length, len; length=Norme(*pVect); if(length==0) return false; len=1.0f/length; pVect->X *= len; pVect->Y *= len; pVect->Z *= len; return true; }
double Vector::Angle(Vector Vector2){// regarder les cos et sinus attention c'est en radient faire fonction en degres regarder acosf et PI double n1=Norme(); double n2=Vector2.Norme(); double S=Scalar(Vector2); Vector V= Vectoriel(Vector2); /// ici double cosA = acosf( S/( n1* n2)); double sinA = asinf( V.Norme()/( n1* n2)); if(sinA>0) return cosA; else return 2*M_PI-cosA; }
void phy_BoundVelocity(vect_t *Vel, float MaxVel) { double Speed; double NewSpeed; vect_t velocity; velocity.X = Vel->X; velocity.Y = 0; velocity.Z = Vel->Z; Speed = Norme(velocity); if(Speed < MaxVel) return; NewSpeed = MaxVel / Speed; Vel->X *= (float)NewSpeed; // Vel->Y *= (float)NewSpeed; // Vel->Z *= (float)NewSpeed; }
void phy_SlowMove_2(vect_t *Vel, float factor) { float Speed; float NewSpeed; vect_t velocity; velocity.X = Vel->X; velocity.Y = 0; velocity.Z = Vel->Z; Speed = (float)Norme(velocity); if(!Speed) return; NewSpeed = Speed - factor * 0.005f; if(NewSpeed<0) NewSpeed=0; NewSpeed /= Speed; Vel->X *= NewSpeed; // Vel->Y *= NewSpeed; Vel->Z *= NewSpeed; }
void Normalise() {double n=Norme();if (n!=0.0) {x=x/n;y=y/n;z=z/n;}}
void Vector::Normalize(){ double n=Norme(); setX(getX()/n); setY(getY()/n); setZ(getZ()/n); }