コード例 #1
0
ファイル: Manipulator.cpp プロジェクト: m10914/Sphere
//---------------------------------------------------------------------------------------------
// Name:
// Desc: deprecated - for single test manipulator
//---------------------------------------------------------------------------------------------
HRESULT CManipulator::InversedKinematics(D3DXVECTOR3 vecDest)
{		
	//recursive
	int i = 0;
	D3DXVECTOR3 vDest = D3DXVECTOR3(vecDest.x, vecDest.y, vecDest.z + cube[4]->fLength);
	D3DXVECTOR3 vInit = D3DXVECTOR3(0,0,cube[0]->fLength);
	D3DXVECTOR3 vDiff = vDest-vInit;
	
	float* fRes = new float[numOfChains];
	for( i=0; i < numOfChains; i++) fRes[i] = 0;

	if( findpoint_recursive(1,numOfChains-2,vDiff,fRes,0,0) )
	{
		float totalangle = 0;
		for(int j=1; j < numOfChains-1; j++)
		{
			SetAngles(j,D3DXVECTOR2( fRes[j], 0 ));
			totalangle += fRes[j];
		}

		//rotating first cube
		SetAngles(0, D3DXVECTOR2(0, atan2(vecDest.x,vecDest.y)));

		//rotationg last cube
		SetAngles(4, D3DXVECTOR2(D3DX_PI-(totalangle), 0));

		return S_OK;
	}
	else
	{
		AppendReport(L"Error 1: Destination unreachable");
		return E_FAIL;
	}
	

	/*
	// non recursive - deprecated!!!
	D3DXVECTOR3 myvec3;
	if(SUCCEEDED( findpoint(vecDest,&myvec3) ))
	{
		SetAngles(1, D3DXVECTOR2( myvec3.x, 0));
		SetAngles(2, D3DXVECTOR2( myvec3.y, 0));
		SetAngles(3, D3DXVECTOR2( myvec3.z, 0));

		//rotating first cube
		SetAngles(0, D3DXVECTOR2(0, atan2(vecDest.x,vecDest.y)));

		//rotationg last cube
		SetAngles(4, D3DXVECTOR2(D3DX_PI-(myvec3.x+myvec3.y+myvec3.z), 0));
	}
	*/

	return S_OK;
}
コード例 #2
0
ファイル: CSector.cpp プロジェクト: cugone/Abrams2012
A2DE_BEGIN


