/////////////////////////////////////////////////////////////////////// // Class : CXform // Method : rotate // Description : Append a rotation // Return Value : - // Comments : void CXform::rotate(float angle,float x,float y,float z) { matrix tmp,tmp2; const float r = (float) radians(angle); rotatem(tmp,-x,-y,-z,r); mulmm(tmp2,tmp,to); movmm(to,tmp2); rotatem(tmp,x,y,z,r); mulmm(tmp2,from,tmp); movmm(from,tmp2); }
// Update the position matrices, and // update the world-space bounding box and hotspots. // This is called once whenever the gate's position // or angle changes. void guiGate::updateBBoxes(bool noUpdateWires) { // Get the translation vars: float x, y; this->getGLcoords(x, y); // Get the angle vars: istringstream iss(gparams["angle"]); GLfloat angle; iss >> angle; loadidentitym(mModel); translatem(mModel, x, y); rotatem(mModel, angle); // Update all of the hotspots' world coordinates: map< string, gateHotspot* >::iterator hs = hotspots.begin(); while(hs != hotspots.end()) { (hs->second)->worldLocation = modelToWorld((hs->second)->modelLocation); (hs->second)->calcBBox(); hs++; } // Convert bbox to world-space: klsBBox worldBBox; worldBBox.addPoint(modelToWorld( modelBBox.getTopLeft() ) ); worldBBox.addPoint(modelToWorld( modelBBox.getTopRight() ) ); worldBBox.addPoint(modelToWorld( modelBBox.getBottomLeft() ) ); worldBBox.addPoint(modelToWorld( modelBBox.getBottomRight()) ); this->setBBox(worldBBox); // Update the connected wires' shapes to accomidate the new gate position: map < string, guiWire* >::iterator connWalk = connections.begin(); while(!noUpdateWires && connWalk != connections.end()) { (connWalk->second)->updateConnectionPos(this->getID(), connWalk->first); connWalk++; } }