Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 167 vs 168 for /trunk/Source Code/Scenes/PhysXScene/PhysXScene.cpp

Diff revisions: vs.
  @@ -21,16 +21,16 @@
21 21 }
22 22
23 23 void PhysXScene::processInput(){
24 - if(state()->_angleLR) renderState()->getCamera()->RotateX(state()->_angleLR);
25 - if(state()->_angleUD) renderState()->getCamera()->RotateY(state()->_angleUD);
26 - if(state()->_moveFB) renderState()->getCamera()->MoveForward(state()->_moveFB /5);
27 - if(state()->_moveLR) renderState()->getCamera()->MoveStrafe(state()->_moveLR /5);
24 + if(state()._angleLR) renderState().getCamera().rotateYaw(state()._angleLR);
25 + if(state()._angleUD) renderState().getCamera().rotatePitch(state()._angleUD);
26 + if(state()._moveFB) renderState().getCamera().moveForward(state()._moveFB);
27 + if(state()._moveLR) renderState().getCamera().moveStrafe(state()._moveLR);
28 28 }
29 29
30 - bool PhysXScene::load(const std::string& name){
31 - ///Load scene resources
32 - SCENE_LOAD(name,true,true);
33 - ///Add a light
30 + bool PhysXScene::load(const std::string& name, CameraManager* const cameraMgr){
31 + //Load scene resources
32 + bool loadState = SCENE_LOAD(name,cameraMgr,true,true);
33 + //Add a light
34 34 vec2<F32> sunAngle(0.0f, RADIANS(45.0f));
35 35 _sunvector = vec3<F32>(-cosf(sunAngle.x) * sinf(sunAngle.y),-cosf(sunAngle.y),-sinf(sunAngle.x) * sinf(sunAngle.y));
36 36 Light* light = addDefaultLight();
  @@ -43,7 +43,6 @@
43 43 }
44 44
45 45 bool PhysXScene::loadResources(bool continueOnErrors){
46 - _mousePressed = false;
47 46
48 47 GUI::getInstance().addText("fpsDisplay", //Unique ID
49 48 vec2<I32>(60,20), //Position
  @@ -57,9 +56,8 @@
57 56 "Number of items in Render Bin: %d",0);
58 57
59 58 _taskTimers.push_back(0.0f); //Fps
60 - renderState()->getCamera()->RotateX(RADIANS(-75));
61 - renderState()->getCamera()->RotateY(RADIANS(25));
62 - renderState()->getCamera()->setEye(vec3<F32>(0,30,-40));
59 + renderState().getCamera().setRotation(25/*yaw*/,-75/*pitch*/);
60 + renderState().getCamera().setEye(vec3<F32>(0,30,-40));
63 61 _addingActors = false;
64 62 ParamHandler::getInstance().setParam("rendering.enableFog",false);
65 63 ParamHandler::getInstance().setParam("postProcessing.bloomFactor",0.1f);
  @@ -102,37 +100,23 @@
102 100 void PhysXScene::onKeyDown(const OIS::KeyEvent& key){
103 101 Scene::onKeyDown(key);
104 102 switch(key.key) {
105 - case OIS::KC_W:
106 - state()->_moveFB = 0.25f;
107 - break;
108 - case OIS::KC_A:
109 - state()->_moveLR = 0.25f;
110 - break;
111 - case OIS::KC_S:
112 - state()->_moveFB = -0.25f;
113 - break;
114 - case OIS::KC_D:
115 - state()->_moveLR = -0.25f;
116 - break;
117 - default:
118 - break;
103 + default: break;
104 + case OIS::KC_W: state()._moveFB = 1; break;
105 + case OIS::KC_A: state()._moveLR = -1; break;
106 + case OIS::KC_S: state()._moveFB = -1; break;
107 + case OIS::KC_D: state()._moveLR = 1; break;
119 108 }
120 109 }
121 110
122 111 void PhysXScene::onKeyUp(const OIS::KeyEvent& key){
123 112 Scene::onKeyUp(key);
124 113 switch(key.key) {
114 + default: break;
125 115 case OIS::KC_W:
126 - case OIS::KC_S:
127 - state()->_moveFB = 0;
128 - break;
116 + case OIS::KC_S: state()._moveFB = 0; break;
129 117 case OIS::KC_A:
130 - case OIS::KC_D:
131 - state()->_moveLR = 0;
132 - break;
133 - case OIS::KC_F1:
134 - _sceneGraph->print();
135 - break;
118 + case OIS::KC_D: state()._moveLR = 0; break;
119 + case OIS::KC_F1: _sceneGraph->print(); break;
136 120 case OIS::KC_1:
137 121 PHYSICS_DEVICE.createPlane(vec3<F32>(0,0,0),random(0.5f,2.0f));
138 122 break;
  @@ -149,43 +133,28 @@
149 133 Task_ptr e(New Task(kernel->getThreadPool(),0,true,true,DELEGATE_BIND(&PhysXScene::createStack, DELEGATE_REF(*this),(U32)random(5,10))));
150 134 addTask(e);
151 135 } break;
152 - default:
153 - break;
154 136 }
155 137 }
156 138
157 139 void PhysXScene::onMouseMove(const OIS::MouseEvent& key){
158 - if(_mousePressed){
159 - if(_prevMouse.x - key.state.X.abs > 1 )
160 - state()->_angleLR = -0.15f;
161 - else if(_prevMouse.x - key.state.X.abs < -1 )
162 - state()->_angleLR = 0.15f;
163 - else
164 - state()->_angleLR = 0;
165 -
166 - if(_prevMouse.y - key.state.Y.abs > 1 )
167 - state()->_angleUD = -0.1f;
168 - else if(_prevMouse.y - key.state.Y.abs < -1 )
169 - state()->_angleUD = 0.1f;
170 - else
171 - state()->_angleUD = 0;
172 - }
173 -
174 - _prevMouse.x = key.state.X.abs;
175 - _prevMouse.y = key.state.Y.abs;
176 - }
177 -
178 - void PhysXScene::onMouseClickDown(const OIS::MouseEvent& key,OIS::MouseButtonID button){
179 - Scene::onMouseClickDown(key,button);
180 - if(button == 0)
181 - _mousePressed = true;
140 + if(_mousePressed[OIS::MB_Right]){
141 + if(_previousMousePos.x - key.state.X.abs > 1 ) state()._angleLR = -1;
142 + else if(_previousMousePos.x - key.state.X.abs < -1 ) state()._angleLR = 1;
143 + else state()._angleLR = 0;
144 +
145 + if(_previousMousePos.y - key.state.Y.abs > 1 ) state()._angleUD = -1;
146 + else if(_previousMousePos.y - key.state.Y.abs < -1 ) state()._angleUD = 1;
147 + else state()._angleUD = 0;
148 + }
149 +
150 + _previousMousePos.x = key.state.X.abs;
151 + _previousMousePos.y = key.state.Y.abs;
182 152 }
183 153
184 154 void PhysXScene::onMouseClickUp(const OIS::MouseEvent& key,OIS::MouseButtonID button){
185 155 Scene::onMouseClickUp(key,button);
186 - if(button == 0) {
187 - _mousePressed = false;
188 - state()->_angleUD = 0;
189 - state()->_angleLR = 0;
156 + if(!_mousePressed[OIS::MB_Right]){
157 + state()._angleUD = 0;
158 + state()._angleLR = 0;
190 159 }
191 160 }