本文整理汇总了C++中CKinematics类的典型用法代码示例。如果您正苦于以下问题:C++ CKinematics类的具体用法?C++ CKinematics怎么用?C++ CKinematics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CKinematics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grenade_hit_callback
//проверка на попадание "осколком" по объекту
ICF static BOOL grenade_hit_callback(collide::rq_result& result, LPVOID params)
{
SExpQParams& ep = *(SExpQParams*)params;
u16 mtl_idx = GAMEMTL_NONE_IDX;
if(result.O){
CKinematics* V = 0;
if (0!=(V=smart_cast<CKinematics*>(result.O->Visual()))){
CBoneData& B= V->LL_GetData((u16)result.element);
mtl_idx = B.game_mtl_idx;
}
}else{
//получить треугольник и узнать его материал
CDB::TRI* T = Level().ObjectSpace.GetStaticTris()+result.element;
mtl_idx = T->material;
}
SGameMtl* mtl = GMLib.GetMaterialByIdx(mtl_idx);
ep.shoot_factor *=mtl->fShootFactor;
#ifdef DEBUG
if(ph_dbg_draw_mask.test(phDbgDrawExplosions))
{
Fvector p;p.set(ep.l_dir);p.mul(result.range);p.add(ep.source_p);
u8 c =u8(mtl->fShootFactor*255.f);
DBG_DrawPoint(p,0.1f,D3DCOLOR_XRGB(255-c,0,c));
}
#endif
return (ep.shoot_factor>0.01f);
}
示例2: PCKinematics
void CModelPool::dump()
{
Log ("--- model pool --- begin:");
u32 sz = 0;
u32 k = 0;
for (xr_vector<ModelDef>::iterator I=Models.begin(); I!=Models.end(); I++) {
CKinematics* K = PCKinematics(I->model);
if (K){
u32 cur = K->mem_usage (false);
sz += cur;
Msg("#%3d: [%3d/%5d Kb] - %s",k++,I->refs,cur/1024,I->name.c_str());
}
}
Msg ("--- models: %d, mem usage: %d Kb ",k,sz/1024);
sz = 0;
k = 0;
int free_cnt = 0;
for (REGISTRY_IT it=Registry.begin(); it!=Registry.end(); it++)
{
CKinematics* K = PCKinematics((dxRender_Visual*)it->first);
VERIFY (K);
if (K){
u32 cur = K->mem_usage (true);
sz += cur;
bool b_free = (Pool.find(it->second)!=Pool.end() );
if(b_free) ++free_cnt;
Msg("#%3d: [%s] [%5d Kb] - %s",k++, (b_free)?"free":"used", cur/1024,it->second.c_str());
}
}
Msg ("--- instances: %d, free %d, mem usage: %d Kb ",k, free_cnt, sz/1024);
Log ("--- model pool --- end.");
}
示例3: load_section
void CDamageManager::load_section(LPCSTR section,CInifile* ini)
{
string32 buffer;
CKinematics *kinematics = smart_cast<CKinematics*>(m_object->Visual());
CInifile::Sect &damages = ini->r_section(section);
for (CInifile::SectCIt i=damages.Data.begin(); damages.Data.end() != i; ++i) {
if (xr_strcmp(*(*i).first,"default")) { // read all except default line
VERIFY (m_object);
int bone = kinematics->LL_BoneID(i->first);
R_ASSERT2 (BI_NONE != bone, *(*i).first);
CBoneInstance &bone_instance = kinematics->LL_GetBoneInstance(u16(bone));
bone_instance.set_param (0,(float)atof(_GetItem(*(*i).second,0,buffer)));
bone_instance.set_param (1,(float)atoi(_GetItem(*(*i).second,1,buffer)));
bone_instance.set_param (2,(float)atof(_GetItem(*(*i).second,2,buffer)));
if (_GetItemCount(*(*i).second) < 4)
{
bone_instance.set_param (3,(float)atof(_GetItem(*(*i).second,0,buffer)));
}
else
{
bone_instance.set_param (3,(float)atof(_GetItem(*(*i).second,3,buffer)));
}
if(0==bone && (fis_zero(bone_instance.get_param(0)) || fis_zero(bone_instance.get_param(2)) ) ){
string256 error_str;
sprintf_s(error_str,"hit_scale and wound_scale for root bone cannot be zero. see section [%s]",section);
R_ASSERT2(0,error_str);
}
}
}
}
示例4: VERIFY
void CDamageManager::HitScale (const int element, float& hit_scale, float& wound_scale, bool aim_bullet)
{
if(BI_NONE == u16(element))
{
//считаем что параметры для BI_NONE заданы как 1.f
hit_scale = 1.f * m_default_hit_factor;
wound_scale = 1.f * m_default_wound_factor;
return;
}
CKinematics* V = smart_cast<CKinematics*>(m_object->Visual()); VERIFY(V);
// get hit scale
float scale;
if (aim_bullet)
{
scale = V->LL_GetBoneInstance(u16(element)).get_param(3);
}
else
{
scale = V->LL_GetBoneInstance(u16(element)).get_param(0);
}
hit_scale = scale;
// get wound scale
scale = V->LL_GetBoneInstance(u16(element)).get_param(2);
wound_scale = scale;
}
示例5: Execute
virtual void Execute(LPCSTR arguments)
{
if (!arguments || !*arguments) {
Msg ("! no arguments passed");
return;
}
string_path name;
string_path fn;
if (0==strext(arguments))
strconcat (sizeof(name),name,arguments,".ogf");
else
strcpy_s (name,sizeof(name),arguments);
if (!FS.exist(arguments) && !FS.exist(fn, "$level$", name) && !FS.exist(fn, "$game_meshes$", name)) {
Msg ("! Cannot find visual \"%s\"",arguments);
return;
}
IRender_Visual *visual = Render->model_Create(arguments);
CKinematics *kinematics = smart_cast<CKinematics*>(visual);
if (!kinematics) {
Render->model_Delete(visual);
Msg ("! Invalid visual type \"%s\" (not a CKinematics)",arguments);
return;
}
Msg ("bones for model \"%s\"",arguments);
for (u16 i=0, n=kinematics->LL_BoneCount(); i<n; ++i)
Msg ("%s",*kinematics->LL_GetData(i).name);
Render->model_Delete (visual);
}
示例6:
void CObjectHandler::weapon_bones (int &b0, int &b1, int &b2) const
{
CWeapon *weapon = smart_cast<CWeapon*>(inventory().ActiveItem());
if (!weapon || !planner().m_storage.property(ObjectHandlerSpace::eWorldPropertyStrapped)) {
if (weapon)
weapon->strapped_mode (false);
b0 = m_r_hand;
b1 = m_r_finger2;
b2 = m_l_finger1;
return;
}
THROW3 (weapon->can_be_strapped(),"Cannot strap weapon",*weapon->cName());
if (weapon->ID() != m_strap_object_id) {
CKinematics *kinematics = smart_cast<CKinematics*>(planner().m_object->Visual());
m_strap_bone0 = kinematics->LL_BoneID(weapon->strap_bone0());
m_strap_bone1 = kinematics->LL_BoneID(weapon->strap_bone1());
m_strap_object_id = weapon->ID();
}
weapon->strapped_mode (true);
b0 = m_strap_bone0;
b1 = m_strap_bone1;
b2 = b1;
}
示例7:
void CAI_Trader::g_WeaponBones (int &L, int &R1, int &R2)
{
CKinematics *V = smart_cast<CKinematics*>(Visual());
R1 = V->LL_BoneID("bip01_r_hand");
R2 = V->LL_BoneID("bip01_r_finger2");
L = V->LL_BoneID("bip01_l_finger1");
}
示例8: PHSaveState
void CPhysicsShellHolder::PHSaveState(NET_Packet &P)
{
//CPhysicsShell* pPhysicsShell=PPhysicsShell();
CKinematics* K =smart_cast<CKinematics*>(Visual());
//Flags8 lflags;
//if(pPhysicsShell&&pPhysicsShell->isActive()) lflags.set(CSE_PHSkeleton::flActive,pPhysicsShell->isEnabled());
// P.w_u8 (lflags.get());
if(K)
{
P.w_u64(K->LL_GetBonesVisible());
P.w_u16(K->LL_GetBoneRoot());
}
else
{
P.w_u64(u64(-1));
P.w_u16(0);
}
/////////////////////////////
Fvector min,max;
min.set(flt_max,flt_max,flt_max);
max.set(-flt_max,-flt_max,-flt_max);
/////////////////////////////////////
u16 bones_number=PHGetSyncItemsNumber();
for(u16 i=0;i<bones_number;i++)
{
SPHNetState state;
PHGetSyncItem(i)->get_State(state);
Fvector& p=state.position;
if(p.x<min.x)min.x=p.x;
if(p.y<min.y)min.y=p.y;
if(p.z<min.z)min.z=p.z;
if(p.x>max.x)max.x=p.x;
if(p.y>max.y)max.y=p.y;
if(p.z>max.z)max.z=p.z;
}
min.sub(2.f*EPS_L);
max.add(2.f*EPS_L);
VERIFY(!min.similar(max));
P.w_vec3(min);
P.w_vec3(max);
P.w_u16(bones_number);
for(u16 i=0;i<bones_number;i++)
{
SPHNetState state;
PHGetSyncItem(i)->get_State(state);
state.net_Save(P,min,max);
}
}
示例9: UpdateCL
void CCarWeapon::UpdateCL()
{
if(!m_bActive) return;
UpdateBarrelDir ();
CKinematics* K = smart_cast<CKinematics*>(m_object->Visual());
K->CalculateBones_Invalidate();
K->CalculateBones ();
UpdateFire ();
}
示例10: Init
void CHangingLamp::RespawnInit()
{
Init();
if(Visual()){
CKinematics* K = smart_cast<CKinematics*>(Visual());
K->LL_SetBonesVisible(u64(-1));
K->CalculateBones_Invalidate();
K->CalculateBones ();
}
}
示例11: todo
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);
CKinematics* V = smart_cast<CKinematics*> (E->Visual());
VERIFY (V);
// Get matrices
int boneL,boneR,boneR2;
E->g_WeaponBones(boneL,boneR,boneR2);
// 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);
}
示例12: VERIFY
void CParticlesPlayer::GetBonePos (CObject* pObject, u16 bone_id, const Fvector& offset, Fvector& result)
{
VERIFY(pObject);
CKinematics* pKinematics = smart_cast<CKinematics*>(pObject->Visual());
VERIFY(pKinematics);
CBoneInstance& l_tBoneInstance = pKinematics->LL_GetBoneInstance(bone_id);
result = offset;
l_tBoneInstance.mTransform.transform_tiny(result);
pObject->XFORM().transform_tiny(result);
}
示例13: init_bones
void CDamageManager::init_bones(LPCSTR section,CInifile* ini)
{
CKinematics *kinematics = smart_cast<CKinematics*>(m_object->Visual());
VERIFY (kinematics);
for(u16 i = 0; i<kinematics->LL_BoneCount(); i++)
{
CBoneInstance &bone_instance = kinematics->LL_GetBoneInstance(i);
bone_instance.set_param (0,m_default_hit_factor);
bone_instance.set_param (1,1.f);
bone_instance.set_param (2,m_default_wound_factor);
}
}
示例14:
void CCar::SWheelBreak::Load(LPCSTR section)
{
CKinematics *K =PKinematics(pwheel->car->Visual()) ;
CInifile *ini =K->LL_UserData() ;
VERIFY (ini) ;
break_torque = ini->r_float("car_definition","break_torque") ;
hand_break_torque = READ_IF_EXISTS(ini,r_float,"car_definition","hand_break_torque",break_torque) ;
if(ini->section_exist(section))
{
break_torque =READ_IF_EXISTS(ini,r_float,section,"break_torque",break_torque);
hand_break_torque =READ_IF_EXISTS(ini,r_float,section,"hand_break_torque",hand_break_torque);
}
}
示例15:
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 ();
}