[Orxonox-commit 7751] r12344 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox

jeromela at orxonox.net jeromela at orxonox.net
Thu May 9 11:14:44 CEST 2019


Author: jeromela
Date: 2019-05-09 11:14:44 +0200 (Thu, 09 May 2019)
New Revision: 12344

Modified:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
Log:
Working on setting new speed

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-05-09 09:09:18 UTC (rev 12343)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-05-09 09:14:44 UTC (rev 12344)
@@ -137,7 +137,7 @@
             // Attach the ball to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to.
             this->center_->attach(this->ball_);
             //Startposition Ball
-            this->ball_->setPosition(0, 0, 50);
+            this->ball_->setPosition(0, 0, 40);
             this->ball_->setFieldDimension(this->center_->getFieldDimension());
             this->ball_->setSpeed(0);
             this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor());

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-05-09 09:09:18 UTC (rev 12343)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-05-09 09:14:44 UTC (rev 12344)
@@ -43,8 +43,6 @@
 #include "sound/WorldSound.h"
 #include "core/XMLPort.h"
 
-#include "OrxoBloxStones.h"
-
 namespace orxonox
 {
     RegisterClass(OrxoBloxBall);
@@ -148,12 +146,24 @@
                 // Set the ball to be exactly at the boundary.
                 position.z = this-> fieldHeight_ / 2;
                 // Set the velocity to zero
-                this->setSpeed(0); // doesn't work here, why??;
-                //velocity.x = 0;
-                //velocity.y = 0;
-                //velocity.z = 0; 
-                orxout() << "Output" << endl;
-                ChatManager::message("Waiting");
+
+                //this->setSpeed(0); // doesn't work here, why??;
+                //Stopping ball
+                orxout() << "Ball stopped" << endl;
+                velocity.x = 0;
+                velocity.y = 0;
+                velocity.z = 0; 
+
+                ChatManager::message("Waiting for your input");
+                //Input new speed here:
+                ChatManager::message("Setting new speed");
+
+                //Set new speed here!!
+                velocity.x = rnd(-100,100);
+                velocity.z = rnd(-10,-100);
+                
+                
+
             }
             if (position.z < -this->fieldHeight_ / 2){
                 position.z = -this->fieldHeight_ / 2;
@@ -204,19 +214,20 @@
         The speed to be set.
     */
     void OrxoBloxBall::setSpeed(float speed)
-    {
+    {   
+
         if (speed != this->speed_) // If the speed changes
         {
             this->speed_ = speed;
-
             // Set the speed in the direction of the balls current velocity.
             Vector3 velocity = this->getVelocity();
-            //if (velocity.x != 0)
-                velocity.x = sgn(velocity.x) * this->speed_;
-            //else // If the balls current velocity is zero, the speed is set in a random direction.
-            //    velocity.x = this->speed_ * sgn(rnd(-1,1));
+            if (velocity.x != 0)
+                velocity.x = speed;
+                //velocity.x = sgn(velocity.x) * speed;
+            else // If the balls current velocity is zero, the speed is set in a random direction.
+                velocity.x = speed * sgn(rnd(-1,1));
             //velocity.y = this->speed_;
-            velocity.z = this->speed_;
+            velocity.z = speed;
 
             this->setVelocity(velocity);
         }
@@ -278,12 +289,16 @@
     void OrxoBloxBall::Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
 
         Vector3 velocity = this->getVelocity();
-        Vector3 positionOtherObject = otherObject->getPosition();
-        btVector3 myPosition = contactPoint.getPositionWorldOnA();
+        Vector3 myPosition = otherObject->getPosition();
+        btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
         orxout() << "About to Bounce >D" << endl;
+        //if (positionOtherObject.y < 0) {
+            //this.destroy()
+        //}S
+        //else {
         
-            int distance_X = myPosition.getX() - positionOtherObject.x;
-            int distance_Z = myPosition.getZ() - positionOtherObject.z;
+            int distance_X = positionOtherObject.getX() - myPosition.x;
+            int distance_Z = positionOtherObject.getZ() - myPosition.z;
 
             if (distance_X < 0)
                 distance_X = -distance_X;
@@ -318,11 +333,6 @@
         orxout() << "About to Bounce >D" << endl;
         bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint);
         Bounce(otherObject, ownCollisionShape, contactPoint);
-        OrxoBloxStones* stone = orxonox_cast<OrxoBloxStones*>(otherObject);       
-        if(stone != nullptr)
-        {
-            delete stone;
-        }
         return result;
     }
 



More information about the Orxonox-commit mailing list