----------------------------------------------------------------------------- Object Rendering -----------------------------------------------------------------------------
| 181 | // Object Rendering |
| 182 | //----------------------------------------------------------------------------- |
| 183 | void RenderShapeExample::createShape() |
| 184 | { |
| 185 | if ( mShapeFile.isEmpty() ) |
| 186 | return; |
| 187 | |
| 188 | // If this is the same shape then no reason to update it |
| 189 | if ( mShapeInstance && mShapeFile.equal( mShape.getPath().getFullPath(), String::NoCase ) ) |
| 190 | return; |
| 191 | |
| 192 | // Clean up our previous shape |
| 193 | if ( mShapeInstance ) |
| 194 | SAFE_DELETE( mShapeInstance ); |
| 195 | mShape = NULL; |
| 196 | |
| 197 | // Attempt to get the resource from the ResourceManager |
| 198 | mShape = ResourceManager::get().load( mShapeFile ); |
| 199 | |
| 200 | if ( !mShape ) |
| 201 | { |
| 202 | Con::errorf( "RenderShapeExample::createShape() - Unable to load shape: %s", mShapeFile.c_str() ); |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | // Attempt to preload the Materials for this shape |
| 207 | if ( isClientObject() && |
| 208 | !mShape->preloadMaterialList( mShape.getPath() ) && |
| 209 | NetConnection::filesWereDownloaded() ) |
| 210 | { |
| 211 | mShape = NULL; |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | // Update the bounding box |
| 216 | mObjBox = mShape->bounds; |
| 217 | resetWorldBox(); |
| 218 | setRenderTransform(mObjToWorld); |
| 219 | |
| 220 | // Create the TSShapeInstance |
| 221 | mShapeInstance = new TSShapeInstance( mShape, isClientObject() ); |
| 222 | } |
| 223 | |
| 224 | void RenderShapeExample::prepRenderImage( SceneRenderState *state ) |
| 225 | { |