| 74 | | RigGeometry::RigGeometry(const osg::Geometry& b) : osg::Geometry(b, osg::CopyOp::SHALLOW_COPY) |
| 75 | | { |
| 76 | | _supportsDisplayList = false; |
| 77 | | setUseVertexBufferObjects(true); |
| 78 | | setUpdateCallback(new UpdateVertex); |
| 79 | | setDataVariance(osg::Object::DYNAMIC); |
| 80 | | _needToComputeMatrix = true; |
| 81 | | _matrixFromSkeletonToGeometry = _invMatrixFromSkeletonToGeometry = osg::Matrix::identity(); |
| 82 | | |
| 83 | | // disable the computation of boundingbox for the rig mesh |
| 84 | | setComputeBoundingBoxCallback(new RigComputeBoundingBoxCallback); |
| 85 | | } |
| 145 | | if (getRigTransformImplementation()->needInit()) |
| 146 | | if (!getRigTransformImplementation()->init(*this)) |
| 147 | | return; |
| 148 | | getRigTransformImplementation()->update(*this); |
| | 136 | RigTransform& implementation = *getRigTransformImplementation(); |
| | 137 | (implementation)(*this); |
| | 138 | } |
| | 139 | |
| | 140 | void RigGeometry::copyFrom(osg::Geometry& from) |
| | 141 | { |
| | 142 | bool copyToSelf = (this==&from); |
| | 143 | |
| | 144 | osg::Geometry& target = *this; |
| | 145 | |
| | 146 | if (!copyToSelf) target.setStateSet(from.getStateSet()); |
| | 147 | |
| | 148 | // copy over primitive sets. |
| | 149 | if (!copyToSelf) target.getPrimitiveSetList() = from.getPrimitiveSetList(); |
| | 150 | |
| | 151 | if (from.getVertexArray()) |
| | 152 | { |
| | 153 | if (!copyToSelf) target.setVertexArray(from.getVertexArray()); |
| | 154 | } |
| | 155 | |
| | 156 | target.setNormalBinding(from.getNormalBinding()); |
| | 157 | if (from.getNormalArray()) |
| | 158 | { |
| | 159 | if (!copyToSelf) target.setNormalArray(from.getNormalArray()); |
| | 160 | } |
| | 161 | |
| | 162 | target.setColorBinding(from.getColorBinding()); |
| | 163 | if (from.getColorArray()) |
| | 164 | { |
| | 165 | if (!copyToSelf) target.setColorArray(from.getColorArray()); |
| | 166 | } |
| | 167 | |
| | 168 | target.setSecondaryColorBinding(from.getSecondaryColorBinding()); |
| | 169 | if (from.getSecondaryColorArray()) |
| | 170 | { |
| | 171 | if (!copyToSelf) target.setSecondaryColorArray(from.getSecondaryColorArray()); |
| | 172 | } |
| | 173 | |
| | 174 | target.setFogCoordBinding(from.getFogCoordBinding()); |
| | 175 | if (from.getFogCoordArray()) |
| | 176 | { |
| | 177 | if (!copyToSelf) target.setFogCoordArray(from.getFogCoordArray()); |
| | 178 | } |
| | 179 | |
| | 180 | for(unsigned int ti=0;ti<from.getNumTexCoordArrays();++ti) |
| | 181 | { |
| | 182 | if (from.getTexCoordArray(ti)) |
| | 183 | { |
| | 184 | if (!copyToSelf) target.setTexCoordArray(ti,from.getTexCoordArray(ti)); |
| | 185 | } |
| | 186 | } |
| | 187 | |
| | 188 | ArrayDataList& arrayList = from.getVertexAttribArrayList(); |
| | 189 | for(unsigned int vi=0;vi< arrayList.size();++vi) |
| | 190 | { |
| | 191 | ArrayData& arrayData = arrayList[vi]; |
| | 192 | if (arrayData.array.valid()) |
| | 193 | { |
| | 194 | if (!copyToSelf) target.setVertexAttribData(vi,arrayData); |
| | 195 | } |
| | 196 | } |