本文整理汇总了C++中Fmatrix::mul方法的典型用法代码示例。如果您正苦于以下问题:C++ Fmatrix::mul方法的具体用法?C++ Fmatrix::mul怎么用?C++ Fmatrix::mul使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fmatrix
的用法示例。
在下文中一共展示了Fmatrix::mul方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DebugRender
void CKinematics::DebugRender(Fmatrix& XFORM)
{
CalculateBones ();
CBoneData::BoneDebug dbgLines;
(*bones)[iRoot]->DebugQuery (dbgLines);
Fvector Z; Z.set(0,0,0);
Fvector H1; H1.set(0.01f,0.01f,0.01f);
Fvector H2; H2.mul(H1,2);
for (u32 i=0; i<dbgLines.size(); i+=2) {
Fmatrix& M1 = bone_instances[dbgLines[i]].mTransform;
Fmatrix& M2 = bone_instances[dbgLines[i+1]].mTransform;
Fvector P1,P2;
M1.transform_tiny(P1,Z);
M2.transform_tiny(P2,Z);
RCache.dbg_DrawLINE(XFORM,P1,P2,D3DCOLOR_XRGB(0,255,0));
Fmatrix M;
M.mul_43(XFORM,M2);
RCache.dbg_DrawOBB(M,H1,D3DCOLOR_XRGB(255,255,255));
RCache.dbg_DrawOBB(M,H2,D3DCOLOR_XRGB(255,255,255));
}
for (u32 b=0; b<bones->size(); b++)
{
Fobb& obb = (*bones)[b]->obb;
Fmatrix& Mbone = bone_instances[b].mTransform;
Fmatrix Mbox; obb.xform_get(Mbox);
Fmatrix X; X.mul(Mbone,Mbox);
Fmatrix W; W.mul(XFORM,X);
RCache.dbg_DrawOBB(W,obb.m_halfsize,D3DCOLOR_XRGB(0,0,255));
}
}
示例2: get_screen_space_coverage_diagonal
float CBaseMonster::get_screen_space_coverage_diagonal()
{
Fbox b = Visual()->getVisData().box;
Fmatrix xform;
xform.mul (Device.mFullTransform,XFORM());
Fvector2 mn ={flt_max,flt_max},mx={flt_min,flt_min};
for (u32 k=0; k<8; ++k)
{
Fvector p;
b.getpoint (k,p);
xform.transform (p);
mn.x = _min(mn.x,p.x);
mn.y = _min(mn.y,p.y);
mx.x = _max(mx.x,p.x);
mx.y = _max(mx.y,p.y);
}
float const width = mx.x - mn.x;
float const height = mx.y - mn.y;
float const average_diagonal = _sqrt(width * height);
return average_diagonal;
}
示例3: PickupInfoDraw
void CActor::PickupInfoDraw(CObject* object)
{
LPCSTR draw_str = NULL;
CInventoryItem* item = smart_cast<CInventoryItem*>(object);
if(!item) return;
Fmatrix res;
res.mul (Device.mFullTransform,object->XFORM());
Fvector4 v_res;
Fvector shift;
draw_str = item->NameItem();
shift.set(0,0,0);
res.transform(v_res,shift);
if (v_res.z < 0 || v_res.w < 0) return;
if (v_res.x < -1.f || v_res.x > 1.f || v_res.y<-1.f || v_res.y>1.f) return;
float x = (1.f + v_res.x)/2.f * (Device.dwWidth);
float y = (1.f - v_res.y)/2.f * (Device.dwHeight);
UI().Font().pFontLetterica16Russian->SetAligment (CGameFont::alCenter);
UI().Font().pFontLetterica16Russian->SetColor (PICKUP_INFO_COLOR);
UI().Font().pFontLetterica16Russian->Out (x,y,draw_str);
}
示例4: GetUILocatorMatrix
void CUIArtefactDetectorElite::GetUILocatorMatrix(Fmatrix& _m)
{
Fmatrix trans = m_parent->HudItemData()->m_item_transform;
u16 bid = m_parent->HudItemData()->m_model->LL_BoneID("cover");
Fmatrix cover_bone = m_parent->HudItemData()->m_model->LL_GetTransform(bid);
_m.mul (trans, cover_bone);
_m.mulB_43 (m_map_attach_offset);
}
示例5: q_scale_vs_basem
//sclale base' * q by scale_factor returns result in matrix m_res
IC void q_scale_vs_basem(Fmatrix &m_res,const Fquaternion &q, const Fquaternion &base,float scale_factor)
{
Fmatrix mb,imb;
mb.rotation(base);
imb.invert(mb);
Fmatrix m;m.rotation(q);
m_res.mul(imb,m);
q_scalem(m_res,scale_factor);
}
示例6: Update
void SCarLight::Update()
{
VERIFY(!ph_world->Processing());
if(!isOn()) return;
CCar* pcar=m_holder->PCar();
CBoneInstance& BI = smart_cast<IKinematics*>(pcar->Visual())->LL_GetBoneInstance(bone_id);
Fmatrix M;
M.mul(pcar->XFORM(),BI.mTransform);
light_render->set_rotation (M.k,M.i);
glow_render->set_direction(M.k);
glow_render->set_position (M.c);
light_render->set_position (M.c);
}
示例7: float
// 2D texgen (texture adjustment matrix)
void CRenderTarget::u_compute_texgen_screen (Fmatrix& m_Texgen)
{
float _w = float(Device.dwWidth);
float _h = float(Device.dwHeight);
float o_w = (.5f / _w);
float o_h = (.5f / _h);
Fmatrix m_TexelAdjust =
{
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, -0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.5f + o_w, 0.5f + o_h, 0.0f, 1.0f
};
m_Texgen.mul (m_TexelAdjust,RCache.xforms.m_wvp);
}
示例8: ImportMAXSkeleton
//----------------------------------------------------------------------------
// Skeleton functions
//----------------------------------------------------------------------------
bool CEditableObject::ImportMAXSkeleton(CExporter* E)
{
bool bResult = true;
CEditableMesh* MESH = xr_new<CEditableMesh>(this);
m_Meshes.push_back(MESH);
// import mesh
if (!MESH->Convert(E)) return FALSE;
// BONES
m_Bones.reserve(E->m_Bones.size());
for (int B=0; B!=E->m_Bones.size(); B++){
m_Bones.push_back(xr_new<CBone>());
CBone* BONE = m_Bones.back();
CBoneDef* bone = E->m_Bones[B];
CBoneDef* parent_bone = bone->parent;
Fvector offset,rotate;
float length= 0.1f;
Fmatrix m;
if (parent_bone) m.mul(parent_bone->matOffset,bone->matInit);
else m.set(bone->matInit);
m.getXYZi (rotate);
offset.set (m.c);
BONE->SetWMap (bone->name.c_str());
BONE->SetName (bone->name.c_str());
BONE->SetParentName (Helper::ConvertSpace(string(bone->pBone->GetParentNode()->GetName())).c_str());
BONE->SetRestParams (length,offset,rotate);
}
// DEFAULT BONE PART
m_BoneParts.push_back(SBonePart());
SBonePart& BP = m_BoneParts.back();
BP.alias = "default";
for (int b_i=0; b_i<(int)m_Bones.size(); b_i++)
BP.bones.push_back(Bones()[b_i]->Name());
m_objectFlags.set(CEditableObject::eoDynamic,TRUE);
if ((0==GetVertexCount())||(0==GetFaceCount())){
bResult = false;
}else{
ELog.Msg(mtInformation,"Model '%s' contains: %d points, %d faces, %d bones", E->m_MeshNode->GetName(), GetVertexCount(), GetFaceCount(), Bones().size());
}
return bResult;
}
示例9: HUD
void CActor::RenderText (LPCSTR Text, Fvector dpos, float* pdup, u32 color)
{
if (!g_Alive()) return;
CBoneInstance& BI = smart_cast<CKinematics*>(Visual())->LL_GetBoneInstance(u16(m_head));
Fmatrix M;
smart_cast<CKinematics*>(Visual())->CalculateBones ();
M.mul (XFORM(),BI.mTransform);
//------------------------------------------------
Fvector v0, v1;
v0.set(M.c); v1.set(M.c);
Fvector T = Device.vCameraTop;
v1.add(T);
Fvector v0r, v1r;
Device.mFullTransform.transform(v0r,v0);
Device.mFullTransform.transform(v1r,v1);
float size = v1r.distance_to(v0r);
CGameFont* pFont = HUD().Font().pFontArial14;
if (!pFont) return;
// float OldFontSize = pFont->GetHeight ();
float delta_up = 0.0f;
if (size < mid_size) delta_up = upsize;
else delta_up = upsize*(mid_size/size);
dpos.y += delta_up;
if (size > mid_size) size = mid_size;
// float NewFontSize = size/mid_size * fontsize;
//------------------------------------------------
M.c.y += dpos.y;
Fvector4 v_res;
Device.mFullTransform.transform(v_res,M.c);
if (v_res.z < 0 || v_res.w < 0) return;
if (v_res.x < -1.f || v_res.x > 1.f || v_res.y<-1.f || v_res.y>1.f) return;
float x = (1.f + v_res.x)/2.f * (Device.dwWidth);
float y = (1.f - v_res.y)/2.f * (Device.dwHeight);
pFont->SetAligment (CGameFont::alCenter);
pFont->SetColor (color);
// pFont->SetHeight (NewFontSize);
pFont->Out (x,y,Text);
//-------------------------------------------------
// pFont->SetHeight(OldFontSize);
*pdup = delta_up;
};
示例10: draw_object_info
void CLevelDebug::draw_object_info()
{
// handle all of the objects
for (OBJECT_INFO_MAP_IT it = m_objects_info.begin(); it != m_objects_info.end(); ++it) {
// если объект невалидный - удалить информацию
if (!it->first || it->first->getDestroy()) {
for (CLASS_INFO_MAP_IT it_class = it->second.begin(); it_class != it->second.end(); ++it_class){
xr_delete(it_class->second);
}
m_objects_info.erase(it);
break;
}
Fmatrix res;
res.mul (Device.mFullTransform,it->first->XFORM());
Fvector4 v_res;
float delta_height = 0.f;
// handle all of the classes
for (CLASS_INFO_MAP_IT class_it = it->second.begin(); class_it != it->second.end(); ++class_it) {
// get up on 2 meters
res.transform(v_res, class_it->second->get_shift_pos());
// check if the object in sight
if (v_res.z < 0 || v_res.w < 0) continue;
if (v_res.x < -1.f || v_res.x > 1.f || v_res.y<-1.f || v_res.y>1.f) continue;
// get real (x,y)
float x = (1.f + v_res.x)/2.f * (Device.dwWidth);
float y = (1.f - v_res.y)/2.f * (Device.dwHeight) - delta_height;
float start_y = y;
// handle all of the text inside class
class_it->second->draw_info(x,y);
delta_height = start_y - y;
}
}
}
示例11:
void CActor::RenderIndicator (Fvector dpos, float r1, float r2, ref_shader IndShader)
{
if (!g_Alive()) return;
u32 dwOffset = 0,dwCount = 0;
FVF::LIT* pv_start = (FVF::LIT*)RCache.Vertex.Lock(4,hFriendlyIndicator->vb_stride,dwOffset);
FVF::LIT* pv = pv_start;
// base rect
CBoneInstance& BI = smart_cast<CKinematics*>(Visual())->LL_GetBoneInstance(u16(m_head));
Fmatrix M;
smart_cast<CKinematics*>(Visual())->CalculateBones ();
M.mul (XFORM(),BI.mTransform);
Fvector pos = M.c; pos.add(dpos);
const Fvector& T = Device.vCameraTop;
const Fvector& R = Device.vCameraRight;
Fvector Vr, Vt;
Vr.x = R.x*r1;
Vr.y = R.y*r1;
Vr.z = R.z*r1;
Vt.x = T.x*r2;
Vt.y = T.y*r2;
Vt.z = T.z*r2;
Fvector a,b,c,d;
a.sub (Vt,Vr);
b.add (Vt,Vr);
c.invert (a);
d.invert (b);
pv->set (d.x+pos.x,d.y+pos.y,d.z+pos.z, 0xffffffff, 0.f,1.f); pv++;
pv->set (a.x+pos.x,a.y+pos.y,a.z+pos.z, 0xffffffff, 0.f,0.f); pv++;
pv->set (c.x+pos.x,c.y+pos.y,c.z+pos.z, 0xffffffff, 1.f,1.f); pv++;
pv->set (b.x+pos.x,b.y+pos.y,b.z+pos.z, 0xffffffff, 1.f,0.f); pv++;
// render
dwCount = u32(pv-pv_start);
RCache.Vertex.Unlock (dwCount,hFriendlyIndicator->vb_stride);
RCache.set_xform_world (Fidentity);
RCache.set_Shader (IndShader);
RCache.set_Geometry (hFriendlyIndicator);
RCache.Render (D3DPT_TRIANGLESTRIP,dwOffset,0, dwCount, 0, 2);
};
示例12:
void CHelicopter::UpdateHeliParticles ()
{
CKinematics* K = smart_cast<CKinematics*>(Visual());
m_particleXFORM = K->LL_GetTransform(m_smoke_bone);
m_particleXFORM.mulA_43(XFORM());
if (m_pParticle){
Fvector vel;
Fvector last_pos = PositionStack.back().vPosition;
vel.sub(Position(), last_pos);
vel.mul(5.0f);
m_pParticle->UpdateParent(m_particleXFORM, vel );
}
//lighting
if(m_light_render->get_active()){
Fmatrix xf;
Fmatrix& M = K->LL_GetTransform(u16(m_light_bone));
xf.mul (XFORM(),M);
VERIFY(!fis_zero(DET(xf)));
m_light_render->set_rotation (xf.k,xf.i);
m_light_render->set_position (xf.c);
if (m_lanim)
{
int frame;
u32 clr = m_lanim->CalculateBGR(Device.fTimeGlobal,frame); // òþ÷ò¨ð•ðõª ò ¯þ¨üðªõ BGR
Fcolor fclr;
fclr.set ((float)color_get_B(clr),(float)color_get_G(clr),(float)color_get_R(clr),1.f);
fclr.mul_rgb (m_light_brightness/255.f);
m_light_render->set_color (fclr);
}
}
}
示例13: ProcessCam
BOOL CMonsterEffectorHit::ProcessCam(SCamEffectorInfo& info)
{
fLifeTime -= Device.fTimeDelta;
if(fLifeTime<0) return FALSE;
// процент оставшегос¤ времени
float time_left_perc = fLifeTime / total;
// »нициализаци¤
Fmatrix Mdef;
Mdef.identity ();
Mdef.j.set (info.n);
Mdef.k.set (info.d);
Mdef.i.crossproduct (info.n,info.d);
Mdef.c.set (info.p);
float period_all = period_number * PI_MUL_2; // макс. значение цикла
float cur_amp = max_amp * (PI / 180) * time_left_perc;
Fvector dangle;
dangle.x = cur_amp/offset.x * _sin(period_all/offset.x * (1.0f - time_left_perc));
dangle.y = cur_amp/offset.y * _cos(period_all/offset.y * (1.0f - time_left_perc));
dangle.z = cur_amp/offset.z * _sin(period_all/offset.z * (1.0f - time_left_perc));
// ”становить углы смещени¤
Fmatrix R;
R.setHPB (dangle.x,dangle.y,dangle.z);
Fmatrix mR;
mR.mul (Mdef,R);
info.d.set (mR.k);
info.n.set (mR.j);
return TRUE;
}
示例14: Process
BOOL CPseudogigantStepEffector::Process(Fvector &p, Fvector &d, Fvector &n, float& fFov, float& fFar, float& fAspect)
{
fLifeTime -= Device.fTimeDelta; if(fLifeTime<0) return FALSE;
// процент оставшегос¤ времени
float time_left_perc = fLifeTime / total;
// »нициализаци¤
Fmatrix Mdef;
Mdef.identity ();
Mdef.j.set (n);
Mdef.k.set (d);
Mdef.i.crossproduct (n,d);
Mdef.c.set (p);
float period_all = period_number * PI_MUL_2; // макс. значение цикла
float k = 1 - time_left_perc + EPS_L + (1 - power);
float cur_amp = max_amp * (PI / 180) / (10 * k * k);
Fvector dangle;
dangle.x = cur_amp/2 * _sin(period_all * (1.0f - time_left_perc));
dangle.y = cur_amp * _cos(period_all/2 * (1.0f - time_left_perc));
dangle.z = cur_amp/4 * _sin(period_all/4 * (1.0f - time_left_perc));
// ”становить углы смещени¤
Fmatrix R;
R.setHPB (dangle.x,dangle.y,dangle.z);
Fmatrix mR;
mR.mul (Mdef,R);
d.set (mR.k);
n.set (mR.j);
return TRUE;
}
示例15:
void CDrawUtilities::DrawCone (const Fmatrix& parent, const Fvector& apex, const Fvector& dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire)
{
Fmatrix mScale;
mScale.scale (2.f*radius,2.f*radius,height);
// build final rotation / translation
Fvector L_dir,L_up,L_right;
L_dir.set (dir); L_dir.normalize ();
L_up.set (0,1,0); if (_abs(L_up.dotproduct(L_dir))>.99f) L_up.set(0,0,1);
L_right.crossproduct(L_up,L_dir); L_right.normalize ();
L_up.crossproduct (L_dir,L_right); L_up.normalize ();
Fmatrix mR;
mR.i = L_right; mR._14 = 0;
mR.j = L_up; mR._24 = 0;
mR.k = L_dir; mR._34 = 0;
mR.c = apex; mR._44 = 1;
// final xform
Fmatrix xf; xf.mul (mR,mScale);
xf.mulA_43 (parent);
RCache.set_xform_world(xf);
DrawIdentCone (bSolid,bWire,clr_s,clr_w);
}