Hey guys,
got another problem with one of the lua tutorials, I went through the Camera Control tutorial and wrote the code in the script editor exactly like it is in the pdf. When I run the code now, the camera does rotate like crazy, but I dont know what the problem could be...
hope someone can help me here:
--Include the engine_const.lua file for keyboard input
require("Scripts/constants/engine_const")
--registering the abstract path
RegisterAbstractPath("")
--Set a graphics mode
Graphics(800,600)
--Framework object
fw = CreateFramework()
--Set camera
camera = fw.main.camera
camera:SetPosition(Vec3(0,1,-5))
--Create directionallight
light1 = CreateDirectionalLight()
light1:SetRotation(Vec3(45,45,0))
--Load a mesh
scene = LoadMesh("abstract::scene.gmf")
if scene == nil then
Notify("Failed to load scene.gmf")
end
--Move the mouse to the center of the screen and hide it
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
HideMouse(1)
camrotation=Vec3(0)
--Main loop
while KeyDown(KEY_ESCAPE)==0 do
--Camera rotation
gx=Curve(MouseX() - GraphicsWidth() /2,
gx, 10) gx=Curve(MouseX() - GraphicsWidth() /2,
gx, 10) gy=Curve(MouseY() - GraphicsHeight() /2, gy, 10)
camrotation.x = camrotation.x + gy / 10
camrotation.y = camrotation.y - gx / 10
camera:SetRotation(camrotation,1)
--Camera movement
move = Curve(KeyDown(KEY_W) - KeyDown(KEY_S), move, 10)
strafe = Curve(KeyDown(KEY_D) - KeyDown(KEY_A), strafe, 10)
camera:Move(Vec3(move/10, 0, strafe/10))
fw:Update()
fw:Render()
Flip(0)
end