本文整理汇总了C++中Fplane::classify方法的典型用法代码示例。如果您正苦于以下问题:C++ Fplane::classify方法的具体用法?C++ Fplane::classify怎么用?C++ Fplane::classify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fplane
的用法示例。
在下文中一共展示了Fplane::classify方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: if
bool object::inside (Fvector const &position) const
{
CCF_Shape *shape = static_cast<CCF_Shape*>(collidable.model);
VERIFY (shape);
typedef xr_vector<CCF_Shape::shape_def> Shapes;
Shapes::const_iterator i = shape->shapes.begin();
Shapes::const_iterator e = shape->shapes.end();
for ( ; i != e; ++i) {
switch ((*i).type) {
case 0 : {
if ((*i).data.sphere.P.distance_to(position) <= (*i).data.sphere.R)
return (true);
continue;
}
case 1 : {
Fmatrix matrix;
const Fmatrix &box = (*i).data.box;
matrix.mul_43 (XFORM(),box);
Fvector A,B[8];
Fplane plane;
A.set (-.5f, -.5f, -.5f); matrix.transform_tiny(B[0],A);
A.set (-.5f, -.5f, +.5f); matrix.transform_tiny(B[1],A);
A.set (-.5f, +.5f, +.5f); matrix.transform_tiny(B[2],A);
A.set (-.5f, +.5f, -.5f); matrix.transform_tiny(B[3],A);
A.set (+.5f, +.5f, +.5f); matrix.transform_tiny(B[4],A);
A.set (+.5f, +.5f, -.5f); matrix.transform_tiny(B[5],A);
A.set (+.5f, -.5f, +.5f); matrix.transform_tiny(B[6],A);
A.set (+.5f, -.5f, -.5f); matrix.transform_tiny(B[7],A);
plane.build (B[0],B[3],B[5]); if (plane.classify(position) <= 0.f) return (true);
plane.build (B[1],B[2],B[3]); if (plane.classify(position) <= 0.f) return (true);
plane.build (B[6],B[5],B[4]); if (plane.classify(position) <= 0.f) return (true);
plane.build (B[4],B[2],B[1]); if (plane.classify(position) <= 0.f) return (true);
plane.build (B[3],B[2],B[4]); if (plane.classify(position) <= 0.f) return (true);
plane.build (B[1],B[0],B[6]); if (plane.classify(position) <= 0.f) return (true);
continue;
}
default : NODEFAULT;
}
}
return (false);
}
示例3: CreateFromPortal
void CFrustum::CreateFromPortal(sPoly* poly, Fvector& vPN, Fvector& vBase, Fmatrix& mFullXFORM)
{
Fplane P;
P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);
if (poly->size()>6)
{
SimplifyPoly_AABB(poly, P);
P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);
}
// Check plane orientation relative to viewer
// and reverse if needed
if (P.classify(vBase) < 0)
{
std::reverse(poly->begin(), poly->end());
P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);
}
// Base creation
CreateFromPoints(poly->begin(), poly->size(), vBase);
// Near clipping plane
_add(P);
// Far clipping plane
Fmatrix& M = mFullXFORM;
P.n.x = -(M._14 - M._13);
P.n.y = -(M._24 - M._23);
P.n.z = -(M._34 - M._33);
P.d = -(M._44 - M._43);
float denom = 1.0f / P.n.magnitude();
P.n.x *= denom;
P.n.y *= denom;
P.n.z *= denom;
P.d *= denom;
_add(P);
}
示例4: WORD
//.........这里部分代码省略.........
// *** Calc normal
Fvector vNorm;
vNorm.set(0,0,0);
for (u32 n=0; n<normals.size(); n++)
vNorm.add(normals[n]);
vNorm.div(float(normals.size()));
vNorm.normalize();
/*
{
// second algorithm (Magic)
Fvector N,O;
N.set(vNorm);
O.set(points[0]);
Mgc::OrthogonalPlaneFit(
points.size(),(Mgc::Vector3*)points.begin(),
*((Mgc::Vector3*)&O),
*((Mgc::Vector3*)&N)
);
if (N.y<0) N.invert();
N.normalize();
vNorm.lerp(vNorm,N,.3f);
vNorm.normalize();
}
*/
// *** Align plane
Fvector vOffs;
vOffs.set(0,-1000,0);
Fplane PL; PL.build(vOffs,vNorm);
for (u32 p=0; p<points.size(); p++)
{
float dist = PL.classify(points[p]);
if (dist>0) {
vOffs = points[p];
PL.build(vOffs,vNorm);
}
}
// *** Create node and register it
N.Sector =Sector; // sector
N.Plane.build (vOffs,vNorm); // build plane
D.set (0,1,0);
N.Plane.intersectRayPoint(PointDown,D,N.Pos); // "project" position
// *** Validate results
vNorm.set(0,1,0);
if (vNorm.dotproduct(N.Plane.n)<_cos(deg2rad(60.f))) return FALSE;
float y_old = vAt.y;
float y_new = N.Pos.y;
if (y_old>y_new) {
// down
if (y_old-y_new > g_params.fCanDOWN ) return FALSE;
} else {
// up
if (y_new-y_old > g_params.fCanUP ) return FALSE;
}
// *** Validate plane
{
Fvector PLP; D.set(0,-1,0);
int num_successed_rays = 0;
for (int x=-RCAST_Count; x<=RCAST_Count; x++)
{
示例5: CreateNode
//.........这里部分代码省略.........
// *** Calc normal
Fvector vNorm;
vNorm.set(0,0,0);
for (DWORD n=0; n<normals.size(); n++)
vNorm.add(normals[n]);
vNorm.div(float(normals.size()));
vNorm.normalize();
/*
{
// second algorithm (Magic)
Fvector N,O;
N.set(vNorm);
O.set(points[0]);
Mgc::OrthogonalPlaneFit(
points.size(),(Mgc::Vector3*)points.begin(),
*((Mgc::Vector3*)&O),
*((Mgc::Vector3*)&N)
);
if (N.y<0) N.invert();
N.normalize();
vNorm.lerp(vNorm,N,.3f);
vNorm.normalize();
}
*/
// *** Align plane
Fvector vOffs;
vOffs.set(0,-1000,0);
Fplane PL; PL.build(vOffs,vNorm);
for (DWORD p=0; p<points.size(); p++)
{
float dist = PL.classify(points[p]);
if (dist>0) {
vOffs = points[p];
PL.build(vOffs,vNorm);
}
}
// *** Create node and register it
N.Plane.build (vOffs,vNorm); // build plane
D.set (0,1,0);
N.Plane.intersectRayPoint(PointDown,D,N.Pos); // "project" position
// *** Validate results
vNorm.set(0,1,0);
if (vNorm.dotproduct(N.Plane.n)<_cos(deg2rad(60.f))) return FALSE;
float y_old = vAt.y;
float y_new = N.Pos.y;
if (y_old>y_new) {
// down
if (y_old-y_new > m_Params.fCanDOWN ) return FALSE;
} else {
// up
if (y_new-y_old > m_Params.fCanUP ) return FALSE;
}
// *** Validate plane
{
Fvector PLP; D.set(0,-1,0);
int num_successed_rays = 0;
for (int x=-RCAST_Count; x<=RCAST_Count; x++)
{
P.x = N.Pos.x + coeff*float(x);
示例6: if
void CLightShadows::render ()
{
// Gain access to collision-DB
CDB::MODEL* DB = g_pGameLevel->ObjectSpace.GetStaticModel();
CDB::TRI* TRIS = DB->get_tris();
Fvector* VERTS = DB->get_verts();
int slot_line = S_rt_size/S_size;
// Projection and xform
float _43 = Device.mProject._43;
Device.mProject._43 -= 0.002f;
RCache.set_xform_world (Fidentity);
RCache.set_xform_project (Device.mProject);
Fvector View = Device.vCameraPosition;
// Render shadows
RCache.set_Shader (sh_World);
RCache.set_Geometry (geom_World);
int batch = 0;
u32 Offset = 0;
FVF::LIT* pv = (FVF::LIT*) RCache.Vertex.Lock (batch_size*3,geom_World->vb_stride,Offset);
for (u32 s_it=0; s_it<shadows.size(); s_it++)
{
Device.Statistic->RenderDUMP_Srender.Begin ();
shadow& S = shadows[s_it];
float Le = S.L->color.intensity()*S.E;
int s_x = S.slot%slot_line;
int s_y = S.slot/slot_line;
Fvector2 t_scale, t_offset;
t_scale.set (float(S_size)/float(S_rt_size),float(S_size)/float(S_rt_size));
t_scale.mul (.5f);
t_offset.set(float(s_x)/float(slot_line),float(s_y)/float(slot_line));
t_offset.x += .5f/S_rt_size;
t_offset.y += .5f/S_rt_size;
// Search the cache
cache_item* CI = 0; BOOL bValid = FALSE;
cache_item CI_what; CI_what.O = S.O; CI_what.L = S.L; CI_what.tris=0;
xr_vector<cache_item>::iterator CI_ptr = std::lower_bound(cache.begin(),cache.end(),CI_what,cache_search);
if (CI_ptr==cache.end())
{ // empty ?
CI_ptr = cache.insert (CI_ptr,CI_what);
CI = &*CI_ptr;
bValid = FALSE;
} else {
if (CI_ptr->O != CI_what.O || CI_ptr->L != CI_what.L)
{ // we found something different
CI_ptr = cache.insert (CI_ptr,CI_what);
CI = &*CI_ptr;
bValid = FALSE;
} else {
// Everything, OK. Check if info is still relevant...
CI = &*CI_ptr;
bValid = TRUE;
if (!CI->Op.similar(CI->O->renderable.xform.c)) bValid = FALSE;
else if (!CI->Lp.similar(CI->L->position)) bValid = FALSE;
}
}
CI->time = Device.dwTimeGlobal; // acess time
if (!bValid) {
// Frustum
CFrustum F;
F.CreateFromMatrix (S.M,FRUSTUM_P_ALL);
// Query
xrc.frustum_options (0);
xrc.frustum_query (DB,F);
if (0==xrc.r_count()) continue;
// Clip polys by frustum
tess.clear ();
for (CDB::RESULT* p = xrc.r_begin(); p!=xrc.r_end(); p++)
{
VERIFY((p->id>=0)&&(p->id<DB->get_tris_count()));
//
CDB::TRI& t = TRIS[p->id];
if (t.suppress_shadows) continue;
sPoly A,B;
A.push_back (VERTS[t.verts[0]]);
A.push_back (VERTS[t.verts[1]]);
A.push_back (VERTS[t.verts[2]]);
// Calc plane, throw away degenerate tris and invisible to light polygons
Fplane P; float mag = 0;
Fvector t1,t2,n;
t1.sub (A[0],A[1]);
t2.sub (A[0],A[2]);
n.crossproduct (t1,t2);
mag = n.square_magnitude();
if (mag<EPS_S) continue;
n.mul (1.f/_sqrt(mag));
P.build_unit_normal (A[0],n);
float DOT_Fade = P.classify(S.L->position);
if (DOT_Fade<0) continue;
// Clip polygon
sPoly* clip = F.ClipPoly (A,B);
if (0==clip) continue;
//.........这里部分代码省略.........