void RenderablePlaneProjection::update(const UpdateData& data) { double time = data.time; const Image img = openspace::ImageSequencer2::ref().getLatestImageForInstrument(_instrument); if (img.path == "") return; else _hasImage = true; _stateMatrix = SpiceManager::ref().positionTransformMatrix(_target.frame, GalacticFrame, time); double timePast = abs(img.startTime - _previousTime); std::string tex = _texturePath; if (_moving || _planeIsDirty) updatePlane(img, time); else if (timePast > DBL_EPSILON) { _previousTime = time = img.startTime; updatePlane(img, time); } if (_shader->isDirty()) _shader->rebuildFromFile(); if (_textureIsDirty) { loadTexture(); _textureIsDirty = false; } }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ if (key==OF_KEY_LEFT) dataCursor->second.x += -0.1; if (key==OF_KEY_RIGHT) dataCursor->second.x += +0.1; if (key==OF_KEY_UP) dataCursor->second.y += +0.1; if (key==OF_KEY_DOWN) dataCursor->second.y += -0.1; if (key=='a') dataCursor->second.z += +0.1; if (key=='z') dataCursor->second.z += -0.1; updatePlane(); if (key=='c') camera.toggleCursorDraw(); if (key=='f') ofToggleFullscreen(); if (key==OF_KEY_RETURN) { if (dataCursor == data.end()) dataCursor = data.begin(); else dataCursor++; } }
GridDisplay::GridDisplay() : Display() { frame_property_ = new TfFrameProperty( "Reference Frame", TfFrameProperty::FIXED_FRAME_STRING, "The TF frame this grid will use for its origin.", this, 0, true ); cell_count_property_ = new IntProperty( "Plane Cell Count", 10, "The number of cells to draw in the plane of the grid.", this, SLOT( updateCellCount() )); cell_count_property_->setMin( 1 ); height_property_ = new IntProperty( "Normal Cell Count", 0, "The number of cells to draw along the normal vector of the grid. " " Setting to anything but 0 makes the grid 3D.", this, SLOT( updateHeight() )); height_property_->setMin( 0 ); cell_size_property_ = new FloatProperty( "Cell Size", 1.0f, "The length, in meters, of the side of each cell.", this, SLOT( updateCellSize() )); cell_size_property_->setMin( 0.0001 ); style_property_ = new EnumProperty( "Line Style", "Lines", "The rendering operation to use to draw the grid lines.", this, SLOT( updateStyle() )); style_property_->addOption( "Lines", Grid::Lines ); style_property_->addOption( "Billboards", Grid::Billboards ); line_width_property_ = new FloatProperty( "Line Width", 0.03, "The width, in meters, of each grid line.", style_property_, SLOT( updateLineWidth() ), this ); line_width_property_->setMin( 0.001 ); line_width_property_->hide(); color_property_ = new ColorProperty( "Color", Qt::gray, "The color of the grid lines.", this, SLOT( updateColor() )); alpha_property_ = new FloatProperty( "Alpha", 0.5f, "The amount of transparency to apply to the grid lines.", this, SLOT( updateColor() )); alpha_property_->setMin( 0.0f ); alpha_property_->setMax( 1.0f ); plane_property_ = new EnumProperty( "Plane", "XY", "The plane to draw the grid along.", this, SLOT( updatePlane() )); plane_property_->addOption( "XY", XY ); plane_property_->addOption( "XZ", XZ ); plane_property_->addOption( "YZ", YZ ); offset_property_ = new VectorProperty( "Offset", Ogre::Vector3::ZERO, "Allows you to offset the grid from the origin of the reference frame. In meters.", this, SLOT( updateOffset() )); }
void GridDisplay::onInitialize() { QColor color = color_property_->getColor(); color.setAlphaF( alpha_property_->getFloat() ); frame_property_->setFrameManager( context_->getFrameManager() ); grid_ = new Grid( scene_manager_, scene_node_, (Grid::Style) style_property_->getOptionInt(), cell_count_property_->getInt(), cell_size_property_->getFloat(), line_width_property_->getFloat(), qtToOgre( color )); grid_->getSceneNode()->setVisible( false ); updatePlane(); }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(100, 100, 100); ofEnableSmoothing(); camera.setCursorDraw(true); data.insert(pair<string, ofVec3f&>("center", center)); data.insert(pair<string, ofVec3f&>("normal", normal)); data.insert(pair<string, ofVec3f&>("up", up)); data.insert(pair<string, ofVec3f&>("scale xy", scale)); dataCursor = data.begin(); center = ofVec3f(1.0f, 1.0f, 0.0f); normal = ofVec3f(1.0f, 1.0f, 1.0f).normalize(); up = ofVec3f(0.0f, 1.0f, 0.0f).normalize(); scale = ofVec2f(1.0f, 1.0f); updatePlane(); plane.setInfinite(false); }