Example #1
0
void CExplosiveRocket::PH_A_CrPr			()
{
	if (m_just_after_spawn)
	{
		CPhysicsShellHolder& obj = CInventoryItem::object();
		VERIFY(obj.Visual());
		IKinematics *K = obj.Visual()->dcast_PKinematics();
		VERIFY( K );
		if (!obj.PPhysicsShell())
		{
			Msg("! ERROR: PhysicsShell is NULL, object [%s][%d]", obj.cName().c_str(), obj.ID());
			return;
		}
		if(!obj.PPhysicsShell()->isFullActive())
		{
			K->CalculateBones_Invalidate();
			K->CalculateBones(TRUE);
		}
		obj.PPhysicsShell()->GetGlobalTransformDynamic(&obj.XFORM());
		K->CalculateBones_Invalidate();
		K->CalculateBones(TRUE);
		obj.spatial_move();
		m_just_after_spawn = false;
	}
}
Example #2
0
void CHelicopter::UpdateCL()
{
    inherited::UpdateCL	();
    CExplosive::UpdateCL();
    if(PPhysicsShell() && (state() == CHelicopter::eDead) ) {

        PPhysicsShell()->InterpolateGlobalTransform(&XFORM());

        IKinematics* K		= smart_cast<IKinematics*>(Visual());
        K->CalculateBones	();
        //smoke
        UpdateHeliParticles();

        if(m_brokenSound._feedback())
            m_brokenSound.set_position(XFORM().c);


        return;
    }
    else
        PPhysicsShell()->SetTransform(XFORM(),  mh_unspecified );

    m_movement.Update();

    m_stepRemains+=Device.fTimeDelta;
    while(m_stepRemains>STEP) {
        MoveStep();
        m_stepRemains-=STEP;
    }

#ifdef DEBUG
    if(bDebug) {
        CGameFont* F		= UI().Font().pFontDI;
        F->SetAligment		(CGameFont::alCenter);
//		F->SetSizeI			(0.02f);
        F->OutSetI			(0.f,-0.8f);
        F->SetColor			(0xffffffff);
        F->OutNext			("Heli: speed=%4.4f acc=%4.4f dist=%4.4f",m_movement.curLinearSpeed, m_movement.curLinearAcc, m_movement.GetDistanceToDestPosition());
    }
#endif

    if(m_engineSound._feedback())
        m_engineSound.set_position(XFORM().c);



    m_enemy.Update();
    //weapon
    UpdateWeapons();
    UpdateHeliParticles();

    IKinematics* K		= smart_cast<IKinematics*>(Visual());
    K->CalculateBones	();
}
Example #3
0
void CCharacterPhysicsSupport::in_NetSpawn( CSE_Abstract* e )
{
	m_sv_hit = SHit();
	if( m_EntityAlife.use_simplified_visual	( ) )
	{
		m_flags.set( fl_death_anim_on, TRUE );
		IKinematics*	ka = smart_cast<IKinematics*>( m_EntityAlife.Visual( ) );
		VERIFY( ka );
		ka->CalculateBones_Invalidate( );
		ka->CalculateBones( TRUE );
		CollisionCorrectObjPos( m_EntityAlife.Position( ) );
		m_pPhysicsShell		= P_build_Shell( &m_EntityAlife, false );
		ka->CalculateBones_Invalidate( );
		ka->CalculateBones( TRUE );
		return;
	}
	CPHDestroyable::Init();//this zerows colbacks !!;
	IRenderVisual *pVisual = m_EntityAlife.Visual();
	IKinematicsAnimated*ka= smart_cast<IKinematicsAnimated*>( pVisual );
	IKinematics*pK= smart_cast<IKinematics*>( pVisual );
	VERIFY( &e->spawn_ini() );
	m_death_anims.setup( ka, *e->s_name , pSettings );
	if( !m_EntityAlife.g_Alive() )
	{
		if( m_eType == etStalker )
			ka->PlayCycle( "waunded_1_idle_0" );
		else
			ka->PlayCycle( "death_init" );

	}else if( !m_EntityAlife.animation_movement_controlled( ) )
		ka->PlayCycle( "death_init" );///непонятно зачем это вообще надо запускать
									  ///этот хак нужен, потому что некоторым монстрам 
									  ///анимация после спона, может быть вообще не назначена
	pK->CalculateBones_Invalidate( );
	pK->CalculateBones( TRUE );
	
	CPHSkeleton::Spawn( e );
	movement( )->EnableCharacter();
	movement( )->SetPosition(m_EntityAlife.Position( ) );
	movement( )->SetVelocity	( 0, 0, 0 );
	if(m_eType!=etActor)
	{
		m_flags.set( fl_specific_bonce_demager, TRUE );
		m_BonceDamageFactor = 1.f;
	}
	if( Type( ) == etStalker )
	{
		m_hit_animations.SetupHitMotions( *smart_cast<IKinematicsAnimated*>( m_EntityAlife.Visual( ) ) );
	}
	anim_mov_state.init( );

	anim_mov_state.active = m_EntityAlife.animation_movement_controlled( );
}
Example #4
0
void CCar::CreateSkeleton(CSE_Abstract	*po)
{

	if (!Visual()) return;
	IRenderVisual *pVis = Visual();
	IKinematics* pK = smart_cast<IKinematics*>(pVis);
	IKinematicsAnimated* pKA = smart_cast<IKinematicsAnimated*>(pVis);
	if(pKA)
	{
		pKA->PlayCycle		("idle");
		pK->CalculateBones	(TRUE);
	}
	phys_shell_verify_object_model ( *this );
#pragma todo(" replace below by P_build_Shell or call inherited")
	m_pPhysicsShell		= P_create_Shell();
	m_pPhysicsShell->build_FromKinematics(pK,&bone_map);
	m_pPhysicsShell->set_PhysicsRefObject(this);
	m_pPhysicsShell->mXFORM.set(XFORM());
	m_pPhysicsShell->Activate(true);
	m_pPhysicsShell->SetAirResistance(0.f,0.f);
	m_pPhysicsShell->SetPrefereExactIntegration();

	ApplySpawnIniToPhysicShell(&po->spawn_ini(),m_pPhysicsShell,false);
	ApplySpawnIniToPhysicShell(pK->LL_UserData(),m_pPhysicsShell,false);
}
Example #5
0
void CPhysicObject::PH_A_CrPr		()
{
	if (m_just_after_spawn)
	{
		VERIFY(Visual());
		IKinematics *K = Visual()->dcast_PKinematics();
		VERIFY( K );
		if (!PPhysicsShell())
		{
			return;
		}
		if(!PPhysicsShell()->isFullActive())
		{
			K->CalculateBones_Invalidate();
			K->CalculateBones(TRUE);
		}
		PPhysicsShell()->GetGlobalTransformDynamic(&XFORM());
		K->CalculateBones_Invalidate();
		K->CalculateBones(TRUE);
#if	0
		Fbox bb= BoundingBox	();
		DBG_OpenCashedDraw		();
		Fvector c,r,p;
		bb.get_CD(c,r );
		XFORM().transform_tiny(p,c);
		DBG_DrawAABB( p, r,D3DCOLOR_XRGB(255, 0, 0));
		//PPhysicsShell()->XFORM().transform_tiny(c);
		Fmatrix mm;
		PPhysicsShell()->GetGlobalTransformDynamic(&mm);
		mm.transform_tiny(p,c);
		DBG_DrawAABB( p, r,D3DCOLOR_XRGB(0, 255, 0));
		DBG_ClosedCashedDraw	(50000);
#endif
		spatial_move();
		m_just_after_spawn = false;
		
		VERIFY(!OnServer());
		
		PPhysicsShell()->get_ElementByStoreOrder(0)->Fix();
		PPhysicsShell()->SetIgnoreStatic	();	
		//PPhysicsShell()->SetIgnoreDynamic	();
		//PPhysicsShell()->DisableCollision();
	}
	//CalculateInterpolationParams()
};
Example #6
0
void CPHSkeleton::UnsplitSingle(CPHSkeleton* SO)
{
	//Msg("%o,received has %d,",this,m_unsplited_shels.size());
	if (0==m_unsplited_shels.size())	return;	//. hack
	CPhysicsShellHolder* obj = PPhysicsShellHolder();
	CPhysicsShellHolder* O =SO->PPhysicsShellHolder();
	VERIFY2(m_unsplited_shels.size(),"NO_SHELLS !!");
	VERIFY2(!O->m_pPhysicsShell,"this has shell already!!!");
	CPhysicsShell* newPhysicsShell=m_unsplited_shels.front().first;
	O->m_pPhysicsShell=newPhysicsShell;
	VERIFY(_valid(newPhysicsShell->mXFORM));
	IKinematics *newKinematics=smart_cast<IKinematics*>(O->Visual());
	IKinematics *pKinematics  =smart_cast<IKinematics*>(obj->Visual());

	Flags64 mask0,mask1;
	u16 split_bone=m_unsplited_shels.front().second;
	mask1.assign(pKinematics->LL_GetBonesVisible());//source bones mask
	pKinematics->LL_SetBoneVisible(split_bone,FALSE,TRUE);

	pKinematics->CalculateBones_Invalidate	();
	pKinematics->CalculateBones				(TRUE);

	mask0.assign(pKinematics->LL_GetBonesVisible());//first part mask
	VERIFY2(mask0.flags,"mask0 -Zero");
	mask0.invert();
	mask1.and(mask0.flags);//second part mask


	newKinematics->LL_SetBoneRoot		(split_bone);
	VERIFY2(mask1.flags,"mask1 -Zero");
	newKinematics->LL_SetBonesVisible	(mask1.flags);

	newKinematics->CalculateBones_Invalidate	();
	newKinematics->CalculateBones				(TRUE);

	newPhysicsShell->set_Kinematics(newKinematics);
	VERIFY(_valid(newPhysicsShell->mXFORM));
	newPhysicsShell->ResetCallbacks(split_bone,mask1);
	VERIFY(_valid(newPhysicsShell->mXFORM));

	newPhysicsShell->ObjectInRoot().identity();

	if(!newPhysicsShell->isEnabled())O->processing_deactivate();
	newPhysicsShell->set_PhysicsRefObject(O);
	
	m_unsplited_shels.erase(m_unsplited_shels.begin());
	O->setVisible(TRUE);
	O->setEnabled(TRUE);


	SO->CopySpawnInit		();
	CopySpawnInit			();
	VERIFY3(CheckObjectSize(pKinematics),*(O->cNameVisual()),"Object unsplit whith no size");
	VERIFY3(CheckObjectSize(newKinematics),*(O->cNameVisual()),"Object unsplit whith no size");

}
Example #7
0
void CInventoryItem::UpdateXForm	()
{
	if (0==object().H_Parent())	return;

	// Get access to entity and its visual
	CEntityAlive*	E		= smart_cast<CEntityAlive*>(object().H_Parent());
	if (!E) return;
	
	if (E->cast_base_monster()) return;

	const CInventoryOwner	*parent = smart_cast<const CInventoryOwner*>(E);
	if (parent && parent->use_simplified_visual())
		return;

	if (parent->attached(this))
		return;

	R_ASSERT		(E);
	IKinematics*	V		= smart_cast<IKinematics*>	(E->Visual());
	VERIFY			(V);

	// Get matrices
	int						boneL = -1, boneR = -1, boneR2 = -1;
	E->g_WeaponBones(boneL,boneR,boneR2);
	if (boneR == -1)	return;
	//	if ((HandDependence() == hd1Hand) || (STATE == eReload) || (!E->g_Alive()))
	//		boneL = boneR2;
#pragma todo("TO ALL: serious performance problem")
	V->CalculateBones	();
	Fmatrix& mL			= V->LL_GetTransform(u16(boneL));
	Fmatrix& mR			= V->LL_GetTransform(u16(boneR));
	// Calculate
	Fmatrix			mRes;
	Fvector			R,D,N;
	D.sub			(mL.c,mR.c);	D.normalize_safe();

	if(fis_zero(D.magnitude()))
	{
		mRes.set(E->XFORM());
		mRes.c.set(mR.c);
	}
	else
	{		
		D.normalize();
		R.crossproduct	(mR.j,D);

		N.crossproduct	(D,R);
		N.normalize();

		mRes.set		(R,N,D,mR.c);
		mRes.mulA_43	(E->XFORM());
	}

	//	UpdatePosition	(mRes);
	object().Position().set(mRes.c);
}
void imotion_position::move_update( )
{
	VERIFY( shell );
	IKinematics *K = shell->PKinematics();
	VERIFY( K );

	disable_update( false );
	K->CalculateBones_Invalidate( );
	K->CalculateBones(  );
	disable_update( true );
	VERIFY( shell );
	
}
Example #9
0
void CPHSkeleton::RespawnInit()
{
	IKinematics*	K	=	smart_cast<IKinematics*>(PPhysicsShellHolder()->Visual());
	if(K)
	{
		K->LL_SetBoneRoot(0);
		K->LL_SetBonesVisible(0xffffffffffffffffL);
		K->CalculateBones_Invalidate();
		K->CalculateBones(TRUE);
	}
	Init();
	ClearUnsplited();
}
Example #10
0
void CCar::SpawnInitPhysics	(CSE_Abstract	*D)
{
	CSE_PHSkeleton		*so = smart_cast<CSE_PHSkeleton*>(D);
	R_ASSERT						(so);
	ParseDefinitions				();//parse ini filling in m_driving_wheels,m_steering_wheels,m_breaking_wheels
	CreateSkeleton					(D);//creates m_pPhysicsShell & fill in bone_map
	IKinematics *K					=smart_cast<IKinematics*>(Visual());
	K->CalculateBones_Invalidate();//this need to call callbacks
	K->CalculateBones	(TRUE);
	Init							();//inits m_driving_wheels,m_steering_wheels,m_breaking_wheels values using recieved in ParceDefinitions & from bone_map
	//PPhysicsShell()->add_ObjectContactCallback(ActorObstacleCallback);
	SetDefaultNetState				(so);
	CPHUpdateObject::Activate       ();
}
Example #11
0
void	CPhysicObject::		anim_time_set					( float time )
{
	if( !check_blend( m_anim_blend, cName().c_str(), cNameSect().c_str(), cNameVisual().c_str() ) )
		return ;
	if( time < 0.f || time > m_anim_blend->timeTotal )
	{
#ifdef	DEBUG	
		Msg( " ! can not set blend time %f - it must be in range 0 - %f(timeTotal) obj: %s, model: %s, anim: %s", time, m_anim_blend->timeTotal, cName().c_str(), cNameVisual().c_str(), smart_cast<IKinematicsAnimated*>( PPhysicsShell()->PKinematics() )->LL_MotionDefName_dbg( m_anim_blend->motionID ).first );
#endif
		return;
	}
	m_anim_blend->timeCurrent = time;
	IKinematics *K = smart_cast<IKinematics*>(Visual());
	VERIFY( K );
	K->CalculateBones_Invalidate();
	K->CalculateBones(TRUE);
}
Example #12
0
void CArtefact::UpdateXForm()
{
	if (Device.dwFrame!=dwXF_Frame)
	{
		dwXF_Frame			= Device.dwFrame;

		if (0==H_Parent())	return;

		// Get access to entity and its visual
		CEntityAlive*		E		= smart_cast<CEntityAlive*>(H_Parent());
        
		if(!E)				return	;

		const CInventoryOwner	*parent = smart_cast<const CInventoryOwner*>(E);
		if (parent && parent->use_simplified_visual())
			return;

		VERIFY				(E);
		IKinematics*		V		= smart_cast<IKinematics*>	(E->Visual());
		VERIFY				(V);
		if(CAttachableItem::enabled())
			return;

		// Get matrices
		int					boneL = -1, boneR = -1, boneR2 = -1;
		E->g_WeaponBones	(boneL,boneR,boneR2);
		if (boneR == -1)	return;

		boneL = boneR2;

		V->CalculateBones	();
		Fmatrix& mL			= V->LL_GetTransform(u16(boneL));
		Fmatrix& mR			= V->LL_GetTransform(u16(boneR));

		// Calculate
		Fmatrix				mRes;
		Fvector				R,D,N;
		D.sub				(mL.c,mR.c);	D.normalize_safe();
		R.crossproduct		(mR.j,D);		R.normalize_safe();
		N.crossproduct		(D,R);			N.normalize_safe();
		mRes.set			(R,N,D,mR.c);
		mRes.mulA_43		(E->XFORM());
//		UpdatePosition		(mRes);
		XFORM().mul			(mRes,offset());
	}
}
Example #13
0
void CWeaponStatMgun::cam_Update			(float dt, float fov)
{
	Fvector							P,Da;
	Da.set							(0,0,0);

	IKinematics* K					= smart_cast<IKinematics*>(Visual());
	K->CalculateBones_Invalidate	();
	K->CalculateBones				(TRUE);
	const Fmatrix& C				= K->LL_GetTransform(m_camera_bone);
	XFORM().transform_tiny			(P,C.c);

	Fvector d = C.k;
	XFORM().transform_dir			(d);
	Fvector2 des_cam_dir;

	d.getHP(des_cam_dir.x, des_cam_dir.y);
	des_cam_dir.mul(-1.0f);


	Camera()->yaw		= angle_inertion_var(Camera()->yaw,		des_cam_dir.x,	0.5f,	7.5f,	PI_DIV_6,	Device.fTimeDelta);
	Camera()->pitch		= angle_inertion_var(Camera()->pitch,	des_cam_dir.y,	0.5f,	7.5f,	PI_DIV_6,	Device.fTimeDelta);




	if(OwnerActor()){
		// rotate head
		OwnerActor()->Orientation().yaw			= -Camera()->yaw;
		OwnerActor()->Orientation().pitch		= -Camera()->pitch;
	}
	

	Camera()->Update							(P,Da);
	Level().Cameras().UpdateFromCamera			(Camera());

}
Example #14
0
void CWeapon::UpdateXForm	()
{
	if (Device.dwFrame == dwXF_Frame)
		return;

	dwXF_Frame				= Device.dwFrame;

	if (!H_Parent())
		return;

	// Get access to entity and its visual
	CEntityAlive*			E = smart_cast<CEntityAlive*>(H_Parent());
	
	if (!E) {
		if (!IsGameTypeSingle())
			UpdatePosition	(H_Parent()->XFORM());

		return;
	}

	const CInventoryOwner	*parent = smart_cast<const CInventoryOwner*>(E);
	if (parent && parent->use_simplified_visual())
		return;

	if (parent->attached(this))
		return;

	IKinematics*			V = smart_cast<IKinematics*>	(E->Visual());
	VERIFY					(V);

	// Get matrices
	int						boneL = -1, boneR = -1, boneR2 = -1;

	// this ugly case is possible in case of a CustomMonster, not a Stalker, nor an Actor
	E->g_WeaponBones		(boneL,boneR,boneR2);

	if (boneR == -1)		return;

	if ((HandDependence() == hd1Hand) || (GetState() == eReload) || (!E->g_Alive()))
		boneL				= boneR2;

	V->CalculateBones		();
	Fmatrix& mL				= V->LL_GetTransform(u16(boneL));
	Fmatrix& mR				= V->LL_GetTransform(u16(boneR));
	// Calculate
	Fmatrix					mRes;
	Fvector					R,D,N;
	D.sub					(mL.c,mR.c);	

	if(fis_zero(D.magnitude())) {
		mRes.set			(E->XFORM());
		mRes.c.set			(mR.c);
	}
	else {		
		D.normalize			();
		R.crossproduct		(mR.j,D);

		N.crossproduct		(D,R);			
		N.normalize			();

		mRes.set			(R,N,D,mR.c);
		mRes.mulA_43		(E->XFORM());
	}

	UpdatePosition			(mRes);
}
Example #15
0
void CWeapon::UpdateAddonsVisibility()
{
	IKinematics* pWeaponVisual = smart_cast<IKinematics*>(Visual()); R_ASSERT(pWeaponVisual);

	u16  bone_id;
	UpdateHUDAddonsVisibility								();	

	pWeaponVisual->CalculateBones_Invalidate				();

	bone_id = pWeaponVisual->LL_BoneID					(wpn_scope);
	if(ScopeAttachable())
	{
		if(IsScopeAttached())
		{
			if(!pWeaponVisual->LL_GetBoneVisible		(bone_id))
			pWeaponVisual->LL_SetBoneVisible				(bone_id,TRUE,TRUE);
		}else{
			if(pWeaponVisual->LL_GetBoneVisible				(bone_id))
				pWeaponVisual->LL_SetBoneVisible			(bone_id,FALSE,TRUE);
		}
	}
	if(m_eScopeStatus==ALife::eAddonDisabled && bone_id!=BI_NONE && 
		pWeaponVisual->LL_GetBoneVisible(bone_id) )
	{
		pWeaponVisual->LL_SetBoneVisible					(bone_id,FALSE,TRUE);
//		Log("scope", pWeaponVisual->LL_GetBoneVisible		(bone_id));
	}
	bone_id = pWeaponVisual->LL_BoneID						(wpn_silencer);
	if(SilencerAttachable())
	{
		if(IsSilencerAttached()){
			if(!pWeaponVisual->LL_GetBoneVisible		(bone_id))
				pWeaponVisual->LL_SetBoneVisible			(bone_id,TRUE,TRUE);
		}else{
			if( pWeaponVisual->LL_GetBoneVisible			(bone_id))
				pWeaponVisual->LL_SetBoneVisible			(bone_id,FALSE,TRUE);
		}
	}
	if(m_eSilencerStatus==ALife::eAddonDisabled && bone_id!=BI_NONE && 
		pWeaponVisual->LL_GetBoneVisible(bone_id) )
	{
		pWeaponVisual->LL_SetBoneVisible					(bone_id,FALSE,TRUE);
//		Log("silencer", pWeaponVisual->LL_GetBoneVisible	(bone_id));
	}

	bone_id = pWeaponVisual->LL_BoneID						(wpn_grenade_launcher);
	if(GrenadeLauncherAttachable())
	{
		if(IsGrenadeLauncherAttached())
		{
			if(!pWeaponVisual->LL_GetBoneVisible		(bone_id))
				pWeaponVisual->LL_SetBoneVisible			(bone_id,TRUE,TRUE);
		}else{
			if(pWeaponVisual->LL_GetBoneVisible				(bone_id))
				pWeaponVisual->LL_SetBoneVisible			(bone_id,FALSE,TRUE);
		}
	}
	if(m_eGrenadeLauncherStatus==ALife::eAddonDisabled && bone_id!=BI_NONE && 
		pWeaponVisual->LL_GetBoneVisible(bone_id) )
	{
		pWeaponVisual->LL_SetBoneVisible					(bone_id,FALSE,TRUE);
//		Log("gl", pWeaponVisual->LL_GetBoneVisible			(bone_id));
	}
	

	pWeaponVisual->CalculateBones_Invalidate				();
	pWeaponVisual->CalculateBones							(TRUE);
}
Example #16
0
void	imotion_position::state_end( )
{
	VERIFY( shell );
	inherited::state_end( );
	
	CPhysicsShellHolder *obj= static_cast<CPhysicsShellHolder*>( shell->get_ElementByStoreOrder( 0 )->PhysicsRefObject() );
	VERIFY( obj );
	obj->processing_deactivate();
	shell->Enable();
	shell->setForce( Fvector().set( 0.f, 0.f, 0.f ) );
	shell->setTorque( Fvector().set( 0.f, 0.f, 0.f ) );

	shell->AnimToVelocityState( end_delta, default_l_limit * 10, default_w_limit * 10 );
#ifdef	DEBUG
	dbg_draw_state_end( shell );
#endif
	shell->remove_ObjectContactCallback( get_depth );
	IKinematics *K = shell->PKinematics();
	disable_update( false );
	disable_bone_calculation( *K, false );
	K->SetUpdateCallback( saved_visual_callback );
	deinit_bones();

	save_fixes( K );
	
	shell->EnabledCallbacks( TRUE );

	restore_fixes( );

	VERIFY( K );

	IKinematicsAnimated	*KA = smart_cast<IKinematicsAnimated*>( shell->PKinematics() );
	VERIFY( KA );
	update_callback.motion = 0;
	KA->SetUpdateTracksCalback( 0 );

#if 0

			DBG_OpenCashedDraw();
			shell->dbg_draw_geometry( 0.02, D3DCOLOR_ARGB( 255, 0, 255, 0 )  );
			DBG_DrawBones( *shell->get_ElementByStoreOrder( 0 )->PhysicsRefObject() );
			DBG_ClosedCashedDraw( 50000 );

#endif

	u16 root = K->LL_GetBoneRoot();
	if( root!=0 )
	{
		K->LL_GetTransform( 0 ).set( Fidentity );
		K->LL_SetBoneVisible( 0, FALSE, FALSE );
		u16 bip01 = K->LL_BoneID( "bip01" );
		if( bip01 != BI_NONE && bip01 != root )
		{
			K->LL_GetTransform( bip01 ).set( Fidentity );
			K->LL_SetBoneVisible( bip01, FALSE, FALSE );
		}
	}

	K->CalculateBones_Invalidate();
	K->CalculateBones( true );

#if 0 

			DBG_OpenCashedDraw();
			shell->dbg_draw_geometry( 0.02, D3DCOLOR_ARGB( 255, 0, 0, 255 )  );
			DBG_DrawBones( *shell->get_ElementByStoreOrder( 0 )->PhysicsRefObject() );
			DBG_ClosedCashedDraw( 50000 );

#endif
}
Example #17
0
void CInventoryItem::PH_A_CrPr		()
{
	if (m_just_after_spawn)
	{
		VERIFY(object().Visual());
		IKinematics *K = object().Visual()->dcast_PKinematics();
		VERIFY( K );
		if (!object().PPhysicsShell())
		{
			Msg("! ERROR: PhysicsShell is NULL, object [%s][%d]", object().cName().c_str(), object().ID());
			VERIFY2(0, "physical shell is NULL");
			return;
		}
		if(!object().PPhysicsShell()->isFullActive())
		{
			K->CalculateBones_Invalidate();
			K->CalculateBones(TRUE);
		}
		object().PPhysicsShell()->GetGlobalTransformDynamic(&object().XFORM());
		K->CalculateBones_Invalidate();
		K->CalculateBones(TRUE);
#if	0
		Fbox bb= BoundingBox	();
		DBG_OpenCashedDraw		();
		Fvector c,r,p;
		bb.get_CD(c,r );
		XFORM().transform_tiny(p,c);
		DBG_DrawAABB( p, r,D3DCOLOR_XRGB(255, 0, 0));
		//PPhysicsShell()->XFORM().transform_tiny(c);
		Fmatrix mm;
		PPhysicsShell()->GetGlobalTransformDynamic(&mm);
		mm.transform_tiny(p,c);
		DBG_DrawAABB( p, r,D3DCOLOR_XRGB(0, 255, 0));
		DBG_ClosedCashedDraw	(50000);
#endif
		object().spatial_move();
		m_just_after_spawn = false;
		
		VERIFY(!OnServer());
		
		object().PPhysicsShell()->get_ElementByStoreOrder(0)->Fix();
		object().PPhysicsShell()->SetIgnoreStatic	();	
		//object().PPhysicsShell()->SetIgnoreDynamic	();
		//PPhysicsShell()->DisableCollision();
	}
	/*net_updateData* p					= NetSync();
	//restore recalculated data and get data for interpolation	
	if (!object().CrPr_IsActivated())	return;
	////////////////////////////////////
	CPHSynchronize* pSyncObj			= NULL;
	pSyncObj = object().PHGetSyncItem	(0);
	if (!pSyncObj)						return;
	////////////////////////////////////
	pSyncObj->get_State					(p->PredictedState);
	////////////////////////////////////
	pSyncObj->set_State					(p->RecalculatedState);
	////////////////////////////////////

	if (!m_flags.test(FInInterpolate)) return;
	////////////////////////////////////
	Fmatrix xformX;
	pSyncObj->cv2obj_Xfrom(p->PredictedState.quaternion, p->PredictedState.position, xformX);

	VERIFY2								(_valid(xformX),*object().cName());
	pSyncObj->cv2obj_Xfrom				(p->PredictedState.quaternion, p->PredictedState.position, xformX);
	
	p->IEndRot.set						(xformX);
	p->IEndPos.set						(xformX.c);
	VERIFY2								(_valid(p->IEndPos),*object().cName());
	/////////////////////////////////////////////////////////////////////////
	CalculateInterpolationParams		();
	///////////////////////////////////////////////////*/
};
Example #18
0
BOOL CHelicopter::net_Spawn(CSE_Abstract*	DC)
{

    SetfHealth(100.0f);
    setState(CHelicopter::eAlive);
    m_flame_started					=false;
    m_light_started					=false;
    m_exploded						=false;
    m_ready_explode					=false;
    m_dead							=false;

    if (!inherited::net_Spawn(DC))
        return			(FALSE);

    CPHSkeleton::Spawn((CSE_Abstract*)(DC));
    for(u32 i=0; i<4; ++i)
        CRocketLauncher::SpawnRocket(*m_sRocketSection, smart_cast<CGameObject*>(this));

    // assigning m_animator here
    CSE_Abstract		*abstract	=(CSE_Abstract*)(DC);
    CSE_ALifeHelicopter	*heli		= smart_cast<CSE_ALifeHelicopter*>(abstract);
    VERIFY				(heli);

    R_ASSERT						(Visual()&&smart_cast<IKinematics*>(Visual()));
    IKinematics* K					= smart_cast<IKinematics*>(Visual());
    CInifile* pUserData				= K->LL_UserData();

    m_rotate_x_bone			= K->LL_BoneID	(pUserData->r_string("helicopter_definition","wpn_rotate_x_bone"));
    m_rotate_y_bone			= K->LL_BoneID	(pUserData->r_string("helicopter_definition","wpn_rotate_y_bone"));
    m_fire_bone				= K->LL_BoneID	(pUserData->r_string("helicopter_definition","wpn_fire_bone"));
    m_death_bones_to_hide	= pUserData->r_string("on_death_mode","scale_bone");
    m_left_rocket_bone		= K->LL_BoneID	(pUserData->r_string("helicopter_definition","left_rocket_bone"));
    m_right_rocket_bone		= K->LL_BoneID	(pUserData->r_string("helicopter_definition","right_rocket_bone"));

    m_smoke_bone 			= K->LL_BoneID	(pUserData->r_string("helicopter_definition","smoke_bone"));
    m_light_bone 			= K->LL_BoneID	(pUserData->r_string("helicopter_definition","light_bone"));

    CExplosive::Load		(pUserData,"explosion");
    CExplosive::SetInitiator(ID());

    LPCSTR s = pUserData->r_string("helicopter_definition","hit_section");

    if( pUserData->section_exist(s) ) {
        int lc = pUserData->line_count(s);
        LPCSTR name;
        LPCSTR value;
        s16 boneID;
        for (int i=0 ; i<lc; ++i) {
            pUserData->r_line( s, i, &name, &value);
            boneID	=K->LL_BoneID(name);
            m_hitBones.insert( std::make_pair(boneID, (float)atof(value)) );
        }
    }

    CBoneInstance& biX		= smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_x_bone);
    biX.set_callback		(bctCustom,BoneMGunCallbackX,this);
    CBoneInstance& biY		= smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_y_bone);
    biY.set_callback		(bctCustom,BoneMGunCallbackY,this);
    CBoneData& bdX			= K->LL_GetData(m_rotate_x_bone);
    VERIFY(bdX.IK_data.type==jtJoint);
    m_lim_x_rot.set			(bdX.IK_data.limits[0].limit.x,bdX.IK_data.limits[0].limit.y);
    CBoneData& bdY			= K->LL_GetData(m_rotate_y_bone);
    VERIFY(bdY.IK_data.type==jtJoint);
    m_lim_y_rot.set			(bdY.IK_data.limits[1].limit.x,bdY.IK_data.limits[1].limit.y);

    xr_vector<Fmatrix> matrices;
    K->LL_GetBindTransform	(matrices);
    m_i_bind_x_xform.invert	(matrices[m_rotate_x_bone]);
    m_i_bind_y_xform.invert	(matrices[m_rotate_y_bone]);
    m_bind_rot.x			= matrices[m_rotate_x_bone].k.getP();
    m_bind_rot.y			= matrices[m_rotate_y_bone].k.getH();
    m_bind_x.set			(matrices[m_rotate_x_bone].c);
    m_bind_y.set			(matrices[m_rotate_y_bone].c);

    IKinematicsAnimated	*A	= smart_cast<IKinematicsAnimated*>(Visual());
    if (A) {
        A->PlayCycle		(*heli->startup_animation);
        K->CalculateBones	(TRUE);
    }

    m_engineSound.create			(*heli->engine_sound,st_Effect,sg_SourceType);
    m_engineSound.play_at_pos		(0,XFORM().c,sm_Looped);

    CShootingObject::Light_Create	();


    setVisible						(TRUE);
    setEnabled						(TRUE);



    m_stepRemains						= 0.0f;

//lighting
    m_light_render						= ::Render->light_create();
    m_light_render->set_shadow			(false);
    m_light_render->set_type			(IRender_Light::POINT);
    m_light_render->set_range			(m_light_range);
    m_light_render->set_color			(m_light_color);

    if(g_Alive())processing_activate	();
    TurnEngineSound(false);
    if(pUserData->section_exist("destroyed"))
        CPHDestroyable::Load(pUserData,"destroyed");
#ifdef DEBUG
    Device.seqRender.Add(this,REG_PRIORITY_LOW-1);
#endif

    return TRUE;
}