BOOL CObject::net_Spawn (CSE_Abstract* data) { PositionStack.clear (); VERIFY (_valid(renderable.xform)); if (0==Visual() && pSettings->line_exist( cNameSect(), "visual" ) ) cNameVisual_set (pSettings->r_string( cNameSect(), "visual" ) ); if (0==collidable.model) { if (pSettings->line_exist(cNameSect(),"cform")) { //LPCSTR cf = pSettings->r_string (*cNameSect(), "cform"); VERIFY3 (*NameVisual, "Model isn't assigned for object, but cform requisted",*cName()); collidable.model = xr_new<CCF_Skeleton> (this); } } R_ASSERT(spatial.space); spatial_register(); if (register_schedule()) shedule_register (); // reinitialize flags //. Props.bActiveCounter = 0; processing_activate (); setDestroy (false); MakeMeCrow (); return TRUE ; }
// Lain: added Start/Stop idle light calls void CCustomZone::o_switch_2_fast () { if (m_zone_flags.test(eFastMode)) return ; m_zone_flags.set(eFastMode, TRUE); StartIdleLight(); processing_activate (); }
bool CCar::attach_Actor(CGameObject* actor) { if(Owner()||CPHDestroyable::Destroyed()) return false; CHolderCustom::attach_Actor(actor); IKinematics* K = smart_cast<IKinematics*>(Visual()); CInifile* ini = K->LL_UserData(); int id; if(ini->line_exist("car_definition","driver_place")) id=K->LL_BoneID(ini->r_string("car_definition","driver_place")); else { Owner()->setVisible(0); id=K->LL_GetBoneRoot(); } CBoneInstance& instance=K->LL_GetBoneInstance (u16(id)); m_sits_transforms.push_back(instance.mTransform); OnCameraChange(ectFirst); PPhysicsShell()->Enable(); PPhysicsShell()->add_ObjectContactCallback(ActorObstacleCallback); // VisualUpdate(); processing_activate(); ReleaseHandBreak(); // CurrentGameUI()->UIMainIngameWnd->CarPanel().Show(true); // CurrentGameUI()->UIMainIngameWnd->CarPanel().SetCarHealth(fEntityHealth/100.f); //CurrentGameUI()->UIMainIngameWnd.ShowBattery(true); //CBoneData& bone_data=K->LL_GetData(id); //Fmatrix driver_pos_tranform; //driver_pos_tranform.setHPB(bone_data.bind_hpb.x,bone_data.bind_hpb.y,bone_data.bind_hpb.z); //driver_pos_tranform.c.set(bone_data.bind_translate); //m_sits_transforms.push_back(driver_pos_tranform); //H_SetParent(actor); return true; }
void CAI_Crow::Die (CObject* who) { inherited::Die (who) ; processing_activate () ; // enable UpdateCL for dead crows - especially for physics support // and do it especially before Creating physics shell or it definitely throws processing enable/disable calls: underflow CreateSkeleton () ; };
void CPhysicObject::net_Import (NET_Packet& P) { u8 NumItems = 0; NumItems = P.r_u8(); if (!NumItems) return; CSE_ALifeObjectPhysic::mask_num_items num_items; num_items.common = NumItems; NumItems = num_items.num_items; /*if (num_items.mask & CSE_ALifeObjectPhysic::animated) { net_Import_Anim_Params(P); }*/ net_update_PItem N; N.dwTimeStamp = Device.dwTimeGlobal; net_Import_PH_Params(P,N,num_items); //////////////////////////////////////////// P.r_u8(); // freezed or not.. if (this->cast_game_object()->Local()) { return; } net_updatePhData *p = NetSync(); // if (!p->NET_IItem.empty() && (p->NET_IItem.back().dwTimeStamp>=N.dwTimeStamp)) // return; //if (!p->NET_IItem.empty()) //m_flags.set (FInInterpolate, TRUE); Level().AddObject_To_Objects4CrPr (this); //this->CrPr_SetActivated (false); //this->CrPr_SetActivationStep (0); p->NET_IItem.push_back (N); while (p->NET_IItem.size() > 2) { p->NET_IItem.pop_front (); } if (!m_activated) { #ifdef DEBUG Msg("Activating object [%d] before interpolation starts", ID()); #endif // #ifdef DEBUG processing_activate(); m_activated = true; } };
void CHangingLamp::TurnOn () { light_render->set_active (true); if (glow_render) glow_render->set_active (true); if (light_ambient) light_ambient->set_active (true); if (Visual()){ CKinematics* K = smart_cast<CKinematics*>(Visual()); K->LL_SetBoneVisible (light_bone, TRUE, TRUE); K->CalculateBones_Invalidate(); K->CalculateBones (); } processing_activate (); }
BOOL CWeaponStatMgun::net_Spawn(CSE_Abstract* DC) { if(!inheritedPH::net_Spawn (DC)) return FALSE; IKinematics* K = smart_cast<IKinematics*>(Visual()); CInifile* pUserData = K->LL_UserData(); R_ASSERT2 (pUserData,"Empty WeaponStatMgun user data!"); m_rotate_x_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_x_bone")); m_rotate_y_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_y_bone")); m_fire_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","fire_bone")); m_camera_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","camera_bone")); U16Vec fixed_bones; fixed_bones.push_back (K->LL_GetBoneRoot()); PPhysicsShell() = P_build_Shell(this,false,fixed_bones); 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_x_rot = matrices[m_rotate_x_bone].k.getP(); m_bind_y_rot = 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); m_cur_x_rot = m_bind_x_rot; m_cur_y_rot = m_bind_y_rot; m_destEnemyDir.setHP (m_bind_y_rot,m_bind_x_rot); XFORM().transform_dir (m_destEnemyDir); inheritedShooting::Light_Create(); processing_activate (); setVisible (TRUE); setEnabled (TRUE); return TRUE; }
//} void CBreakableObject::CreateBroken() { phys_shell_verify_object_model ( *this ); processing_activate(); m_Shell=P_create_splited_Shell(); m_Shell->preBuild_FromKinematics(smart_cast<IKinematics*>(Visual())); m_Shell->mXFORM.set(XFORM()); //m_Shell->SetAirResistance(0.002f*skel_airr_lin_factor, // 0.3f*skel_airr_ang_factor); m_Shell->set_PhysicsRefObject(this); m_Shell->Build(); m_Shell->setMass(m_Shell->getMass()*0.1f*100.f); //dMass m; //dMassSetBox(&m,m_Shell->getMass()/100.f,1.f,1.f,1.f); //m_Shell->addEquelInertiaToEls(m); m_Shell->MassAddBox( m_Shell->getMass()/100.f, Fvector().set(1,1,1) ); m_Shell->SmoothElementsInertia(0.3f); Fobb b; Visual()->getVisData().box.getradius(b.m_halfsize); m_Shell->SetMaxAABBRadius(_max(_max(b.m_halfsize.x,b.m_halfsize.y),b.m_halfsize.z)*2.f);//+2.f }
BOOL CHangingLamp::net_Spawn(CSE_Abstract* DC) { CSE_Abstract *e = (CSE_Abstract*)(DC); CSE_ALifeObjectHangingLamp *lamp = smart_cast<CSE_ALifeObjectHangingLamp*>(e); R_ASSERT (lamp); inherited::net_Spawn (DC); Fcolor clr; // set bone id // CInifile* pUserData = K->LL_UserData(); // R_ASSERT3 (pUserData,"Empty HangingLamp user data!",lamp->get_visual()); xr_delete(collidable.model); if (Visual()){ CKinematics* K = smart_cast<CKinematics*>(Visual()); R_ASSERT (Visual()&&smart_cast<CKinematics*>(Visual())); light_bone = K->LL_BoneID (*lamp->light_main_bone); VERIFY(light_bone!=BI_NONE); ambient_bone = K->LL_BoneID (*lamp->light_ambient_bone);VERIFY(ambient_bone!=BI_NONE); collidable.model = xr_new<CCF_Skeleton> (this); // alpet: загрузка иммунитетов из спавн-конфига CInifile* ini=K->LL_UserData(); if(ini && ini->section_exist("immunities")) CHitImmunity::LoadImmunities("immunities",ini); } fBrightness = lamp->brightness; clr.set (lamp->color); clr.a = 1.f; clr.mul_rgb (fBrightness); light_render = ::Render->light_create(); light_render->set_shadow(!!lamp->flags.is(CSE_ALifeObjectHangingLamp::flCastShadow)); light_render->set_type (lamp->flags.is(CSE_ALifeObjectHangingLamp::flTypeSpot)?IRender_Light::SPOT:IRender_Light::POINT); light_render->set_range (lamp->range); light_render->set_color (clr); light_render->set_cone (lamp->spot_cone_angle); light_render->set_texture(*lamp->light_texture); light_render->set_virtual_size(lamp->m_virtual_size); if (lamp->glow_texture.size()) { glow_render = ::Render->glow_create(); glow_render->set_texture(*lamp->glow_texture); glow_render->set_color (clr); glow_render->set_radius (lamp->glow_radius); } if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPointAmbient)){ ambient_power = lamp->m_ambient_power; light_ambient = ::Render->light_create(); light_ambient->set_type (IRender_Light::POINT); light_ambient->set_shadow(false); clr.mul_rgb (ambient_power); light_ambient->set_range(lamp->m_ambient_radius); light_ambient->set_color(clr); light_ambient->set_texture(*lamp->m_ambient_texture); light_ambient->set_virtual_size(lamp->m_virtual_size); } fHealth = lamp->m_health; lanim = LALib.FindItem(*lamp->color_animator); CPHSkeleton::Spawn(e); if (smart_cast<CKinematicsAnimated*>(Visual())) smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle("idle"); if (smart_cast<CKinematics*>(Visual())){ smart_cast<CKinematics*> (Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*> (Visual())->CalculateBones(); //.intepolate_pos } if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPhysic)&&!Visual()) Msg("! WARNING: lamp, obj name [%s],flag physics set, but has no visual",*cName()); //. if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPhysic)&&Visual()&&!guid_physic_bone) fHealth=0.f; if (Alive()) TurnOn (); else{ processing_activate (); // temporal enable TurnOff (); // -> and here is disable :) } setVisible ((BOOL)!!Visual()); setEnabled ((BOOL)!!collidable.model); return (TRUE); }
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; }