|
@@ -1047,6 +1047,99 @@ void Viewer::SetCameraMode(int mode)
|
|
|
rubberbandManipulator_->setMode(camMode_);
|
|
|
}
|
|
|
|
|
|
+EntityModel* Viewer::AddRadarModel(osg::Vec3 trail_color,std::string name)
|
|
|
+{
|
|
|
+
|
|
|
+ osg::ref_ptr<osg::Group> group = 0;
|
|
|
+
|
|
|
+ osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
|
|
+ geode->addDrawable(new osg::ShapeDrawable(new osg::Box()));
|
|
|
+
|
|
|
+ osg::ref_ptr<osg::Group> bbGroup = new osg::Group;
|
|
|
+ osg::ref_ptr<osg::PositionAttitudeTransform> tx = new osg::PositionAttitudeTransform;
|
|
|
+
|
|
|
+ osg::Material* material = new osg::Material();
|
|
|
+
|
|
|
+ // Set color of vehicle based on its index
|
|
|
+ double* color;
|
|
|
+ double b = 1.5; // brighness
|
|
|
+ color = color_blue;
|
|
|
+
|
|
|
+ material->setDiffuse(osg::Material::FRONT, osg::Vec4(b * color[0], b * color[1], b * color[2], 1.0));
|
|
|
+ material->setAmbient(osg::Material::FRONT, osg::Vec4(b * color[0], b * color[1], b * color[2], 1.0));
|
|
|
+
|
|
|
+ if (group == 0)
|
|
|
+ {
|
|
|
+ // If no model loaded, make a shaded copy of bounding box as model
|
|
|
+ osg::ref_ptr<osg::Geode> geodeCopy = dynamic_cast<osg::Geode*>(geode->clone(osg::CopyOp::DEEP_COPY_ALL));
|
|
|
+ group = new osg::Group;
|
|
|
+ tx->addChild(geodeCopy);
|
|
|
+ geodeCopy->setNodeMask(NodeMask::NODE_MASK_ENTITY_MODEL);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Set dimensions of the entity "box"
|
|
|
+
|
|
|
+ // Scale to something car-ish
|
|
|
+ tx->setScale(osg::Vec3(4.5, 1.8, 1.5));
|
|
|
+ tx->setPosition(osg::Vec3(1.5, 0, 0.75));
|
|
|
+
|
|
|
+ tx->addChild(geode);
|
|
|
+ tx->getOrCreateStateSet()->setAttribute(material);
|
|
|
+ bbGroup->setName("BoundingBox");
|
|
|
+ bbGroup->addChild(tx);
|
|
|
+
|
|
|
+// group->addChild(bbGroup);
|
|
|
+// group->setName(name);
|
|
|
+
|
|
|
+ EntityModel* model;
|
|
|
+// if (type == EntityModel::EntityType::ENTITY_TYPE_VEHICLE)
|
|
|
+// {
|
|
|
+// model = new CarModel(osgViewer_, group, rootnode_, trails_, dot_node_, trail_color, name);
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+ model = new EntityModel(osgViewer_, group, rootnode_, trails_, dot_node_, trail_color, name);
|
|
|
+// }
|
|
|
+
|
|
|
+ model->state_set_ = model->lod_->getOrCreateStateSet(); // Creating material
|
|
|
+ model->blend_color_ = new osg::BlendColor(osg::Vec4(1, 1, 1, 1));
|
|
|
+ model->state_set_->setAttributeAndModes(model->blend_color_);
|
|
|
+ model->blend_color_->setDataVariance(osg::Object::DYNAMIC);
|
|
|
+
|
|
|
+ osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::CONSTANT_ALPHA, osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);
|
|
|
+ model->state_set_->setAttributeAndModes(bf);
|
|
|
+ model->state_set_->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
|
|
|
+ model->state_set_->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
|
|
+
|
|
|
+ entities_.push_back(model);
|
|
|
+
|
|
|
+// // Focus on first added car
|
|
|
+// if (entities_.size() == 1)
|
|
|
+// {
|
|
|
+// currentCarInFocus_ = 0;
|
|
|
+// rubberbandManipulator_->setTrackNode(entities_.back()->txNode_,
|
|
|
+// rubberbandManipulator_->getMode() == osgGA::RubberbandManipulator::CAMERA_MODE::RB_MODE_TOP ? false : true);
|
|
|
+// nodeTrackerManipulator_->setTrackNode(entities_.back()->txNode_);
|
|
|
+// }
|
|
|
+
|
|
|
+// if (type == EntityModel::EntityType::ENTITY_TYPE_VEHICLE)
|
|
|
+// {
|
|
|
+// CarModel* vehicle = (CarModel*)entities_.back();
|
|
|
+// CreateRoadSensors(vehicle);
|
|
|
+
|
|
|
+// if (road_sensor)
|
|
|
+// {
|
|
|
+// vehicle->road_sensor_->Show();
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// vehicle->road_sensor_->Hide();
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ return entities_.back();
|
|
|
+}
|
|
|
+
|
|
|
EntityModel* Viewer::AddEntityModel(std::string modelFilepath, osg::Vec3 trail_color, EntityModel::EntityType type,
|
|
|
bool road_sensor, std::string name, OSCBoundingBox* boundingBox)
|
|
|
{
|