⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boxstack.lua

📁 使用stl技术,(还没看,是听说的)
💻 LUA
字号:
-- Set up a scene to demo the engine
------------------------------------

-- Function for adding things to the scene
function triggerScene( )
    o = createBox( )
    o:getPhysics( ):setLinearVelocity( camera:getDirection( ) * 170 )
    o:getPhysics( ):setAngularVelocity( math.random( -2, 2 ),
                                        math.random( -7, 7 ),
                                        math.random( -2, 2 ) )	
    o:setPosition( camera:getPosition( ) )  
end

-- Function to update the scene
function updateScene( time )    
   
end

-- Function to go forward
function doForward( )

end

-- Function to go backward
function doBackward( )

end

-- Function to go left
function doLeft( )

end

-- Function to go right
function doRight( )

end

-- Function to go forward
function doForward( )


end

-- Create a new box
function createBox( )
    newObject = objects:createObject( objects:getNextUniqueName( ), "box" )    
    newObject:getEntity( ):setAllMaterials( "box" )
 
    -- Show how to link back to your own app
    demo:addReactor( newObject )
    return newObject
end

-- Create a new sphere
function createSphere( )
    newObject = objects:createObject( objects:getNextUniqueName( ), "sphere" )
    newObject:getEntity( ):setAllMaterials( "box" ) 
    return newObject
end

-- Function to setup a scene
function resetScene( )
    -- Position camera
    camera:setPosition( 0, 10, 100 )
  
    -- Reset object pool
    objects:clearPool( )
    -- Clear the physics
    phys:reset( )
	
    -- Setup a "floor" object
    floor = objects:createObject( "theFloor", "floor" )
    floor:getEntity( ):setAllMaterials( "floor" )
    floor:setPosition(  vector3.ZERO )
    -- Make sure it's not being dynamcially updated
    p = floor:getPhysics( )
    p:setDynamicsEnabled(false,false)
   
    -- Look at the floor
    camera:lookAt( floor )
    
    -- Real gravity
    phys:setGravity( 0, -20, 0 )
   
    -- Make the scene look a little prettier
    graph:setAmbientLight( 0.8, 0.8, 0.8 )
    graph:setSkyBox( true, "background", 7000, true )
    graph:setFog( graphicsSystem.FM_EXP,
                  colour.new( colour, 1.0, 1.0, 1.0, 1.0 ), 0.005, 0, 1 )

    -- Setup some blocks to play with   
    rows = 9
    blockSize = 2
	
    for row = 1, rows do
        for column = 1, ( rows - row ) do
            o = createBox( )
            o:setPosition( vector3.new( vector3, ( row * ( blockSize / 2 ) )+( column * blockSize )-
			   ( ( rows / 2 ) * blockSize ),
                           ( ( row - 1 ) * blockSize ) + 1.5,
                           0 ) )
    	    o:getPhysics( ):setDynamicsEnabled( true, false)
        end
    end    
 end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -