Example #1
0
bool CIKFoot::make_shift( Fmatrix &xm,const Fvector &cl_point, bool collide, const Fplane &p, const Fvector &pick_dir )const
{
	Fvector shift = pick_dir;

	//Fvector toe; ToePosition( toe ); xm.transform_tiny( toe );
	Fvector point;
	xm.transform_tiny( point, cl_point );
	float dot = p.n.dotproduct( shift );
	if( _abs( dot ) < min_dot )
	{
		shift.add( Fvector( ).mul( p.n, min_dot - _abs( dot ) ) );
		dot = p.n.dotproduct( shift );
	}
	VERIFY( !fis_zero( dot ) );
	float shift_m = ( -p.d - p.n.dotproduct( point ) )/dot;
	if(collide && shift_m > 0.f )
		return false;
	clamp( shift_m, -collide_dist, collide_dist );
	shift.mul( shift_m );
	xm.c.add( shift );
#if	0
	if(shift_m > 0.f)
	{
		DBG_OpenCashedDraw();
		DBG_DrawLine( toe, Fvector().add( toe, shift ), D3DCOLOR_XRGB( 255, 255, 255 )  );
		DBG_ClosedCashedDraw( 1000 );
	}
#endif
	return true;
}
Example #2
0
void CGameObject::OnRender			()
{
	if (!ai().get_level_graph())
		return;

	CDebugRenderer					&renderer = Level().debug_renderer();
	if (/**bDebug && /**/Visual()) {
		float						half_cell_size = 1.f*ai().level_graph().header().cell_size()*.5f;
		Fvector						additional = Fvector().set(half_cell_size,half_cell_size,half_cell_size);

		render_box					(Visual(),XFORM(),Fvector().set(0.f,0.f,0.f),true,color_rgba(0,0,255,255));
		render_box					(Visual(),XFORM(),additional,false,color_rgba(0,255,0,255));
	}

	if (0) {
		Fvector						bc,bd; 
		Visual()->getVisData().box.get_CD	(bc,bd);
		Fmatrix						M = Fidentity;
		float						half_cell_size = ai().level_graph().header().cell_size()*.5f;
		bd.add						(Fvector().set(half_cell_size,half_cell_size,half_cell_size));
		M.scale						(bd);
		Fmatrix						T = XFORM();
		T.c.add						(bc);
		renderer.draw_obb			(T,bd,color_rgba(255,255,255,255));
	}
}
Example #3
0
void CUISequenceVideoItem::Update()
{
	// deferred start
	if (Device.dwTimeContinual>=m_time_start){
		if (m_flags.test(etiDelayed)){
			m_owner->MainWnd()->AttachChild	(m_wnd);
			m_wnd->Show		(true);
			m_flags.set		(etiDelayed,FALSE);
		}
	}else return;

	u32 sync_tm				= (0==m_sound[0]._handle())?Device.dwTimeContinual:(m_sound[0]._feedback()?m_sound[0]._feedback()->play_time():m_sync_time);
	m_sync_time				= sync_tm;
	// processing A&V
	if (m_texture){
		BOOL is_playing		= m_sound[0]._handle()?!!m_sound[0]._feedback():m_texture->video_IsPlaying();
		if (is_playing){
			m_texture->video_Sync		(m_sync_time);
		}else{
			// sync start
			if (m_flags.test(etiNeedStart)){
				m_sound[0].play_at_pos	(NULL, Fvector().set(-0.5f,0.f,0.3f), sm_2D);
				m_sound[1].play_at_pos	(NULL, Fvector().set(+0.5f,0.f,0.3f), sm_2D);
				m_texture->video_Play	(FALSE,m_sync_time);
				m_flags.set				(etiNeedStart,FALSE);
				CUIWindow* w			= m_owner->MainWnd()->FindChild("back");
				if (w)					w->Show(!!m_flags.test(etiBackVisible));
			}else{
				m_flags.set				(etiPlaying,FALSE);
			}
		}
	}
}
Example #4
0
void	CIKFoot::SetFootGeom		( ik_foot_geom &fg, const Fmatrix &ref_bone, const Fmatrix& object_matrix ) const
{
	Fmatrix gl_bone; gl_bone.mul_43( object_matrix, ref_bone );

	Fvector pos_toe; ToePosition( pos_toe );
	gl_bone.transform_tiny( pos_toe );

	Fvector heel;  Fvector	 pos_hill;
	Fmatrix foot =( Fmatrix( ).mul_43( object_matrix, ref_bone_to_foot( foot, ref_bone ) ) );
	foot.transform_tiny( pos_hill, HeelPosition( heel ) );
	const Fvector v_m = Fvector().add(pos_toe, pos_hill ).mul(0.5f) ;
	
	Fvector normal, direction;
	get_local_vector( normal, m_foot_normal );
	get_local_vector( direction, m_foot_direction );
	
	Fvector v_side =  Fvector().crossproduct( normal, direction );
	gl_bone.transform_dir ( v_side );
	float vsm = v_side.magnitude();
	VERIFY( vsm > EPS_L );
	v_side.mul( Fvector().sub(pos_toe, pos_hill ).magnitude()/vsm );

	fg.set( pos_toe, pos_hill, Fvector().add( v_m, v_side ) ); 

}
Example #5
0
BOOL CPPEffectorControllerAura::update()
{
	// update factor
	if (m_effector_state == eStatePermanent) {
		m_factor = 1.f;
	} else {
		m_factor = float(Device.dwTimeGlobal - m_time_state_started) / float(m_time_to_fade);
		if (m_effector_state == eStateFadeOut) m_factor = 1 - m_factor;

		if (m_factor > 1) {
			m_effector_state	= eStatePermanent;
			m_factor			= 1.f;
		} else if (m_factor < 0) {
			if (m_snd_left._feedback())		m_snd_left.stop();
			if (m_snd_right._feedback())	m_snd_right.stop();
		
			return FALSE;
		}
	}

	// start new or play again?
	if (!m_snd_left._feedback() && !m_snd_right._feedback()) {
		m_snd_left.play_at_pos	(Actor(), Fvector().set(-1.f, 0.f, 1.f), sm_Looped | sm_2D);
		m_snd_right.play_at_pos	(Actor(), Fvector().set(-1.f, 0.f, 1.f), sm_Looped | sm_2D);
	} 

	if (m_snd_left._feedback())		m_snd_left.set_volume	(m_factor);
	if (m_snd_right._feedback())	m_snd_right.set_volume	(m_factor);

	return TRUE;
}
void CCustomDetector::OnStateSwitch(u32 S)
{
	inherited::OnStateSwitch(S);

	switch(S)
	{
	case eShowing:
		{
			g_player_hud->attach_item	(this);
			m_sounds.PlaySound			("sndShow", Fvector().set(0,0,0), this, true, false);
			PlayHUDMotion				(m_bFastAnimMode?"anm_show_fast":"anm_show", TRUE, this, GetState());
			SetPending					(TRUE);
		}break;
	case eHiding:
		{
			m_sounds.PlaySound			("sndHide", Fvector().set(0,0,0), this, true, false);
			PlayHUDMotion				(m_bFastAnimMode?"anm_hide_fast":"anm_hide", TRUE, this, GetState());
			SetPending					(TRUE);
		}break;
	case eIdle:
		{
			PlayAnimIdle				();
			SetPending					(FALSE);
		}break;
}
}
Example #7
0
void CControllerPsyHit::set_sound_state(ESoundState state)
{
	CController *monster = smart_cast<CController *>(m_object);
	if (state == ePrepare) {
		monster->m_sound_tube_prepare.play_at_pos(Actor(), Fvector().set(0.f, 0.f, 0.f), sm_2D);
	} else 
	if (state == eStart) {
		if (monster->m_sound_tube_prepare._feedback())	monster->m_sound_tube_prepare.stop();

		monster->m_sound_tube_start.play_at_pos(Actor(), Fvector().set(0.f, 0.f, 0.f), sm_2D);
		monster->m_sound_tube_pull.play_at_pos(Actor(), Fvector().set(0.f, 0.f, 0.f), sm_2D);
	} else 
	if (state == eHit) {
		if (monster->m_sound_tube_start._feedback())	monster->m_sound_tube_start.stop();
		if (monster->m_sound_tube_pull._feedback())		monster->m_sound_tube_pull.stop();
		
		//monster->m_sound_tube_hit_left.play_at_pos(Actor(), Fvector().set(-1.f, 0.f, 1.f), sm_2D);
		//monster->m_sound_tube_hit_right.play_at_pos(Actor(), Fvector().set(1.f, 0.f, 1.f), sm_2D);
	} else 
	if (state == eNone) {
		if (monster->m_sound_tube_start._feedback())	monster->m_sound_tube_start.stop();
		if (monster->m_sound_tube_pull._feedback())		monster->m_sound_tube_pull.stop();
		if (monster->m_sound_tube_prepare._feedback())	monster->m_sound_tube_prepare.stop();
	}

	m_sound_state = state;
}
Example #8
0
	void operator () (const Fvector& p)
	{
		Fvector lpos;
		i_bind_transform.transform_tiny(lpos, p );
		//Fvector diff;diff.sub( lpos, pos );
		if( Fvector().sub( lpos, start_pos ).dotproduct( ax ) > Fvector().sub( pos, start_pos ).dotproduct( ax ) )
						pos.set( lpos );
	}
Example #9
0
bool CSnork::trace_geometry(const Fvector &d, float &range)
{
	Fvector				dir;
	float				h, p;

	Fvector				Pl,Pc,Pr;
	Fvector				center;
	Center				(center);

	range				= trace (d);
	if (range > TRACE_RANGE) return false;
	
	float angle			= asin(1.f / range);

	// trace center ray
	dir					= d;

	dir.getHP			(h,p);
	p					+= angle;
	dir.setHP			(h,p);
	dir.normalize_safe	();

	range				= trace (dir);
	if (range > TRACE_RANGE) return false;

	Pc.mad				(center, dir, range);

	// trace left ray
	Fvector				temp_p;
	temp_p.mad			(Pc, XFORM().i, Radius() / 2);
	dir.sub				(temp_p, center);
	dir.normalize_safe	();

	range				= trace (dir);
	if (range > TRACE_RANGE) return false;

	Pl.mad				(center, dir, range);

	// trace right ray
	Fvector inv			= XFORM().i; 
	inv.invert			();
	temp_p.mad			(Pc, inv, Radius() / 2);
	dir.sub				(temp_p, center);
	dir.normalize_safe	();

	range				= trace (dir);
	if (range > TRACE_RANGE) return false;

	Pr.mad				(center, dir, range);

	float				h1,p1,h2,p2;

	Fvector().sub(Pl, Pc).getHP(h1,p1);
	Fvector().sub(Pc, Pr).getHP(h2,p2);

	return (fsimilar(h1,h2,0.1f) && fsimilar(p1,p2,0.1f));
}
Example #10
0
	ik_pick_result(ik_foot_geom::e_collide_point _point): 
		p(invalide_plane),
		point( _point ),
		position( Fvector().set( -FLT_MAX, -FLT_MAX, -FLT_MAX ) )
	{
		triangle[0] = Fvector().set( -FLT_MAX, -FLT_MAX, -FLT_MAX );
		triangle[1] = Fvector().set( -FLT_MAX, -FLT_MAX, -FLT_MAX );
		triangle[2] = Fvector().set( -FLT_MAX, -FLT_MAX, -FLT_MAX );
	}
