_Mesh.py
Go to the documentation of this file.
00001 """autogenerated by genpy from rve_msgs/Mesh.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 import rve_msgs.msg
00008 import std_msgs.msg
00009 
00010 class Mesh(genpy.Message):
00011   _md5sum = "544197659e77fd938c6b88a78a309ade"
00012   _type = "rve_msgs/Mesh"
00013   _has_header = False #flag to mark the presence of a Header object
00014   _full_text = """SubMesh[] submeshes
00015 Material[] materials
00016 ================================================================================
00017 MSG: rve_msgs/SubMesh
00018 int8 material_index
00019 uint32[] indices
00020 Vector3[] positions
00021 Vector3[] normals
00022 Vector3[] tangents
00023 Vector3[] binormals
00024 
00025 TexCoordChannel[] tex_coords
00026 ColorChannel[] colors
00027 ================================================================================
00028 MSG: rve_msgs/Vector3
00029 float32 x
00030 float32 y
00031 float32 z
00032 
00033 ================================================================================
00034 MSG: rve_msgs/TexCoordChannel
00035 uint8 dims
00036 TexCoord[] array
00037 
00038 ================================================================================
00039 MSG: rve_msgs/TexCoord
00040 float32[3] uvw
00041 ================================================================================
00042 MSG: rve_msgs/ColorChannel
00043 std_msgs/ColorRGBA[] array
00044 
00045 ================================================================================
00046 MSG: std_msgs/ColorRGBA
00047 float32 r
00048 float32 g
00049 float32 b
00050 float32 a
00051 
00052 ================================================================================
00053 MSG: rve_msgs/Material
00054 uint8 CULL_CLOCKWISE = 0
00055 uint8 CULL_COUNTERCLOCKWISE = 1
00056 uint8 CULL_NONE = 2
00057 
00058 UUID id
00059 
00060 float32 opacity
00061 
00062 bool has_color
00063 ColorRGB color
00064 
00065 bool has_texture
00066 string texture 
00067 
00068 bool has_normal_map
00069 string normal_map
00070 
00071 bool disable_shading
00072 
00073 uint8 cull_mode
00074 ================================================================================
00075 MSG: rve_msgs/UUID
00076 uint8[16] data
00077 
00078 ================================================================================
00079 MSG: rve_msgs/ColorRGB
00080 float32 r
00081 float32 g
00082 float32 b
00083 
00084 """
00085   __slots__ = ['submeshes','materials']
00086   _slot_types = ['rve_msgs/SubMesh[]','rve_msgs/Material[]']
00087 
00088   def __init__(self, *args, **kwds):
00089     """
00090     Constructor. Any message fields that are implicitly/explicitly
00091     set to None will be assigned a default value. The recommend
00092     use is keyword arguments as this is more robust to future message
00093     changes.  You cannot mix in-order arguments and keyword arguments.
00094 
00095     The available fields are:
00096        submeshes,materials
00097 
00098     :param args: complete set of field values, in .msg order
00099     :param kwds: use keyword arguments corresponding to message field names
00100     to set specific fields.
00101     """
00102     if args or kwds:
00103       super(Mesh, self).__init__(*args, **kwds)
00104       #message fields cannot be None, assign default values for those that are
00105       if self.submeshes is None:
00106         self.submeshes = []
00107       if self.materials is None:
00108         self.materials = []
00109     else:
00110       self.submeshes = []
00111       self.materials = []
00112 
00113   def _get_types(self):
00114     """
00115     internal API method
00116     """
00117     return self._slot_types
00118 
00119   def serialize(self, buff):
00120     """
00121     serialize message into buffer
00122     :param buff: buffer, ``StringIO``
00123     """
00124     try:
00125       length = len(self.submeshes)
00126       buff.write(_struct_I.pack(length))
00127       for val1 in self.submeshes:
00128         buff.write(_struct_b.pack(val1.material_index))
00129         length = len(val1.indices)
00130         buff.write(_struct_I.pack(length))
00131         pattern = '<%sI'%length
00132         buff.write(struct.pack(pattern, *val1.indices))
00133         length = len(val1.positions)
00134         buff.write(_struct_I.pack(length))
00135         for val2 in val1.positions:
00136           _x = val2
00137           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00138         length = len(val1.normals)
00139         buff.write(_struct_I.pack(length))
00140         for val2 in val1.normals:
00141           _x = val2
00142           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00143         length = len(val1.tangents)
00144         buff.write(_struct_I.pack(length))
00145         for val2 in val1.tangents:
00146           _x = val2
00147           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00148         length = len(val1.binormals)
00149         buff.write(_struct_I.pack(length))
00150         for val2 in val1.binormals:
00151           _x = val2
00152           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00153         length = len(val1.tex_coords)
00154         buff.write(_struct_I.pack(length))
00155         for val2 in val1.tex_coords:
00156           buff.write(_struct_B.pack(val2.dims))
00157           length = len(val2.array)
00158           buff.write(_struct_I.pack(length))
00159           for val3 in val2.array:
00160             buff.write(_struct_3f.pack(*val3.uvw))
00161         length = len(val1.colors)
00162         buff.write(_struct_I.pack(length))
00163         for val2 in val1.colors:
00164           length = len(val2.array)
00165           buff.write(_struct_I.pack(length))
00166           for val3 in val2.array:
00167             _x = val3
00168             buff.write(_struct_4f.pack(_x.r, _x.g, _x.b, _x.a))
00169       length = len(self.materials)
00170       buff.write(_struct_I.pack(length))
00171       for val1 in self.materials:
00172         _v1 = val1.id
00173         _x = _v1.data
00174         # - if encoded as a list instead, serialize as bytes instead of string
00175         if type(_x) in [list, tuple]:
00176           buff.write(_struct_16B.pack(*_x))
00177         else:
00178           buff.write(_struct_16s.pack(_x))
00179         _x = val1
00180         buff.write(_struct_fB.pack(_x.opacity, _x.has_color))
00181         _v2 = val1.color
00182         _x = _v2
00183         buff.write(_struct_3f.pack(_x.r, _x.g, _x.b))
00184         buff.write(_struct_B.pack(val1.has_texture))
00185         _x = val1.texture
00186         length = len(_x)
00187         if python3 or type(_x) == unicode:
00188           _x = _x.encode('utf-8')
00189           length = len(_x)
00190         buff.write(struct.pack('<I%ss'%length, length, _x))
00191         buff.write(_struct_B.pack(val1.has_normal_map))
00192         _x = val1.normal_map
00193         length = len(_x)
00194         if python3 or type(_x) == unicode:
00195           _x = _x.encode('utf-8')
00196           length = len(_x)
00197         buff.write(struct.pack('<I%ss'%length, length, _x))
00198         _x = val1
00199         buff.write(_struct_2B.pack(_x.disable_shading, _x.cull_mode))
00200     except struct.error as se: self._check_types(se)
00201     except TypeError as te: self._check_types(te)
00202 
00203   def deserialize(self, str):
00204     """
00205     unpack serialized message in str into this message instance
00206     :param str: byte array of serialized message, ``str``
00207     """
00208     try:
00209       if self.submeshes is None:
00210         self.submeshes = None
00211       if self.materials is None:
00212         self.materials = None
00213       end = 0
00214       start = end
00215       end += 4
00216       (length,) = _struct_I.unpack(str[start:end])
00217       self.submeshes = []
00218       for i in range(0, length):
00219         val1 = rve_msgs.msg.SubMesh()
00220         start = end
00221         end += 1
00222         (val1.material_index,) = _struct_b.unpack(str[start:end])
00223         start = end
00224         end += 4
00225         (length,) = _struct_I.unpack(str[start:end])
00226         pattern = '<%sI'%length
00227         start = end
00228         end += struct.calcsize(pattern)
00229         val1.indices = struct.unpack(pattern, str[start:end])
00230         start = end
00231         end += 4
00232         (length,) = _struct_I.unpack(str[start:end])
00233         val1.positions = []
00234         for i in range(0, length):
00235           val2 = rve_msgs.msg.Vector3()
00236           _x = val2
00237           start = end
00238           end += 12
00239           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00240           val1.positions.append(val2)
00241         start = end
00242         end += 4
00243         (length,) = _struct_I.unpack(str[start:end])
00244         val1.normals = []
00245         for i in range(0, length):
00246           val2 = rve_msgs.msg.Vector3()
00247           _x = val2
00248           start = end
00249           end += 12
00250           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00251           val1.normals.append(val2)
00252         start = end
00253         end += 4
00254         (length,) = _struct_I.unpack(str[start:end])
00255         val1.tangents = []
00256         for i in range(0, length):
00257           val2 = rve_msgs.msg.Vector3()
00258           _x = val2
00259           start = end
00260           end += 12
00261           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00262           val1.tangents.append(val2)
00263         start = end
00264         end += 4
00265         (length,) = _struct_I.unpack(str[start:end])
00266         val1.binormals = []
00267         for i in range(0, length):
00268           val2 = rve_msgs.msg.Vector3()
00269           _x = val2
00270           start = end
00271           end += 12
00272           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00273           val1.binormals.append(val2)
00274         start = end
00275         end += 4
00276         (length,) = _struct_I.unpack(str[start:end])
00277         val1.tex_coords = []
00278         for i in range(0, length):
00279           val2 = rve_msgs.msg.TexCoordChannel()
00280           start = end
00281           end += 1
00282           (val2.dims,) = _struct_B.unpack(str[start:end])
00283           start = end
00284           end += 4
00285           (length,) = _struct_I.unpack(str[start:end])
00286           val2.array = []
00287           for i in range(0, length):
00288             val3 = rve_msgs.msg.TexCoord()
00289             start = end
00290             end += 12
00291             val3.uvw = _struct_3f.unpack(str[start:end])
00292             val2.array.append(val3)
00293           val1.tex_coords.append(val2)
00294         start = end
00295         end += 4
00296         (length,) = _struct_I.unpack(str[start:end])
00297         val1.colors = []
00298         for i in range(0, length):
00299           val2 = rve_msgs.msg.ColorChannel()
00300           start = end
00301           end += 4
00302           (length,) = _struct_I.unpack(str[start:end])
00303           val2.array = []
00304           for i in range(0, length):
00305             val3 = std_msgs.msg.ColorRGBA()
00306             _x = val3
00307             start = end
00308             end += 16
00309             (_x.r, _x.g, _x.b, _x.a,) = _struct_4f.unpack(str[start:end])
00310             val2.array.append(val3)
00311           val1.colors.append(val2)
00312         self.submeshes.append(val1)
00313       start = end
00314       end += 4
00315       (length,) = _struct_I.unpack(str[start:end])
00316       self.materials = []
00317       for i in range(0, length):
00318         val1 = rve_msgs.msg.Material()
00319         _v3 = val1.id
00320         start = end
00321         end += 16
00322         _v3.data = str[start:end]
00323         _x = val1
00324         start = end
00325         end += 5
00326         (_x.opacity, _x.has_color,) = _struct_fB.unpack(str[start:end])
00327         val1.has_color = bool(val1.has_color)
00328         _v4 = val1.color
00329         _x = _v4
00330         start = end
00331         end += 12
00332         (_x.r, _x.g, _x.b,) = _struct_3f.unpack(str[start:end])
00333         start = end
00334         end += 1
00335         (val1.has_texture,) = _struct_B.unpack(str[start:end])
00336         val1.has_texture = bool(val1.has_texture)
00337         start = end
00338         end += 4
00339         (length,) = _struct_I.unpack(str[start:end])
00340         start = end
00341         end += length
00342         if python3:
00343           val1.texture = str[start:end].decode('utf-8')
00344         else:
00345           val1.texture = str[start:end]
00346         start = end
00347         end += 1
00348         (val1.has_normal_map,) = _struct_B.unpack(str[start:end])
00349         val1.has_normal_map = bool(val1.has_normal_map)
00350         start = end
00351         end += 4
00352         (length,) = _struct_I.unpack(str[start:end])
00353         start = end
00354         end += length
00355         if python3:
00356           val1.normal_map = str[start:end].decode('utf-8')
00357         else:
00358           val1.normal_map = str[start:end]
00359         _x = val1
00360         start = end
00361         end += 2
00362         (_x.disable_shading, _x.cull_mode,) = _struct_2B.unpack(str[start:end])
00363         val1.disable_shading = bool(val1.disable_shading)
00364         self.materials.append(val1)
00365       return self
00366     except struct.error as e:
00367       raise genpy.DeserializationError(e) #most likely buffer underfill
00368 
00369 
00370   def serialize_numpy(self, buff, numpy):
00371     """
00372     serialize message with numpy array types into buffer
00373     :param buff: buffer, ``StringIO``
00374     :param numpy: numpy python module
00375     """
00376     try:
00377       length = len(self.submeshes)
00378       buff.write(_struct_I.pack(length))
00379       for val1 in self.submeshes:
00380         buff.write(_struct_b.pack(val1.material_index))
00381         length = len(val1.indices)
00382         buff.write(_struct_I.pack(length))
00383         pattern = '<%sI'%length
00384         buff.write(val1.indices.tostring())
00385         length = len(val1.positions)
00386         buff.write(_struct_I.pack(length))
00387         for val2 in val1.positions:
00388           _x = val2
00389           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00390         length = len(val1.normals)
00391         buff.write(_struct_I.pack(length))
00392         for val2 in val1.normals:
00393           _x = val2
00394           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00395         length = len(val1.tangents)
00396         buff.write(_struct_I.pack(length))
00397         for val2 in val1.tangents:
00398           _x = val2
00399           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00400         length = len(val1.binormals)
00401         buff.write(_struct_I.pack(length))
00402         for val2 in val1.binormals:
00403           _x = val2
00404           buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
00405         length = len(val1.tex_coords)
00406         buff.write(_struct_I.pack(length))
00407         for val2 in val1.tex_coords:
00408           buff.write(_struct_B.pack(val2.dims))
00409           length = len(val2.array)
00410           buff.write(_struct_I.pack(length))
00411           for val3 in val2.array:
00412             buff.write(val3.uvw.tostring())
00413         length = len(val1.colors)
00414         buff.write(_struct_I.pack(length))
00415         for val2 in val1.colors:
00416           length = len(val2.array)
00417           buff.write(_struct_I.pack(length))
00418           for val3 in val2.array:
00419             _x = val3
00420             buff.write(_struct_4f.pack(_x.r, _x.g, _x.b, _x.a))
00421       length = len(self.materials)
00422       buff.write(_struct_I.pack(length))
00423       for val1 in self.materials:
00424         _v5 = val1.id
00425         _x = _v5.data
00426         # - if encoded as a list instead, serialize as bytes instead of string
00427         if type(_x) in [list, tuple]:
00428           buff.write(_struct_16B.pack(*_x))
00429         else:
00430           buff.write(_struct_16s.pack(_x))
00431         _x = val1
00432         buff.write(_struct_fB.pack(_x.opacity, _x.has_color))
00433         _v6 = val1.color
00434         _x = _v6
00435         buff.write(_struct_3f.pack(_x.r, _x.g, _x.b))
00436         buff.write(_struct_B.pack(val1.has_texture))
00437         _x = val1.texture
00438         length = len(_x)
00439         if python3 or type(_x) == unicode:
00440           _x = _x.encode('utf-8')
00441           length = len(_x)
00442         buff.write(struct.pack('<I%ss'%length, length, _x))
00443         buff.write(_struct_B.pack(val1.has_normal_map))
00444         _x = val1.normal_map
00445         length = len(_x)
00446         if python3 or type(_x) == unicode:
00447           _x = _x.encode('utf-8')
00448           length = len(_x)
00449         buff.write(struct.pack('<I%ss'%length, length, _x))
00450         _x = val1
00451         buff.write(_struct_2B.pack(_x.disable_shading, _x.cull_mode))
00452     except struct.error as se: self._check_types(se)
00453     except TypeError as te: self._check_types(te)
00454 
00455   def deserialize_numpy(self, str, numpy):
00456     """
00457     unpack serialized message in str into this message instance using numpy for array types
00458     :param str: byte array of serialized message, ``str``
00459     :param numpy: numpy python module
00460     """
00461     try:
00462       if self.submeshes is None:
00463         self.submeshes = None
00464       if self.materials is None:
00465         self.materials = None
00466       end = 0
00467       start = end
00468       end += 4
00469       (length,) = _struct_I.unpack(str[start:end])
00470       self.submeshes = []
00471       for i in range(0, length):
00472         val1 = rve_msgs.msg.SubMesh()
00473         start = end
00474         end += 1
00475         (val1.material_index,) = _struct_b.unpack(str[start:end])
00476         start = end
00477         end += 4
00478         (length,) = _struct_I.unpack(str[start:end])
00479         pattern = '<%sI'%length
00480         start = end
00481         end += struct.calcsize(pattern)
00482         val1.indices = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
00483         start = end
00484         end += 4
00485         (length,) = _struct_I.unpack(str[start:end])
00486         val1.positions = []
00487         for i in range(0, length):
00488           val2 = rve_msgs.msg.Vector3()
00489           _x = val2
00490           start = end
00491           end += 12
00492           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00493           val1.positions.append(val2)
00494         start = end
00495         end += 4
00496         (length,) = _struct_I.unpack(str[start:end])
00497         val1.normals = []
00498         for i in range(0, length):
00499           val2 = rve_msgs.msg.Vector3()
00500           _x = val2
00501           start = end
00502           end += 12
00503           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00504           val1.normals.append(val2)
00505         start = end
00506         end += 4
00507         (length,) = _struct_I.unpack(str[start:end])
00508         val1.tangents = []
00509         for i in range(0, length):
00510           val2 = rve_msgs.msg.Vector3()
00511           _x = val2
00512           start = end
00513           end += 12
00514           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00515           val1.tangents.append(val2)
00516         start = end
00517         end += 4
00518         (length,) = _struct_I.unpack(str[start:end])
00519         val1.binormals = []
00520         for i in range(0, length):
00521           val2 = rve_msgs.msg.Vector3()
00522           _x = val2
00523           start = end
00524           end += 12
00525           (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
00526           val1.binormals.append(val2)
00527         start = end
00528         end += 4
00529         (length,) = _struct_I.unpack(str[start:end])
00530         val1.tex_coords = []
00531         for i in range(0, length):
00532           val2 = rve_msgs.msg.TexCoordChannel()
00533           start = end
00534           end += 1
00535           (val2.dims,) = _struct_B.unpack(str[start:end])
00536           start = end
00537           end += 4
00538           (length,) = _struct_I.unpack(str[start:end])
00539           val2.array = []
00540           for i in range(0, length):
00541             val3 = rve_msgs.msg.TexCoord()
00542             start = end
00543             end += 12
00544             val3.uvw = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=3)
00545             val2.array.append(val3)
00546           val1.tex_coords.append(val2)
00547         start = end
00548         end += 4
00549         (length,) = _struct_I.unpack(str[start:end])
00550         val1.colors = []
00551         for i in range(0, length):
00552           val2 = rve_msgs.msg.ColorChannel()
00553           start = end
00554           end += 4
00555           (length,) = _struct_I.unpack(str[start:end])
00556           val2.array = []
00557           for i in range(0, length):
00558             val3 = std_msgs.msg.ColorRGBA()
00559             _x = val3
00560             start = end
00561             end += 16
00562             (_x.r, _x.g, _x.b, _x.a,) = _struct_4f.unpack(str[start:end])
00563             val2.array.append(val3)
00564           val1.colors.append(val2)
00565         self.submeshes.append(val1)
00566       start = end
00567       end += 4
00568       (length,) = _struct_I.unpack(str[start:end])
00569       self.materials = []
00570       for i in range(0, length):
00571         val1 = rve_msgs.msg.Material()
00572         _v7 = val1.id
00573         start = end
00574         end += 16
00575         _v7.data = str[start:end]
00576         _x = val1
00577         start = end
00578         end += 5
00579         (_x.opacity, _x.has_color,) = _struct_fB.unpack(str[start:end])
00580         val1.has_color = bool(val1.has_color)
00581         _v8 = val1.color
00582         _x = _v8
00583         start = end
00584         end += 12
00585         (_x.r, _x.g, _x.b,) = _struct_3f.unpack(str[start:end])
00586         start = end
00587         end += 1
00588         (val1.has_texture,) = _struct_B.unpack(str[start:end])
00589         val1.has_texture = bool(val1.has_texture)
00590         start = end
00591         end += 4
00592         (length,) = _struct_I.unpack(str[start:end])
00593         start = end
00594         end += length
00595         if python3:
00596           val1.texture = str[start:end].decode('utf-8')
00597         else:
00598           val1.texture = str[start:end]
00599         start = end
00600         end += 1
00601         (val1.has_normal_map,) = _struct_B.unpack(str[start:end])
00602         val1.has_normal_map = bool(val1.has_normal_map)
00603         start = end
00604         end += 4
00605         (length,) = _struct_I.unpack(str[start:end])
00606         start = end
00607         end += length
00608         if python3:
00609           val1.normal_map = str[start:end].decode('utf-8')
00610         else:
00611           val1.normal_map = str[start:end]
00612         _x = val1
00613         start = end
00614         end += 2
00615         (_x.disable_shading, _x.cull_mode,) = _struct_2B.unpack(str[start:end])
00616         val1.disable_shading = bool(val1.disable_shading)
00617         self.materials.append(val1)
00618       return self
00619     except struct.error as e:
00620       raise genpy.DeserializationError(e) #most likely buffer underfill
00621 
00622 _struct_I = genpy.struct_I
00623 _struct_B = struct.Struct("<B")
00624 _struct_16B = struct.Struct("<16B")
00625 _struct_fB = struct.Struct("<fB")
00626 _struct_b = struct.Struct("<b")
00627 _struct_2B = struct.Struct("<2B")
00628 _struct_4f = struct.Struct("<4f")
00629 _struct_3f = struct.Struct("<3f")
00630 _struct_16s = struct.Struct("<16s")


rve_msgs
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:30:38