00001 /* 00002 * Copyright (c) 2010, Willow Garage, Inc. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of the Willow Garage, Inc. nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 #ifndef RVE_RENDER_CLIENT_MESH_INSTANCE_H 00031 #define RVE_RENDER_CLIENT_MESH_INSTANCE_H 00032 00033 #include "forwards.h" 00034 #include "single_scene_object.h" 00035 #include "mesh.h" 00036 00037 #include <rve_common/uuid.h> 00038 00039 #include <rve_msgs/Vector3.h> 00040 #include <rve_msgs/Quaternion.h> 00041 00042 namespace rve_interfaces 00043 { 00044 class MeshInstanceProxy; 00045 } 00046 00047 namespace rve_render_client 00048 { 00049 00050 class Material; 00051 class Color; 00052 00053 class MeshInstance : public SingleSceneObject 00054 { 00055 public: 00056 00057 void setPosition(const rve_msgs::Vector3& pos); 00058 void setOrientation(const rve_msgs::Quaternion& orient); 00059 void setScale(const rve_msgs::Vector3& scale); 00060 00061 const rve_msgs::Vector3& getPosition() const { return position_; } 00062 const rve_msgs::Quaternion& getOrientation() const { return orientation_; } 00063 const rve_msgs::Vector3& getScale() const { return scale_; } 00064 00065 const MeshPtr& getMesh() { return mesh_; } 00066 00067 void setMaterial(const MaterialPtr& mat); 00068 void setMaterial(uint32_t submesh_index, const MaterialPtr& mat); 00069 00070 virtual void doCreate(ContextInfo& info); 00071 virtual void doDestroy(ContextInfo& info); 00072 virtual void getContextDependencies(V_UUID& deps); 00073 00074 private: 00075 MeshInstance(const MeshPtr& mesh); 00076 ~MeshInstance(); 00077 00078 rve_interfaces::MeshInstanceProxy* getProxy(const ContextInfo& info); 00079 00080 rve_msgs::Vector3 position_; 00081 rve_msgs::Quaternion orientation_; 00082 rve_msgs::Vector3 scale_; 00083 00084 MeshPtr mesh_; 00085 00086 typedef std::map<uint32_t, MaterialPtr> M_Material; 00087 M_Material materials_; 00088 00089 uint32_t proxy_index_; 00090 00091 friend MeshInstancePtr createMeshInstance(Scene*, const MeshPtr&); 00092 friend MeshInstancePtr createMeshInstance(const MeshPtr& mesh); 00093 friend void destroyMeshInstance(MeshInstance*); 00094 }; 00095 00096 00097 MeshInstancePtr createMeshInstance(const MeshPtr& mesh); 00098 MeshInstancePtr createMeshInstance(const std::string& mesh_resource); 00099 MeshInstancePtr createMeshInstance(Scene* scene, const MeshPtr& mesh); 00100 MeshInstancePtr createMeshInstance(Scene* scene, const std::string& mesh_resource); 00101 00102 } // namespace rve_render_client 00103 00104 #endif // RVE_RENDER_CLIENT_MESH_INSTANCE_H 00105