DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
#include "GameScene.h" #include "RigidEntity.h" #include "LoadedVisObj.h" #include "CompoundEntity.h" #include "ControllablePhysObj.h" //#include "SkinnedEntity.h" #include "RecordReplay.h" #include "ScriptEngine.h" GameScene* GameScene::theSingleton = NULL; Real GameScene::GravityValue = -9.81f; #define CLONE_STR(dest,source) {dest = new char[strlen(source)+1];strcpy(dest,source);} String trimNumericSuffix(const String& src){ const char* src_str = src.c_str(); char* dest; CLONE_STR(dest,src_str); int alphaCount=0; char* curChar = dest; while ((*curChar<'0' || *curChar>'9') && (*curChar != 0)){//while not a number and not null alphaCount++; curChar++; }; myassert(alphaCount<=strlen(dest)); char* trimedStr = new char[alphaCount]; char* curTrimedChar = trimedStr; curChar = dest; int count =0; while (count < alphaCount){ *curTrimedChar = *curChar; curChar++; curTrimedChar++; count++; }; *curTrimedChar=0; //end the newly created string SAFE_DELETE_ARRAY(dest); return String(trimedStr); } GameScene::GameScene(const String& resourceName, SceneManager* pSceneManager, RenderWindow* renderWindow, Camera* camera, NxPhysicsSDK* pPhysicSDK, NxScene* pPhysicScene): mSceneMgr(pSceneManager),mRenderWindow(renderWindow),mCamera(camera),mPhysSDK(pPhysicSDK),mPhysScene(pPhysicScene), mIsRunning(true){ myassert(theSingleton==NULL); theSingleton = this; //load visual objects OgreMax::OgreMaxScene* loadedScene = new OgreMax::OgreMaxScene(); loadedScene->Load(resourceName+".scene",mRenderWindow,OgreMax::OgreMaxScene::NO_OPTIONS,mSceneMgr,mSceneMgr->getRootSceneNode()); //iterate through all scene node and loaded the corresponding physical object for (Node::ChildNodeIterator iter = loadedScene->GetSceneManager()->getRootSceneNode()->getChildIterator();iter.hasMoreElements();){ SceneNode* sceneNode = (SceneNode*)iter.getNext(); myassert(sceneNode!=NULL); String name = sceneNode->getName(); String trimedName = trimNumericSuffix(name); //if (sceneNode->getChildIterator().hasMoreElements()){//group // CompoundVisObj* visObj = new CompoundVisObj(sceneNode); // CompoundEntity* compoundEntity = new CompoundEntity(trimedName,"base",visObj); //}else{//single object // VisualObject* visObj = new VisualObject(sceneNode); // RigidEntity* rigidEntity = new RigidEntity(trimedName,visObj); //} VisualObject* visObj = new VisualObject(sceneNode); RigidEntity* rigidEntity = new RigidEntity(trimedName,visObj); } SAFE_DELETE(loadedScene);//delete the loader mInputManager = new InputManager(); RecordReplay* pRecordReplay = new RecordReplay(); ScriptEngine* pScriptEngine = new ScriptEngine(); } GameScene::~GameScene(){ while (mEntityPool.GetPool().size()>0){ GameEntity* firstElement = (GameEntity*)*(mEntityPool.GetPool().begin()); SAFE_DELETE(firstElement); } SAFE_DELETE(mInputManager); if(mPhysSDK!= NULL) { if(mPhysScene != NULL) mPhysSDK->releaseScene(*mPhysScene); mPhysScene = NULL; NxReleasePhysicsSDK(mPhysSDK); mPhysSDK = NULL; } delete recordReplay;//cannot use SAFE_DELETE in this case! //mEntityPool.Clear();//TODO: review this line theSingleton = NULL; } //void GameScene::NXU_notifyActor(NxActor *actor, const char *userProperties){ // //SceneNode* visualObjNode = mSceneMgr->getSceneNode(actor->getName()); // //VisualObject* visObj = new VisualObject(visualObjNode); // //RigidPhysObj* ridObj = new RigidPhysObj(actor,visObj); // //GameEntity* entity = new GameEntity(visObj,ridObj); //} void GameScene::FrameMove(Real elapsedTime){ if (mIsRunning){ //if (elapsedTime<1.0f/60.0f) elapsedTime = 1.0f/60.0f; if (elapsedTime>1.0f/15.0f) elapsedTime = 1.0f/15.0f;//limit the speed! elapsedTime = recordReplay->funcWrapper(elapsedTime); //elapsedTime = 1.0f/60.0f; //printf("%f\n",elapsedTime); for (list
::iterator iter = mEntityPool.GetPool().begin(); iter!=mEntityPool.GetPool().end(); iter++){ (static_cast
(*iter))->FrameMove(elapsedTime); } ControllablePhysObj::UpdateAllControllablePhysObj(); mInputManager->FrameMove(elapsedTime); mPhysScene->simulate(elapsedTime); mPhysScene->flushStream(); mPhysScene->fetchResults(NX_RIGID_BODY_FINISHED, true); } } PhysicalEventHandler* GameScene::RayCastClosest(const Vec3& from, const Vec3& direction, Vec3* hitPosition, Vec3* hitNormal){ NxRaycastHit hit; NxShape* shape = mPhysScene->raycastClosestShape(NxRay(from,(Vec3)(direction.normalisedCopy())),NX_ALL_SHAPES,hit,-1,3.40e+38, NX_RAYCAST_IMPACT | NX_RAYCAST_NORMAL ); if (shape!=NULL){ if (shape->getActor().userData != NULL){ if (hitPosition!=NULL) *hitPosition = hit.worldImpact; if (hitNormal!=NULL) *hitNormal = hit.worldNormal; return static_cast
(shape->getActor().userData); }else return NULL; }else return NULL; } void GameScene::_GetRayCameraToViewport(const Vec3& mousePos, Vec3& from, Vec3& direction){ Ray rr = mCamera->getCameraToViewportRay((float)mousePos.x/mRenderWindow->getViewport(0)->getActualWidth(), (float)mousePos.y/mRenderWindow->getViewport(0)->getActualHeight()); from = rr.getOrigin(); from = recordReplay->funcWrapper(from); //from.x = recordReplay->funcWrapper(from.x); //from.y = recordReplay->funcWrapper(from.y); //from.z = recordReplay->funcWrapper(from.z); direction = rr.getDirection(); direction = recordReplay->funcWrapper(direction); //direction.x = recordReplay->funcWrapper(direction.x); //direction.y = recordReplay->funcWrapper(direction.y); //direction.z = recordReplay->funcWrapper(direction.z); } void GameScene::FrustumCheck(const Vec3& mouseTopLeft, const Vec3& mouseBottomRight, void (*callback)(PhysicalEventHandler*)){ //this->mPhysScene->cullShapes(4,,NX_ALL_SHAPES,) };
GameScene.cpp
Page URL
File URL
Prev
19/55
Next
Download
( 5 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.