Jump to content

Camera Problem


Benton
 Share

Recommended Posts

Hey all,

 

I am trying to load a scene and place a camera at a camera node.

 

require("Scripts/constants/engine_const")
--Register abstract path
RegisterAbstractPath("")
--Set graphics mode
if Graphics(1024,768)==0 then
Notify("Failed to set graphics mode.",1)
return
end
fw = CreateFramework()
world=CreateWorld()
if world==nil then
Notify("Failed to initialize engine.",1)   return
end
gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8)
camera=CreateCamera()
camera:SetPosition(Vec3(0,600,0))


scene = LoadScene("abstract::deserthighway.sbx")

cameraStart = scene:FindChild("start")
camera:SetPosition(cameraStart:GetPosition())

while AppTerminate()==0 do

if KeyHit(KEY_ESCAPE)==1 then
 break
end

UpdateAppTime()
world:Update(AppSpeed())

SetBuffer(gbuffer)
world:Render()
SetBuffer(BackBuffer())
world:RenderLights(gbuffer)

DrawText(UPS(),0,0)
Flip(0)

end

 

 

Lua Error:

[string "C:/Users/Benton/Documents/Leadwerk Projects/Game/start.lua"]:29: attempt to indel global 'cameraStart' (a nil value)

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

the error tells you it didn't find the entity named "start"... are you sure that is the name? check the sbx file to be sure...

 

also, if you are using framework there is no reason to create a world or a camera as framework does this for you... and in the main loop, just use fw:Update() and fw:Render()... you can remove the rest...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

The name is "start". Triple checked it.

 

require("Scripts/constants/engine_const")
--Register abstract path
RegisterAbstractPath("")
--Set graphics mode
if Graphics(1024,768)==0 then
Notify("Failed to set graphics mode.",1)
return
end
fw = CreateFramework()
gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8)
camera = fw.main.camera

scene = LoadScene("abstract::deserthighway.sbx")

--cameraStart = scene:FindChild("start")
--camera:SetPosition(cameraStart:GetPosition())

while AppTerminate()==0 do

if KeyHit(KEY_ESCAPE)==1 then
 break
end


fw:Update()

SetBuffer(gbuffer)
fw:Render()

end

 

Now this just brings up a window that is all white, nothing is being rendered. When I put Flip(0) in the update, it turns black but still nothing is being rendered, the scene DOES NOT load.

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

Ok fixed it, I needed to put SetBuffer(BackBuffer()) in the update.

 

However, it renders everything well but still has the nil value error when locating the camera node.

 

require("Scripts/constants/engine_const")
--Register abstract path
RegisterAbstractPath("")
--Set graphics mode
if Graphics(1024,768)==0 then
Notify("Failed to set graphics mode.",1)
return
end
fw = CreateFramework()
gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8)
camera = fw.main.camera

scene = LoadScene("abstract::deserthighway.sbx")

cameraStart = scene:FindChild("start")
camera:SetPosition(cameraStart:GetPosition())

while AppTerminate()==0 do

if KeyHit(KEY_ESCAPE)==1 then
 break
end


fw:Update()

SetBuffer(gbuffer)
SetBuffer(BackBuffer())
fw:Render()
Flip(0)
DrawText(UPS(),0,0)

end

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

post the sbx and/or the script for the "start" entity

 

also, you do not need the gbuffer... framework handles all of this for you...:

 

require("Scripts/constants/engine_const")
require("Scripts/math/vector")
RegisterAbstractPath("")
Graphics(1024,768)
fw = CreateFramework()

scene = LoadScene("abstract::deserthighway.sbx")
fw.main.camera:SetPosition(StringToVec3(scene:GetKey("cameraposition")))

start = scene:FindChild("start")

if start==nil then
  Notify("not found")
else
  fw.main.camera:SetPosition(start:GetPosition(1))
end

while AppTerminate()==0 and KeyHit(KEY_ESCAPE)==0 do
  fw:Update()
  fw:Render()
  Flip(1)
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...