[Orxonox-commit 2976] r7674 - in code/trunk: data/levels src/modules/objects
dafrick at orxonox.net
dafrick at orxonox.net
Fri Nov 26 00:01:54 CET 2010
Author: dafrick
Date: 2010-11-26 00:01:53 +0100 (Fri, 26 Nov 2010)
New Revision: 7674
Modified:
code/trunk/data/levels/The Time Machine.oxw
code/trunk/src/modules/objects/ForceField.cc
code/trunk/src/modules/objects/ForceField.h
Log:
Resolving some stupid bugs and some adding some minor improvements.
Modified: code/trunk/data/levels/The Time Machine.oxw
===================================================================
--- code/trunk/data/levels/The Time Machine.oxw 2010-11-25 22:24:50 UTC (rev 7673)
+++ code/trunk/data/levels/The Time Machine.oxw 2010-11-25 23:01:53 UTC (rev 7674)
@@ -172,95 +172,7 @@
<!--Triggers (used for the Time Machine effect)_____________________________________________________________________________________________________________________________________________-->
<!--Creating Spaceships_____________________________________________________________________________________________________________________________________________________________________-->
-
-<?lua for i=0,5,1 do
- y=math.random(-500,500)
- z=math.random(-1000,1000)
- y2=math.random(-500,500)
- z2=math.random(-1000,1000)
- health=230
- addh=100
-?>
-
- <EventTrigger name="BotDied" >
- <events>
- <trigger>
- <SpaceShip position="-4000,<?lua print(y) ?>,<?lua print(z) ?>" lookat="1000,<?lua print(y) ?>,<?lua print(z) ?>" health=<?lua print(health) ?> maxhealth=<?lua print(health) ?> initialhealth=<?lua print(health) ?> >
- <templates>
- <Template link=spaceshipassff />
- </templates>
- <controller>
- <WaypointPatrolController alertnessradius=1000 team=0 active=1 >
- <waypoints>
- <Model mesh="cube.mesh" scale=0 position="1000,<?lua print(math.random(-1000,1000)) ?>,<?lua print(math.random(-1000,1000)) ?>" />
- </waypoints>
- <events>
- <activity>
- <Trigger mode=or>
- <EventTrigger invert=true>
- <events>
- <trigger>
- <EventListener event=EnterTimeMachine />
- </trigger>
- </events>
- </EventTrigger>
- <EventTrigger>
- <events>
- <trigger>
- <EventListener event=trigger2 />
- </trigger>
- </events>
- </EventTrigger>
- </Trigger>
- </activity>
- </events>
- </WaypointPatrolController>
- </controller>
- </SpaceShip>
- </trigger>
- </events>
- </EventTrigger>
- <EventTrigger name="BotDied" >
- <events>
- <trigger>
- <SpaceShip position="4000,<?lua print(y2) ?>,<?lua print(z2) ?>" lookat="-1000,<?lua print(y2) ?>, <?lua print(z2) ?>" health=<?lua print(health+addh) ?> maxhealth=<?lua print(health+addh) ?> initialhealth=<?lua print(health+addh) ?> >
- <templates>
- <Template link=spaceshippirate />
- </templates>
- <controller>
- <WaypointPatrolController alertnessradius=1000 team=1 active=1 >
- <waypoints>
- <Model mesh="cube.mesh" scale=0 position="-1000,<?lua print(math.random(-1000,1000)) ?>, <?lua print(math.random(-1000,1000)) ?>" />
- </waypoints>
- <events>
- <activity>
- <Trigger mode=or>
- <EventTrigger invert=true>
- <events>
- <trigger>
- <EventListener event=EnterTimeMachine />
- </trigger>
- </events>
- </EventTrigger>
- <EventTrigger>
- <events>
- <trigger>
- <EventListener event=trigger2 />
- </trigger>
- </events>
- </EventTrigger>
- </Trigger>
- </activity>
- </events>
- </WaypointPatrolController>
- </controller>
- </SpaceShip>
- </trigger>
- </events>
- </EventTrigger>
-<?lua end ?>
-
<!--Creating Spaceships_____END_____________________________________________________________________________________________________________________________________________________________-->
<!--BILLBOARD IN THE MIDDLE OF THE BATTLEFIELD-->
Modified: code/trunk/src/modules/objects/ForceField.cc
===================================================================
--- code/trunk/src/modules/objects/ForceField.cc 2010-11-25 22:24:50 UTC (rev 7673)
+++ code/trunk/src/modules/objects/ForceField.cc 2010-11-25 23:01:53 UTC (rev 7674)
@@ -41,8 +41,8 @@
{
CreateFactory(ForceField);
- /*static*/ const std::string modeStringNormal_s = "tube";
- /*static*/ const std::string modeStringSphere_s = "sphere";
+ /*static*/ const std::string ForceField::modeTube_s = "tube";
+ /*static*/ const std::string ForceField::modeSphere_s = "sphere";
ForceField::ForceField(BaseObject* creator) : StaticEntity(creator)
{
@@ -53,7 +53,7 @@
this->velocity_ = 100;
this->diameter_ = 500;
this->length_ = 5000;
- this->mode_ = ForceFieldMode::tube;
+ this->mode_ = forceFieldMode::tube;
}
ForceField::~ForceField()
@@ -69,14 +69,15 @@
XMLPortParam(ForceField, "diameter", setDiameter, getDiameter, xmlelement, mode).defaultValues(500);
XMLPortParam(ForceField, "length" , setLength , getLength , xmlelement, mode).defaultValues(2000);
XMLPortParam(ForceField, "mode", setMode, getMode, xmlelement, mode);
+ COUT(0) << "ForceField created " << this->velocity_ << " " << this->diameter_ << " " << this->radius_ << " " << this->length_ << " " << this->halfLength_ << " " << this->getMode() << std::endl;
}
void ForceField::tick(float dt)
{
- // Iterate over all objects that could possibly be affected by the ForceField.
- for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
+ if(this->mode_ == forceFieldMode::tube)
{
- if(this->mode_ == ForceFieldMode::tube)
+ // Iterate over all objects that could possibly be affected by the ForceField.
+ for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
{
// The direction of the orientation of the force field.
Vector3 direction = this->getOrientation() * WorldEntity::FRONT;
@@ -88,20 +89,24 @@
// The object is outside of the length of the ForceField.
if(distanceVector.length() > this->halfLength_)
- return;
+ continue;
// The distance of the object form the orientation vector. (Or rather the smallest distance from the orientation vector)
float distanceFromDirectionVector = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length();
// If the object in a tube of radius diameter/2 around the direction of orientation.
if(distanceFromDirectionVector >= this->radius_)
- return;
+ continue;
// Apply a force to the object in the direction of the orientation.
// The force is highest when the object is directly on the direction vector, with a linear decrease, finally reaching zero, when distanceFromDirectionVector = radius.
- it->applyCentralForce(((this->radius_ - distanceFromDirectionVector)/(this->radius_)) * this->velocity_ * direction);
+ it->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction);
}
- else if(this->mode_ == ForceFieldMode::sphere)
+ }
+ else if(this->mode_ == forceFieldMode::sphere)
+ {
+ // Iterate over all objects that could possibly be affected by the ForceField.
+ for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
{
Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
float distance = distanceVector.length();
@@ -116,14 +121,14 @@
void ForceField::setMode(const std::string& mode)
{
- if(mode == ForceField::modeStringTube_s)
- this->mode_ = ForceFieldMode::tube;
- else if(mode == ForceField::modeStringSphere_s)
- this->mode_ = ForceFieldMode::sphere;
+ if(mode == ForceField::modeTube_s)
+ this->mode_ = forceFieldMode::tube;
+ else if(mode == ForceField::modeSphere_s)
+ this->mode_ = forceFieldMode::sphere;
else
{
COUT(2) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << std::endl;
- this->mode_ = ForceFieldMode::tube;
+ this->mode_ = forceFieldMode::tube;
}
}
@@ -131,12 +136,12 @@
{
switch(this->mode_)
{
- case ForceFieldMode::tube:
- return ForceField::modeStringTube_s;
- case ForceFieldMode::sphere:
- return ForceField::modeStringSphere_s;
+ case forceFieldMode::tube:
+ return ForceField::modeTube_s;
+ case forceFieldMode::sphere:
+ return ForceField::modeSphere_s;
default:
- return ForceField::modeStringTube_s;
+ return ForceField::modeTube_s;
}
}
}
Modified: code/trunk/src/modules/objects/ForceField.h
===================================================================
--- code/trunk/src/modules/objects/ForceField.h 2010-11-25 22:24:50 UTC (rev 7673)
+++ code/trunk/src/modules/objects/ForceField.h 2010-11-25 23:01:53 UTC (rev 7674)
@@ -55,7 +55,7 @@
@inGroup Objects
*/
- namespace ForceFieldMode
+ namespace forceFieldMode
{
enum Value {
tube, //!< The ForceField has a tube shape.
@@ -115,15 +115,15 @@
inline const std::string& getMode(void);
private:
- static const std::string modeStringTube_s;
- static const std::string modeStringSphere_s;
+ static const std::string modeTube_s;
+ static const std::string modeSphere_s;
float velocity_;
float diameter_;
float radius_;
float length_;
float halfLength_;
- ForceFieldMode::Value mode_;
+ forceFieldMode::Value mode_;
};
}
More information about the Orxonox-commit
mailing list