void CControlManagerCustom::check_jump_over_physics()
{
	if (!m_man->path_builder().is_moving_on_path()) return;
	if (!m_man->check_start_conditions(ControlCom::eControlJump)) return;
	if (!m_object->check_start_conditions(ControlCom::eControlJump)) return;
	if (m_object->GetScriptControl()) return;

	Fvector prev_pos	= m_object->Position();
	float	dist_sum	= 0.f;

	for(u32 i = m_man->path_builder().detail().curr_travel_point_index(); i<m_man->path_builder().detail().path().size();i++) {
		const DetailPathManager::STravelPathPoint &travel_point = m_man->path_builder().detail().path()[i];

		// получить список объектов вокруг врага
		m_nearest.clear_not_free		();
		Level().ObjectSpace.GetNearest	(m_nearest,travel_point.position, m_object->Radius(), NULL);

		for (u32 k=0;k<m_nearest.size();k++) {
			CPhysicsShellHolder *obj = smart_cast<CPhysicsShellHolder *>(m_nearest[k]);
			if (!obj || !obj->PPhysicsShell() || !obj->PPhysicsShell()->isActive() || (obj->Radius() < 0.5f)) continue;
			if (m_object->Position().distance_to(obj->Position()) < MAX_DIST_SUM / 2) continue;

			Fvector dir = Fvector().sub(travel_point.position, m_object->Position());

			// проверка на  Field-Of-View
			float	my_h	= m_object->Direction().getH();
			float	h		= dir.getH();

			float from	= angle_normalize(my_h - deg(8));
			float to	= angle_normalize(my_h + deg(8));

			if (!is_angle_between(h, from, to)) continue;

			dir = Fvector().sub(obj->Position(), m_object->Position());

			// вычислить целевую позицию для прыжка
			Fvector target;
			obj->Center(target);
			target.y += obj->Radius();
			// --------------------------------------------------------

			m_jump->setup_data().flags.set			(SControlJumpData::ePrepareSkip, true);
			m_jump->setup_data().target_object		= 0;
			m_jump->setup_data().target_position	= target;

			jump(m_jump->setup_data());

			return;
		}

		dist_sum += prev_pos.distance_to(travel_point.position);
		if (dist_sum > MAX_DIST_SUM) break;

		prev_pos = travel_point.position;
	}
}
Example #12
0
Fvector	CScriptGameObject::head_orientation		() const
{
	CAI_Stalker		*stalker = smart_cast<CAI_Stalker*>(&object());
	if (!stalker) {
		ai().script_engine().script_log	(ScriptStorage::eLuaMessageTypeError,"CScriptGameObject : cannot access class member head_orientation!");
		return		(Fvector().set(flt_max,flt_max,flt_max));
	}
	const SRotation	&r = stalker->movement().head_orientation().current;
	return			(Fvector().setHP(-r.yaw,-r.pitch));
}
Example #13
0
void CRadioactiveZone::feel_touch_new					(CObject* O	)
{
	inherited::feel_touch_new(O);
	if (GameID() != GAME_SINGLE)
	{
		if (O->CLS_ID == CLSID_OBJECT_ACTOR)
		{
			CreateHit(O->ID(),ID(),Fvector().set(0, 0, 0),0.0f,BI_NONE,Fvector().set(0, 0, 0),0.0f,ALife::eHitTypeRadiation);
		}
	};
};
Example #14
0
void CRadioactiveZone::feel_touch_new					(CObject* O	)
{
	inherited::feel_touch_new(O);
	if (GameID() != eGameIDSingle)
	{
		if (smart_cast<CActor*>(O))
		{
			CreateHit(O->ID(),ID(),Fvector().set(0, 0, 0),0.0f,BI_NONE,Fvector().set(0, 0, 0),0.0f,m_eHitTypeBlowout);// ALife::eHitTypeRadiation
		}
	};
};
Example #15
0
void ESceneObjectTools::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark)
{
	if (tex_name&&tex_name[0]){
        for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){
            CSceneObject* s_obj		= dynamic_cast<CSceneObject*>(*a_it);
            CEditableObject* e_obj	= s_obj->GetReference(); VERIFY(e_obj);
            SurfaceVec& s_vec		= e_obj->Surfaces();
            for (SurfaceIt it=s_vec.begin(); it!=s_vec.end(); it++){
                if (0==stricmp((*it)->_Texture(),tex_name)){
					Fvector 		verts[3];
					for (EditMeshIt mesh_it=e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++){
                    	SurfFaces& 		surf_faces	= (*mesh_it)->GetSurfFaces();
                    	SurfFacesPairIt sf_it 		= surf_faces.find(*it);
                        if (sf_it!=surf_faces.end()){
                            IntVec& lst				= sf_it->second;
                            for (IntIt i_it=lst.begin(); i_it!=lst.end(); i_it++){
                                e_obj->GetFaceWorld	(s_obj->_Transform(),*mesh_it,*i_it,verts);
                                u32 clr	= 0x80FFFFFF;
                                if (allow_ratio){
                                	// select color
                                    const Fvector2* tc[3];
                                    Fvector 		c,e01,e02;
                                    e01.sub			(verts[1],verts[0]);
                                    e02.sub			(verts[2],verts[0]);
                                    float area		= c.crossproduct(e01,e02).magnitude()/2.f;
                                    (*mesh_it)->GetFaceTC(*i_it,tc);
                                    e01.sub			(Fvector().set(tc[1]->x,tc[1]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0));
                                    e02.sub			(Fvector().set(tc[2]->x,tc[2]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0));
                                    float p_area	= c.crossproduct(e01,e02).magnitude()/2.f;
                                    float ratio		= _sqrt((p_area*t_width*t_height)/area);
                                    int idx_clr		= 4;
                                    float w			= 0.f;
                                    if (ratio>=0.f && ratio<50.f) 			{idx_clr=0; w=ratio/30.f;}
                                    else if (ratio>=50.f && ratio<150.f) 	{idx_clr=1; w=(ratio-30.f)/150.f;}
                                    else if (ratio>=150.f && ratio<250.f) 	{idx_clr=2; w=(ratio-150.f)/250.f;}
                                    else if (ratio>=250.f && ratio<500.f) 	{idx_clr=3; w=(ratio-250.f)/500.f;}
                                    float inv_w		= 1.f-w;
                                    clr				= color_rgba(color_get_R(ratio_colors[idx_clr+0])*inv_w+color_get_R(ratio_colors[idx_clr+1])*w,
                                    							 color_get_G(ratio_colors[idx_clr+0])*inv_w+color_get_G(ratio_colors[idx_clr+1])*w,
                                                                 color_get_B(ratio_colors[idx_clr+0])*inv_w+color_get_B(ratio_colors[idx_clr+1])*w,
                                                                 color_get_A(ratio_colors[idx_clr+0])*inv_w+color_get_A(ratio_colors[idx_clr+1])*w);
                                }
                                Tools->m_DebugDraw.AppendSolidFace(verts[0],verts[1],verts[2],clr,false);
                                if (mark)	Tools->m_DebugDraw.AppendWireFace(verts[0],verts[1],verts[2],clr,false);
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #16
0
CPPEffectorControllerAura::CPPEffectorControllerAura(const SPPInfo &ppi, u32 time_to_fade, const ref_sound &snd_left, const ref_sound &snd_right)
: inherited(ppi)
{
	m_time_to_fade			= time_to_fade;
	m_effector_state		= eStateFadeIn;
	m_time_state_started	= Device.dwTimeGlobal;

	m_snd_left.clone		(snd_left,st_Effect,sg_SourceType);	
	m_snd_right.clone		(snd_right,st_Effect,sg_SourceType);	

	m_snd_left.play_at_pos	(Actor(), Fvector().set(-1.f, 0.f, 1.f), sm_Looped | sm_2D);
	m_snd_right.play_at_pos	(Actor(), Fvector().set(-1.f, 0.f, 1.f), sm_Looped | sm_2D);

}
Example #17
0
void CElevatorState::UpdateStClimbingDown()
{
	VERIFY(m_ladder&&m_character);
	Fvector d;
	
	if(ClimbDirection()>0.f&&m_ladder->BeforeLadder(m_character))
		SwitchState(clbClimbingUp);
	float to_ax=m_ladder->DDToAxis(m_character,d);
	Fvector ca;ca.set(m_character->ControlAccel());
	float  control_a=to_mag_and_dir(ca);
	if(!fis_zero(to_ax)&&!fis_zero(control_a)&&abs(-ca.dotproduct(Fvector(m_ladder->Norm()).normalize()))<M_SQRT1_2)SwitchState(clbDepart);
	if(m_ladder->AxDistToLowerP(m_character)-m_character->FootRadius()<stop_climbing_dist)
		SwitchState(clbNearDown);
	UpdateClimbingCommon(d,to_ax,ca,control_a);

	if(m_ladder->AxDistToUpperP(m_character)<-m_character->FootRadius())SwitchState(clbNoLadder);

	Fvector vel;
	m_character->GetVelocity(vel);
	if(vel.y>EPS_S)
	{
		m_character->ApplyForce(0.f,-m_character->Mass()*ph_world->Gravity(),0.f);
	}
	//if(to_ax-m_character->FootRadius()>out_dist)
	//														SwitchState((clbNone));
	//if(fis_zero(control_a)) 
	//	m_character->ApplyForce(d,m_character->Mass());
}
Example #18
0
bool   accessible_epsilon (CBaseMonster * const object, Fvector const pos, float epsilon)
{
	Fvector const offsets[]			=	{	Fvector().set( 0.f,			0.f,	0.f),
											Fvector().set(- epsilon, 	0.f,  	0.f),
											Fvector().set(+ epsilon, 	0.f,  	0.f),
											Fvector().set( 0.f,			0.f, 	- epsilon),
											Fvector().set( 0.f,			0.f, 	+ epsilon)	};
	
	for ( u32 i=0; i<sizeof(offsets)/sizeof(offsets[0]); ++i )
	{
		if ( object->movement().restrictions().accessible(pos + offsets[i]) )
			return						true;
	}

	return								false;
}
Example #19
0
ik_goal_matrix::e_collide_state	 CIKFoot::CollideFoot( float angle, float &out_angle, const Fvector	&global_toe, const Fvector	&foot_normal,  const Fvector	&global_bone_pos, const Fplane &p, const Fvector &ax )const
{

	float	dfoot_tri		=-p.d - p.n.dotproduct( global_bone_pos );												// dist from foot bone pos to tri plain
	Fvector	axp;			axp.sub( global_toe, global_bone_pos );	
	float	dfoot_toe		=p.n.dotproduct( axp );
	out_angle = angle;
	if( dfoot_tri < m_foot_width * _abs( foot_normal.dotproduct( p.n ) ) )
		return ik_goal_matrix::cl_aligned;
	axp.sub( Fvector( ).mul( ax, axp.dotproduct( ax ) ) );															//vector from nc_toe to ax
	float	dtoe_ax = axp.magnitude();	

	out_angle = 0.f;

	if( dtoe_ax<EPS_S )
		return ik_goal_matrix::cl_free;
	if( dfoot_toe > dtoe_ax - EPS_S )
		return ik_goal_matrix::cl_free;
	if( dfoot_toe < dfoot_tri )
		return ik_goal_matrix::cl_free;

	float ang_nc	= acosf( dfoot_toe/dtoe_ax );
	float ang_c		= acosf( dfoot_tri/dtoe_ax );
	out_angle = -( ang_c - ang_nc );
	return ik_goal_matrix::cl_rotational;
}
Example #20
0
void CCustomZone::PlayHitParticles(CGameObject* pObject)
{
	m_hit_sound.play_at_pos(0, pObject->Position());

	shared_str particle_str = NULL;

	if(pObject->Radius()<SMALL_OBJECT_RADIUS)
	{
		if(!m_sHitParticlesSmall) return;
		particle_str = m_sHitParticlesSmall;
	}
	else
	{
		if(!m_sHitParticlesBig) return;
		particle_str = m_sHitParticlesBig;
	}

	if( particle_str.size() )
	{
		CParticlesPlayer* PP = smart_cast<CParticlesPlayer*>(pObject);
		if (PP){
			u16 play_bone = PP->GetRandomBone(); 
			if (play_bone!=BI_NONE)
				PP->StartParticles	(particle_str,play_bone,Fvector().set(0,1,0), ID());
		}
	}
}
Example #21
0
void SArtefactDetectorsSupport::SetVisible(bool b)
{
	m_switchVisTime			= Device.dwTimeGlobal; 
	if(b == !!m_parent->getVisible())	return;
	
	if(b)
		m_parent->StartLights	();
	else
		m_parent->StopLights	();

	if(b)
	{
		LPCSTR curr				= pSettings->r_string(m_parent->cNameSect().c_str(), (b)?"det_show_particles":"det_hide_particles");

		IKinematics* K			= smart_cast<IKinematics*>(m_parent->Visual());
		R_ASSERT2				(K, m_parent->cNameSect().c_str());
		LPCSTR bone				= pSettings->r_string(m_parent->cNameSect().c_str(), "particles_bone");
		u16 bone_id				= K->LL_BoneID(bone);
		R_ASSERT2				(bone_id!=BI_NONE, bone);

		m_parent->CParticlesPlayer::StartParticles(curr,bone_id,Fvector().set(0,1,0),m_parent->ID());

		curr					= pSettings->r_string(m_parent->cNameSect().c_str(), (b)?"det_show_snd":"det_hide_snd");
		m_sound.create			(curr, st_Effect, sg_SourceType);
		m_sound.play_at_pos		(0, m_parent->Position(), 0);
	}
	
	m_parent->setVisible	(b);
	m_parent->SwitchAfParticles(b);
}
Example #22
0
void ESceneAIMapTool::GetBBox(Fbox& bb, bool bSelOnly)
{
    switch (LTools->GetSubTarget()){
    case estAIMapNode:{
    	if (bSelOnly){
            for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++)
                if ((*it)->flags.is(SAINode::flSelected)){
                	bb.modify(Fvector().add((*it)->Pos,-m_Params.fPatchSize*0.5f));
                	bb.modify(Fvector().add((*it)->Pos,m_Params.fPatchSize*0.5f));
                }
        }else{
        	bb.merge		(m_AIBBox);
        }
    }break;
    }
}
Example #23
0
void CIKLimb::Collide(SCalculateData* cd)
{

	Fvector pos;
	CKinematics* K=cd->m_K;
	K->LL_GetTransform(m_bones[2]).transform_tiny(pos,m_toe_position);//!!

	cd->m_obj->transform_tiny(pos);
	pos.y+=peak_dist;

	collide::rq_result	R;
	CGameObject *O=(CGameObject*)K->Update_Callback_Param;
	if(g_pGameLevel->ObjectSpace.RayPick( pos, Fvector().set(0,-1,0), peak_dist+0.5f, collide::rqtBoth, R, O))
	{
		if(!R.O)
		{
			//Fvector*	pVerts	= Level().ObjectSpace.GetStaticVerts();
			cd->m_tri	= Level().ObjectSpace.GetStaticTris() + R.element;
			//normal.mknormal	(pVerts[pTri->verts[0]],pVerts[pTri->verts[1]],pVerts[pTri->verts[2]]);
			cd->m_tri_hight=peak_dist-R.range;
			return;
		}
	}


}
Example #24
0
void CParticlesPlayer::LoadParticles(CKinematics* K)
{
    VERIFY				(K);

    m_Bones.clear();


    //считать список косточек и соответствующих
    //офсетов  куда можно вешать партиклы
    CInifile* ini		= K->LL_UserData();
    if(ini&&ini->section_exist("particle_bones")) {
        bone_mask		= 0;
        CInifile::Sect& data		= ini->r_section("particle_bones");
        for (CInifile::SectIt I=data.begin(); I!=data.end(); I++) {
            CInifile::Item& item	= *I;
            u16 index				= K->LL_BoneID(*item.first);
            R_ASSERT3(index != BI_NONE, "Particles bone not found", *item.first);
            Fvector					offs;
            sscanf					(*item.second,"%f,%f,%f",&offs.x,&offs.y,&offs.z);
            m_Bones.push_back		(SBoneInfo(index,offs));
            bone_mask				|= u64(1)<<u64(index);
        }
    }
    if(m_Bones.empty())
    {
        bone_mask			= u64(1)<<u64(0);
        m_Bones.push_back	(SBoneInfo(K->LL_GetBoneRoot(),Fvector().set(0,0,0)));
    }
}
Example #25
0
void CBaseMonster::Hit_Psy(CObject *object, float value) 
{
	NET_Packet		P;
	SHit			HS;
	HS.GenHeader		(GE_HIT, object->ID());				//					//	u_EventGen		(P,GE_HIT, object->ID());				// 
	HS.whoID			= (ID());									// own		//	P.w_u16			(ID());									// own
	HS.weaponID			= (ID());									// own		//	P.w_u16			(ID());									// own
	HS.dir				= (Fvector().set(0.f,1.f,0.f));			// direction	//	P.w_dir			(Fvector().set(0.f,1.f,0.f));			// direction
	HS.power			= (value);								// hit value	//	P.w_float		(value);								// hit value
	HS.boneID			= (BI_NONE);								// bone		//	P.w_s16			(BI_NONE);								// bone
	HS.p_in_bone_space	= (Fvector().set(0.f,0.f,0.f));							//	P.w_vec3		(Fvector().set(0.f,0.f,0.f));			
	HS.impulse			= (0.f);												//	P.w_float		(0.f);									
	HS.hit_type			= (ALife::eHitTypeTelepatic);							//	P.w_u16			(u16(ALife::eHitTypeTelepatic));
	HS.Write_Packet	(P);
	u_EventSend		(P);
}
Example #26
0
void CCustomZone::PlayObjectIdleParticles(CGameObject* pObject)
{
	CParticlesPlayer* PP = smart_cast<CParticlesPlayer*>(pObject);
	if(!PP) return;

	shared_str particle_str = NULL;

	//разные партиклы для объектов разного размера
	if(pObject->Radius()<SMALL_OBJECT_RADIUS)
	{
		if(!m_sIdleObjectParticlesSmall) return;
		particle_str = m_sIdleObjectParticlesSmall;
	}
	else
	{
		if(!m_sIdleObjectParticlesBig) return;
		particle_str = m_sIdleObjectParticlesBig;
	}

	
	//запустить партиклы на объекте
	//. new
	PP->StopParticles (particle_str, BI_NONE, true);

	PP->StartParticles (particle_str, Fvector().set(0,1,0), ID());
	if (!IsEnabled())
		PP->StopParticles	(particle_str, BI_NONE, true);
}
Example #27
0
void	CBurer::Hit								(SHit* pHDS)
{
	if ( m_shield_active							&& 
		 pHDS->hit_type == ALife::eHitTypeFireWound	&& 
		 Device.dwFrame != last_hit_frame				) 
	{
		// вычислить позицию и направленность партикла
		Fmatrix pos; 
		//CParticlesPlayer::MakeXFORM(this,element,Fvector().set(0.f,0.f,1.f),p_in_object_space,pos);
		CParticlesPlayer::MakeXFORM					(this,pHDS->bone(),pHDS->dir,pHDS->p_in_bone_space,pos);

		// установить particles
		CParticlesObject* ps					=	CParticlesObject::Create(particle_fire_shield,TRUE);
		
		ps->UpdateParent							(pos,Fvector().set(0.f,0.f,0.f));
		GamePersistent().ps_needtoplay.push_back	(ps);

	} 
	else if ( !m_shield_active )
	{
		inherited::Hit								(pHDS);
	}

	last_hit_frame								=	Device.dwFrame;
}
Example #28
0
void	imotion_position::rootbone_callback	( CBoneInstance *BI )
{
	imotion_position *im = ( imotion_position* )BI->callback_param();
	VERIFY( im );
	if( !im->update_callback.update )
		return;
	VERIFY( im->shell );
	IKinematics *K  = im->shell->PKinematics( );
	VERIFY( K );
	IKinematicsAnimated *KA = smart_cast<IKinematicsAnimated *>( K );
	VERIFY( KA );
	SKeyTable	keys;
	KA->LL_BuldBoneMatrixDequatize( &K->LL_GetData( 0 ), u8(-1), keys );
	
	CKey *key = 0;
	for( int i = 0; i < keys.chanel_blend_conts[0]; ++i )
	{
		if ( keys.blends[0][i] == im->blend)
			key = &keys.keys[0][i];
	}
	if( key )
	{
		key->Q.rotation( Fvector().set( 0, 1, 0 ), im->angle );
	}
	KA->LL_BoneMatrixBuild( *BI, &Fidentity, keys );

	R_ASSERT2( _valid(BI->mTransform), "imotion_position::rootbone_callback" );
}
Example #29
0
bool	CTeleWhirlwindObject::destroy_object		(const Fvector dir,float val) 
{
	CPHDestroyable* D=object->ph_destroyable();
	if(D)
	{
		D->PhysicallyRemoveSelf();
		D->Destroy(m_telekinesis->OwnerObject()->ID());
		
//.		m_telekinesis->add_impact(dir,val*10.f);

		xr_vector<shared_str>::iterator i = D->m_destroyed_obj_visual_names.begin();
		xr_vector<shared_str>::iterator e = D->m_destroyed_obj_visual_names.end();
		if (IsGameTypeSingle())
		{
			for(;e!=i;i++)
				m_telekinesis->add_impact(dir,val*10.f);
		};	


		CParticlesPlayer* PP = smart_cast<CParticlesPlayer*>(object);
		if(PP)
		{
			u16 root=(smart_cast<IKinematics*>(object->Visual()))->LL_GetBoneRoot();
			PP->StartParticles(m_telekinesis->destroing_particles(),root, Fvector().set(0,1,0),m_telekinesis->OwnerObject()->ID());
		}
		return true;
	}
	return false;
}
Example #30
0
u32	CScriptGameObject::vertex_in_direction(u32 level_vertex_id, Fvector direction, float max_distance) const
{
    CCustomMonster	*monster = smart_cast<CCustomMonster*>(&object());
    if (!monster)
    {
        ai().script_engine().script_log(ScriptStorage::eLuaMessageTypeError, "CCustomMonster : cannot access class member vertex_in_direction!");
        return		(u32(-1));
    }

    if (!monster->movement().restrictions().accessible(level_vertex_id))
    {
        ai().script_engine().script_log(ScriptStorage::eLuaMessageTypeError, "CCustomMonster::vertex_in_direction - start vertex id is not accessible!");
        return		(u32(-1));
    }

    direction.normalize_safe();
    direction.mul(max_distance);
    Fvector			start_position = ai().level_graph().vertex_position(level_vertex_id);
    Fvector			finish_position = Fvector(start_position).add(direction);
    u32				result = u32(-1);
    monster->movement().restrictions().add_border(level_vertex_id, max_distance);
    ai().level_graph().farthest_vertex_in_direction(level_vertex_id, start_position, finish_position, result, 0, true);
    monster->movement().restrictions().remove_border();
    return			(ai().level_graph().valid_vertex_id(result) ? result : level_vertex_id);
}