VR-Exchange 2.4 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pDiGuy.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2014 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <portal/pObject.h>
13 #include <vlpi/articulatedPartCollection.h>
14 #include <vlpi/attachedPartCollection.h>
15 #include <vlpi/entityIdentifier.h>
16 #include <matrix/vlTaitBryan.h>
17 #include <vlutil/vlPrintUtil.h>
18 #include <vlutil/vlString.h>
19 #include <vector>
20 #include <map>
21 
22 namespace MAKVrExchange
23 {
24 
29  {
30  public:
31 
34 
36  typedef std::vector<char> PixelData;
37 
39  typedef std::map<DtU16, PixelData> ShapeDataMap;
40 
42  typedef std::map<DtU16, ShapeDataMap> LinkShapeMap;
43 
45 
46  public:
47 
49  DtPortalDiGuy();
50 
52  DtPortalDiGuy( const DtPortalDiGuy& other );
53 
55  virtual ~DtPortalDiGuy();
56 
58  DtPortalDiGuy& operator = ( const DtPortalDiGuy& other );
59 
62 
63  bool operator == ( const DtPortalDiGuy& other ) const;
64  bool operator != ( const DtPortalDiGuy& other ) const;
65 
67 
70 
74  DtDEC_ATTRIBUTE( DtEntityIdentifier, EntityId, entityId );
75 
79  DtDEC_ATTRIBUTE( DtString, ObjectId, objectId );
80 
82  DtDEC_ATTRIBUTE( DtEntityIdentifier, Parent, parent );
83 
85  DtDEC_ATTRIBUTE( DtString, Action, action );
86 
88  DtDEC_ATTRIBUTE( bool, ActionPaused, actionPaused );
89 
91  DtDEC_ATTRIBUTE( double, ActionSpeed, actionSpeed );
92 
94  DtDEC_ATTRIBUTE( bool, Visible, visible );
95 
97  DtDEC_ATTRIBUTE( DtString, BodyAppearance, bodyAppearance );
98 
100  DtDEC_ATTRIBUTE( DtString, HeadAppearance, headAppearance );
101 
103  DtDEC_ATTRIBUTE( DtString, ItemAppearance, itemAppearance );
104 
106  DtDEC_ATTRIBUTE( DtString, Type, type );
107 
109  DtDEC_ATTRIBUTE( LinkShapeMap, ShapeVariations, shapeVariations );
110 
112  DtDEC_ATTRIBUTE( DtVector, CharacterScale, characterScale );
113 
115 
116  public:
117 
120 
123  typedef std::vector<DtString> AccessoryAppearanceList;
124 
125  DtU32 accessoryAppearanceCount() const;
126  void setAccessoryAppearanceCount( DtU32 numAccessories );
127  const AccessoryAppearanceList& accessoryAppearances() const;
128  void setAccessoryAppearances( const AccessoryAppearanceList& appearances );
129  DtString accessoryAppearance( int index ) const;
130  void setAccessoryAppearance( int index, const DtString& appearance );
131 
133 
134  public:
135 
137 
138  static DtPortalMessage* create();
139 
140  virtual unsigned int netSize() const;
141  virtual void writeSelfToBuffer( void* buffer ) const ;
142  virtual void readSelfFromBuffer( const void* buffer );
143 
144  virtual std::ostream& printDataToStream( std::ostream& str ) const;
145 
146  protected:
147 
148  // Avoid hiding DtPortal message getSize, encode, and decodes.
152 
153  virtual int getSize( const LinkShapeMap& value ) const;
154  virtual char* encode( const LinkShapeMap& value, char* buffer ) const;
155  virtual const char* decode( LinkShapeMap& value, const char* buffer ) const;
156 
157  virtual int getSize( const ShapeDataMap& value ) const;
158  virtual char* encode( const ShapeDataMap& value, char* buffer ) const;
159  virtual const char* decode( ShapeDataMap& value, const char* buffer ) const;
160 
161  protected:
162 
164 
165  };
166 
167 
169  {
170  return new DtPortalDiGuy();
171  }
172 
174  {
175  int size = sizeof(DtNetU32); // # of LinkShapeMap entries.
176  LinkShapeMap::const_iterator itr = v.begin();
177  LinkShapeMap::const_iterator end = v.end();
178  for ( ; itr != end; ++itr )
179  {
180  size += sizeof(DtNetU16); // map key (link index)
181  size += getSize( itr->second ); // ShapeDataMap.
182  }
183 
184  return size;
185  }
186 
187  inline int DtPortalDiGuy::getSize( const DtPortalDiGuy::ShapeDataMap& v ) const
188  {
189  int size = sizeof(DtNetU32); // # of LinkShapeMap entries.
190  ShapeDataMap::const_iterator itr = v.begin();
191  ShapeDataMap::const_iterator end = v.end();
192  for ( ; itr != end; ++itr )
193  {
194  size += sizeof(DtNetU16); // map key (shape index)
195  size += getSize( itr->second ); // PixelData (std::vector<char>)
196  }
197 
198  return size;
199  }
200 
201 }
202 
204 template<>
205 void DtPrintAttribute( std::ostream& stream, const char* label,

Document ID: Generated on Thu Jul 23 10:25:22 EDT 2015 from SVN revision 155065
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)