Changeset 164
- Timestamp:
- 07/11/05 03:25:50 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r159 r164 33 33 */ 34 34 35 virtual bool setOption( const String &, const void *);35 virtual bool setOption(const String &, const void *); 36 36 /** Gets the given option for the Scene VisibilityManager. 37 37 @remarks 38 38 See setOption 39 39 */ 40 virtual bool getOption( const String &, void *);40 virtual bool getOption(const String &, void *); 41 41 42 bool getOptionValues( const String & key, StringVector &refValueList);43 bool getOptionKeys( StringVector &refKeys);42 bool getOptionValues(const String & key, StringVector &refValueList); 43 bool getOptionKeys(StringVector &refKeys); 44 44 45 45 /** Sets the visibility manager. … … 75 75 /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 76 76 */ 77 //Entity* createEntity(const String& entityName, const String& meshName);77 Entity* createEntity(const String& entityName, const String& meshName); 78 78 79 79 /** Returns pointer to visibility manager. … … 85 85 OctreeHierarchyInterface *GetHierarchyInterface(); 86 86 87 /** Inherited from scene manager. Neccesary to draw terrain properly. 88 */ 87 89 void endFrame(); 88 90 -
trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp
r159 r164 6 6 7 7 namespace Ogre { 8 8 9 //----------------------------------------------------------------------- 9 ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp, 10 ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, 11 Viewport *vp, 10 12 const bool renderPatches): 11 13 PlatformQueryManager(hierarchyInterface, vp), mRenderPatchesForItemBuffer(renderPatches) … … 13 15 } 14 16 //----------------------------------------------------------------------- 15 bool ItemBufferQueryManager::ShootRay(const Ray &ray, std::vector<Mesh *> *visibleMeshes, bool isGlobalLine) 17 bool ItemBufferQueryManager::ShootRay(const Ray &ray, 18 std::vector<Mesh *> *visibleMeshes, 19 bool isGlobalLine) 16 20 { 17 21 // run OGRE ray shooting query … … 50 54 ColourValue bg = mViewport->getBackgroundColour(); 51 55 mViewport->setBackgroundColour(ColourValue(0, 0, 0, 0)); 56 pfHierarchyInterface->GetRenderSystem()->clearFrameBuffer(FBT_COLOUR | FBT_DEPTH); 52 57 58 //-- render item buffer 59 sm->_renderScene(pCam, mViewport, false); 60 //mViewport->getTarget()->update(); 53 61 54 // --- render item buffer 55 pfHierarchyInterface->GetSceneManager()->_renderScene(pCam, mViewport, false); 62 //for(int j=0; j<10000000; j++) printf("wait"); 56 63 57 64 … … 64 71 65 72 int n = mRenderPatchesForItemBuffer ? (int)visiblePatches->size() : (int)visibleGeometry->size(); 66 73 74 std::stringstream d; d << "dimx: " << dimx << ", dimy: " << dimy; 75 LogManager::getSingleton().logMessage(d.str()); 76 67 77 // loop through frame buffer & collect visible pixels 68 78 for (int idx = 0; idx < dimy * dimx * 3; idx += 3) 69 79 { 70 // 80 //-- decode color code to receive id 71 81 int id = buf[idx] << 16; 72 82 id += buf[idx + 1] << 8; 73 83 id += buf[idx + 2]; 74 84 75 // if valid id <= add visibility (id values start at 1 85 std::stringstream d; d << "myid: " << (int)buf[idx] << " " << (int)buf[idx + 1] << " " << (int)buf[idx + 2]; 86 LogManager::getSingleton().logMessage(d.str()); 87 88 // if valid id <= add visibility (id values start at 1) 76 89 if ((id > 0) && (id < n)) 77 90 { … … 144 157 145 158 subEnt->setId(id); 159 subEnt->setId((41 << 16) + (4 << 8) + 60); 160 //subEnt->setId((2 << 16) + (4 << 8) + 60); 146 161 } 147 162 -
trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp
r159 r164 49 49 50 50 // ---- capture visibility from all 6 directions 51 for (int i=0; i < 6; i++)51 for (int dir=0; dir < 6; dir++) 52 52 { 53 53 sign *= -1; … … 60 60 61 61 // prevent from initialising geometry / node array again 62 if ( i> 0)62 if (dir > 0) 63 63 { 64 64 mWasInitialised = true; … … 70 70 71 71 // permute directions 72 Vector3 dir (0,0,0);73 dir [i/2] = sign;72 Vector3 direction(0,0,0); 73 direction[dir/2] = sign; 74 74 75 cam->setDirection(dir );75 cam->setDirection(direction); 76 76 } 77 77 -
trunk/VUT/Ogre/src/OgreTerrainContentGenerator.cpp
r161 r164 16 16 RayQueryExecutor::~RayQueryExecutor() 17 17 { 18 delete mRaySceneQuery;18 OGRE_DELETE(mRaySceneQuery); 19 19 } 20 20 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r159 r164 739 739 } 740 740 */ 741 //----------------------------------------------------------------------- 742 /* 741 /*//----------------------------------------------------------------------- 743 742 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, 744 743 const String& meshName) -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r160 r164 37 37 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 38 38 39 //mDisplayNodes = true; 40 //mShowBoundingBoxes = true; 41 //mShowBoxes = true; 39 //mDisplayNodes = true;//mShowBoundingBoxes = true;//mShowBoxes = true; 42 40 43 41 // TODO: set maxdepth to reasonable value … … 120 118 if (mRenderNodesForViz || mRenderNodesContentForViz) 121 119 { 122 // change node material so it is better suited for visualization120 // HACK: change node material so it is better suited for visualization 123 121 MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 124 122 nodeMat->setAmbient(1, 1, 0); … … 130 128 if (mRenderNodesForViz) 131 129 { 132 if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) 133 && (*it)->getAttachedObject(0)->getMovableType() == "Entity") 134 getRenderQueue()->addRenderable((*it)); 130 // render the leaf nodes 131 if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) && 132 (*it)->getAttachedObject(0)->getMovableType() == "Entity") 133 { 134 getRenderQueue()->addRenderable((*it)); 135 } 135 136 136 137 // addbounding boxes instead of node itself … … 508 509 } 509 510 510 // --- item buffer511 //-- item buffer 511 512 512 513 // Iterate through priorities … … 743 744 */ 744 745 //----------------------------------------------------------------------- 745 /*746 746 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, 747 747 const String& meshName) … … 752 752 { 753 753 ent->getSubEntity(i)->setId(mCurrentEntityId); 754 ent->getSubEntity(i)->setId((41 << 16) + (4 << 8) + 60); 755 //ent->getSubEntity(i)->setId((2 << 16) + (4 << 8) + 60); 754 756 } 755 757 … … 759 761 return ent; 760 762 } 761 */762 763 } // namespace Ogre -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r161 r164 120 120 mCurrentObjectType(0), 121 121 mApplication(app), 122 mUseAnimation(false) 122 mUseAnimation(false), 123 mDeleteObjects(false) 123 124 { 124 125 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 206 207 207 208 Real val = Math::RangeRandom(0, 360); // random rotation 209 208 210 // get results, create a node/entity on the position 209 211 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( … … 301 303 } 302 304 305 if (mDeleteObjects) 306 { 307 mApplication->deleteEntityStates(); 308 mTerrainContentGenerator->RemoveGeneratedObjects(); 309 mDeleteObjects = false; 310 } 311 303 312 if (mUseAnimation) // update animations 304 313 { … … 1034 1043 break; 1035 1044 case KC_F9: 1036 toggleUseAnimation();1045 mUseAnimation = !mUseAnimation; 1037 1046 break; 1038 1047 case KC_F11: 1039 takeScreen Shot();1048 takeScreenshot(); 1040 1049 break; 1041 1050 case KC_F12: … … 1053 1062 break; 1054 1063 case KC_DELETE: 1055 mApplication->deleteEntityStates(); 1056 mTerrainContentGenerator->RemoveGeneratedObjects(); 1064 mDeleteObjects = true; 1057 1065 break; 1058 1066 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); … … 1223 1231 } 1224 1232 //----------------------------------------------------------------------- 1225 void TerrainFrameListener::takeScreen Shot()1233 void TerrainFrameListener::takeScreenshot() 1226 1234 { 1227 1235 char tmp[20]; … … 1415 1423 queryPanel->setHeight(top + border_height); 1416 1424 } 1417 //-----------------------------------------------------------------------1418 void TerrainFrameListener::toggleUseAnimation()1419 {1420 mUseAnimation = !mUseAnimation;1421 } -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r161 r164 112 112 void toggleShowShadows(); 113 113 void toggleDisplayCameraDetails(); 114 void takeScreen Shot();114 void takeScreenshot(); 115 115 void nextSceneDetailLevel(); 116 116 void nextFilter(); … … 125 125 void toggleShowViz(); 126 126 void toggleRecord(); 127 void toggleUseAnimation();128 127 129 128 /** Applies visibility query. Collects the visible objects … … 241 240 float mMoveScale; 242 241 Degree mRotScale; 242 243 243 // just to stop toggles flipping too fast 244 244 Real mTimeDelay; … … 272 272 int mCurrentObjectType; 273 273 274 bool mDeleteObjects; 275 274 276 TestCullingTerrainApplication *mApplication; 275 277 }; -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r161 r164 24 24 }; 25 25 26 const float walk_duration = 10.0f; 27 const float wait_duration = 2.0f; 28 const float rotate_factor = 0.7f; 29 const float move_factor = 0.03; 30 26 31 /***************************************/ 27 32 /* EntityState implementation */ 28 33 /***************************************/ 34 Vector3 EntityState::msMinPos = Vector3::ZERO; 35 Vector3 EntityState::msMaxPos = Vector3::ZERO; 36 29 37 EntityState::EntityState(Entity *ent, State entityState, Real speed): 30 38 mEntity(ent), mState(entityState), mAnimationSpeed(speed) … … 53 61 } 54 62 //----------------------------------------------------------------------- 63 EntityState::~EntityState() 64 { 65 mAnimationState = NULL; 66 mEntity = NULL; 67 } 68 //----------------------------------------------------------------------- 55 69 Entity *EntityState::GetEntity() 56 70 { … … 66 80 { 67 81 mTimeElapsed -= timeSinceLastFrame * mAnimationSpeed; 82 83 if (!mEntity || !mAnimationState) 84 return; 68 85 69 86 if (mState == MOVING) // toggle between moving (longer) and waiting (short) 70 87 { 71 88 SceneNode *parent = mEntity->getParentSceneNode(); 89 90 if (!parent) 91 return; 72 92 73 93 if (mTimeElapsed <= 0) // toggle animation state … … 76 96 { 77 97 SetAnimationState("Walk", true); 78 mTimeElapsed = 10; // walk for mTimeElapsed units 79 80 // choose random direction between zero and two pi 81 Radian rnd = Radian(Math::UnitRandom() * Math::HALF_PI); 98 99 mTimeElapsed = walk_duration; // walk for mTimeElapsed units 100 101 // choose random rotation 102 Radian rnd = Radian(Math::UnitRandom() * Math::PI * rotate_factor); 82 103 83 104 //mEntity->getParentSceneNode()->rotate(); … … 87 108 { 88 109 SetAnimationState("Idle", true); 89 mTimeElapsed = 2; // wait for mTimeElapsed seconds110 mTimeElapsed = wait_duration; // wait for mTimeElapsed seconds 90 111 } 91 112 } 92 113 93 if (mAnimationState->getAnimationName() == "Walk") 114 if (mAnimationState->getAnimationName() == "Walk") // move forward 94 115 { 116 // store old position, just in case we get out of bounds 95 117 Vector3 oldPos = parent->getPosition(); 96 97 parent->translate(parent->getLocalAxes(), Vector3(0.03 * mAnimationSpeed, 0, 0)); 98 99 // HACK: if out of bounds => go back to idle 118 parent->translate(parent->getLocalAxes(), Vector3(move_factor * mAnimationSpeed, 0, 0)); 119 120 // HACK: if out of bounds => reset to old position and set animationstate to idle 100 121 if (OutOfBounds(parent)) 101 122 { 102 123 parent->setPosition(oldPos); 103 SetAnimationState("Idle );124 SetAnimationState("Idle", true); 104 125 105 mTimeElapsed = 2;126 mTimeElapsed = wait_duration; 106 127 } 107 128 } 108 129 } 109 130 110 if (mAnimationState) // add time to drive animation 111 { 112 mAnimationState->addTime(timeSinceLastFrame * mAnimationSpeed); 113 } 131 // add time to drive animation 132 mAnimationState->addTime(timeSinceLastFrame * mAnimationSpeed); 114 133 } 115 134 //----------------------------------------------------------------------- 116 135 void EntityState::SetAnimationState(String stateStr, bool loop) 117 136 { 137 if (!mEntity) 138 return; 139 118 140 mAnimationState = mEntity->getAnimationState(stateStr); 119 141 mAnimationState->setLoop(loop); … … 126 148 127 149 if ((pos > msMinPos) && (pos < msMaxPos)) 128 return true; 129 130 return false; 131 } 150 return false; 151 152 return true; 153 } 154 155 156 132 157 /*********************************************************/ 133 158 /* TestCullingTerrainApplication implementation */ … … 136 161 137 162 TestCullingTerrainApplication::TestCullingTerrainApplication(): 138 mTerrainContentGenerator(NULL) 163 mTerrainContentGenerator(NULL), mRayQueryExecutor(NULL) 139 164 { 140 165 } … … 144 169 OGRE_DELETE(mTerrainContentGenerator); 145 170 OGRE_DELETE(mRayQueryExecutor); 171 146 172 deleteEntityStates(); 147 173 } … … 151 177 for (int i = 0; i < (int)mEntityStates.size(); ++i) 152 178 { 153 delete mEntityStates[i];154 mEntityStates[i] = NULL;155 } 179 OGRE_DELETE(mEntityStates[i]); 180 } 181 156 182 mEntityStates.clear(); 157 183 } … … 248 274 mSceneMgr->setWorldGeometry(terrain_cfg); 249 275 250 // ray query executor251 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr);252 276 253 277 //-- CEGUI setup … … 274 298 mSceneMgr->_renderScene(mCamera, mWindow->getViewport(0), true); 275 299 300 // ray query executor: needed to clamp to terrain 301 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 302 303 mTerrainMinPos = EntityState::msMinPos = Vector3(0, 0, 0); 304 mTerrainMaxPos = EntityState::msMaxPos = Vector3(3000, 5000, 3000); 305 276 306 mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 277 307 … … 280 310 { 281 311 // to provide much occlusion, 282 // height is restricted to 50 => no objects appear on peaks 283 mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 50.0f, 3000.0f)); 312 // height is restricted to 50 => no objects are created on peaks 313 mTerrainContentGenerator->SetMinPos(Vector3(mTerrainMinPos)); 314 mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, 50.0f, mTerrainMaxPos.z)); 284 315 mTerrainContentGenerator->SetOffset(0); 285 316 … … 288 319 } 289 320 290 // no limitations needed anymore: the user can set291 // objects also on peaks of terrain292 mTerrainContentGenerator->SetMaxPos( Vector3(3000.0f, 5000.0f, 3000.0f));321 // no limitations anymore => it is possible for the user to put single 322 // objects on peaks of the terrain (only few, not relevant for occlusion) 323 mTerrainContentGenerator->SetMaxPos(mTerrainMaxPos); 293 324 } 294 325 //----------------------------------------------------------------------- … … 314 345 for (int i = 0; i < (int)mEntityStates.size(); ++i) 315 346 { 316 SceneNode *s m= mEntityStates[i]->GetEntity()->getParentSceneNode();347 SceneNode *sn = mEntityStates[i]->GetEntity()->getParentSceneNode(); 317 348 318 349 mEntityStates[i]->update(timeSinceLastFrame); … … 320 351 if (mEntityStates[i]->GetState() == EntityState::MOVING) 321 352 { 322 Clamp2Terrain(sn, 0); 323 //sm->setNodeVisible(false); 353 Clamp2Terrain(sn, 0); //sn->setNodeVisible(false); 324 354 } 325 355 } -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r161 r164 34 34 35 35 EntityState(Entity *ent, State entityState, Real speed); 36 36 ~EntityState(); 37 37 /** Update the entity state. 38 38 */ … … 46 46 */ 47 47 EntityState::State GetState(); 48 49 static bool OutOfBounds(SceneNode *node); 50 51 static Vector3 msMinPos; 52 static Vector3 msMaxPos; 48 53 49 54 protected: … … 136 141 RayQueryExecutor *mRayQueryExecutor; 137 142 143 Vector3 mTerrainMinPos; 144 Vector3 mTerrainMaxPos; 138 145 private: 139 146 void chooseSceneManager(void);
Note: See TracChangeset
for help on using the changeset viewer.