本文整理汇总了C++中QVector::Cast方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::Cast方法的具体用法?C++ QVector::Cast怎么用?C++ QVector::Cast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::Cast方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BeginDrawState
bool PointStarVlist::BeginDrawState (const QVector ¢er, const Vector & velocity, const Vector & torque, bool roll, bool yawpitch, int whichTexture) {
UpdateGraphics();
static bool StarStreaks=XMLSupport::parse_bool(vs_config->getVariable("graphics","star_streaks","false"));
GFXColorMaterial(AMBIENT|DIFFUSE);
bool ret=false;
if (StarStreaks) {
Matrix rollMatrix;
static float velstreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_scale","5"));
static float minstreak= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_min","1"));
static float fov_smoothing=XMLSupport::parse_float(vs_config->getVariable("graphics","warp.fovlink.smoothing",".4"));
float fov_smoot = pow(double(fov_smoothing),GetElapsedTime());
Vector vel (-velocity*velstreakscale);
float speed = vel.Magnitude();
if ((smoothstreak>=minstreak||vel.MagnitudeSquared()>=minstreak*minstreak)&&(speed>1.0e-7)) {
ret=true;
vel*=1./speed;
speed = fov_smoot*speed + (1-fov_smoot)*smoothstreak;
if (speed<minstreak) speed=minstreak;
static float streakcap = XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_max","100"));
if (speed>streakcap) {
speed=streakcap;
}
vel=vel*speed;
smoothstreak=speed;
GFXColorVertex * v = vlist->BeginMutate(0)->colors;
int numvertices = vlist->GetNumVertices();
static float torquestreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","torque_star_streak_scale","1"));
for (int j=0; j<numvertices-1; j+=2) {
int i=j;
// if (SlowStarStreaks)
// i=((rand()%numvertices)/2)*2;
Vector vpoint (v[i+1].x,v[i+1].y,v[i+1].z);
Vector recenter =(vpoint-center.Cast());
if (roll) {
RotateAxisAngle(rollMatrix,torque,torque.Magnitude()*torquestreakscale*.003);
vpoint = Transform(rollMatrix,recenter)+center.Cast();
}
v[i].x=vpoint.i-vel.i;
v[i].y=vpoint.j-vel.j;
v[i].z=vpoint.k-vel.k;
// static float NumSlowStarStreaks=XMLSupport::parse_float(vs_config->getVariable("graphics","num_star_streaks",".05"));
// if (SlowStarStreaks&&j<NumSlowStarStreaks*numvertices)
// break;
}
vlist->EndMutate();
}
}
if (ret) {
vlist->LoadDrawState();
vlist->BeginDrawState();
} else {
nonstretchvlist->LoadDrawState();
nonstretchvlist->BeginDrawState();
}
return ret;
}
示例2: AUDListener
void AUDListener (const QVector & pos, const Vector & vel) {
#ifdef HAVE_AL
mylistener.pos = pos.Cast();
mylistener.vel = vel;
if (g_game.sound_enabled) {
if (usepositional)
alListener3f (AL_POSITION, scalepos*pos.i,scalepos*pos.j,scalepos*pos.k);
if (usedoppler)
alListener3f (AL_VELOCITY, scalevel*vel.i,scalevel*vel.j,scalevel*vel.k);
}
// printf ("(%f,%f,%f) <%f %f %f>\n",pos.i,pos.j,pos.k,vel.i,vel.j,vel.k);
#endif
}
示例3: dockingdistance
static float dockingdistance (Unit* port, Unit * un) {
vector<DockingPorts>::const_iterator i =port->GetImageInformation().dockingports.begin();
vector<DockingPorts>::const_iterator end =port->GetImageInformation().dockingports.end();
QVector pos (InvTransform (port->cumulative_transformation_matrix,un->Position()));
float mag=FLT_MAX;
for (;i!=end;++i) {
float tmag =(pos.Cast()-(*i).pos).Magnitude()-un->rSize()-(*i).radius;
if (tmag < mag)
mag=tmag;
}
if (mag==FLT_MAX)
return UnitUtil::getDistance(port,un);
return mag;
}