Просмотр исходного кода

Rebased 3DPhysics Examples on Screenrewrite, Fixed missing HUD in 3DPhysics_Character

Joachim Meyer 12 лет назад
Родитель
Сommit
48539351f2

+ 3 - 2
Examples/C++/Contents/3DPhysics_Character/HelloPolycodeApp.cpp

@@ -7,11 +7,12 @@ HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
 	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
 	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
 
-	Scene *hud = new Scene();
+	Scene *hud = new Scene(Scene::SCENE_2D);
 	onGroundLabel = new SceneLabel("Arrow keys to control, spacebar to jump, press R to reset", 16);
+	onGroundLabel->setPosition(-85,230);
 	hud->addChild(onGroundLabel);	
 	onGroundLabel = new SceneLabel("On Ground:", 16);
-	onGroundLabel->setPosition(0,20);
+	onGroundLabel->setPosition(-280,215);
 	hud->addChild(onGroundLabel);
 	
 

+ 6 - 6
Examples/C++/Contents/3DPhysics_RayTest/HelloPolycodeApp.cpp

@@ -7,8 +7,8 @@ HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
 	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
 	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
 
-	Screen *hud = new Screen();
-	ScreenLabel *label = new ScreenLabel("Click on a shape to select it.", 16);
+	Scene *hud = new Scene(Scene::SCENE_2D);
+	SceneLabel *label = new SceneLabel("Click on a shape to select it.", 16);
 	hud->addChild(label);	
 
 	scene = new CollisionScene();
@@ -20,17 +20,17 @@ HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
 	box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1,1,1);
 	box->loadTexture("Resources/pink_texture.png");
 	box->setPosition(0,1,0);
-	scene->addCollisionChild(box, CollisionSceneEntity::SHAPE_MESH);
+	scene->addCollisionChild(box, CollisionEntity::SHAPE_MESH);
 
 	box = new ScenePrimitive(ScenePrimitive::TYPE_CONE, 1,1,10);
 	box->loadTexture("Resources/pink_texture.png");
 	box->setPosition(1,1,2);
-	scene->addCollisionChild(box, CollisionSceneEntity::SHAPE_CONE);
+	scene->addCollisionChild(box, CollisionEntity::SHAPE_CONE);
 
 	box = new ScenePrimitive(ScenePrimitive::TYPE_CYLINDER, 2,0.5,10);
 	box->loadTexture("Resources/pink_texture.png");
 	box->setPosition(2,1,-1);
-	scene->addCollisionChild(box, CollisionSceneEntity::SHAPE_CYLINDER);
+	scene->addCollisionChild(box, CollisionEntity::SHAPE_CYLINDER);
 
 	
 	scene->getDefaultCamera()->setPosition(7,7,7);
@@ -49,7 +49,7 @@ void HelloPolycodeApp::handleEvent(Event *e) {
 		InputEvent *inputEvent = (InputEvent*)e;
 		switch(e->getEventCode()) {
 			case InputEvent::EVENT_MOUSEDOWN:
-				Vector3 dir = CoreServices::getInstance()->getRenderer()->projectRayFrom2DCoordinate(inputEvent->mousePosition.x, inputEvent->mousePosition.y);
+				Vector3 dir = CoreServices::getInstance()->getRenderer()->projectRayFrom2DCoordinate(inputEvent->mousePosition.x, inputEvent->mousePosition.y, CoreServices::getInstance()->getRenderer()->getCameraMatrix(), CoreServices::getInstance()->getRenderer()->getProjectionMatrix(),CoreServices::getInstance()->getRenderer()->getViewport());
 				RayTestResult res = scene->getFirstEntityInRay(scene->getDefaultCamera()->getPosition(), dir * 1000);				
 
 				if(lastEntity) {

+ 3 - 2
Examples/C++/Contents/3DPhysics_Vehicle/HelloPolycodeApp.cpp

@@ -7,9 +7,10 @@ HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
 	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
 	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
 
-	Screen *hud = new Screen();
+	Scene *hud = new Scene(Scene::SCENE_2D);
 	
-	onGroundLabel = new ScreenLabel("Arrow keys to control, spacebar to brake, press R to reset car", 16);
+	onGroundLabel = new SceneLabel("Arrow keys to control, spacebar to brake, press R to reset car", 16);
+	onGroundLabel->setPosition(-70,230);
 	hud->addChild(onGroundLabel);	
 	
 	scene = new PhysicsScene();

+ 1 - 1
Examples/C++/Contents/3DPhysics_Vehicle/HelloPolycodeApp.h

@@ -17,7 +17,7 @@ private:
 	PhysicsVehicle *vehicleController;
 	ScenePrimitive *testBox;
 	ScenePrimitive *vehicle;	
-	ScreenLabel *onGroundLabel;	
+	SceneLabel *onGroundLabel;	
 	Number steeringValue;
 	Number engineForce;
 	bool breaking;