本文整理汇总了C++中Fvector::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Fvector::set方法的具体用法?C++ Fvector::set怎么用?C++ Fvector::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fvector
的用法示例。
在下文中一共展示了Fvector::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closestPointOnLine
IC void closestPointOnLine(Fvector& res, const Fvector& a, const Fvector& b, const Fvector& p)
{
// Determine t (the length of the xr_vector from ‘a’ to ‘p’)
Fvector c;
c.sub(p,a);
Fvector V;
V.sub(b,a);
float d = V.magnitude();
V.div(d);
float t = V.dotproduct(c);
// Check to see if ‘t’ is beyond the extents of the line segment
if (t <= 0.0f) {
res.set(a);
return;
}
if (t >= d) {
res.set(b);
return;
}
// Return the point between ‘a’ and ‘b’
// set length of V to t. V is normalized so this is easy
res.mad (a,V,t);
}
示例2: if
void CPHMovementControl::CorrectPathDir (const Fvector &real_path_dir,const xr_vector<DetailPathManager::STravelPathPoint> & path,int index,Fvector &corrected_path_dir)
{
const float epsilon=0.1f;
float plane_motion=dXZMag(real_path_dir);
if(fis_zero(plane_motion,epsilon))
{
if(!fis_zero(plane_motion,EPS))
{
corrected_path_dir.set(real_path_dir);
corrected_path_dir.y=0.f;
corrected_path_dir.mul(1.f/plane_motion);
}
else if(index!=m_path_size-1)
{
corrected_path_dir.sub(path[index+1].position,path[index].position);
corrected_path_dir.normalize_safe();
CorrectPathDir(corrected_path_dir,path,index+1,corrected_path_dir);
}
else
{
corrected_path_dir.set(real_path_dir);
}
}
else
{
corrected_path_dir.set(real_path_dir);
}
}
示例3: UpdateCLChild
void CBlackGraviArtefact::UpdateCLChild()
{
VERIFY(!ph_world->Processing());
inherited::UpdateCLChild ();
if (getVisible() && m_pPhysicsShell) {
if (m_bStrike) {
Fvector P;
P.set(Position());
feel_touch_update(P,m_fRadius);
GraviStrike();
CParticlesObject* pStaticPG;
pStaticPG = CParticlesObject::Create(*m_sParticleName,TRUE);
Fmatrix pos;
pos.set(XFORM());
Fvector vel;
//vel.sub(Position(),ps_Element(0).vPosition);
//vel.div((Level().timeServer()-ps_Element(0).dwTime)/1000.f);
vel.set(0,0,0);
pStaticPG->UpdateParent(pos, vel);
pStaticPG->Play();
m_bStrike = false;
}
}else if(H_Parent()) XFORM().set(H_Parent()->XFORM());
}
示例4: get_reject_pos
bool CLevelChanger::get_reject_pos(Fvector& p, Fvector& r)
{
p.set(0,0,0);
r.set(0,0,0);
//-- db.actor:set_actor_position(patrol("t_way"):point(0))
//-- local dir = patrol("t_look"):point(0):sub(patrol("t_way"):point(0))
//-- db.actor:set_actor_direction(-dir:getH())
if(m_ini_file && m_ini_file->section_exist("pt_move_if_reject"))
{
LPCSTR p_name = m_ini_file->r_string("pt_move_if_reject", "path");
const CPatrolPath* patrol_path = ai().patrol_paths().path(p_name);
VERIFY (patrol_path);
const CPatrolPoint* pt;
pt = &patrol_path->vertex(0)->data();
p = pt->position();
Fvector tmp;
pt = &patrol_path->vertex(1)->data();
tmp.sub (pt->position(),p);
tmp.getHP (r.y,r.x);
return true;
}
return false;
}
示例5: sCollector
sCollector(const Fbox &bb){
VMscale.set (bb.max.x-bb.min.x, bb.max.y-bb.min.y, bb.max.z-bb.min.z);
VMmin.set (bb.min);
VMeps.set (VMscale.x/clpMX/2,VMscale.y/clpMY/2,VMscale.z/clpMZ/2);
VMeps.x = (VMeps.x<EPS_L)?VMeps.x:EPS_L;
VMeps.y = (VMeps.y<EPS_L)?VMeps.y:EPS_L;
VMeps.z = (VMeps.z<EPS_L)?VMeps.z:EPS_L;
}
示例6:
void CClimableObject::DSideToAxis (CPHCharacter *actor,Fvector &dir)const
{
VERIFY(actor);
DToAxis(actor,dir);
Fvector side;side.set(m_side);
to_mag_and_dir(side);
side.mul(side.dotproduct(dir));
dir.set(side);
}
示例7: DToPlain
void CClimableObject::DToPlain(CPHCharacter *actor,Fvector &dist)const
{
VERIFY(actor);
DToAxis(actor,dist);
Fvector norm;norm.set(m_norm);
to_mag_and_dir(norm);
float dot=norm.dotproduct(dist);
norm.mul(dot);
dist.set(norm);
}
示例8: closestPointOnTriangle
IC void closestPointOnTriangle(Fvector& result, const cl_tri& T, const Fvector& P) {
Fvector Rab; closestPointOnEdge(Rab, T.p[0], T.p[1], T.e10, T.e10s, P); float dAB = P.distance_to_sqr(Rab);
Fvector Rbc; closestPointOnEdge(Rbc, T.p[1], T.p[2], T.e21, T.e21s, P); float dBC = P.distance_to_sqr(Rbc);
Fvector Rca; closestPointOnEdge(Rca, T.p[2], T.p[0], T.e02, T.e02s, P); float dCA = P.distance_to_sqr(Rca);
float min;
if (dBC < dAB) { min = dBC; result.set(Rbc); }
else { min = dAB; result.set(Rab); }
if (dCA < min) result.set(Rca);
}
示例9: PlayEntranceParticles
void CCustomZone::PlayEntranceParticles(CGameObject* pObject)
{
m_entrance_sound.play_at_pos (0, pObject->Position());
LPCSTR particle_str = NULL;
if(pObject->Radius()<SMALL_OBJECT_RADIUS)
{
if(!m_sEntranceParticlesSmall)
return;
particle_str = m_sEntranceParticlesSmall.c_str();
}
else
{
if(!m_sEntranceParticlesBig)
return;
particle_str = m_sEntranceParticlesBig.c_str();
}
Fvector vel;
CPhysicsShellHolder* shell_holder=smart_cast<CPhysicsShellHolder*>(pObject);
if(shell_holder)
shell_holder->PHGetLinearVell(vel);
else
vel.set (0,0,0);
//выбрать случайную косточку на объекте
CParticlesPlayer* PP = smart_cast<CParticlesPlayer*>(pObject);
if (PP)
{
u16 play_bone = PP->GetRandomBone();
if (play_bone!=BI_NONE)
{
CParticlesObject* pParticles = CParticlesObject::Create(particle_str, TRUE);
Fmatrix xform;
Fvector dir;
if(fis_zero (vel.magnitude()))
dir.set (0,1,0);
else
{
dir.set (vel);
dir.normalize ();
}
PP->MakeXFORM (pObject,play_bone,dir,Fvector().set(0,0,0),xform);
pParticles->UpdateParent(xform, vel);
pParticles->Play (false);
}
}
if(m_zone_flags.test(eBoltEntranceParticles) && smart_cast<CBolt*>(pObject))
PlayBoltEntranceParticles();
}
示例10: ai
void CLevelGraph::draw_covers ()
{
float half_size = ai().level_graph().header().cell_size()*.5f;
xr_vector<CCoverPoint*> nearest;
nearest.reserve (1000);
ai().cover_manager().covers().nearest(Device.vCameraPosition,5.f,nearest);
xr_vector<CCoverPoint*>::const_iterator I = nearest.begin();
xr_vector<CCoverPoint*>::const_iterator E = nearest.end();
for ( ; I != E; ++I) {
Fvector position = (*I)->position();
position.y += 1.f;
Level().debug_renderer().draw_aabb (position,half_size - .01f,1.f,ai().level_graph().header().cell_size()*.5f-.01f,D3DCOLOR_XRGB(0*255,255,0*255));
CVertex *v = vertex((*I)->level_vertex_id());
Fvector direction;
float best_value = -1.f;
u32 i = 0, j = 0;
for (; i<36; ++i) {
float value = cover_in_direction(float(10*i)/180.f*PI,v);
direction.setHP (float(10*i)/180.f*PI,0);
direction.normalize ();
direction.mul (value*half_size);
direction.add (position);
direction.y = position.y;
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(0,0,255));
value = compute_square(float(10*i)/180.f*PI,PI/2.f,v);
if (value > best_value) {
best_value = value;
j = i;
}
}
direction.set (position.x - half_size*float(v->cover(0))/15.f,position.y,position.z);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
direction.set (position.x,position.y,position.z + half_size*float(v->cover(1))/15.f);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
direction.set (position.x + half_size*float(v->cover(2))/15.f,position.y,position.z);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
direction.set (position.x,position.y,position.z - half_size*float(v->cover(3))/15.f);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
float value = cover_in_direction(float(10*j)/180.f*PI,v);
direction.setHP (float(10*j)/180.f*PI,0);
direction.normalize ();
direction.mul (value*half_size);
direction.add (position);
direction.y = position.y;
Level().debug_renderer().draw_line (Fidentity,position,direction,D3DCOLOR_XRGB(0,0,0));
}
}
示例11: PathDIrPoint
void CPHMovementControl::PathDIrPoint(const xr_vector<DetailPathManager::STravelPathPoint> &path, int index, float distance, float precesition, Fvector &dir )
{
Fvector to_path_point;
Fvector corrected_path_dir;CorrectPathDir(GetPathDir(),path,index,corrected_path_dir);
to_path_point.sub(vPathPoint,vPosition); //_new position
float mag=to_path_point.magnitude();
if(mag<EPS) //near the point
{
if(0==index||m_path_size-1==index) //on path eidge
{
dir.set(corrected_path_dir);//??
return;
}
dir.sub(path[index].position,path[index-1].position);
dir.normalize_safe();
dir.add(corrected_path_dir);
dir.normalize_safe();
}
to_path_point.mul(1.f/mag);
if(m_path_size-1==index)//on_path_edge
{
dir.set(to_path_point);
return;
}
if(mag<EPS||fis_zero(dXZMag(to_path_point),EPS))
{
dir.set(corrected_path_dir);
return;//mean dir
}
Fvector tangent;
tangent.crossproduct(Fvector().set(0,1,0),to_path_point);
VERIFY(!fis_zero(tangent.magnitude()));
tangent.normalize();
if(dir.square_magnitude()>EPS)
{
if(tangent.dotproduct(dir)<0.f)tangent.invert();
}
else
{
if(tangent.dotproduct(corrected_path_dir)<0.f)tangent.invert();
}
if(mag>FootRadius())to_path_point.mul(precesition);
else to_path_point.mul(mag*precesition);
dir.add(tangent,to_path_point);
dir.normalize_safe();
}
示例12: 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);
}
示例13: detectSector
IRender_Sector* CRender::detectSector(const Fvector& P)
{
IRender_Sector* S = NULL;
Fvector dir;
Sectors_xrc.ray_options (CDB::OPT_ONLYNEAREST);
dir.set (0,-1,0);
S = detectSector(P,dir);
if (NULL==S)
{
dir.set (0,1,0);
S = detectSector(P,dir);
}
return S;
}
示例14: GetJumpDir
void CElevatorState::GetJumpDir(const Fvector& accel,Fvector& dir)
{
VERIFY(m_ladder&&m_character);
Fvector norm,side;
m_ladder->DDNorm(norm);
m_ladder->DDSide(side);
Fvector ac;ac.set(accel).normalize_safe();
float side_component=ac.dotproduct(side);
dir.set(norm);
if(_abs(side_component)>M_SQRT1_2)
{
if(side_component<0.f)side.invert();
dir.add(side);
dir.normalize_safe();
}
}
示例15: UpdateCL
void CSnork::UpdateCL()
{
inherited::UpdateCL ();
//////////////////////////////////////////////////////////////////////////
//CObject *obj = Level().CurrentEntity();
//if (!obj) return;
//find_geometry ();
//////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
// test
CObject *obj = Level().CurrentEntity();
if (!obj) return;
const CCoverPoint *point = CoverMan->find_cover(obj->Position(), 10.f, 30.f);
DBG().level_info(this).clear();
if (point) {
DBG().level_info(this).add_item (point->position(),COLOR_RED);
Fvector pos;
pos.set(Position());
pos.y+=5.f;
DBG().level_info(this).add_item (Position(),pos,COLOR_GREEN);
}
#endif
}