Sector::Sector(double x, double y, double startAngle, double endAngle, double radius, const ALLEGRO_COLOR& color, bool filled) : Shape(x, y, (radius < 0.0 ? 0.0 : radius * 2), (radius < 0.0 ? 0.0 : radius * 2), color, filled), _arc(x, y, startAngle, endAngle, (radius < 0.0 ? 0.0 : radius), color, filled) {
    _type = Shape::SHAPETYPE_SECTOR;
    SetAngles(_arc.GetStartAngle(), _arc.GetEndAngle());
    CalculateArea();
}
コード例 #3
0
LUAMTA_FUNCTION(camera, SetAngles)
{
	auto self = my->ToCameraPtr(1);

	self->SetAngles(my->ToAng3(2));

	return 0;
}
コード例 #4
0
ファイル: CSector.cpp プロジェクト: cugone/Abrams2012
Sector& Sector::operator=(const Sector& rhs) {
    if(this == &rhs) return *this;

    Shape::operator=(rhs);
    SetAngles(rhs._arc.GetStartAngle(), rhs._arc.GetEndAngle());
    CalculateArea();

    return *this;
}
コード例 #5
0
ファイル: matrix.cpp プロジェクト: BSVino/Digitanks
Matrix4x4::Matrix4x4(const EAngle& angDirection, const Vector& vecPosition)
{
	SetAngles(angDirection);
	SetTranslation(vecPosition);

	m[0][3] = 0;
	m[1][3] = 0;
	m[2][3] = 0;
	m[3][3] = 1;
}
コード例 #6
0
ファイル: Manipulator.cpp プロジェクト: m10914/Sphere
//---------------------------------------------------------------------------------------------
// Name:
// Desc:
//---------------------------------------------------------------------------------------------
HRESULT CManipulator::PredefinedPosition(int num)
{
	int i;
	if(num >= numPredefinedPos) return E_FAIL;

	for( i = 0; i < 5; i++ )
	{
		SetAngles(i, predefinedPositions[num][i]);
	}
	return S_OK;
}
コード例 #7
0
ファイル: ent_haste.cpp プロジェクト: pkamenarsky/hastegame
void EntHaste::Think(void)
{
	Entity::Think();

	SetAngles(angles - Vector3f(0, EE.Frametime() * 300.0f, 0));

	float_time += EE.Frametime();
	SetOrigin(Vector3f(origin[0], y + sin(float_time * 8) * 2.5, origin[2]));

	ApplyEntityTransformToModel();
}
コード例 #8
0
/*
================
idSecurityCamera::Think
================
*/
void idSecurityCamera::Think( void ) {
	float pct;
	float travel;
	if( thinkFlags & TH_THINK ) {
		if( g_showEntityInfo.GetBool() ) {
			DrawFov();
		}
		if( health <= 0 ) {
			BecomeInactive( TH_THINK );
			return;
		}
	}
	// run physics
	RunPhysics();
	if( thinkFlags & TH_THINK ) {
		if( CanSeePlayer() ) {
			if( alertMode == SCANNING ) {
				float	sightTime;
				SetAlertMode( ALERT );
				stopSweeping = gameLocal.time;
				if( sweeping ) {
					CancelEvents( &EV_SecurityCam_Pause );
				} else {
					CancelEvents( &EV_SecurityCam_ReverseSweep );
				}
				sweeping = false;
				StopSound( SND_CHANNEL_ANY, false );
				StartSound( "snd_sight", SND_CHANNEL_BODY, 0, false, NULL );
				sightTime = spawnArgs.GetFloat( "sightTime", "5" );
				PostEventSec( &EV_SecurityCam_Alert, sightTime );
			}
		} else {
			if( alertMode == ALERT ) {
				float	sightResume;
				SetAlertMode( LOSINGINTEREST );
				CancelEvents( &EV_SecurityCam_Alert );
				sightResume = spawnArgs.GetFloat( "sightResume", "1.5" );
				PostEventSec( &EV_SecurityCam_ContinueSweep, sightResume );
			}
			if( sweeping ) {
				idAngles a = GetPhysics()->GetAxis().ToAngles();
				pct = ( gameLocal.time - sweepStart ) / ( sweepEnd - sweepStart );
				travel = pct * sweepAngle;
				if( negativeSweep ) {
					a.yaw = angle + travel;
				} else {
					a.yaw = angle - travel;
				}
				SetAngles( a );
			}
		}
	}
	Present();
}
コード例 #9
0
/*
================
idItem::Think
================
*/
void idItem::Think( void ) {
	if ( thinkFlags & TH_THINK ) {
		if ( spin ) {
			idAngles	ang;
			idVec3		org;

			ang.pitch = ang.roll = 0.0f;
			ang.yaw = ( gameLocal.time & 4095 ) * 360.0f / -4096.0f;
			SetAngles( ang );

			//float scale = 0.005f + entityNumber * 0.00001f;
			//org = orgOrigin;
			//org.z += 4.0f + cos( ( gameLocal.time + 2000 ) * scale ) * 4.0f;

			// sikk - Fixed item bobbing
			float scale = 0.005f;
			org = orgOrigin;
			org.z += 4.0f + cos( ( gameLocal.time * scale + entityNumber ) ) * 4.0f;
			SetOrigin( org );
		}
	}

	Present();

// ---> sikk - Crumb Light
	// add the light
	if ( renderLight.lightRadius.x > 0.0f ) {
		renderLight.origin = GetPhysics()->GetOrigin() + GetPhysics()->GetAxis() * lightOffset;
		renderLight.axis = GetPhysics()->GetAxis();
		if ( ( lightDefHandle != -1 ) ) {
			//if ( lightEndTime > 0 && gameLocal.time <= lightEndTime + gameLocal.GetMSec() ) {
			//	idVec3 color( 0, 0, 0 );
			//	if ( gameLocal.time < lightEndTime ) {
			//		float frac = ( float )( gameLocal.time - lightStartTime ) / ( float )( lightEndTime - lightStartTime );
			//		color.Lerp( lightColor, color, frac );
			//	} 
			//	renderLight.shaderParms[SHADERPARM_RED] = color.x;
			//	renderLight.shaderParms[SHADERPARM_GREEN] = color.y;
			//	renderLight.shaderParms[SHADERPARM_BLUE] = color.z;
			//} 
			gameRenderWorld->UpdateLightDef( lightDefHandle, &renderLight );
		} else {
			lightDefHandle = gameRenderWorld->AddLightDef( &renderLight );
		}
	}
// <--- sikk - Crumb Light
}
コード例 #10
0
ファイル: wbevent.cpp プロジェクト: MinorKeyGames/Eldritch
void WBEvent::Set( const HashedString& Name, const SParameter* const pParameter )
{
	if( !pParameter )
	{
		return;
	}

	switch( pParameter->GetType() )
	{
	case EWBEPT_Bool:		SetBool(	Name, pParameter->GetBool() );		break;
	case EWBEPT_Int:		SetInt(		Name, pParameter->GetInt() );		break;
	case EWBEPT_Float:		SetFloat(	Name, pParameter->GetFloat() );		break;
	case EWBEPT_Hash:		SetHash(	Name, pParameter->GetHash() );		break;
	case EWBEPT_Vector:		SetVector(	Name, pParameter->GetVector() );	break;
	case EWBEPT_Angles:		SetAngles(	Name, pParameter->GetAngles() );	break;
	case EWBEPT_Entity:		SetEntity(	Name, pParameter->GetEntity() );	break;
	case EWBEPT_Pointer:	SetPointer(	Name, pParameter->GetPointer() );	break;
	}
}
コード例 #11
0
ファイル: Item.cpp プロジェクト: angjminer/deamos
/*
================
idItem::Think
================
*/
void idItem::Think( void ) {
	if ( thinkFlags & TH_THINK ) {
		if ( spin ) {
			idAngles	ang;
			idVec3		org;

			ang.pitch = ang.roll = 0.0f;
			ang.yaw = ( gameLocal.time & 4095 ) * 360.0f / -4096.0f;
			SetAngles( ang );

			float scale = 0.005f + entityNumber * 0.00001f;

			org = orgOrigin;
			org.z += 4.0f + cos( ( gameLocal.time + 2000 ) * scale ) * 4.0f;
			SetOrigin( org );
		}
	}

	Present();
}
コード例 #12
0
ファイル: Leaf.cpp プロジェクト: revelator/Revelation-Engine
END_CLASS

