Changeset 3495

Show
Ignore:
Timestamp:
03/13/10 12:31:46 (5 months ago)
Author:
trichards
Message:

Updated Tutorial4 scripts to test scene creation via script. Not all of these script changes work yet. The goal is to get the C++ code to expose the script methods required by these changed scripts.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • tutorials/branches/0185_GEN_PHYSICS_REFACTOR_2/Tutorial4/scripts/client/GameClient.lua

    r3480 r3495  
    6464 
    6565-- ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- 
    66 function GameClient:createScene() 
    67     print("=============\nCreate Scene...\n============") 
    68     local minSize = Math.Vector3(-2000.0, -4000.0, -2000.0); 
    69     local maxSize = Math.Vector3( 2000.0,  2000.0,  2000.0); 
    70      
    71     self.zone = self:getGame():getPhysicsService():createZone(); 
    72     self.zone:setZoneSize(minSize, maxSize); 
    73      
    74     self:getTerrainService():setPhysicsZone(self.zone); 
     66function GameClient:createTerrain() 
     67    local terrainService = self:getTerrainService();  
     68    terrainService:setPhysicsZone(self.zone); 
    7569     
    7670    local matXfm = Math.Matrix4(); 
     
    7872    matXfm:setPosition(0, 0, 0); 
    7973     
    80     self.terrain = self:getTerrainService():createTerrain(); 
    81     self.terrain:loadVisualization("terrain.cfg", matXfm); 
     74    local physicsConfig = Utility.Config(  
     75    { 
     76        ["type"]          = "terrain", 
     77        ["terrainType"]   = "heightfield", 
     78                ["fileName"]      = "terrain.raw", 
     79                ["width"]         = 2048, 
     80                ["widthSamples"]  = 512, 
     81                ["depth"]         = 2048, 
     82                ["depthSamples"]  = 512, 
     83                ["scale"]         = 1.0, 
     84                ["thickness"]     = 1.0, 
     85                ["wrap"]          = true, 
     86    }); 
    8287     
    83     -- Load the physics terrain 
    84     self:loadTerrain("terrain.cfg", matXfm); 
     88    local renderingConfig = Utility.Config( 
     89    { 
     90        ["type"]          = "terrain", 
     91        ["fileName"]      = "terrain.cfg", 
     92    }); 
     93     
     94    self.terrain = terrainService:createTerrain(physicsConfig, renderingConfig); 
     95     
     96    -- TODO set physics material and collision group? 
     97     
     98end 
     99 
     100-- ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- 
     101function GameClient:createSky() 
     102    local skyConfig = Utility.Config( 
     103    { 
     104        ["type"]            = "skybox"; 
     105        ["resourceName"]    = "SteveCube";         
     106    }); 
     107     
     108    self.sky = getSkyService().createSky(skyConfig); 
     109     
     110end 
     111 
     112-- ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- 
     113function GameClient:createSceneLighting() 
     114    self:getSceneService():setAmbientLight(0.8, 0.8, 0.8, 1.0); 
     115     
     116    self.lights = {}; 
     117    lights[1] = self:getSceneService().createLight("default", "Light"); 
     118    lights[1]:setPosition(5000, 5000, 5000); 
     119end 
     120 
     121-- ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- 
     122function GameClient:createScene() 
     123    print("=============\nCreate Scene...\n============") 
     124    local minSize = Math.Vector3(-2000.0, -4000.0, -2000.0); 
     125    local maxSize = Math.Vector3( 2000.0,  2000.0,  2000.0); 
     126 
     127    self.zone = self:getGame():getPhysicsService():createZone(); 
     128    self.zone:setZoneSize(minSize, maxSize); 
     129 
     130    self:setCurrentPhysicsZone(self.zone); 
     131 
     132    -- Load the terrain 
     133    self:createTerrain(); 
     134 
     135    -- Load the sky 
     136    self:createSky(); 
     137 
     138    -- Create the sceen lighting     
     139    self:createSceneLighting(); 
    85140end 
    86141