本文整理汇总了C++中Fmatrix::transform_tiny方法的典型用法代码示例。如果您正苦于以下问题:C++ Fmatrix::transform_tiny方法的具体用法?C++ Fmatrix::transform_tiny怎么用?C++ Fmatrix::transform_tiny使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fmatrix
的用法示例。
在下文中一共展示了Fmatrix::transform_tiny方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawDirectionalLight
void CDrawUtilities::DrawDirectionalLight(const Fvector& p, const Fvector& d, float radius, float range, u32 c)
{
float r=radius*0.71f;
Fvector R,N,D; D.normalize(d);
Fmatrix rot;
N.set (0,1,0);
if (_abs(D.y)>0.99f) N.set(1,0,0);
R.crossproduct(N,D); R.normalize();
N.crossproduct(D,R); N.normalize();
rot.set(R,N,D,p);
float sz=radius+range;
// fill VB
_VertexStream* Stream = &RCache.Vertex;
u32 vBase;
FVF::L* pv = (FVF::L*)Stream->Lock(6,vs_L->vb_stride,vBase);
pv->set (0,0,r, c); rot.transform_tiny(pv->p); pv++;
pv->set (0,0,sz, c); rot.transform_tiny(pv->p); pv++;
pv->set (-r,0,r, c); rot.transform_tiny(pv->p); pv++;
pv->set (-r,0,sz, c); rot.transform_tiny(pv->p); pv++;
pv->set (r,0,r, c); rot.transform_tiny(pv->p); pv++;
pv->set (r,0,sz, c); rot.transform_tiny(pv->p); pv++;
Stream->Unlock (6,vs_L->vb_stride);
// and Render it as triangle list
DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,3);
Fbox b;
b.min.set(-r,-r,-r);
b.max.set(r,r,r);
DrawLineSphere ( p, radius, c, true );
}
示例2: DrawPlane
void CDrawUtilities::DrawPlane (const Fvector& center, const Fvector2& scale, const Fvector& rotate, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire)
{
Fmatrix M;
M.setHPB (rotate.y,rotate.x,rotate.z);
M.translate_over(center);
// fill VB
_VertexStream* Stream = &RCache.Vertex;
u32 vBase;
if (bSolid){
DU_DRAW_SH(dxRenderDeviceRender::Instance().m_SelectionShader);
FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase);
pv->set (-scale.x, 0, -scale.y, clr_s); M.transform_tiny(pv->p); pv++;
pv->set (-scale.x, 0, +scale.y, clr_s); M.transform_tiny(pv->p); pv++;
pv->set (+scale.x, 0, +scale.y, clr_s); M.transform_tiny(pv->p); pv++;
pv->set (+scale.x, 0, -scale.y, clr_s); M.transform_tiny(pv->p); pv++;
pv->set (*(pv-4));
Stream->Unlock(5,vs_L->vb_stride);
if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE);
DU_DRAW_DP (D3DPT_TRIANGLEFAN,vs_L,vBase,2);
if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW);
}
if (bWire){
DU_DRAW_SH(dxRenderDeviceRender::Instance().m_WireShader);
FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase);
pv->set (-scale.x, 0, -scale.y, clr_w); M.transform_tiny(pv->p); pv++;
pv->set (+scale.x, 0, -scale.y, clr_w); M.transform_tiny(pv->p); pv++;
pv->set (+scale.x, 0, +scale.y, clr_w); M.transform_tiny(pv->p); pv++;
pv->set (-scale.x, 0, +scale.y, clr_w); M.transform_tiny(pv->p); pv++;
pv->set (*(pv-4));
Stream->Unlock(5,vs_L->vb_stride);
DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,4);
}
}
示例3: Calculate
void CIKLimb::Calculate(CKinematics* K,const Fmatrix &obj)
{
SCalculateData cd(this,K,obj);
m_prev_state_anim=true;
Collide(&cd);
if(cd.m_tri)
{
Matrix m ;
GoalMatrix (m,&cd) ;
#ifdef DEBUG
if(m_limb.SetGoal(m,ph_dbg_draw_mask.test(phDbgIKLimits)))
#else
if(m_limb.SetGoal(m,TRUE))
#endif
{
Fmatrix hip;
CBoneData& BD=K->LL_GetData(m_bones[0]);
hip.mul_43(K->LL_GetTransform(BD.GetParentID()),BD.bind_transform);
hip.invert();
float x[7];
Fvector pos;
pos.set(K->LL_GetTransform(m_bones[1]).c);
hip.transform_tiny(pos);
xm2im.transform_tiny(pos);
if(m_limb.SolveByPos(cast_fp(pos),x))
{
cd.m_angles=x;
CalculateBones(&cd);
m_prev_state_anim=false;
}
}
}
}
示例4: GetFaceWorld
void CEditableObject::GetFaceWorld(const Fmatrix& parent, CEditableMesh* M, int idx, Fvector* verts)
{
const Fvector* PT[3];
M->GetFacePT(idx, PT);
parent.transform_tiny(verts[0],*PT[0]);
parent.transform_tiny(verts[1],*PT[1]);
parent.transform_tiny(verts[2],*PT[2]);
}
示例5: build_mesh
//----------------------------------------------------
IC bool build_mesh(const Fmatrix& parent, CEditableMesh* mesh, CGeomPartExtractor* extractor, u32 game_mtl_mask, BOOL ignore_shader)
{
bool bResult = true;
mesh->GenerateVNormals (&parent);
// fill faces
for (SurfFaces::const_iterator sp_it=mesh->GetSurfFaces().begin(); sp_it!=mesh->GetSurfFaces().end(); sp_it++){
const IntVec& face_lst = sp_it->second;
CSurface* surf = sp_it->first;
int gm_id = surf->_GameMtl();
if (gm_id==GAMEMTL_NONE_ID){
ELog.DlgMsg (mtError,"Object '%s', surface '%s' contain invalid game material.",mesh->Parent()->m_LibName.c_str(),surf->_Name());
bResult = FALSE;
break;
}
SGameMtl* M = GMLib.GetMaterialByID(gm_id);
if (0==M){
ELog.DlgMsg (mtError,"Object '%s', surface '%s' contain undefined game material.",mesh->Parent()->m_LibName.c_str(),surf->_Name());
bResult = FALSE;
break;
}
if (!M->Flags.is(game_mtl_mask)) continue;
// check engine shader compatibility
if (!ignore_shader){
IBlender* B = EDevice.Resources->_FindBlender(surf->_ShaderName());
if (FALSE==B){
ELog.Msg (mtError,"Can't find engine shader '%s'. Object '%s', surface '%s'. Export interrupted.",surf->_ShaderName(),mesh->Parent()->m_LibName.c_str(),surf->_Name());
bResult = FALSE;
break;
}
if (TRUE==B->canBeLMAPped()){
ELog.Msg (mtError,"Object '%s', surface '%s' contain static engine shader - '%s'. Export interrupted.",mesh->Parent()->m_LibName.c_str(),surf->_Name(),surf->_ShaderName());
bResult = FALSE;
break;
}
}
const st_Face* faces = mesh->GetFaces(); VERIFY(faces);
const Fvector* vn = mesh->GetVNormals(); VERIFY(vn);
const Fvector* pts = mesh->GetVertices(); VERIFY(pts);
for (IntVec::const_iterator f_it=face_lst.begin(); f_it!=face_lst.end(); f_it++){
const st_Face& face = faces[*f_it];
Fvector v[3],n[3];
parent.transform_tiny (v[0],pts[face.pv[0].pindex]);
parent.transform_tiny (v[1],pts[face.pv[1].pindex]);
parent.transform_tiny (v[2],pts[face.pv[2].pindex]);
parent.transform_dir (n[0],vn[*f_it*3+0]); n[0].normalize();
parent.transform_dir (n[1],vn[*f_it*3+1]); n[1].normalize();
parent.transform_dir (n[2],vn[*f_it*3+2]); n[2].normalize();
const Fvector2* uv[3];
mesh->GetFaceTC (*f_it,uv);
extractor->AppendFace (surf,v,n,uv);
}
if (!bResult) break;
}
mesh->UnloadVNormals ();
return bResult;
}
示例6: RecurseTri
//--------------------------------------------------------------------------------
void CWallmarksEngine::RecurseTri(u32 t, Fmatrix &mView, CWallmarksEngine::static_wallmark &W)
{
CDB::TRI* T = sml_collector.getT()+t;
if (T->dummy) return;
T->dummy = 0xffffffff;
// Some vars
u32* v_ids = T->verts;
Fvector* v_data = sml_collector.getV();
sml_poly_src.clear ();
sml_poly_src.push_back (v_data[v_ids[0]]);
sml_poly_src.push_back (v_data[v_ids[1]]);
sml_poly_src.push_back (v_data[v_ids[2]]);
sml_poly_dest.clear ();
sPoly* P = sml_clipper.ClipPoly (sml_poly_src, sml_poly_dest);
//. todo
// uv_gen = mView * []
// UV = pos*uv_gen
if (P) {
// Create vertices and triangulate poly (tri-fan style triangulation)
FVF::LIT V0,V1,V2;
Fvector UV;
mView.transform_tiny(UV, (*P)[0]);
V0.set ((*P)[0],0,(1+UV.x)*.5f,(1-UV.y)*.5f);
mView.transform_tiny(UV, (*P)[1]);
V1.set ((*P)[1],0,(1+UV.x)*.5f,(1-UV.y)*.5f);
for (u32 i=2; i<P->size(); i++)
{
mView.transform_tiny(UV, (*P)[i]);
V2.set ((*P)[i],0,(1+UV.x)*.5f,(1-UV.y)*.5f);
W.verts.push_back (V0);
W.verts.push_back (V1);
W.verts.push_back (V2);
V1 = V2;
}
// recurse
for (auto i=0; i<3; i++)
{
u32 adj = sml_adjacency[3*t+i];
if (0xffffffff==adj) continue;
CDB::TRI* SML = sml_collector.getT() + adj;
v_ids = SML->verts;
Fvector test_normal;
test_normal.mknormal (v_data[v_ids[0]],v_data[v_ids[1]],v_data[v_ids[2]]);
float cosa = test_normal.dotproduct(sml_normal);
if (cosa<0.034899f) continue; // cos(88)
RecurseTri (adj,mView,W);
}
}
}
示例7:
void xrMU_Model::export_cform_rcast (CDB::CollectorPacked& CL, Fmatrix& xform)
{
for (u32 fit=0; fit<m_faces.size(); fit++) m_faces[fit]->flags.bProcessed = false;
v_faces adjacent;
adjacent.reserve(6*2*3);
for (v_faces_it it = m_faces.begin(); it!=m_faces.end(); it++)
{
_face* F = (*it);
Shader_xrLC& SH = F->Shader();
if (!SH.flags.bLIGHT_CastShadow) continue;
// Collect
adjacent.clear ();
for (int vit=0; vit<3; vit++)
{
_vertex* V = F->v[vit];
for (u32 adj=0; adj<V->adjacent.size(); adj++)
adjacent.push_back(V->adjacent[adj]);
}
// Unique
std::sort (adjacent.begin(),adjacent.end());
adjacent.erase (std::unique(adjacent.begin(),adjacent.end()),adjacent.end());
BOOL bAlready = FALSE;
for (u32 ait=0; ait<adjacent.size(); ait++)
{
_face* Test = adjacent[ait];
if (Test==F) continue;
if (!Test->flags.bProcessed)continue;
if (F->isEqual(*Test))
{
bAlready = TRUE;
break;
}
}
//
if (!bAlready)
{
F->flags.bProcessed = true;
Fvector P[3];
xform.transform_tiny (P[0],F->v[0]->P);
xform.transform_tiny (P[1],F->v[1]->P);
xform.transform_tiny (P[2],F->v[2]->P);
#ifdef _WIN64
CL.add_face_D (P[0],P[1],P[2],*((u64*)&F) );
#else
CL.add_face_D (P[0],P[1],P[2],*((u32*)&F) );
#endif
}
}
}
示例8: transform
void pDomain::transform(const pDomain& domain, const Fmatrix& m)
{
switch (type)
{
case PDBox:{
Fbox* bb_dest=(Fbox*)&p1;
Fbox* bb_from=(Fbox*)&domain.p1;
bb_dest->xform(*bb_from,m);
}break;
case PDPlane:
m.transform_tiny(p1,domain.p1);
m.transform_dir(p2,domain.p2);
// radius1 stores the d of the plane eqn.
radius1 = -(p1 * p2);
break;
case PDSphere:
m.transform_tiny(p1,domain.p1);
break;
case PDCylinder:
case PDCone:
m.transform_tiny(p1,domain.p1);
m.transform_dir(p2,domain.p2);
m.transform_dir(u,domain.u);
m.transform_dir(v,domain.v);
break;
case PDBlob:
m.transform_tiny(p1,domain.p1);
break;
case PDPoint:
m.transform_tiny(p1,domain.p1);
break;
case PDLine:
m.transform_tiny(p1,domain.p1);
m.transform_dir(p2,domain.p2);
break;
case PDRectangle:
m.transform_tiny(p1,domain.p1);
m.transform_dir(p2,domain.p2);
m.transform_dir(u,domain.u);
m.transform_dir(v,domain.v);
break;
case PDTriangle:
m.transform_tiny(p1,domain.p1);
m.transform_dir(p2,domain.p2);
m.transform_dir(u,domain.u);
m.transform_dir(v,domain.v);
break;
case PDDisc:
m.transform_tiny(p1,domain.p1);
m.transform_dir(p2,domain.p2);
m.transform_dir(u,domain.u);
m.transform_dir(v,domain.v);
break;
default:
NODEFAULT;
}
}
示例9: object
bool CSpaceRestrictorWrapper::inside (const Fvector &position, float radius) const
{
Fsphere sphere;
sphere.P = position;
sphere.R = radius;
typedef CShapeData::ShapeVec ShapeVec;
ShapeVec::const_iterator I = object().shapes.begin();
ShapeVec::const_iterator E = object().shapes.end();
for ( ; I != E; ++I) {
switch ((*I).type) {
case 0 : {
Fsphere temp;
m_xform.transform_tiny(temp.P,(*I).data.sphere.P);
temp.R = (*I).data.sphere.R;
if (sphere.intersect(temp))
return (true);
continue;
}
case 1 : {
Fmatrix temp;
temp.mul_43 (m_xform,(*I).data.box);
// Build points
Fvector vertices;
Fvector points[8];
Fplane plane;
vertices.set(-.5f, -.5f, -.5f); temp.transform_tiny(points[0],vertices);
vertices.set(-.5f, -.5f, +.5f); temp.transform_tiny(points[1],vertices);
vertices.set(-.5f, +.5f, +.5f); temp.transform_tiny(points[2],vertices);
vertices.set(-.5f, +.5f, -.5f); temp.transform_tiny(points[3],vertices);
vertices.set(+.5f, +.5f, +.5f); temp.transform_tiny(points[4],vertices);
vertices.set(+.5f, +.5f, -.5f); temp.transform_tiny(points[5],vertices);
vertices.set(+.5f, -.5f, +.5f); temp.transform_tiny(points[6],vertices);
vertices.set(+.5f, -.5f, -.5f); temp.transform_tiny(points[7],vertices);
plane.build(points[0],points[3],points[5]); if (plane.classify(sphere.P)>sphere.R) break;
plane.build(points[1],points[2],points[3]); if (plane.classify(sphere.P)>sphere.R) break;
plane.build(points[6],points[5],points[4]); if (plane.classify(sphere.P)>sphere.R) break;
plane.build(points[4],points[2],points[1]); if (plane.classify(sphere.P)>sphere.R) break;
plane.build(points[3],points[2],points[4]); if (plane.classify(sphere.P)>sphere.R) break;
plane.build(points[1],points[0],points[6]); if (plane.classify(sphere.P)>sphere.R) break;
return (true);
}
default : NODEFAULT;
}
}
return (false);
}
示例10: CalculateSelectedPortals
int CPortalUtils::CalculateSelectedPortals(ObjectList& sectors){
// calculate portals
Fbox bb;
Scene->GetBox(bb,OBJCLASS_SCENEOBJECT);
sCollector* CL = xr_new<sCollector>(bb);
Fmatrix T;
//1. xform + weld
UI->SetStatus("xform + weld...");
for (ObjectIt s_it=sectors.begin(); s_it!=sectors.end(); s_it++){
CSector* S=(CSector*)(*s_it);
for (SItemIt s_it=S->sector_items.begin();s_it!=S->sector_items.end();s_it++){
if (s_it->object->IsMUStatic()) continue;
s_it->GetTransform(T);
Fvector* m_verts=s_it->mesh->m_Verts;
for (u32 f_id=0; f_id<s_it->mesh->GetFCount(); f_id++){
Fvector v0, v1, v2;
st_Face& P=s_it->mesh->GetFaces()[f_id];
T.transform_tiny(v0,m_verts[P.pv[0].pindex]);
T.transform_tiny(v1,m_verts[P.pv[1].pindex]);
T.transform_tiny(v2,m_verts[P.pv[2].pindex]);
CL->add_face(v0,v1,v2,S);
}
}
}
//2. update pervertex adjacency
UI->SetStatus("updating per-vertex adjacency...");
CL->update_adjacency();
//3. find edges
UI->SetStatus("searching edges...");
CL->find_edges();
//4. sort edges
UI->SetStatus("sorting edges...");
CL->sort_edges();
//5. make portals
UI->SetStatus("calculating portals...");
CL->make_portals();
//6. export portals
UI->SetStatus("building portals...");
CL->export_portals();
Scene->UndoSave();
int iRes = CL->portals.size();
xr_delete(CL);
return iRes;
}
示例11:
u16 CIKFoot::get_ref_bone ( const Fmatrix & foot_transform, const Fmatrix &toe_transform ) const
{
Fvector n0,n1;
get_local_vector( 2, n0, m_foot_normal );
get_local_vector( 3, n1, m_foot_normal );
foot_transform.transform_tiny( n0 );
toe_transform.transform_tiny( n1 );
n0.normalize();n1.normalize();
if( n0.dotproduct( n1 ) < 0.99f )
return 3 ;
else
return 2 ;
}
示例12: ToePosition
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 ) );
}
示例13: make_shift
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;
}
示例14:
// Fill Vertices
void CSkeletonX::_FillVerticesSoft1W(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size, u16* indices, CBoneData::FacesVec& faces)
{
VERIFY (*Vertices1W);
for (CBoneData::FacesVecIt it=faces.begin(); it!=faces.end(); it++){
Fvector p[3];
u32 idx = (*it)*3;
CSkeletonWallmark::WMFace F;
for (u32 k=0; k<3; k++){
vertBoned1W& vert = Vertices1W[indices[idx+k]];
F.bone_id[k][0] = (u16)vert.matrix;
F.bone_id[k][1] = F.bone_id[k][0];
F.weight[k] = 0.f;
const Fmatrix& xform = Parent->LL_GetBoneInstance(F.bone_id[k][0]).mRenderTransform;
F.vert[k].set (vert.P);
xform.transform_tiny (p[k],F.vert[k]);
}
Fvector test_normal;
test_normal.mknormal (p[0],p[1],p[2]);
float cosa = test_normal.dotproduct(normal);
if (cosa<EPS) continue;
if (CDB::TestSphereTri(wm.ContactPoint(),size,p))
{
Fvector UV;
for (u32 k=0; k<3; k++){
Fvector2& uv = F.uv[k];
view.transform_tiny(UV,p[k]);
uv.x = (1+UV.x)*.5f;
uv.y = (1-UV.y)*.5f;
}
wm.m_Faces.push_back(F);
}
}
}
示例15: Attach
void CEditShape::Attach(CEditShape* from)
{
ApplyScale ();
// transfer data
from->ApplyScale ();
Fmatrix M = from->_Transform();
M.mulA_43 (_ITransform());
for (ShapeIt it=from->shapes.begin(); it!=from->shapes.end(); it++){
switch (it->type){
case cfSphere:{
Fsphere& T = it->data.sphere;
M.transform_tiny(T.P);
add_sphere (T);
}break;
case cfBox:{
Fmatrix B = it->data.box;
B.mulA_43 (M);
add_box (B);
}break;
default: THROW;
}
}
// common
Scene->RemoveObject (from,true,true);
xr_delete (from);
ComputeBounds ();
}