void idEntity_Leaf::Spawn() {
	liveTime		= spawnArgs.GetFloat( "leaf_liveTime" );	// in seconds. Keep this low to prevent too many leaves in the map at a time. each leaf is an entity! Try to make each leaf live at least until it touches the ground. Some leaves will slide along the ground if they live long enough. default: 8
	moveSpeed		= spawnArgs.GetFloat( "leaf_moveSpeed" );	// from 1-10. How fast the leaves move regardless of wind. Keep this high. default: 10
	spread			= spawnArgs.GetFloat( "leaf_spread" );	// from 1-10. Affects how far apart leafs speread apart when falling. default: 10
	windPower		= spawnArgs.GetFloat( "leaf_windPower" );	// from 1-10. How strong the wind is on the leaves. default: 1
	windDir			= spawnArgs.GetVector( "leaf_windDir" );	// Wind direction. default: '0 1 0'
	gravity			= spawnArgs.GetVector( "leaf_gravity" );	// Gravity of the leaf. Keep this pretty low, or accept the default. default: '0 0 -20'
	origin			= spawnArgs.GetVector( "leaf_origin" );
	ang				= GetAngles();
	dieTime			= gameLocal.time + liveTime * 1000;
	if( moveSpeed == 0 ) {
		moveSpeed = 1;
	}
	if( origin != idVec3( 0, 0, 0 ) ) {
		SetOrigin( origin );
	}
	spread = spread / 20; //max spread is 0.5
	dir = gameLocal.random.RandomInt( 3 );
	if( dir < 1 ) {
		spreadX = spread;
	} else if( dir < 2 && dir > 1 ) {
		spreadX = 0;
	} else {
		spreadX = -spread;
	}
	dir = gameLocal.random.RandomInt( 3 );
	if( dir < 1 ) {
		spreadY = spread;
	} else if( dir < 2 && dir > 1 ) {
		spreadY = 0;
	} else {
		spreadY = -spread;
	}
	SetAngles( idAngles( gameLocal.random.CRandomFloat() * 360, gameLocal.random.CRandomFloat() * 360, gameLocal.random.CRandomFloat() * 360 ) );
	GetPhysics()->SetLinearVelocity( idVec3( 0, 0, 0 ) );
	GetPhysics()->SetGravity( idVec3( 0, 0, 0 ) ); //gravity - if we set zero gravity, the leaves stop when they hit the ground. dont know why, but it's cool!
	curVel = GetPhysics()->GetLinearVelocity();
	nextAngles = 0;
}
コード例 #13
0
        void AimAt(TF2Player* prey, CUserCmd* predator, int hitbox, bool silent)
        {
            //How many degrees do you have to look on y-axis and x
            //Adjust movement based on y look axis
            //Aim at him
            Vector aimAt;
            
            prey->GetHitboxPos(aimAt, hitbox);

            Vector me = TF2Entity::Me()->vecEyeOrigin();
            Vector vecdist = aimAt - me;


            float yAng = atan2(vecdist.y, vecdist.x) * 180.0f / M_PI;
            float xAng = atan2(vecdist.z, hypotf(vecdist.x, vecdist.y)) * -180.0f / M_PI;

            if (silent)
                SetAngles(predator,yAng);

            predator->viewangles.x = xAng;
            predator->viewangles.y = yAng;
        }
