[Orxonox-commit 5409] r10072 - in code/branches/presentationFS14: . data/levels data/levels/includes data/levels/templates src/modules/objects src/modules/objects/controllers src/orxonox/controllers src/orxonox/worldentities
smerkli at orxonox.net
smerkli at orxonox.net
Thu May 22 14:35:02 CEST 2014
Author: smerkli
Date: 2014-05-22 14:35:02 +0200 (Thu, 22 May 2014)
New Revision: 10072
Added:
code/branches/presentationFS14/data/levels/templates/standardTurret.oxt
code/branches/presentationFS14/src/modules/objects/controllers/
code/branches/presentationFS14/src/modules/objects/controllers/CMakeLists.txt
code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc
code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h
code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc
code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h
Removed:
code/branches/presentationFS14/data/levels/templates/spaceshipTurret.oxt
code/branches/presentationFS14/src/modules/objects/controllers/CMakeLists.txt
code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc
code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h
code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc
code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h
Modified:
code/branches/presentationFS14/
code/branches/presentationFS14/data/levels/includes/weaponSettingsTurret.oxi
code/branches/presentationFS14/data/levels/turretTest.oxw
code/branches/presentationFS14/src/modules/objects/CMakeLists.txt
code/branches/presentationFS14/src/modules/objects/Turret.cc
code/branches/presentationFS14/src/modules/objects/Turret.h
code/branches/presentationFS14/src/orxonox/controllers/ArtificialController.cc
code/branches/presentationFS14/src/orxonox/worldentities/WorldEntity.cc
Log:
Merged turretFS14 branch
Property changes on: code/branches/presentationFS14
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/Racingbot:9388-9513
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/core6:9552-9666
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/sfxThilo:9691-9917
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/surfaceRace:9028-9199
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/turret:9380-9501
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
+ /code/branches/Racingbot:9388-9513
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/core6:9552-9666
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/sfxThilo:9691-9917
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/surfaceRace:9028-9199
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/turret:9380-9501
/code/branches/turretFS14:9998-10070
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
Modified: code/branches/presentationFS14/data/levels/includes/weaponSettingsTurret.oxi
===================================================================
--- code/branches/presentationFS14/data/levels/includes/weaponSettingsTurret.oxi 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/data/levels/includes/weaponSettingsTurret.oxi 2014-05-22 12:35:02 UTC (rev 10072)
@@ -10,13 +10,13 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <attached>
- <Model mesh="sphere.mesh" position="3,3,-2.2" scale=0.6 />
- </attached>
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3, 3,-2.2" />
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3,-3,-2.2" />
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3, 3,-2.2" />
- <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3,-3,-2.2" />
+ <!-- <attached>
+ <Model mesh="sphere.mesh" position="1.7,1.7,-24.5" scale=0.6 />
+ </attached> -->
+ <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="1.7, 1.7,-30" />
+ <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="1.7, -1.7,-30" />
+ <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="-1.7, 1.7,-30" />
+ <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="-1.7, -1.7,-30" />
</Weapon>
</WeaponPack>
</weapons>
Deleted: code/branches/presentationFS14/data/levels/templates/spaceshipTurret.oxt
===================================================================
--- code/branches/presentationFS14/data/levels/templates/spaceshipTurret.oxt 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/data/levels/templates/spaceshipTurret.oxt 2014-05-22 12:35:02 UTC (rev 10072)
@@ -1,60 +0,0 @@
-<Template name=spaceshipturret>
- <SpaceShip
- hudtemplate = spaceshiphud
- camerapositiontemplate = spaceshipturretcameras
- spawnparticlesource = "Orxonox/fairytwirl"
- spawnparticleduration = 3
- explosionchunks = 6
-
- health = 100
- maxhealth = 200
- initialhealth = 100
-
- shieldhealth = 30
- initialshieldhealth = 30
- maxshieldhealth = 50
- shieldabsorption = 0.8
- reloadrate = 1
- reloadwaittime = 1
-
- primaryThrust = 100
- auxilaryThrust = 30
- rotationThrust = 50
-
- lift = 1;
- stallSpeed = 220;
-
- boostPower = 15
- boostPowerRate = 1
- boostRate = 5
- boostCooldownDuration = 10
-
- shakeFrequency = 15
- shakeAmplitude = 9
-
- collisionType = "dynamic"
- mass = 100
- linearDamping = 0.7
- angularDamping = 0.9999999
- >
- <attached>
- <Model position="0,0,0" yaw="90" roll="-90" mesh="turretHead.mesh" scale3D="10,10,10"/>
- </attached>
- <collisionShapes>
- <SphereCollisionShape radius="10" position = "0,0,0"/>
- </collisionShapes>
-<?lua
- include("../includes/weaponSettingsTurret.oxi")
-?>
- </SpaceShip>
-</Template>
-
-<Template name=spaceshipturretcameras defaults=0>
- <SpaceShip>
- <camerapositions>
- <CameraPosition position="0,10, 40" drag=true mouselook=true />
- <CameraPosition position="0,20, 80" drag=true mouselook=true />
- <CameraPosition position="0,30,120" drag=true mouselook=true />
- </camerapositions>
- </SpaceShip>
-</Template>
Copied: code/branches/presentationFS14/data/levels/templates/standardTurret.oxt (from rev 10070, code/branches/turretFS14/data/levels/templates/standardTurret.oxt)
===================================================================
--- code/branches/presentationFS14/data/levels/templates/standardTurret.oxt (rev 0)
+++ code/branches/presentationFS14/data/levels/templates/standardTurret.oxt 2014-05-22 12:35:02 UTC (rev 10072)
@@ -0,0 +1,40 @@
+<Template name=standardturret>
+ <Turret collisionType="dynamic">
+ <attached>
+ <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" pitch=-90/>
+ <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" pitch=-90/>
+ <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" pitch=-90/>
+ <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" pitch=-90/>
+ <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" pitch=-90/>
+
+ <Turret position="0,0,-10" collisionType="dynamic" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=2000 minAttackRadius=30>
+ <attached>
+ <Model position="0,0,0" pitch="-90" roll="0" mesh="turretHead.mesh" scale3D="10,10,10"/>
+ </attached>
+ <collisionShapes>
+ <SphereCollisionShape radius="10" position = "0,0,0"/>
+ </collisionShapes>
+ <controller>
+ <TurretController/>
+ </controller>
+ <?lua
+ include("../includes/weaponSettingsTurret.oxi")
+ ?>
+ </Turret>
+ </attached>
+
+ <controller>
+ <TeamTargetProxy/>
+ </controller>
+ </Turret>
+</Template>
+
+<Template name=spaceshipturretcameras defaults=0>
+ <SpaceShip>
+ <camerapositions>
+ <CameraPosition position="0,10, 40" drag=true mouselook=true />
+ <CameraPosition position="0,20, 80" drag=true mouselook=true />
+ <CameraPosition position="0,30,120" drag=true mouselook=true />
+ </camerapositions>
+ </SpaceShip>
+</Template>
\ No newline at end of file
Modified: code/branches/presentationFS14/data/levels/turretTest.oxw
===================================================================
--- code/branches/presentationFS14/data/levels/turretTest.oxw 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/data/levels/turretTest.oxw 2014-05-22 12:35:02 UTC (rev 10072)
@@ -2,7 +2,7 @@
<LevelInfo
name = "turret Test"
- description = "A level with a turret in it."
+ description = "A level to test turrets with."
tags = "test"
screenshot = "emptylevel.png"
/>
@@ -15,8 +15,7 @@
<?lua
include("templates/spaceshipAssff.oxt")
- include("templates/spaceshipPirate.oxt")
- include("templates/spaceshipTurret.oxt")
+ include("templates/standardTurret.oxt")
?>
<Level>
@@ -32,31 +31,26 @@
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
<SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+<SpaceShip position = "0,0,800" collisionType="dynamic" team=10>
+ <controller>
+ <TeamTargetProxy team=10/>
+ </controller>
+ <attached>
+ <Model position="0,0,0" mesh="plane.mesh" scale3D="20,20,20" pitch=-90/>
-<StaticEntity position="0,0,0" yaw=0 pitch=0>
- <attached>
- <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" />
- <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" />
- <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" />
- <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" />
- <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" />
- </attached>
-</StaticEntity>
+ <?lua for i = 1, 10, 1 do ?>
+ <Turret position="<?lua print(150-i*30) ?>,<?lua print(150-i*30) ?>,0" pitch="0" yaw="0" roll="0">
+ <templates>
+ <Template link=standardturret />
+ </templates>
+ </Turret>
+ <?lua end ?>
-
-
-<Turret position="0,10,0" pitch="90" yaw="0" roll="0">
- <templates>
- <Template link=spaceshipturret />
- </templates>
- <controller>
- <WaypointPatrolController alertnessradius=100 team=10>
- </WaypointPatrolController>
- </controller>
-</Turret>
-
-
-
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape radius="10" position="0,0,0" halfExtents="200, 200, 0"/>
+ </collisionShapes>
+</SpaceShip>
</Scene>
</Level>
Modified: code/branches/presentationFS14/src/modules/objects/CMakeLists.txt
===================================================================
--- code/branches/presentationFS14/src/modules/objects/CMakeLists.txt 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/src/modules/objects/CMakeLists.txt 2014-05-22 12:35:02 UTC (rev 10072)
@@ -10,6 +10,7 @@
ADD_SUBDIRECTORY(collisionshapes)
ADD_SUBDIRECTORY(eventsystem)
ADD_SUBDIRECTORY(triggers)
+ADD_SUBDIRECTORY(controllers)
ORXONOX_ADD_LIBRARY(objects
MODULE
Modified: code/branches/presentationFS14/src/modules/objects/Turret.cc
===================================================================
--- code/branches/presentationFS14/src/modules/objects/Turret.cc 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/src/modules/objects/Turret.cc 2014-05-22 12:35:02 UTC (rev 10072)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Marian Runo
+ * Marian Runo, Martin Mueller
* Co-authors:
* ...
*
@@ -28,58 +28,257 @@
#include "Turret.h"
#include "core/CoreIncludes.h"
-#include "OgreQuaternion.h"
#include "core/XMLPort.h"
-#include "controllers/WaypointPatrolController.h"
+#include "Scene.h"
+#include <OgreSceneManager.h>
+
namespace orxonox
{
RegisterClass(Turret);
+
+
/**
- * @brief Constructor
+ @brief
+ Sets default values for all variables. Also hides the turret from the radar.
+
+ @param context
+ The context
*/
- Turret::Turret(Context* context) : SpaceShip(context)
+ Turret::Turret(Context* context) : Pawn(context)
{
RegisterObject(Turret);
- this->controller_ = new WaypointPatrolController(this->getContext());
+ this->rotationThrust_ = 50;
+ this->startDir_ = Vector3::ZERO;
+ this->localZ_ = Vector3::UNIT_Z;
+ this->localY_ = Vector3::UNIT_Y;
+ this->localX_ = Vector3::UNIT_X;
+ this->maxAttackRadius_ = 200;
+ this->minAttackRadius_ = 0;
+ this->maxPitch_ = 90;
+ this->maxYaw_ = 90;
+ this->once_ = false;
+ this->rotation_ = Quaternion::IDENTITY;
+
+ this->setRadarVisibility(false);
+
+ //this->rayTest_ = this->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
}
/**
- * @brief Destructor
+ @brief
+ Destructor. Destroys the rayTest_ element (if it was used) .
*/
Turret::~Turret()
{
+ //this->getScene()->getSceneManager()->destroyQuery(this->rayTest_);
+ }
+ /**
+ @brief
+ Checks, if a WorldEntity is inside the turret's range.
+
+ This function is safe to use on turrets that are attached, rotated, etc.
+ The turret's range is determined with the maxPitch, maxYaw, and the two attackRadius.
+
+ @param target
+ The WorldEntity to check
+
+ @return
+ The squared distance to the position. -1, if it's ouside of range
+ */
+ float Turret::isInRange(const WorldEntity* target )
+ {
+ //Check distance
+ Vector3 distance = target->getWorldPosition() - this->getWorldPosition();
+ float distanceVal = distance.squaredLength();
+ if(distanceVal > (this->maxAttackRadius_ * this->maxAttackRadius_) || distanceVal < (this->minAttackRadius_ * this->minAttackRadius_))
+ {
+ return -1.f;
+ }
+
+ //Check pitch
+ Vector3 dir = getTransformedVector(distance, this->localX_, this->localY_, this->localZ_);
+ Vector3 dirProjected = dir;
+ dirProjected.x = 0;
+ Vector3 startDirProjected = this->startDir_;
+ startDirProjected.x = 0;
+ Ogre::Real angle = startDirProjected.angleBetween(dirProjected).valueDegrees();
+ if(angle > this->maxPitch_)
+ {
+ return -1.f;
+ }
+
+ //Check yaw
+ dirProjected = dir;
+ dirProjected.y = 0;
+ startDirProjected = this->startDir_;
+ startDirProjected.y = 0;
+ angle = startDirProjected.angleBetween(dirProjected).valueDegrees();
+ if(angle > this->maxYaw_)
+ {
+ return -1.f;
+ }
+
+ //TODO: Finish this. Find a way to convert objects from Ogre to Orxonox
+ /*Ogre::Ray ray = Ogre::Ray(this->getWorldPosition(), distance);
+ this->rayTest_->setRay(ray);
+ Ogre::RaySceneQueryResult result = this->rayTest_->execute();*/
+
+
+ return distanceVal;
}
+ /**
+ @brief
+ Rotates the turret to make it aim at a certain position.
- void Turret::rotatePitch(const Vector2& value)
+ @note
+ There are no checks, if the position is valid (i.e. if the turret is allowed to aim there).
+ This function must be called again for every tick, or the turret will stop rotating.
+
+ @param position
+ The position to aim at
+ */
+ void Turret::aimAtPosition(const Vector3& position)
{
- orxout()<< "Turret rotate Pitch"<< endl;
+ Vector3 currDir = this->getWorldOrientation() * WorldEntity::FRONT;
+ Vector3 targetDir = position - this->getWorldPosition();
- const Quaternion& orient = this->getOrientation();
- Radian pitch = orient.getPitch();
+ this->rotation_ = currDir.getRotationTo(targetDir);
+ }
- if((value.x > 0 && pitch < Radian(180)) || (value.x < 0 && pitch > Radian(0)))
- SpaceShip::rotatePitch(value);
+ /**
+ @brief
+ Does currently nothing.
+
+ Should rotate the turret with the specified pitch. Contains a failed attempt at limiting said rotation.
+ */
+ void Turret::rotatePitch(const Vector2& value)
+ {
+ //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
+ /*
+ Vector3 currentDir = getTransformedVector(this->getOrientation() * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
+ Vector3 currentDirProjected = currentDir;
+ currentDirProjected.x = 0;
+ Vector3 startDirProjected = this->startDir_;
+ startDirProjected.x = 0;
+ Ogre::Real angle = startDirProjected.angleBetween(currentDirProjected).valueDegrees();
+ //orxout() << "Pitch: " << angle << endl;
+ //if(angle < this->maxPitch_ || (currentDirProjected.y <= 0 && value.x > 0) || (currentDirProjected.y > 0 && value.x < 0) )
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
+ }
+ */
}
+ /**
+ @brief
+ Does currently nothing.
- void Turret::setAlertnessRadius(float value)
+ Should rotate the turret with the specified yaw. Contains a failed attempt at limiting said rotation.
+ */
+ void Turret::rotateYaw(const Vector2& value)
{
- this->controller_->setAlertnessRadius(value);
+ //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
+ /*
+ Vector3 currentDir = getTransformedVector(this->getOrientation() * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
+ Vector3 currentDirProjected = currentDir;
+ currentDirProjected.y = 0;
+ Vector3 startDirProjected = this->startDir_;
+ startDirProjected.y = 0;
+ Ogre::Real angle = startDirProjected.angleBetween(currentDirProjected).valueDegrees();
+ orxout() << "Yaw: " << angle << endl;
+ if(angle < this->maxYaw_ || (currentDirProjected.x <= 0 && value.x < 0) || (currentDirProjected.x > 0 && value.x > 0))
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x*0.8f);
+ }
+ */
}
- float Turret::getAlertnessRadius()
+
+ /**
+ @brief
+ Does currently nothing.
+
+ May be used to limit turret's rotation in the future.
+ */
+ void Turret::rotateRoll(const Vector2& value)
{
- return this->controller_->getAlertnessRadius();
}
+ /**
+ @brief
+ Loads parameters from xml
+
+ Parameters loaded are: rotationThrust, maxAttackRadius, minAttackRadius, maxYaw, maxPitch
+ */
void Turret::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(Turret, XMLPort, xmlelement, mode);
- XMLPortParam(Turret, "alertnessRadius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues("400");
+
+ XMLPortParamVariable(Turret, "rotationThrust", rotationThrust_, xmlelement, mode);
+ XMLPortParam(Turret, "maxAttackRadius", setMaxAttackRadius, getMaxAttackRadius, xmlelement, mode);
+ XMLPortParam(Turret, "minAttackRadius", setMinAttackRadius, getMinAttackRadius, xmlelement, mode);
+ XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode);
+ XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode);
}
+ /**
+ @brief
+ The turret's actions are done here.
-}
+ Every tick, the turret gets rotated if it should, and the local axes get updated with the parent's rotation.
+
+ @param dt
+ Duration of the tick
+ */
+ void Turret::tick(float dt)
+ {
+ SUPER(Turret, tick, dt);
+
+ //Stuff isn't properly initialized in the c'tor, so we have to do it like this
+ if(!this->once_)
+ {
+ //Account for rotations done in xml
+ Quaternion startOrient = this->getOrientation();
+ this->localXStart_ = startOrient * this->localX_;
+ this->localXStart_.normalise();
+ this->localX_ = this->localXStart_;
+ this->localYStart_ = startOrient * this->localY_;
+ this->localYStart_.normalise();
+ this->localY_ = this->localYStart_;
+ this->localZStart_ = startOrient * this->localZ_;
+ this->localZStart_.normalise();
+ this->localZ_ = this->localZStart_;
+
+ //startDir should always be (0,0,-1)
+ this->startDir_ = getTransformedVector(startOrient * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
+
+ this->once_ = true;
+
+ }
+
+ //Adjust local axes to parent's rotation
+ WorldEntity* parent = this->getParent();
+ if(parent)
+ {
+ Quaternion parentrot = parent->getWorldOrientation();
+ this->localX_ = parentrot * this->localXStart_;
+ this->localY_ = parentrot * this->localYStart_;
+ this->localZ_ = parentrot * this->localZStart_;
+ }
+
+ //rotate
+ if(this->rotation_ != Quaternion::IDENTITY)
+ {
+ //Don't make the rotation instantaneous. Use an arbitrary interpolation, not that great...
+ //TODO: make the rotation better (constant velocity etc.). At the moment, the turret rotates
+ //slower the closer it is to the destination
+ Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
+ this->rotate(drot, WorldEntity::World);
+ this->rotation_ = Quaternion::IDENTITY;
+ }
+
+ }
+}
\ No newline at end of file
Modified: code/branches/presentationFS14/src/modules/objects/Turret.h
===================================================================
--- code/branches/presentationFS14/src/modules/objects/Turret.h 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/src/modules/objects/Turret.h 2014-05-22 12:35:02 UTC (rev 10072)
@@ -20,14 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Marian Runo
+ * Marian Runo, Martin Mueller
* Co-authors:
* ...
*
*/
/**
- @file Turret.h
@brief Definition of the Turret class.
@ingroup Objects
*/
@@ -36,33 +35,93 @@
#define _Turret_H__
#include "objects/ObjectsPrereqs.h"
+#include "worldentities/pawns/Pawn.h"
+#include <OgreSceneQuery.h>
-#include "worldentities/pawns/SpaceShip.h"
-
namespace orxonox
{
- class _ObjectsExport Turret : public SpaceShip
+ /**
+ @brief
+ Creates a turret with limited rotation. The point of this class is to be able to attach
+ a turret to a spaceship or a spacestation which is more or less completely autonomous in
+ it's behaviour.
+
+ This class also contains a custom local coordinate system, which gets initially rotated through xml, and
+ afterwards is updated with the parent's rotation (if there is one). This allows for almost trivialal calculation
+ of pitch, yaw and roll through coordinate transformation. (TODO: Ogre should do something like this already, investigate...)
+
+
+ @note
+ The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target.
+ */
+ class _ObjectsExport Turret : public Pawn
{
public:
Turret(Context* context);
virtual ~Turret();
- //virtual void tick(float dt);
-
virtual void rotatePitch(const Vector2& value);
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+ virtual float isInRange(const WorldEntity* target);
+ virtual void aimAtPosition(const Vector3 &position);
- void setAlertnessRadius(float value);
- float getAlertnessRadius();
-
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void tick(float dt);
+ /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
+ inline void setMaxAttackRadius(float radius)
+ { this->maxAttackRadius_ = radius; }
+ /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/
+ inline void setMinAttackRadius(float radius)
+ { this->minAttackRadius_ = radius; }
+
+ /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/
+ inline void setMaxPitch(float pitch)
+ { this->maxPitch_ = pitch; }
+
+ /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/
+ inline void setMaxYaw(float yaw)
+ { this->maxYaw_ = yaw; }
+
+ /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */
+ inline float getMaxAttackRadius() const
+ { return this->maxAttackRadius_; }
+
+ /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */
+ inline float getMinAttackRadius() const
+ { return this->minAttackRadius_; }
+
+ /** @brief Returns the maximum pitch the turret can have. @return The pitch */
+ inline float getMaxPitch() const
+ { return this->maxPitch_; }
+
+ /** @brief Returns the maximum yaw the turret can have. @return The yaw */
+ inline float getMaxYaw() const
+ { return this->maxYaw_; }
+
protected:
- WaypointPatrolController* controller_;
+ Vector3 startDir_; //!< The initial facing direction, in local coordinates.
+ Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml.
+ Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml.
+ Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml.
+ Quaternion rotation_; //!< The rotation to be done by the turret.
+
private:
+ bool once_; //!< Flag for executing code in the tick function only once.
+ Vector3 localZStart_; //!< The local z-axis, without the parent's rotation.
+ Vector3 localYStart_; //!< The local y-axis, without the parent's rotation.
+ Vector3 localXStart_; //!< The local x-axis, without the parent's rotation.
+ float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot.
+ float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot.
+ Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side).
+ Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side).
+ float rotationThrust_; //!< The velocity the turret rotates with.
+ Ogre::RaySceneQuery* rayTest_; //!< Used to perform a raytest, currently unused @see isInRange
+
};
}
#endif
-
Deleted: code/branches/presentationFS14/src/modules/objects/controllers/CMakeLists.txt
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt 2014-05-22 11:41:32 UTC (rev 10070)
+++ code/branches/presentationFS14/src/modules/objects/controllers/CMakeLists.txt 2014-05-22 12:35:02 UTC (rev 10072)
@@ -1,4 +0,0 @@
-ADD_SOURCE_FILES(OBJECTS_SRC_FILES
- TurretController.cc
- TeamTargetProxy.cc
-)
Copied: code/branches/presentationFS14/src/modules/objects/controllers/CMakeLists.txt (from rev 10070, code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt)
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/CMakeLists.txt (rev 0)
+++ code/branches/presentationFS14/src/modules/objects/controllers/CMakeLists.txt 2014-05-22 12:35:02 UTC (rev 10072)
@@ -0,0 +1,4 @@
+ADD_SOURCE_FILES(OBJECTS_SRC_FILES
+ TurretController.cc
+ TeamTargetProxy.cc
+)
Deleted: code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc 2014-05-22 11:41:32 UTC (rev 10070)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc 2014-05-22 12:35:02 UTC (rev 10072)
@@ -1,105 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Mueller
- * Co-authors:
- * ...
- *
- */
-
-#include "TeamTargetProxy.h"
-#include "worldentities/ControllableEntity.h"
-#include "worldentities/pawns/Pawn.h"
-
-namespace orxonox
-{
- RegisterClass(TeamTargetProxy);
-
- /**
- @brief
- Sets default values for all variables.
-
- @param context
- The context
- */
- TeamTargetProxy::TeamTargetProxy(Context* context) : FormationController(context)
- {
- RegisterObject(TeamTargetProxy);
-
- this->once_ = false;
- }
-
- /**
- @brief
- Destructor. Nothing to see here.
- */
- TeamTargetProxy::~TeamTargetProxy()
- {
- }
-
- /**
- @brief
- Copies the team and the target from the parent.
-
- That's all there is.
- */
- void TeamTargetProxy::tick(float dt)
- {
- if (!this->isActive() || !this->getControllableEntity())
- return;
-
- ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
-
- if(this->getTeam() != -1 && !this->once_ && parent)
- {
- orxout(internal_warning) << "TeamTargetProxy: Team already set, may result in undesired behaviour. Will get overridden by the parent's team." << endl;
- }
-
- if(!this->once_)
- this->once_ = true;
-
- //Teams aren't set immediately, after creation, so we have to check every tick...
- if(parent)
- {
- Controller* parentcontroller = parent->getController();
- if(parentcontroller)
- {
- this->setTeam(parentcontroller->getTeam());
- }
- else
- {
- this->setTeam(parent->getTeam());
- }
- this->getControllableEntity()->setTeam(parent->getTeam());
- }
-
- if(parent)
- {
- Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
- if(parenttarget)
- {
- this->setTarget(parenttarget);
- this->getControllableEntity()->setTarget(parenttarget);
- }
- }
- }
-}
\ No newline at end of file
Copied: code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc (from rev 10070, code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc)
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc (rev 0)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc 2014-05-22 12:35:02 UTC (rev 10072)
@@ -0,0 +1,105 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Mueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "TeamTargetProxy.h"
+#include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ RegisterClass(TeamTargetProxy);
+
+ /**
+ @brief
+ Sets default values for all variables.
+
+ @param context
+ The context
+ */
+ TeamTargetProxy::TeamTargetProxy(Context* context) : FormationController(context)
+ {
+ RegisterObject(TeamTargetProxy);
+
+ this->once_ = false;
+ }
+
+ /**
+ @brief
+ Destructor. Nothing to see here.
+ */
+ TeamTargetProxy::~TeamTargetProxy()
+ {
+ }
+
+ /**
+ @brief
+ Copies the team and the target from the parent.
+
+ That's all there is.
+ */
+ void TeamTargetProxy::tick(float dt)
+ {
+ if (!this->isActive() || !this->getControllableEntity())
+ return;
+
+ ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
+
+ if(this->getTeam() != -1 && !this->once_ && parent)
+ {
+ orxout(internal_warning) << "TeamTargetProxy: Team already set, may result in undesired behaviour. Will get overridden by the parent's team." << endl;
+ }
+
+ if(!this->once_)
+ this->once_ = true;
+
+ //Teams aren't set immediately, after creation, so we have to check every tick...
+ if(parent)
+ {
+ Controller* parentcontroller = parent->getController();
+ if(parentcontroller)
+ {
+ this->setTeam(parentcontroller->getTeam());
+ }
+ else
+ {
+ this->setTeam(parent->getTeam());
+ }
+ this->getControllableEntity()->setTeam(parent->getTeam());
+ }
+
+ if(parent)
+ {
+ Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
+ if(parenttarget)
+ {
+ this->setTarget(parenttarget);
+ this->getControllableEntity()->setTarget(parenttarget);
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h 2014-05-22 11:41:32 UTC (rev 10070)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h 2014-05-22 12:35:02 UTC (rev 10072)
@@ -1,60 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Mueller
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _TeamTargetProxy_H__
-#define _TeamTargetProxy_H__
-
-#include "OrxonoxPrereqs.h"
-#include "controllers/FormationController.h"
-
- namespace orxonox
- {
- /**
- @brief
- A controller, that just copies the team and the target of a parent for itself and it's controllable entity.
-
- Useful for following (and similar) situations: (-> means attached to)
- turret (rotates) -> some kind of turret base (looks nice) -> spaceship (flies around)
- The turret has a controller that wants to copy the spaceship's target and team. In this case it doesn't work though,
- because the turret isn't directly attached to the spaceship. Here's where this controller comes in. Drawback: the base
- has to be controllable and ticks every second (performance?)
- */
- class _OrxonoxExport TeamTargetProxy : public FormationController, public Tickable
- {
- public:
- TeamTargetProxy(Context* context);
- virtual ~TeamTargetProxy();
-
- virtual void tick(float dt);
-
- private:
- bool once_; //!< Flag for executing code in the tick function only once.
- };
- }
-
- #endif
\ No newline at end of file
Copied: code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h (from rev 10070, code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h)
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h (rev 0)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h 2014-05-22 12:35:02 UTC (rev 10072)
@@ -0,0 +1,60 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Mueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _TeamTargetProxy_H__
+#define _TeamTargetProxy_H__
+
+#include "OrxonoxPrereqs.h"
+#include "controllers/FormationController.h"
+
+ namespace orxonox
+ {
+ /**
+ @brief
+ A controller, that just copies the team and the target of a parent for itself and it's controllable entity.
+
+ Useful for following (and similar) situations: (-> means attached to)
+ turret (rotates) -> some kind of turret base (looks nice) -> spaceship (flies around)
+ The turret has a controller that wants to copy the spaceship's target and team. In this case it doesn't work though,
+ because the turret isn't directly attached to the spaceship. Here's where this controller comes in. Drawback: the base
+ has to be controllable and ticks every second (performance?)
+ */
+ class _OrxonoxExport TeamTargetProxy : public FormationController, public Tickable
+ {
+ public:
+ TeamTargetProxy(Context* context);
+ virtual ~TeamTargetProxy();
+
+ virtual void tick(float dt);
+
+ private:
+ bool once_; //!< Flag for executing code in the tick function only once.
+ };
+ }
+
+ #endif
\ No newline at end of file
Deleted: code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc 2014-05-22 11:41:32 UTC (rev 10070)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc 2014-05-22 12:35:02 UTC (rev 10072)
@@ -1,202 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Mueller
- * Co-authors:
- * ...
- *
- */
-
-#include "TurretController.h"
-#include "worldentities/pawns/Pawn.h"
-#include "Turret.h"
-
- namespace orxonox
- {
- RegisterClass(TurretController);
-
- /**
- @brief
- Sets default values for all variables.
-
- @param context
- The context
- */
- TurretController::TurretController(Context* context) : ArtificialController(context)
- {
- RegisterObject(TurretController);
-
- this->once_ = false;
-
- }
-
- /**
- @brief
- Destructor. Nothing to see here.
- */
- TurretController::~TurretController()
- {
-
- }
-
- /**
- @brief
- Searches a valid target for the turret to aim at.
-
- Loops through all pawns and tests, if it is in range. Scores every pawn and chooses the best one (the one with the lowest score).
- If the turret has a parent, try to aim at the same target the parent has, if there is one.
-
- @see targetScore
- The function that scores the pawns.
- */
- void TurretController::searchTarget()
- {
- Turret* turret = orxonox_cast<Turret*>(this->getControllableEntity());
-
- //The controller might find a target before teams are set, so we need to check again here.
- if(this->target_ && turret->isInRange(target_) != -1.f && !FormationController::sameTeam(turret, this->target_, this->getGametype()))
- {
- return;
- }
- else
- {
- this->forgetTarget();
- turret->setTarget(0);
- }
-
-
- ControllableEntity* parent = orxonox_cast<ControllableEntity*>(turret->getParent());
- if(parent)
- {
- Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
- if(parenttarget && turret->isInRange(parenttarget))
- {
- this->setTarget(parenttarget);
- turret->setTarget(parenttarget);
- return;
- }
- }
-
- float minScore = FLT_MAX;
- float tempScore;
- Pawn* minScorePawn = 0;
-
- for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
- {
- Pawn* entity = orxonox_cast<Pawn*>(*it);
- if (!entity || FormationController::sameTeam(this->getControllableEntity(), entity, this->getGametype()))
- continue;
- tempScore = turret->isInRange(entity);
- if(tempScore != -1.f)
- {
- if(tempScore < minScore)
- {
- minScore = tempScore;
- minScorePawn = entity;
- }
- }
- }
- this->setTarget(minScorePawn);
- turret->setTarget(minScorePawn);
- }
-
- /**
- @brief
- Tests, if the turret is looking at the target, with a specified tolerance
-
- This uses the world position as opposed to the local position in the old version.
-
- @param angle
- The tolerance, in radians
- */
- bool TurretController::isLookingAtTargetNew(float angle) const
- {
- return (getAngle(this->getControllableEntity()->getWorldPosition(), this->getControllableEntity()->getWorldOrientation() * WorldEntity::FRONT, this->target_->getWorldPosition()) < angle);
- }
-
- /**
- @brief
- Scores a pawn as a target, based on distance and health.
-
- The more health and distance a pawn has, the higher the score. This means lower equals better.
-
- @param pawn
- The pawn to score
-
- @param distance
- The distance. Can be squared or normed, doesn't matter as long as all are treated the same.
- */
- float TurretController::targetScore(Pawn* pawn, float distance) const
- {
- return pawn->getHealth()/pawn->getMaxHealth() + distance;
- }
-
- /**
- @brief
- Does all the controlling of the turret.
-
- If the turret has a parent, copies the team from there, if it's not already set.
- Other actions are: Search a target. If a target has been found, aim and shoot at it.
- */
- void TurretController::tick(float dt)
- {
- if (!this->isActive() || !this->getControllableEntity())
- return;
-
-
- ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
- if(this->getTeam() != -1 && !this->once_ && parent)
- {
- orxout(internal_warning) << "TurretController: Team already set, may result in undesired behaviour. Will get overridden by the parent's team." << endl;
- }
-
- if(!this->once_)
- this->once_ = true;
-
- //Teams aren't set immediately, after creation, so we have to check every tick...
- if(parent)
- {
- Controller* parentcontroller = parent->getController();
- if(parentcontroller)
- {
- this->setTeam(parentcontroller->getTeam());
- }
- else
- {
- this->setTeam(parent->getTeam());
- }
- this->getControllableEntity()->setTeam(parent->getTeam());
- }
-
- this->searchTarget();
- if(this->target_)
- {
- Turret* turret = orxonox_cast<Turret*> (this->getControllableEntity());
- this->aimAtTarget();
- turret->aimAtPosition(target_->getWorldPosition());
- if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
- {
- this->getControllableEntity()->fire(0);
- }
- }
- }
- }
\ No newline at end of file
Copied: code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc (from rev 10070, code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc)
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc (rev 0)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc 2014-05-22 12:35:02 UTC (rev 10072)
@@ -0,0 +1,202 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Mueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "TurretController.h"
+#include "worldentities/pawns/Pawn.h"
+#include "Turret.h"
+
+ namespace orxonox
+ {
+ RegisterClass(TurretController);
+
+ /**
+ @brief
+ Sets default values for all variables.
+
+ @param context
+ The context
+ */
+ TurretController::TurretController(Context* context) : ArtificialController(context)
+ {
+ RegisterObject(TurretController);
+
+ this->once_ = false;
+
+ }
+
+ /**
+ @brief
+ Destructor. Nothing to see here.
+ */
+ TurretController::~TurretController()
+ {
+
+ }
+
+ /**
+ @brief
+ Searches a valid target for the turret to aim at.
+
+ Loops through all pawns and tests, if it is in range. Scores every pawn and chooses the best one (the one with the lowest score).
+ If the turret has a parent, try to aim at the same target the parent has, if there is one.
+
+ @see targetScore
+ The function that scores the pawns.
+ */
+ void TurretController::searchTarget()
+ {
+ Turret* turret = orxonox_cast<Turret*>(this->getControllableEntity());
+
+ //The controller might find a target before teams are set, so we need to check again here.
+ if(this->target_ && turret->isInRange(target_) != -1.f && !FormationController::sameTeam(turret, this->target_, this->getGametype()))
+ {
+ return;
+ }
+ else
+ {
+ this->forgetTarget();
+ turret->setTarget(0);
+ }
+
+
+ ControllableEntity* parent = orxonox_cast<ControllableEntity*>(turret->getParent());
+ if(parent)
+ {
+ Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
+ if(parenttarget && turret->isInRange(parenttarget))
+ {
+ this->setTarget(parenttarget);
+ turret->setTarget(parenttarget);
+ return;
+ }
+ }
+
+ float minScore = FLT_MAX;
+ float tempScore;
+ Pawn* minScorePawn = 0;
+
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+ {
+ Pawn* entity = orxonox_cast<Pawn*>(*it);
+ if (!entity || FormationController::sameTeam(this->getControllableEntity(), entity, this->getGametype()))
+ continue;
+ tempScore = turret->isInRange(entity);
+ if(tempScore != -1.f)
+ {
+ if(tempScore < minScore)
+ {
+ minScore = tempScore;
+ minScorePawn = entity;
+ }
+ }
+ }
+ this->setTarget(minScorePawn);
+ turret->setTarget(minScorePawn);
+ }
+
+ /**
+ @brief
+ Tests, if the turret is looking at the target, with a specified tolerance
+
+ This uses the world position as opposed to the local position in the old version.
+
+ @param angle
+ The tolerance, in radians
+ */
+ bool TurretController::isLookingAtTargetNew(float angle) const
+ {
+ return (getAngle(this->getControllableEntity()->getWorldPosition(), this->getControllableEntity()->getWorldOrientation() * WorldEntity::FRONT, this->target_->getWorldPosition()) < angle);
+ }
+
+ /**
+ @brief
+ Scores a pawn as a target, based on distance and health.
+
+ The more health and distance a pawn has, the higher the score. This means lower equals better.
+
+ @param pawn
+ The pawn to score
+
+ @param distance
+ The distance. Can be squared or normed, doesn't matter as long as all are treated the same.
+ */
+ float TurretController::targetScore(Pawn* pawn, float distance) const
+ {
+ return pawn->getHealth()/pawn->getMaxHealth() + distance;
+ }
+
+ /**
+ @brief
+ Does all the controlling of the turret.
+
+ If the turret has a parent, copies the team from there, if it's not already set.
+ Other actions are: Search a target. If a target has been found, aim and shoot at it.
+ */
+ void TurretController::tick(float dt)
+ {
+ if (!this->isActive() || !this->getControllableEntity())
+ return;
+
+
+ ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
+ if(this->getTeam() != -1 && !this->once_ && parent)
+ {
+ orxout(internal_warning) << "TurretController: Team already set, may result in undesired behaviour. Will get overridden by the parent's team." << endl;
+ }
+
+ if(!this->once_)
+ this->once_ = true;
+
+ //Teams aren't set immediately, after creation, so we have to check every tick...
+ if(parent)
+ {
+ Controller* parentcontroller = parent->getController();
+ if(parentcontroller)
+ {
+ this->setTeam(parentcontroller->getTeam());
+ }
+ else
+ {
+ this->setTeam(parent->getTeam());
+ }
+ this->getControllableEntity()->setTeam(parent->getTeam());
+ }
+
+ this->searchTarget();
+ if(this->target_)
+ {
+ Turret* turret = orxonox_cast<Turret*> (this->getControllableEntity());
+ this->aimAtTarget();
+ turret->aimAtPosition(target_->getWorldPosition());
+ if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
+ {
+ this->getControllableEntity()->fire(0);
+ }
+ }
+ }
+ }
\ No newline at end of file
Deleted: code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TurretController.h 2014-05-22 11:41:32 UTC (rev 10070)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h 2014-05-22 12:35:02 UTC (rev 10072)
@@ -1,65 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Mueller
- * Co-authors:
- * ...
- *
- */
-
-/**
- @brief Definition for the controller for turrets.
-*/
-
-#ifndef _TurretController_H__
-#define _TurretController_H__
-
-#include "OrxonoxPrereqs.h"
-#include "controllers/ArtificialController.h"
-
- namespace orxonox
- {
- /**
- @brief
- Controller for turrets. Chooses a target, and makes the turret aim/shoot at it.
-
- The controllableEntity gets casted to Turret, so this controller won't work for anything else.
- */
- class _OrxonoxExport TurretController : public ArtificialController, public Tickable
- {
- public:
- TurretController(Context* context);
- virtual ~TurretController();
-
- virtual void tick(float dt);
-
- private:
-
- void searchTarget();
- bool isLookingAtTargetNew(float angle) const;
- float targetScore(Pawn* pawn, float distance) const;
-
- bool once_; //!< Flag for executing code in the tick function only once.
- };
- }
-
- #endif
\ No newline at end of file
Copied: code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h (from rev 10070, code/branches/turretFS14/src/modules/objects/controllers/TurretController.h)
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h (rev 0)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h 2014-05-22 12:35:02 UTC (rev 10072)
@@ -0,0 +1,65 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Mueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @brief Definition for the controller for turrets.
+*/
+
+#ifndef _TurretController_H__
+#define _TurretController_H__
+
+#include "OrxonoxPrereqs.h"
+#include "controllers/ArtificialController.h"
+
+ namespace orxonox
+ {
+ /**
+ @brief
+ Controller for turrets. Chooses a target, and makes the turret aim/shoot at it.
+
+ The controllableEntity gets casted to Turret, so this controller won't work for anything else.
+ */
+ class _OrxonoxExport TurretController : public ArtificialController, public Tickable
+ {
+ public:
+ TurretController(Context* context);
+ virtual ~TurretController();
+
+ virtual void tick(float dt);
+
+ private:
+
+ void searchTarget();
+ bool isLookingAtTargetNew(float angle) const;
+ float targetScore(Pawn* pawn, float distance) const;
+
+ bool once_; //!< Flag for executing code in the tick function only once.
+ };
+ }
+
+ #endif
\ No newline at end of file
Modified: code/branches/presentationFS14/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/presentationFS14/src/orxonox/controllers/ArtificialController.cc 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/src/orxonox/controllers/ArtificialController.cc 2014-05-22 12:35:02 UTC (rev 10072)
@@ -93,7 +93,7 @@
static const float hardcoded_projectile_speed = 1250;
- this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity());
+ this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(), hardcoded_projectile_speed, this->target_->getWorldPosition(), this->target_->getVelocity());
this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
Modified: code/branches/presentationFS14/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/presentationFS14/src/orxonox/worldentities/WorldEntity.cc 2014-05-22 12:18:47 UTC (rev 10071)
+++ code/branches/presentationFS14/src/orxonox/worldentities/WorldEntity.cc 2014-05-22 12:35:02 UTC (rev 10072)
@@ -413,8 +413,9 @@
}
else if (this->isDynamic())
{
- orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
- return false;
+ //***HACKY HACK (to allow turrets to be attached)***
+ //orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
+ //return false;
}
else if (this->isKinematic() && newParent->isDynamic())
{
More information about the Orxonox-commit
mailing list