コード例 #1
0
//////////////////////////////////////////////////////////////////////////
// drawEllipsoid
void ScnDebugRenderComponent::drawEllipsoid( const MaVec3d& Position, const MaVec3d& Size, const RsColour& Colour, BcU32 Layer )
{
	// Draw outer circles for all axis.
	BcU32 LOD = 16;
	BcF32 Angle = 0.0f;
	BcF32 AngleInc = ( BcPI * 2.0f ) / BcF32( LOD );

	// Draw axis lines.
	for( BcU32 i = 0; i < LOD; ++i )
	{
		MaVec2d PosA( BcCos( Angle ), -BcSin( Angle ) );
		MaVec2d PosB( BcCos( Angle + AngleInc ), -BcSin( Angle + AngleInc ) );

		MaVec3d XAxisA = MaVec3d( 0.0f,                 PosA.x() * Size.y(), PosA.y() * Size.z() );
		MaVec3d YAxisA = MaVec3d( PosA.x() * Size.x(), 0.0f,                 PosA.y() * Size.z() );
		MaVec3d ZAxisA = MaVec3d( PosA.x() * Size.x(), PosA.y() * Size.y(), 0.0f                 );
		MaVec3d XAxisB = MaVec3d( 0.0f,                 PosB.x() * Size.y(), PosB.y() * Size.z() );
		MaVec3d YAxisB = MaVec3d( PosB.x() * Size.x(), 0.0f,                 PosB.y() * Size.z() );
		MaVec3d ZAxisB = MaVec3d( PosB.x() * Size.x(), PosB.y() * Size.y(), 0.0f                 );

		drawLine( XAxisA + Position, XAxisB + Position, Colour, 0 );
		drawLine( YAxisA + Position, YAxisB + Position, Colour, 0 );
		drawLine( ZAxisA + Position, ZAxisB + Position, Colour, 0 );

		Angle += AngleInc;
	}

	// Draw a cross down centre.
	MaVec3d XAxis = MaVec3d( Size.x(), 0.0f, 0.0f );
	MaVec3d YAxis = MaVec3d( 0.0f, Size.y(), 0.0f );
	MaVec3d ZAxis = MaVec3d( 0.0f, 0.0f, Size.z() );
	drawLine( Position - XAxis, Position + XAxis, Colour, Layer );
	drawLine( Position - YAxis, Position + YAxis, Colour, Layer );
	drawLine( Position - ZAxis, Position + ZAxis, Colour, Layer );
}
コード例 #2
0
ファイル: BcMat4d.cpp プロジェクト: kolhammer/Psybrus
void BcMat4d::rotation( const BcVec3d& Angles )
{
	BcReal sy, sp, sr;
	BcReal cy, cp, cr;
	
	sy = BcSin( Angles.y() );
	sp = BcSin( Angles.x() );
	sr = BcSin( Angles.z() );
	
	cy = BcCos( Angles.y() );
	cp = BcCos( Angles.x() );
	cr = BcCos( Angles.z() );
	
	Row0_.set( cy * cr + sy * sp * sr, -cy * sr + sy * sp * cr, sy * cp, 0.0f );
	Row1_.set( sr * cp, cr * cp, -sp, 0.0f );
	Row2_.set( -sy * cr + cy * sp * sr, sr * sy + cy * sp * cr, cy * cp, 0.0f );
}
コード例 #3
0
//////////////////////////////////////////////////////////////////////////
// renderRangeHUD
void GaGameUnit::renderRangeHUD( ScnCanvasComponentRef Canvas, BcFixed TimeFraction, BcU32 TeamID )
{
	if( Behaviour_ != BEHAVIOUR_DEAD )
	{
		BcU32 TextureIdx = Desc_.Type_;
		BcFixedVec2d GamePosition( getInterpolatedPosition( TimeFraction ) );
		const BcReal ScaleFactor = 32.0f;
		BcVec2d Position( GamePosition.x(), GamePosition.y() );
		Position *= ScaleFactor;

		// Draw range markers if need be.
		if( Desc_.Range_ > 12.0f )
		{
			BcReal Radius = Desc_.Range_ * ScaleFactor;
			for( BcReal Theta = 0.0f; Theta < BcPIMUL2; Theta += (BcPIMUL2 / 48.0f ) )
			{
				BcVec2d OutPos = Position + BcVec2d( BcCos( Theta ), -BcSin( Theta ) ) * Radius;
				Canvas->drawSpriteCentered( OutPos, BcVec2d( 8.0f, 8.0f ), 3, RsColour::WHITE, 4 );
			}
		}
	}
}
コード例 #4
0
ファイル: GaRobotComponent.cpp プロジェクト: neilogd/LD31Game
			{
				auto RobotPosition = Robot->getParentEntity()->getLocalPosition();
				auto DistanceSquared = ( RobotPosition - LocalPosition ).magnitudeSquared();
				if( DistanceSquared < NearestDistSquared )
				{
					NearestDistSquared = DistanceSquared;
					NearestRobot = Robot;
				}
			}

			if( NearestRobot != nullptr )
			{
				auto RobotPosition = NearestRobot->getParentEntity()->getLocalPosition();
				BcF32 RandomDelta = ThisRobot->MoveAngle_;
				ThisRobot->MoveAngle_ += BcPIDIV4;
				MaVec3d Offset( BcCos( RandomDelta ), 0.0f, -BcSin( RandomDelta ) );

				ThisRobot->TargetPosition_ = RobotPosition - ( Offset * BcF32( Distance ) );
			}
			return BcErrorCode;
		}
	},

	/**
	 * Move: Start. 
	 * Will pick a point around start at specified distance.
	 */
	{
		"op_target_start",
		[]( GaRobotComponent* ThisRobot, BcU32 Distance )->BcU32
		{