Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 69 and Version 70 of content/LevelHowTo


Ignore:
Timestamp:
Nov 2, 2015, 11:06:38 PM (9 years ago)
Author:
fvultier
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • content/LevelHowTo

    v69 v70  
    8989The StaticEntity defines the model's place and orientation (and some other values). The Model (a cube) is attached to the StaticEntity. With the proper sized collisionshape attached to the StaticEntity you have a "solid" cube. Without a collisionshape, the cube wouldn't be solid and your spaceship could just fly through it. This exampe is quite useful, since you usually can't see a collisionshape's size. If you combine an invisible collisionshape with a fitting model you can see where a collisionshape is for testing purposes. In this special case both the '''scale3D''' and the '''halfExtents''' parameters are identical. To make the collisionshapes visible in the game type "debugDrawPhysics true" in the ingame console.
    9090
     91== Models ==
     92A level depends on its models. All finished models are stored in __../data_extern/models__. If you want to view most models in the '''Gallery''' level.
     93At the moment we have several asteroids, spaceships, a satellite, two different space stations and some smaller models.
     94For test purposes you can use simple models like the cube or the sphere:
     95{{{
     96#!xml
     97<Model mesh="cube.mesh" position="0,0,0" scale=10 />
     98<Model mesh="sphere.mesh" position="100,0,0" scale3d="10,20,20" />
     99}}}
     100The attribute "scale" applies a uniform scale in all directions. By using the attribute "scale3d" you can define different scaling factors for the x-, y- and z-directions.
     101
    91102== MovableEntity - Let's get the world moving ==
    92103Worldentities can be attached to other worldentities. If you want a model to move in circles, you can create a MovableEntity that rotates and a StaticEntity attached to it. The model that should be rotating is attached to the StaticEntity.
     
    109120</MovableEntity>
    110121}}}
    111 Note that in this example the Model is created by a lua script that is called in a lua tag. Lua is a scripting language that is a very powerful tool for level design.
    112 
    113 == Models ==
    114 A level depends on its models. All finished models are stored in __../data_extern/models__. If you want to view most models in the '''Gallery''' level.
    115 At the moment we have several asteroids, spaceships, a satellite, two different space stations and some smaller models.
    116 For test purposes you can use simple models like the cube or the sphere:
    117 {{{
    118 #!xml
    119 <Model mesh="cube.mesh" position="0,0,0" scale=10 />
    120 <Model mesh="sphere.mesh" position="100,0,0" scale3d="10,20,20" />
    121 }}}
    122 The attribute "scale" applies a uniform scale in all directions. By using the attribute "scale3d" you can define different scaling factors for the x-, y- and z-directions.
     122Note that in this example the Model is created by a lua script that is called in a lua tag. Lua is a scripting language that is a very powerful tool for level design. Later in this tutorial you will learn more about lua. Here is anouther example about the MovableEntity class:
     123{{{
     124#!xml
     125<MovableEntity position="0,0,0" rotationrate="45" rotationaxis="0,0,1">
     126    <attached>
     127        <Model position="0,0,0" mesh="cube.mesh" scale3D="2,2,20" />
     128        <MovableEntity position="0,0,0" rotationrate="180" rotationaxis="0,1,0">
     129            <attached>
     130                <Model position="0,0,0" mesh="sphere.mesh" scale3D="1,1,10" />
     131            </attached>
     132        </MovableEntity>
     133    </attached>
     134</MovableEntity>
     135}}}
     136The first MovableEntity rotates slowly around the z-axis. It has a model of a cube and another MovableEntity attached to it. This second MovableEntity rotates fast around the y-axis. Notice that the first MovableEntity rotates around the global z-axis of the Scene, but the second MovableEntity rotates around the y-axis of its local coordinate system which is relative to its parent (=the first MovableEntity)
     137Inside the second MovableEntity there is another Model attached. Every Model is a StaticEntity. So here he have a nesting of WorldEntities with three layers.
     138The following example shows how to use a MovableEntity to perform a linear movement.
     139{{{
     140#!xml
     141<MovableEntity position="100,0,0" velocity="0,0,10">
     142    <attached>
     143        <Model position="0,0,0" mesh="cube.mesh" scale3D="2,2,20" />
     144        <MovableEntity position="0,0,0" rotationrate="180" rotationaxis="0,1,0">
     145            <attached>
     146                <Model position="0,0,0" mesh="sphere.mesh" scale3D="1,1,10" />
     147            </attached>
     148        </MovableEntity>
     149    </attached>
     150</MovableEntity>
     151}}}
     152Linear movement and rotation can also be combined by setting all three parameters (velocity, rotationaxis and rotationrate).
     153You might noticed that it is possible to fly through the models. This is because the MovablEntities have no physics. Lets change that:
     154{{{
     155#!xml
     156<MovableEntity position="0,0,0" rotationrate="90" rotationaxis="0,0,1" collisionType="dynamic" mass=10>
     157    <attached>
     158        <Model position="0,0,0" mesh="cube.mesh" scale3D="40,4,4" />
     159    </attached>
     160    <collisionShapes>
     161        <BoxCollisionShape position="0,0,0" halfExtents="40,4,4" />
     162    </collisionShapes>   
     163</MovableEntity>
     164}}}
     165Never forget to change the collisionType to dynamic. Otherwise the collision shapes are useless.
     166
     167In the next example the rotating MovableEntity damages your spaceship if you touch it.
     168{{{
     169#!xml
     170<MovableEntity position="0,0,0" rotationrate="90" rotationaxis="0,0,1" collisionType="dynamic" mass=1000 collisiondamage=0.02 enablecollisiondamage=true>
     171    <attached>
     172        <Model position="0,0,0" mesh="cube.mesh" scale3D="40,4,4" />
     173    </attached>
     174    <collisionShapes>
     175        <BoxCollisionShape position="0,0,0" halfExtents="40,4,4" />
     176    </collisionShapes>   
     177</MovableEntity>
     178}}}
     179You always need to set both the collisiondamage and the enablecollisiondamage attribute.
    123180
    124181== Spawnpoints ==