Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SkeletonObjectData.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef SKELETONOBJECTDATA_HH
51 #define SKELETONOBJECTDATA_HH
52
53 #include "OpenFlipper/common/perObjectData.hh"
54
55 #define OBJECTDATA_SKELETON "Skeleton Object Data"
56
63 class SkeletonObjectData : public PerObjectData
64 {
65 public:
66 SkeletonObjectData(){
67 }
68
69 SkeletonObjectData(const SkeletonObjectData& _copy) :
70 PerObjectData(),
71 skins_(_copy.skins_)
72 {
73 }
74
75 ~SkeletonObjectData(){
76 }
77
78 // Copy function
79 PerObjectData* copyPerObjectData() {
80 SkeletonObjectData* copy = new SkeletonObjectData(*this);
81 return copy;
82 }
83
84 public:
88 int skin( unsigned int _index ){
89 if ( _index >= skins_.size() )
90 return -1;
91 return skins_[_index];
92 }
93
97 unsigned int skinCount(){
98 return skins_.size();
99 }
100
104 void addSkin(int _objectId){
105 //check if already available
106 for(unsigned int i=0; i < skins_.size(); i++)
107 if ( skins_[i] == _objectId )
108 return;
109 //add the skin
110 skins_.push_back(_objectId);
111 }
112
116 void removeSkin(int _objectId){
117 //check if already available
118 for(unsigned int i=0; i < skins_.size(); i++)
119 if ( skins_[i] == _objectId ){
120 skins_.erase( skins_.begin() + i );
121 return;
122 }
123 //not found
124 std::cerr << "Cannot remove skin with object id:" << _objectId << ". Not found!" << std::endl;
125 }
126
130 void clearSkins(){
131 skins_.clear();
132 }
133
134 private:
135 //vector of object ids from all skins attached to this skeleton
136 std::vector< int > skins_;
137 };
138
139 #endif //SKELETONOBJECTDATA_HH
SkeletonObjectData::clearSkins
void clearSkins()
Remove all skins from the skeleton.
Definition: SkeletonObjectData.hh:130
SkeletonObjectData::copyPerObjectData
PerObjectData * copyPerObjectData()
Copy Function.
Definition: SkeletonObjectData.hh:79
SkeletonObjectData::removeSkin
void removeSkin(int _objectId)
Remove a skin from the skeleton.
Definition: SkeletonObjectData.hh:116
SkeletonObjectData::skinCount
unsigned int skinCount()
Get the number of associated skins.
Definition: SkeletonObjectData.hh:97
SkeletonObjectData::addSkin
void addSkin(int _objectId)
Add a skin to the skeleton.
Definition: SkeletonObjectData.hh:104
PerObjectData::PerObjectData
PerObjectData()
You have to provide your own constructor for your object.
Definition: perObjectData.cc:63
perObjectData.hh
SkeletonObjectData::skin
int skin(unsigned int _index)
Get the skin with given index (0 <= _index < skinCount())
Definition: SkeletonObjectData.hh:88
PerObjectData
Object Payload.
Definition: perObjectData.hh:86
SkeletonObjectData
Data object attached to the skeleton.
Definition: SkeletonObjectData.hh:63