implemented application and scenegraph
This commit is contained in:
@ -71,16 +71,26 @@ lastFPS <- 0;
|
||||
frameCount <- 0;
|
||||
FPS <- 1;
|
||||
body <- null;
|
||||
camera <- null;
|
||||
mainSceneGraph <- null;
|
||||
|
||||
function Initialize()
|
||||
{
|
||||
::font = Font();//Font ("DejaVuSans.ttf", 24, 1 );
|
||||
::logo = Image ("image.png", 0.0, 0.0, 1.0, 1.0);
|
||||
::body = RigidBody();
|
||||
|
||||
::camera = Camera();
|
||||
::mainSceneGraph = SceneGraph();
|
||||
::camera.lookAt (0.0, 0.0, 0.0);
|
||||
::mainSceneGraph.setCamera (::camera);
|
||||
}
|
||||
|
||||
function OnFrame( delta )
|
||||
function OnFrame (delta, total)
|
||||
{
|
||||
::camera.setPosition (::body.getPosition());
|
||||
}
|
||||
|
||||
function OnOverlay (delta, total)
|
||||
{
|
||||
::frameCount += 1
|
||||
::lastFPS += delta;
|
||||
@ -91,22 +101,32 @@ function OnFrame( delta )
|
||||
::frameCount = 0;
|
||||
::lastFPS -= 0.1;
|
||||
}
|
||||
|
||||
if (::FPS > 0)
|
||||
|
||||
if (total < 2.0)
|
||||
::logo.draw (0.5, 0.5);
|
||||
else
|
||||
{
|
||||
local fps = "FPS: " + FPS + " / " + (1.0/::FPS)*1000.0 + " ms";
|
||||
::font.print( 10, 10, fps, 1, 1 );
|
||||
v <- ::body.getPosition();
|
||||
::font.print(10, 40, "Position: " + v.x + ", " + v.y + ", " + v.z, 1, 1 );
|
||||
|
||||
local seconds = floor(total % 60);
|
||||
if (seconds < 10)
|
||||
::font.print(10, 70, "Time: " + floor(total / 60.0) + ":0" + seconds, 1, 1 );
|
||||
else
|
||||
::font.print(10, 70, "Time: " + floor(total / 60.0) + ":" + seconds, 1, 1 );
|
||||
|
||||
if (::FPS > 0)
|
||||
{
|
||||
local fps = "FPS: " + FPS + " / " + (1.0/::FPS)*1000.0 + " ms";
|
||||
::font.print( 10, 10, fps, 1, 1 );
|
||||
}
|
||||
}
|
||||
// ::logo.draw (0.5, 0.5);
|
||||
|
||||
v <- ::body.getPosition();
|
||||
::font.print(10, 40, "Position: " + v.x + ", " + v.y + ", " + v.z, 1, 1 );
|
||||
}
|
||||
|
||||
function OnStep( delte )
|
||||
function OnStep (delta, total)
|
||||
{
|
||||
::body.applyLocalForce( Vector(0.0, 0.0, 1.0) );
|
||||
}
|
||||
::body.applyLocalForce( Vector(1.0, 0.0, 1.0) );
|
||||
}
|
||||
|
||||
function Shutdown()
|
||||
{
|
||||
|
Reference in New Issue
Block a user