Exemplo n.º 1
0
void	CAsteroid::SetVel(const CVector2& vel)
{
	m_Vel = vel;

	// This is a screensave so we need to make sure we never get a velocity of zero
	// If we do we might burn in an asteroid on the screen
	if (SquareMagnitude(m_Vel) < 0.1f)
	{
		m_Vel.Set(0.1f, RandSFloat()*0.1f);
	}
}
Exemplo n.º 2
0
D3DVALUE Magnitude (const UniVector& v)
{
   return (D3DVALUE) sqrt(SquareMagnitude(v));
}
Exemplo n.º 3
0
	float Vector4::Magnitude() const
	{
		return sqrtf( SquareMagnitude() );
	}
Exemplo n.º 4
0
bool		CAsteroid::Intersects(const CVector2& pos)
{
	if (SquareMagnitude(m_Pos-pos) < SQR(m_Size))
		return true;
	return false;
}
Exemplo n.º 5
0
vector3 TGeometry::Load(TQueryParserComp *Parser)
{
    str = Parser->GetNextSymbol().LowerCase();
    tmp->TextureID = TTexturesManager::GetTextureID(str.c_str());

    i = 0;
    do
    {
        tf = Parser->GetNextSymbol().ToDouble();
        TempVerts[i].Point.x = tf;
        tf = Parser->GetNextSymbol().ToDouble();
        TempVerts[i].Point.y = tf;
        tf = Parser->GetNextSymbol().ToDouble();
        TempVerts[i].Point.z = tf;
        tf = Parser->GetNextSymbol().ToDouble();
        TempVerts[i].Normal.x = tf;
        tf = Parser->GetNextSymbol().ToDouble();
        TempVerts[i].Normal.y = tf;
        tf = Parser->GetNextSymbol().ToDouble();
        TempVerts[i].Normal.z = tf;

        str = Parser->GetNextSymbol().LowerCase();
        if (str == "x")
            TempVerts[i].tu = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) /
                              Parser->GetNextSymbol().ToDouble();
        else if (str == "y")
            TempVerts[i].tu = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) /
                              Parser->GetNextSymbol().ToDouble();
        else if (str == "z")
            TempVerts[i].tu = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) /
                              Parser->GetNextSymbol().ToDouble();
        else
            TempVerts[i].tu = str.ToDouble();
        ;

        str = Parser->GetNextSymbol().LowerCase();
        if (str == "x")
            TempVerts[i].tv = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) /
                              Parser->GetNextSymbol().ToDouble();
        else if (str == "y")
            TempVerts[i].tv = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) /
                              Parser->GetNextSymbol().ToDouble();
        else if (str == "z")
            TempVerts[i].tv = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) /
                              Parser->GetNextSymbol().ToDouble();
        else
            TempVerts[i].tv = str.ToDouble();
        ;

        //            tf= Parser->GetNextSymbol().ToDouble();
        //          TempVerts[i].tu= tf;
        //        tf= Parser->GetNextSymbol().ToDouble();
        //      TempVerts[i].tv= tf;

        TempVerts[i].Point.RotateZ(aRotate.z / 180 * M_PI);
        TempVerts[i].Point.RotateX(aRotate.x / 180 * M_PI);
        TempVerts[i].Point.RotateY(aRotate.y / 180 * M_PI);
        TempVerts[i].Normal.RotateZ(aRotate.z / 180 * M_PI);
        TempVerts[i].Normal.RotateX(aRotate.x / 180 * M_PI);
        TempVerts[i].Normal.RotateY(aRotate.y / 180 * M_PI);

        TempVerts[i].Point += pOrigin;
        tmp->pCenter += TempVerts[i].Point;

        i++;

        //        }
    } while (Parser->GetNextSymbol().LowerCase() != "endtri");

    nv = i;
    tmp->Init(nv);
    tmp->pCenter /= (nv > 0 ? nv : 1);

    //        memcpy(tmp->Vertices,TempVerts,nv*sizeof(TGroundVertex));

    r = 0;
    for (int i = 0; i < nv; i++)
    {
        tmp->Vertices[i] = TempVerts[i];
        tf = SquareMagnitude(tmp->Vertices[i].Point - tmp->pCenter);
        if (tf > r)
            r = tf;
    }

    //        tmp->fSquareRadius= 2000*2000+r;
    tmp->fSquareRadius += r;
}
Exemplo n.º 6
0
		//-----------------------------------------------------------------------------
		bool Vector3D::IsNormal() const
		{
			return (SquareMagnitude() == 1.0f);
		}
Exemplo n.º 7
0
bool CFVec2::IsNormal( void ) const
{
	return( fabsf(SquareMagnitude() - 1.0f) <= 0.0001f );
}
Exemplo n.º 8
0
FLOAT32 CFVec2::Magnitude( void ) const
{
	return sqrtf( SquareMagnitude() );
}