void GFXPickLights( const Vector ¢er, const float radius, vector< int > &lights, const int maxlights, const bool pickglobals ) { QVector tmp; //Beware if re-using rndvar !! Because rand returns an int and on 64 bits archs sizeof( void*) != sizeof( int) !!! //void * rndvar = (void *)rand(); int lightsenabled = _GLLightsEnabled; tmp = QVector( radius, radius, radius ); if (lightsenabled && pickglobals) { // Push global lights into the picked set for (int i = 0; i < GFX_MAX_LIGHTS; ++i) { if ((GLLights[i].options & (OpenGLL::GL_ENABLED|OpenGLL::GLL_LOCAL)) == OpenGLL::GL_ENABLED) { // It's global and enabled lights.push_back(GLLights[i].index); } } } veclinecol *tmppickt[2]; lighttable.Get( center.Cast(), tmppickt ); for (int j = 0; j < 2; j++) { veclinecol::iterator i; for (i = tmppickt[j]->begin(); i != tmppickt[j]->end(); i++) { if ( picklight( *i->lc, center, radius, lightsenabled, i->GetIndex() ) ) { lights.push_back( i->GetIndex() ); lightsenabled++; } } } std::sort( lights.begin(), lights.end(), lightsort( center, radius ) ); }
void CoordinateSelect::UpdateMouse() { if (CoordinateSelectChange==1) { Vector CamPos; Vector CamQ,CamR; _Universe->AccessCamera()->GetPQR(CamPos,CamQ,CamR); Vector mousePoint ( MouseCoordinate(CoordinateSelectmousex,CoordinateSelectmousey)); float mouseDistance= mousePoint.k*mousePoint.k; mousePoint = Transform (CamPos,CamQ,CamR,mousePoint); // QVector cp; CamPos=_Universe->AccessCamera()->GetPosition (); //float mouseDistance = mousePoint.Dot (CamR); //distance out into z...straight line... float distance = CamR.Dot ((LocalPosition-CamPos).Cast());//distance out into z...straight line... // VSFileSystem::Fprintf (stderr, "distance:%f\n",distance); //VSFileSystem::Fprintf (stderr, "mdistance:%f %f\n",mouseDistance,TMD); if (mouseDistance!=0) { LocalPosition = mousePoint*(distance/mouseDistance)+CamPos.Cast(); } else { LocalPosition = 2*CamR+CamPos.Cast(); } CoordinateSelectChange = 0; } if (CoordinateSelectChange ==2) { Vector CamPos, CamQ,CamR; _Universe->AccessCamera()->GetPQR(CamPos,CamQ,CamR); CamPos=_Universe->AccessCamera()->GetPosition (); LocalPosition = LocalPosition - CamPos; float distance = sqrt (CamR.Dot (LocalPosition));//distance out into z...straight line... //make it a ratio btw top and bottom.... for near and far; float ratio = float(g_game.y_resolution - CoordinateSelectmousey)/g_game.y_resolution; float tmp, n, f; GFXGetFrustumVars (true,&tmp,&tmp,&tmp,&tmp,&n,&f);///unkind call :-D tmp = n+ratio*ratio*ratio*(f-n);//how far n^3 law if (distance!=0) { LocalPosition = LocalPosition*(tmp/distance)+CamPos; } else { LocalPosition = CamPos+CamR*n; } CoordinateSelectChange = 0; } }
void LocationSelect::MoveLocation (Vector start,Vector Plane1, Vector Plane2, Vector Plane3) { //BindKey (1,::MouseMoveHandle); //UnbindMouse (getMouseDrawFunc()); LocalPosition = QVector(0,0,0); r = Plane3; p = Plane1; q = Plane2; local_transformation.position= start.Cast(); }
void LocationSelect::MoveLocation (Vector start,Vector Plane1, Vector Plane2) { //BindKey (1,LocationSelect::MouseMoveHandle); //UnbindMouse (getMouseDrawFunc()); //don't draw the mouse //BindKey (']',::incConstant); //BindKey ('[',::decConstant); LocalPosition = QVector(0,0,0); MakeRVector (Plane1,Plane2,r); p = Plane1; q = Plane2; local_transformation.position = start.Cast(); }
void FaceDirection::Execute() { Unit * target = group.GetUnit(); if (target==NULL){ done = finish; return; } Vector face (target->GetTransformation().getR()); if ((parent->Position()-target->Position()).Magnitude()-parent->rSize()-target->rSize()>dist) { SetDest (target->Position()); }else { SetDest(parent->Position()+face.Cast()); //VSFileSystem::vs_fprintf (stderr,"facing...cool"); } ChangeHeading::Execute(); if (!finish) { ResetDone(); } }
void LocationSelect::SetPosition (const Vector &k) { local_transformation.position = k.Cast(); }