void RevolverTool::display(GLContextData& contextData) const { if(getApplicationTime()<showNumbersTime) { /* Set up OpenGL state: */ glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT); glDisable(GL_LIGHTING); glLineWidth(1.0f); glColor3f(0.0f,1.0f,0.0f); glPushMatrix(); /* Draw the "revolver chambers:" */ glMultMatrix(calcHUDTransform(sourceDevice->getPosition())); Scalar chamberAngle=Scalar(2)*Math::Constants<Scalar>::pi/Scalar(factory->numChambers); Scalar angleOffset=Scalar(0); double animTime=(getApplicationTime()-(showNumbersTime-1.0))*2.0; if(animTime<1.0) angleOffset=chamberAngle*Scalar(1.0-animTime); for(int i=0;i<factory->numChambers;++i) { Scalar angle=chamberAngle*Scalar(i)+angleOffset; GLNumberRenderer::Vector pos; pos[0]=Math::sin(angle)*Scalar(getUiSize()*4.0f); pos[1]=Math::cos(angle)*Scalar(getUiSize()*4.0f); pos[2]=0.0f; numberRenderer.drawNumber(pos,(currentChamber+i)%factory->numChambers+1,contextData,0,0); } glPopMatrix(); glPopAttrib(); } }
void RevolverTool::display(GLContextData& contextData) const { if(getApplicationTime()<showNumbersTime) { /* Get the context data item: */ DataItem* dataItem=contextData.retrieveDataItem<DataItem>(this); /* Set up OpenGL state: */ glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT); glDisable(GL_LIGHTING); glLineWidth(1.0f); glColor3f(0.0f,1.0f,0.0f); glPushMatrix(); /* Draw the "revolver chambers:" */ glMultMatrix(getDeviceTransformation(0)); Scalar chamberAngle=Scalar(2)*Math::Constants<Scalar>::pi/Scalar(factory->numButtons); Scalar angleOffset=Scalar(0); double animTime=(getApplicationTime()-(showNumbersTime-1.0))*2.0; if(animTime<1.0) angleOffset=chamberAngle*Scalar(1.0-animTime); for(int i=0;i<factory->numButtons;++i) { Scalar angle=chamberAngle*Scalar(i)+angleOffset; Point position(Math::sin(angle)*Scalar(getUiSize()*4.0f),Scalar(0),Math::cos(angle)*Scalar(getUiSize()*4.0f)); dataItem->writeNumber(position,(mappedButtonIndex+i)%factory->numButtons+1); } glPopMatrix(); glPopAttrib(); } }
MouseDialogNavigationToolFactory::MouseDialogNavigationToolFactory(ToolManager& toolManager) :ToolFactory("MouseDialogNavigationTool",toolManager), rotatePlaneOffset(getInchFactor()*Scalar(3)), rotateFactor(getInchFactor()*Scalar(3)), screenDollyingDirection(0,-1,0), screenScalingDirection(0,-1,0), dollyFactor(Scalar(1)), scaleFactor(getInchFactor()*Scalar(3)), spinThreshold(getUiSize()*Scalar(2)), interactWithWidgets(true) { /* Initialize tool layout: */ layout.setNumButtons(1); /* Insert class into class hierarchy: */ ToolFactory* navigationToolFactory=toolManager.loadClass("NavigationTool"); navigationToolFactory->addChildClass(this); addParentClass(navigationToolFactory); /* Load class settings: */ Misc::ConfigurationFileSection cfs=toolManager.getToolClassSection(getClassName()); rotatePlaneOffset=cfs.retrieveValue<Scalar>("./rotatePlaneOffset",rotatePlaneOffset); rotateFactor=cfs.retrieveValue<Scalar>("./rotateFactor",rotateFactor); screenDollyingDirection=cfs.retrieveValue<Vector>("./screenDollyingDirection",screenDollyingDirection); screenScalingDirection=cfs.retrieveValue<Vector>("./screenScalingDirection",screenScalingDirection); dollyFactor=cfs.retrieveValue<Scalar>("./dollyFactor",dollyFactor); scaleFactor=cfs.retrieveValue<Scalar>("./scaleFactor",scaleFactor); spinThreshold=cfs.retrieveValue<Scalar>("./spinThreshold",spinThreshold); interactWithWidgets=cfs.retrieveValue<bool>("./interactWithWidgets",interactWithWidgets); /* Set tool class' factory pointer: */ MouseDialogNavigationTool::factory=this; }
MouseCursorFaker::MouseCursorFaker(const InputDevice* sDevice,const char* cursorImageFileName,unsigned int cursorNominalSize) :device(sDevice), cursorImage(Images::readCursorFile(cursorImageFileName,cursorNominalSize)), cursorSize(getUiSize(),getUiSize(),0), cursorHotspot(0,1,0) { /* Calculate the cursor texture coordinate box: */ Geometry::Point<float,2> tcMin,tcMax; for(int i=0;i<2;++i) { unsigned int texSize; for(texSize=1;texSize<cursorImage.getSize(i);texSize<<=1) ; tcMin[i]=0.5f/float(texSize); tcMax[i]=(float(cursorImage.getSize(i))-0.5f)/float(texSize); } cursorTexCoordBox=Geometry::Box<float,2>(tcMin,tcMax); }
DaisyWheelToolFactory::DaisyWheelToolFactory(ToolManager& toolManager) :ToolFactory("DaisyWheelTool",toolManager), innerRadius(getUiSize()*Scalar(8)),outerRadius(getUiSize()*Scalar(24)) { /* Initialize tool layout: */ layout.setNumDevices(1); layout.setNumButtons(0,1); /* Insert class into class hierarchy: */ ToolFactory* toolFactory=toolManager.loadClass("UserInterfaceTool"); toolFactory->addChildClass(this); addParentClass(toolFactory); /* Load class settings: */ Misc::ConfigurationFileSection cfs=toolManager.getToolClassSection(getClassName()); innerRadius=cfs.retrieveValue<Scalar>("./innerRadius",innerRadius); outerRadius=cfs.retrieveValue<Scalar>("./outerRadius",outerRadius); /* Set tool class' factory pointer: */ DaisyWheelTool::factory=this; }
RevolverTool::RevolverTool(const ToolFactory* factory,const ToolInputAssignment& inputAssignment) :TransformTool(factory,inputAssignment), numberRenderer(float(getUiSize())*1.5f,true), currentChamber(0), showNumbersTime(0.0) { /* Set the transformation source device: */ if(input.getNumButtonSlots()>1) sourceDevice=getButtonDevice(1); else if(input.getNumValuatorSlots()>0) sourceDevice=getValuatorDevice(0); else sourceDevice=getButtonDevice(0); // User didn't select anything to forward; let's just pretend it makes sense }
PlaneSnapInputDeviceToolFactory::PlaneSnapInputDeviceToolFactory(ToolManager& toolManager) :ToolFactory("PlaneSnapInputDeviceTool",toolManager), markerSize(getUiSize()) { /* Initialize tool layout: */ layout.setNumButtons(1); /* Insert class into class hierarchy: */ ToolFactory* inputDeviceToolFactory=toolManager.loadClass("InputDeviceTool"); inputDeviceToolFactory->addChildClass(this); addParentClass(inputDeviceToolFactory); /* Load class settings: */ Misc::ConfigurationFileSection cfs=toolManager.getToolClassSection(getClassName()); markerSize=cfs.retrieveValue<Scalar>("./markerSize",markerSize); /* Set tool class' factory pointer: */ PlaneSnapInputDeviceTool::factory=this; }
SketchingToolFactory::SketchingToolFactory(ToolManager& toolManager) :ToolFactory("SketchingTool",toolManager), detailSize(getUiSize()), curveFileName("SketchingTool.curves") { /* Initialize tool layout: */ layout.setNumButtons(1); /* Insert class into class hierarchy: */ ToolFactory* toolFactory=toolManager.loadClass("UtilityTool"); toolFactory->addChildClass(this); addParentClass(toolFactory); /* Load class settings: */ Misc::ConfigurationFileSection cfs=toolManager.getToolClassSection(getClassName()); detailSize=cfs.retrieveValue<Scalar>("./detailSize",detailSize); curveFileName=cfs.retrieveString("./curveFileName",curveFileName); /* Set tool class' factory pointer: */ SketchingTool::factory=this; }
SixAxisSurfaceNavigationToolFactory::SixAxisSurfaceNavigationToolFactory(ToolManager& toolManager) :ToolFactory("SixAxisSurfaceNavigationTool",toolManager), canRoll(true), bankTurns(false),levelSpeed(5), canFly(true), probeSize(getDisplaySize()), maxClimb(getDisplaySize()), fixAzimuth(false), drawHud(true),hudColor(0.0f,1.0f,0.0f),hudRadius(float(getFrontplaneDist()*1.25f)),hudFontSize(float(getUiSize())*1.5f) { /* Initialize tool layout: */ layout.setNumValuators(6); /* Load class settings: */ Misc::ConfigurationFileSection cfs=toolManager.getToolClassSection(getClassName()); Vector trans; for(int i=0;i<3;++i) trans[i]=getDisplaySize(); trans=cfs.retrieveValue<Vector>("./translateFactors",trans); for(int i=0;i<3;++i) translateFactors[i]=trans[i]; Vector rot=cfs.retrieveValue<Vector>("./rotateFactors",Vector(180,180,180)); for(int i=0;i<3;++i) rotateFactors[i]=Math::rad(rot[i]); canRoll=cfs.retrieveValue<bool>("./canRoll",canRoll); bankTurns=cfs.retrieveValue<bool>("./bankTurns",bankTurns); levelSpeed=cfs.retrieveValue<Scalar>("./levelSpeed",levelSpeed); if(levelSpeed<Scalar(0)) levelSpeed=Scalar(0); canFly=cfs.retrieveValue<bool>("./canFly",canFly); probeSize=cfs.retrieveValue<Scalar>("./probeSize",probeSize); maxClimb=cfs.retrieveValue<Scalar>("./maxClimb",maxClimb); fixAzimuth=cfs.retrieveValue<bool>("./fixAzimuth",fixAzimuth); drawHud=cfs.retrieveValue<bool>("./drawHud",drawHud); hudColor=cfs.retrieveValue<Color>("./hudColor",hudColor); hudRadius=cfs.retrieveValue<float>("./hudRadius",hudRadius); hudFontSize=cfs.retrieveValue<float>("./hudFontSize",hudFontSize); /* Insert class into class hierarchy: */ ToolFactory* navigationToolFactory=toolManager.loadClass("SurfaceNavigationTool"); navigationToolFactory->addChildClass(this); addParentClass(navigationToolFactory); /* Set tool class' factory pointer: */ SixAxisSurfaceNavigationTool::factory=this; }
void RevolverTool::initContext(GLContextData& contextData) const { /* Create and register a data item: */ DataItem* dataItem=new DataItem(getUiSize()*2.0f); contextData.addDataItem(this,dataItem); }