コード例 #14
0
ファイル: Manipulator.cpp プロジェクト: m10914/Sphere
HRESULT CManipulator::InversedKinematics(D3DXVECTOR3 vecDesc, LPWSTR limbName)
{
	int i,j;
	LIMB* limb = limbs[GetLimbIndexByName(limbName)];
	int limbLength = limb->lastchain - limb->firstchain;
	D3DXVECTOR2* fRes = new D3DXVECTOR2[numOfChains];
	for( i=0; i < numOfChains; i++) fRes[i] = D3DXVECTOR2(0,0);
	D3DXMATRIX matEmpty;
	D3DXMatrixIdentity(&matEmpty);
	char teststr[512] = "str: \0";



	if( findpoint_recursive(GetChainIndexByID(limb->firstchain),GetChainIndexByID(limb->lastchain),vecDesc,fRes,matEmpty) )
	{
		/*for(j=0;j<numOfChains;j++)
		{
			sprintf(teststr,"%s, (%.2f; %.2f)",teststr,fRes[j].x, fRes[j].y);
		}*/

		for(j=GetChainIndexByID(limb->firstchain); j <= GetChainIndexByID(limb->lastchain); j++)
		{
			SetAngles(j,fRes[j],false);
			bProcessing = true;
		}
	}
	else
	{
		AppendReport(L"Error 1: Destination unreachable");
		return E_FAIL;
	}

	free(fRes);

	return S_OK;
}
コード例 #15
0
ファイル: viewangleanim.cpp プロジェクト: paralin/hl2sdk
void CViewAngleAnimation::ClientThink()
{
	if ( IsFinished() )
		return;

	float flCurrentTime = gpGlobals->curtime - m_flAnimStartTime;

	if ( flCurrentTime < 0 )
		flCurrentTime = 0.001;

	// find two nearest points
	int i, c;
	c = m_KeyFrames.Count();
	float flTime = 0;
	for ( i=0;i<c;i++ )
	{
		if ( flTime + m_KeyFrames[i]->m_flTime > flCurrentTime )
		{
			break;
		}

		flTime += m_KeyFrames[i]->m_flTime;
	}

	Assert( i > 0 );

	if ( i >= c )
	{
		if ( i > 0 )
		{
			// animation complete, set to end point
			SetAngles( m_KeyFrames[i-1]->m_vecAngles );
		}

		if ( m_pAnimCompleteCallback )
		{
			m_pAnimCompleteCallback();
		}

		m_bFinished = true;
		return;
	}

	if ( m_KeyFrames[i]->m_iFlags != m_iFlags )
	{
		if ( ( m_KeyFrames[i]->m_iFlags & VIEWANIM_RELATIVE ) && !( m_iFlags & VIEWANIM_RELATIVE ) )
		{
            // new relative position is current angles
			engine->GetViewAngles( m_vecBaseAngles );
		}

		// copy the rest over
		m_iFlags = m_KeyFrames[i]->m_iFlags;
	}

	// previous frame is m_KeyFrames[i-1];
	// next frame is m_KeyFrames[i];
	float flFraction = ( flCurrentTime - flTime ) / ( m_KeyFrames[i]->m_flTime );

	Vector v0, v1, v2, v3;

	if ( i-2 <= 0 )
	{
		QAngleToVector( m_KeyFrames[i-1]->m_vecAngles, v0 );
	}
	else
	{
		QAngleToVector( m_KeyFrames[i-2]->m_vecAngles, v0 );
	}

	QAngleToVector( m_KeyFrames[i-1]->m_vecAngles, v1 );
	QAngleToVector( m_KeyFrames[i]->m_vecAngles, v2 );

	if ( i+1 >= c )
	{
		QAngleToVector( m_KeyFrames[i]->m_vecAngles, v3 );
	}
	else
	{
		QAngleToVector( m_KeyFrames[i+1]->m_vecAngles, v3 );
	}

	Vector out;
	Catmull_Rom_Spline( v0,	v1, v2,	v3,	flFraction,	out );

	QAngle vecCalculatedAngles;
	QAngleToVector( out, vecCalculatedAngles );
	SetAngles( vecCalculatedAngles );
}
コード例 #16
0
ファイル: BoatAnalysisDlg.cpp プロジェクト: kolzar/sail7
bool BoatAnalysisDlg::UnitLoop()
{
	QString str;
	int n, nrhs;

	if (m_ControlMax<m_ControlMin) m_ControlDelta = -fabs(m_ControlDelta);
	nrhs  = (int)fabs((m_ControlMax-m_ControlMin)*1.0001/m_ControlDelta) + 1;

	if(!m_bSequence) nrhs = 1;
	else if(nrhs>=100)
	{
		QMessageBox::warning(this, tr("Warning"),tr("The number of points to be calculated will be limited to 100"));
		nrhs = 100;
	}

	//ESTIMATED UNIT TIMES FOR OPERATIONS

	double TotalTime = 10.0*(double)m_MatSize/400. //BuildInfluenceMatrix :     10 x MatSize/400
					 + 10.                         //CreateRHS :                10
					 + 30.*(double)m_MatSize/400.  //SolveUnitRHS :             30 x MatSize/400
					 + 1./400.   * (double)m_pBoat->m_poaSail.size()  //ComputeFarField : 1 x MatSize/400x nsails
					 + 1.   ;                      //ComputeOnBodyCp :           1

	TotalTime *= (double)nrhs;

	m_pctrlProgress->setMinimum(0);
	m_pctrlProgress->setMaximum((int)TotalTime);
	m_Progress = 0.0;
	qApp->processEvents();

	str = QString(tr("   Solving the problem... ")+"\n");
	AddString(str);

	for (n=0; n<nrhs; n++)
	{
		m_Ctrl = m_ControlMin +(double)n * m_ControlDelta;
		str = QString("      \n    "+tr("Processing parameter= %1")+"\n").arg(m_Ctrl,8,'f',3);
		AddString(str);

		SetAngles(m_pBoatPolar, m_Ctrl, false);
		if (m_bCancel) return true;


		BuildInfluenceMatrix();
		if (m_bCancel) return true;


		CreateRHS(m_RHS);
		if (m_bCancel) return true;


		CreateSourceStrength();
		if (m_bCancel) return true;

		//compute wake contribution
//		CreateWakeContribution();
		if (m_bCancel) return true;

		//add wake contribution to matrix and RHS
//		for(int p=0; p<m_MatSize; p++)
//		{
//			m_uRHS[p]+= m_uWake[p];
//			m_vRHS[p]+= m_wWake[p];
/*			for(int pp=0; pp<m_MatSize; pp++)
			{
				s_aij[p*m_MatSize+pp] += s_aijWake[p*m_MatSize+pp];
			}*/
//		}

		if (m_bCancel) return true;


		if (!Solve())
		{
			m_bWarning = true;
			return true;
		}
		if (m_bCancel) return true;


		ComputeFarField();
		if (m_bCancel) return true;

		ComputeOnBody();
		if (m_bCancel) return true;

		ComputeBoat();
		if (m_bCancel) return true;
	}

	return true;
}
コード例 #17
0
 inline void SetAngles(CUserCmd* me, const float& yangle)
 {
     SetAngles(me->forwardmove, me->sidemove, yangle, me->viewangles.y);
 }
