[Orxonox-commit 2187] r6903 - in code/branches/rocket/src: modules/weapons orxonox/controllers
gnadler at orxonox.net
gnadler at orxonox.net
Sat May 15 14:57:51 CEST 2010
Author: gnadler
Date: 2010-05-15 14:57:51 +0200 (Sat, 15 May 2010)
New Revision: 6903
Modified:
code/branches/rocket/src/modules/weapons/RocketController.cc
code/branches/rocket/src/modules/weapons/RocketController.h
code/branches/rocket/src/orxonox/controllers/DroneController.cc
code/branches/rocket/src/orxonox/controllers/NewHumanController.cc
code/branches/rocket/src/orxonox/controllers/NewHumanController.h
Log:
Cant assign Pawn* to WeakPtr<Pawn>.
Modified: code/branches/rocket/src/modules/weapons/RocketController.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.cc 2010-05-15 09:36:04 UTC (rev 6902)
+++ code/branches/rocket/src/modules/weapons/RocketController.cc 2010-05-15 12:57:51 UTC (rev 6903)
@@ -63,8 +63,11 @@
haha++;
SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity());
- rocket->rotatePitch(0.005);
- rocket->setVelocity(rocket->getVelocity()*1.02);
+ if (this->target_) {
+ rocket->rotatePitch(0.5);
+ rocket->rotateYaw(0.5);
+ }
+ rocket->setVelocity(rocket->getVelocity()*1.03);
}
@@ -76,5 +79,11 @@
}
+ void RocketController::setTarget(Pawn* target) {
+ this->target_ = target;
+ }
+
+
+
}
Modified: code/branches/rocket/src/modules/weapons/RocketController.h
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.h 2010-05-15 09:36:04 UTC (rev 6902)
+++ code/branches/rocket/src/modules/weapons/RocketController.h 2010-05-15 12:57:51 UTC (rev 6903)
@@ -52,6 +52,7 @@
virtual void tick(float dt);
SimpleRocket* getRocket(){return this->rocket;};
+ void setTarget(Pawn* target);
protected:
@@ -59,6 +60,7 @@
SimpleRocket* rocket;
WeakPtr<PlayerInfo> player_;
int haha;
+ WeakPtr<Pawn> target_;
};
Modified: code/branches/rocket/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/rocket/src/orxonox/controllers/DroneController.cc 2010-05-15 09:36:04 UTC (rev 6902)
+++ code/branches/rocket/src/orxonox/controllers/DroneController.cc 2010-05-15 12:57:51 UTC (rev 6903)
@@ -71,7 +71,6 @@
// - apply the to myDrone (e.g. myDrone->rotateYaw(..) )
myDrone->rotateYaw(0.2);
- myDrone->moveFrontBack(2);
}
}
Modified: code/branches/rocket/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/rocket/src/orxonox/controllers/NewHumanController.cc 2010-05-15 09:36:04 UTC (rev 6902)
+++ code/branches/rocket/src/orxonox/controllers/NewHumanController.cc 2010-05-15 12:57:51 UTC (rev 6903)
@@ -573,4 +573,65 @@
this->arrowsOverlay4_->hide();
}
}
+
+ Pawn* NewHumanController::getRocketTarget() {
+
+
+ Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
+
+ Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5f, static_cast<float>(this->currentPitch_)/2*-1+.5f);
+
+ rsq->setRay(mouseRay);
+ rsq->setSortByDistance(true);
+
+ /*
+ Distance of objects:
+ ignore everything under 200 maybe even take 1000 as min distance to shoot at
+
+ shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
+ they vanish only after a distance of 10'000
+ */
+
+
+ Ogre::RaySceneQueryResult& result = rsq->execute();
+ Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
+
+ Ogre::RaySceneQueryResult::iterator itr;
+ for (itr = result.begin(); itr != result.end(); ++itr)
+ {
+ if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)
+ {
+ // Try to cast the user pointer
+ WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
+ if (wePtr)
+ {
+ // go through all parents of object and look whether they are sightable or not
+ bool isSightable = false;
+ WorldEntity* parent = wePtr->getParent();
+ while (parent)
+ {
+ if (this->targetMask_.isExcluded(parent->getIdentifier()))
+ {
+ parent = parent->getParent();
+ continue;
+ }
+ else
+ {
+ isSightable = true;
+ break;
+ }
+ }
+ if (!isSightable)
+ continue;
+ }
+
+ return dynamic_cast<Pawn*> (wePtr);
+ }
+ }
+ }
+
+
+
+
+
}
Modified: code/branches/rocket/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/rocket/src/orxonox/controllers/NewHumanController.h 2010-05-15 09:36:04 UTC (rev 6902)
+++ code/branches/rocket/src/orxonox/controllers/NewHumanController.h 2010-05-15 12:57:51 UTC (rev 6903)
@@ -66,6 +66,9 @@
virtual void doPauseControl();
virtual void doResumeControl();
+ Pawn* getRocketTarget();
+
+
protected:
void updateTarget();
void alignArrows();
More information about the Orxonox-commit
mailing list