Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8389


Ignore:
Timestamp:
May 2, 2011, 10:30:40 PM (13 years ago)
Author:
youngk
Message:

Adding Collision Shapes to Planets. Doesn't currently work.

Location:
code/branches/mac_osx2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/mac_osx2/data/levels/planets.oxw

    r8351 r8389  
     1<LevelInfo
     2 name = "Planet Demonstration"
     3 description = "Demonstration of Planets"
     4 tags = "planets"
     5/>
     6
    17<?lua
     8  include("stats.oxo")
    29  include("HUDTemplates3.oxo")
    3   include("stats.oxo")
    410  include("templates/lodInformation.oxt")
    5   include("templates/spaceshipSwallow.oxt")
    6   include("templates/spaceshipPirate.oxt")
     11  include("templates/spaceshipHXY.oxt")
    712?>
    813
    9 
    10 
    1114<Level
    12  name         = "Planet_Demo"
    13  description  = "Demonstration of planets with high resolution."
    14 
     15 name         = "Planet"
     16 description  = "Demonstration of Planets"
    1517>
    1618  <templates>
    17    <Template link=lodtemplate_default />
     19    <Template link="lodtemplate_default" />
    1820  </templates>
    1921
    2022  <Scene
    21    ambientlight = "0.5, 0.5, 0.5"
    22    skybox       = "Orxonox/skypanoramagen1"
     23    ambientlight = "0.8, 0.8, 0.8"
     24    skybox       = "Orxonox/skypanoramagen1"
    2325  >
     26
     27    <WorldAmbientSound
     28      ambientSource="AlphaCentauri.ogg"
     29      looping="true"
     30      playOnLoad="true"
     31    />
    2432   
    25 <WorldAmbientSound ambientSource="AlphaCentauri.ogg" looping="true" playOnLoad="true" />
    26 <Light type=directional position="-10000,-10000,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" />
     33    <Light
     34      type="directional"
     35      position="-10000,-10000,0"
     36      direction="0.253, 0.593, -0.765"
     37      diffuse="1.0, 0.9, 0.9, 1.0"
     38      specular="1.0, 0.9, 0.9, 1.0"
     39    />
    2740
    28 <?lua
    29 planetsize=40000
    30 ?>
     41    <SpawnPoint
     42      position="1500,0,0"
     43      lookat="0,0,0"
     44      spawnclass="SpaceShip"
     45      pawndesign="spaceshipHXY"
     46    />
    3147
    32 <SpawnPoint position="<?lua print(math.sin(1.5) *(3)*planetsize) ?>,<?lua print(math.cos(1.5) *3*planetsize) ?>,<?lua print(500) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipswallow />
     48    <Planet
     49      position="0,0,0"
     50      scale="1000"
     51      collisionType="dynamic"
     52      linearDamping="0.8"
     53      angularDamping="0"
     54      mass="200"
     55      pitch="0"
     56      mesh="jupiter.mesh"
     57      atmosphere="atmosphere1"
     58      rotationaxis="1,0,0"
     59      rotationrate="1.0"
     60      atmospheresize="300.0f"
     61      imagesize="1024.0f"
     62    >
     63      <collisionShapes>
     64        <SphereCollisionShape radius="1000" position="0,0,0" />
     65      </collisionShapes>
     66    </Planet>
    3367
    34 
    35 <?lua
    36 max = 50
    37 
    38 for i = 1, max, 1
    39 do
    40     x = math.sin(i/max*6)*(1.5)*planetsize
    41     y = i*100
    42     z = math.cos(i/max*6)*(1.5)*planetsize
    43     ?>
    44 <?lua
    45 for k = 1, 25, 1
    46 do
    47 j = math.random()
    48 ?>
    49 
    50     <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    51       <attached>
    52         <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
    53       </attached>
    54       <?lua if i == 5 then ?><collisionShapes>
    55         <SphereCollisionShape radius="<?lua print(j * 70) ?>" />
    56       </collisionShapes> <?lua end ?>
    57     </MovableEntity>
    58 <?lua
    59 end
    60 ?>
    61 <?lua end ?>
    62     <Planet position="0,0,0" scale="<?lua print(planetsize) ?>" pitch=-90 mesh="jupiter.mesh" atmosphere="atmosphere1" rotationaxis="0,1,0" rotationrate="0.2" atmospheresize=300.0f imagesize=1024.0f />
    63     <Planet position="<?lua print(5*planetsize) ?>,0,0" scale=10000 pitch=30 mesh="ganymede.mesh" atmosphere="atmosphere1" rotationaxis="1,0,1" rotationrate="1.5" atmospheresize=224.0f imagesize=1024.0f />
     68    <Planet
     69      position="10000,0,0"
     70      scale="100"
     71      pitch="0"
     72      mesh="ganymede.mesh"
     73      atmosphere="atmosphere1"
     74      rotationaxis="1,0,0"
     75      rotationrate="1.0"
     76      atmospheresize="224.0f"
     77      imagesize="1024.0f"
     78    />
    6479  </Scene>
    6580</Level>
  • code/branches/mac_osx2/src/modules/objects/Planet.cc

    r7401 r8389  
    3737#include "core/XMLPort.h"
    3838#include "Scene.h"
     39#include "objects/collisionshapes/SphereCollisionShape.h"
    3940#include "graphics/Camera.h"
    4041#include "CameraManager.h"
     
    5152        RegisterObject(Planet);
    5253        this->registerVariables();
     54       
     55        // Get notification about collisions
     56        if (GameMode::isMaster())
     57        {
     58            //this->setMass(1.0);
     59            this->enableCollisionCallback();
     60            this->setCollisionResponse(false);
     61            this->setCollisionType(Static);
     62           
     63            SphereCollisionShape* shape = new SphereCollisionShape(this);
     64            //shape->setRadius(20);
     65            this->attachCollisionShape(shape);
     66        }
    5367    }
    5468
Note: See TracChangeset for help on using the changeset viewer.