Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <rve_render_client/cylinder.h>
00031 #include <rve_render_client/material.h>
00032 #include <rve_render_client/scene.h>
00033 #include <rve_msgs/make_vector3.h>
00034
00035 #include <rve_interfaces/Cylinder.h>
00036
00037 #include <boost/bind.hpp>
00038
00039 namespace rve_render_client
00040 {
00041
00042 CylinderPtr createCylinder(Scene* scene)
00043 {
00044 CylinderPtr inst(new Cylinder(), destroySceneObject);
00045 scene->addObject(inst.get());
00046 return inst;
00047 }
00048
00049 CylinderPtr createCylinder()
00050 {
00051 CylinderPtr inst(new Cylinder(), destroySceneObject);
00052 return inst;
00053 }
00054
00055 Cylinder::Cylinder()
00056 : radius_(1.0)
00057 , height_(1.0)
00058 {
00059 orientation_.w = 1.0;
00060 proxy_index_ = addProxy("cylinder");
00061 }
00062
00063 Cylinder::~Cylinder()
00064 {
00065 }
00066
00067 rve_interfaces::CylinderProxy* Cylinder::getProxy(const ContextInfo& context)
00068 {
00069 return SceneObject::getProxy<rve_interfaces::CylinderProxy>(context, proxy_index_);
00070 }
00071
00072 void Cylinder::doCreate(ContextInfo& context)
00073 {
00074 rve_interfaces::CylinderProxy* proxy = getProxy(context);
00075 proxy->create(getSceneID(context.scene), getID());
00076
00077 const rve_common::UUID& scene_id = getSceneID(context.scene);
00078
00079 if (material_)
00080 {
00081 proxy->setMaterialAsync(scene_id, getID(), material_->getID());
00082 }
00083
00084 proxy->setPositionAsync(scene_id, getID(), position_);
00085 proxy->setOrientationAsync(scene_id, getID(), orientation_);
00086 proxy->setRadiusAsync(scene_id, getID(), radius_);
00087 proxy->setHeightAsync(scene_id, getID(), height_);
00088 }
00089
00090 void Cylinder::doDestroy(ContextInfo& context)
00091 {
00092 rve_interfaces::CylinderProxy* proxy = getProxy(context);
00093 proxy->destroy(getSceneID(context.scene), getID());
00094 }
00095
00096 #define CYLINDER_MULTIPLEX(func, ...) \
00097 multiplex<rve_interfaces::CylinderProxy>(boost::bind(&rve_interfaces::CylinderProxy::func, _1, _2, getID(), __VA_ARGS__), proxy_index_);
00098
00099 void Cylinder::setPosition(const rve_msgs::Vector3& pos)
00100 {
00101 position_ = pos;
00102 CYLINDER_MULTIPLEX(setPositionAsync, pos);
00103 }
00104
00105 void Cylinder::setOrientation(const rve_msgs::Quaternion& orient)
00106 {
00107 orientation_ = orient;
00108 CYLINDER_MULTIPLEX(setOrientationAsync, orient);
00109 }
00110
00111 void Cylinder::setRadius(float radius)
00112 {
00113 radius_ = radius;
00114 CYLINDER_MULTIPLEX(setRadiusAsync, radius);
00115 }
00116
00117 void Cylinder::setHeight(float height)
00118 {
00119 height_ = height;
00120 CYLINDER_MULTIPLEX(setHeightAsync, height);
00121 }
00122
00123 void Cylinder::setMaterial(const MaterialPtr& mat)
00124 {
00125 material_ = mat;
00126 if (mat)
00127 {
00128 CYLINDER_MULTIPLEX(setMaterialAsync, mat->getID());
00129 }
00130 }
00131
00132 void Cylinder::getContextDependencies(V_UUID& deps)
00133 {
00134 if (material_)
00135 {
00136 deps.push_back(material_->getID());
00137 }
00138 }
00139
00140 }
00141
00142