コード例 #18
0
ファイル: CSector.cpp プロジェクト: cugone/Abrams2012
Sector::Sector(const Sector& sector) : Shape(sector), _arc(sector._arc) {
    _type = Shape::SHAPETYPE_SECTOR;
    SetAngles(sector._arc.GetStartAngle(), sector._arc.GetEndAngle());
    CalculateArea();
}
コード例 #19
0
ファイル: CSector.cpp プロジェクト: cugone/Abrams2012
void Sector::SetAnglesDegrees(double startAngle, double endAngle) {
    SetAngles(a2de::Math::DegreeToRadian(startAngle), a2de::Math::DegreeToRadian(endAngle));
}
コード例 #20
0
ファイル: CSector.cpp プロジェクト: cugone/Abrams2012
Sector::Sector(const Vector2D& position, double startAngle, double endAngle, double radius, const ALLEGRO_COLOR& color, bool filled) : Shape(position, (radius < 0.0 ? 0.0 : radius * 2), (radius < 0.0 ? 0.0 : radius * 2), color, filled), _arc(position, startAngle, endAngle, (radius < 0.0 ? 0.0 : radius), color, filled) {
    _type = Shape::SHAPETYPE_SECTOR;
    SetAngles(_arc.GetStartAngle(), _arc.GetEndAngle());
    CalculateArea();
}
コード例 #21
0
 void PointOnSphere::IncAngles(float incTheta, float incPhi)
 {
     SetAngles(theta_ + incTheta, phi_ + incPhi);
 }