本文整理汇总了C++中Fmatrix::build_camera方法的典型用法代码示例。如果您正苦于以下问题:C++ Fmatrix::build_camera方法的具体用法?C++ Fmatrix::build_camera怎么用?C++ Fmatrix::build_camera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fmatrix
的用法示例。
在下文中一共展示了Fmatrix::build_camera方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void BuildMatrix (Fmatrix &mView, float invsz, const Fvector norm, const Fvector& from)
{
// build projection
Fmatrix mScale;
Fvector at,up,right,y;
at.sub (from,norm);
y.set (0,1,0);
if (_abs(norm.y)>.99f) y.set(1,0,0);
right.crossproduct (y,norm);
up.crossproduct (norm,right);
mView.build_camera (from,at,up);
mScale.scale (invsz,invsz,invsz);
mView.mulA_43 (mScale);
}
示例2:
void CWallmarksEngine::BuildMatrix (Fmatrix &mView, float invsz, const Fvector& from)
{
// build projection
Fmatrix mScale;
Fvector at,up,right,y;
at.sub (from,sml_normal);
y.set (0,1,0);
if (_abs(sml_normal.y)>.99f) y.set(1,0,0);
right.crossproduct (y,sml_normal);
up.crossproduct (sml_normal,right);
mView.build_camera (from,at,up);
mScale.scale (invsz,invsz,invsz);
mView.mulA_43 (mScale);
}
示例3:
//.........这里部分代码省略.........
}
}
// calculate projection-matrix
Fmatrix mProject,mProjectR;
float p_dist = C.C.distance_to(Lpos);
float p_R = C.O->renderable.visual->vis.sphere.R;
float p_hat = p_R/p_dist;
float p_asp = 1.f;
float p_near = p_dist-p_R-eps;
float p_nearR = C.C.distance_to(L.source->position) + p_R*0.85f + eps;
p_nearR = p_near;
float p_far = _min(Lrange,_max(p_dist+S_fade,p_dist+p_R));
if (p_near<eps) continue;
if (p_far<(p_near+eps)) continue;
if (p_hat>0.9f) continue;
if (p_hat<0.01f) continue;
//Msg ("* near(%f), near-x(%f)",p_near,p_nearR);
mProject.build_projection_HAT (p_hat,p_asp,p_near, p_far);
mProjectR.build_projection_HAT (p_hat,p_asp,p_nearR, p_far);
RCache.set_xform_project (mProject);
// calculate view-matrix
Fmatrix mView;
Fvector v_D,v_N,v_R;
v_D.sub (C.C,Lpos);
v_D.normalize ();
if(1-_abs(v_D.y)<EPS) v_N.set(1,0,0);
else v_N.set(0,1,0);
v_R.crossproduct (v_N,v_D);
v_N.crossproduct (v_D,v_R);
mView.build_camera (Lpos,C.C,v_N);
RCache.set_xform_view (mView);
// combine and build frustum
Fmatrix mCombine,mCombineR;
mCombine.mul (mProject,mView);
mCombineR.mul (mProjectR,mView);
// Select slot and set viewport
int s_x = slot_id%slot_line;
int s_y = slot_id/slot_line;
D3DVIEWPORT9 VP = {s_x*S_size,s_y*S_size,S_size,S_size,0,1 };
CHK_DX (HW.pDevice->SetViewport(&VP));
// Render object-parts
for (u32 n_it=0; n_it<C.nodes.size(); n_it++)
{
NODE& N = C.nodes[n_it];
IRender_Visual *V = N.pVisual;
RCache.set_Element (V->shader_ref->E[SE_R1_LMODELS]);
RCache.set_xform_world (N.Matrix);
V->Render (-1.0f);
}
// register shadow and increment slot
shadows.push_back (shadow());
shadows.back().O = C.O;
shadows.back().slot = slot_id;
shadows.back().C = C.C;
shadows.back().M = mCombineR;
shadows.back().L = L.source;
shadows.back().E = L.energy;
#ifdef DEBUG
示例4: OA_Export
void CDeflector::OA_Export()
{
if (UVpolys.empty()) return;
// Correct normal
// (semi-proportional to pixel density)
FPU::m64r ();
Fvector tN;
tN.set (0,0,0);
float density = 0;
float fcount = 0;
for (UVIt it = UVpolys.begin(); it!=UVpolys.end(); it++)
{
Face *F = it->owner;
Fvector SN;
SN.set (F->N);
SN.mul (1+EPS*F->CalcArea());
tN.add (SN);
density += F->Shader().lm_density;
fcount += 1.f;
}
if (tN.magnitude()>EPS_S && _valid(tN)) normal.set(tN).normalize();
else clMsg("* ERROR: Internal precision error in CDeflector::OA_Export");
density /= fcount;
// Orbitrary Oriented Ortho - Projection
Fmatrix mView;
Fvector at,from,up,right,y;
at.set (0,0,0);
from.add (at,normal);
y.set (0,1,0);
if (_abs(normal.y)>.99f) y.set(1,0,0);
right.crossproduct(y,normal); right.normalize_safe();
up.crossproduct(normal,right); up.normalize_safe();
mView.build_camera(from,at,up);
Fbox bb; bb.invalidate();
for (UVIt it = UVpolys.begin(); it!=UVpolys.end(); it++)
{
UVtri *T = &*it;
Face *F = T->owner;
Fvector P; // projected
for (int i=0; i<3; i++) {
mView.transform_tiny (P,F->v[i]->P);
T->uv[i].set (P.x,P.y);
bb.modify (F->v[i]->P);
}
}
bb.getsphere(Sphere.P,Sphere.R);
// UV rect
Fvector2 min,max,size;
GetRect (min,max);
size.sub (max,min);
// Surface
u32 dwWidth = iCeil(size.x*g_params.m_lm_pixels_per_meter*density+.5f); clamp(dwWidth, 1u,512u-2*BORDER);
u32 dwHeight = iCeil(size.y*g_params.m_lm_pixels_per_meter*density+.5f); clamp(dwHeight,1u,512u-2*BORDER);
layer.create (dwWidth,dwHeight);
}
示例5: if
//.........这里部分代码省略.........
OO->Center(cc);
Log("center=",cc);
Log("visual_center=",OO->Visual()->getVisData().sphere.P);
Log("full_matrix=",OO->XFORM());
Log ("v_N",v_N);
Log ("v_C",v_C);
Log ("v_Cs",v_Cs);
Log("all bones transform:--------");
CKinematics* K = dynamic_cast<CKinematics*>(OO->Visual());
for(u16 ii=0; ii<K->LL_BoneCount();++ii){
Fmatrix tr;
tr = K->LL_GetTransform(ii);
Log("bone ",K->LL_BoneName_dbg(ii));
Log("bone_matrix",tr);
}
Log("end-------");
}
#endif
// handle invalid object-bug
if ((v.x*v.x+v.y*v.y+v.z*v.z)<=flt_zero) {
// invalidate record, so that object will be unshadowed, but doesn't crash
R.dwTimeValid = Device.dwTimeGlobal;
LT->shadow_recv_frame = Device.dwFrame-1;
LT->shadow_recv_slot = -1;
continue ;
}
mView.build_camera (v_C,v_Cs,v_N);
RCache.set_xform_view (mView);
// Select slot, set viewport
int s_x = c_it%P_o_line;
int s_y = c_it/P_o_line;
D3DVIEWPORT9 VP = {s_x*P_o_size,s_y*P_o_size,P_o_size,P_o_size,0,1 };
CHK_DX (HW.pDevice->SetViewport(&VP));
// Clear color to ambience
Fvector& cap = LT->get_approximate();
CHK_DX (HW.pDevice->Clear(0,0, D3DCLEAR_TARGET, color_rgba_f(cap.x,cap.y,cap.z, (cap.x+cap.y+cap.z)/4.f), 1, 0 ));
// calculate uv-gen matrix and clamper
Fmatrix mCombine; mCombine.mul (mProject,mView);
Fmatrix mTemp;
float fSlotSize = float(P_o_size)/float(P_rt_size);
float fSlotX = float(s_x*P_o_size)/float(P_rt_size);
float fSlotY = float(s_y*P_o_size)/float(P_rt_size);
float fTexelOffs = (.5f / P_rt_size);
Fmatrix m_TexelAdjust =
{
0.5f/*x-scale*/, 0.0f, 0.0f, 0.0f,
0.0f, -0.5f/*y-scale*/, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f/*z-range*/, 0.0f,
0.5f/*x-bias*/, 0.5f + fTexelOffs/*y-bias*/, 0.0f/*z-bias*/, 1.0f
};
R.UVgen.mul (m_TexelAdjust,mCombine);
mTemp.scale (fSlotSize,fSlotSize,1);
R.UVgen.mulA_44 (mTemp);
mTemp.translate (fSlotX+fTexelOffs,fSlotY+fTexelOffs,0);
R.UVgen.mulA_44 (mTemp);