Jump to content

Can't see the scene?


gordonramp
 Share

Recommended Posts

--Register abstract path
RegisterAbstractPath("")

--Set graphics mode
if Graphics(1024,768)==0 then
Notify("Failed to set graphics mode.",1)
return
end

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,0,-2))

light=CreateSpotLight(10)
light:SetRotation(Vec3(45,55,0))
light:SetPosition(Vec3(5,5,-5))

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

light=CreateDirectionalLight()
light:SetRotation(Vec3(45,45,45))

while AppTerminate()==0 do



UpdateAppTime()
world:Update(AppSpeed())

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

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

 

I'm trying to load a scene in Lua outside of the Editor with the Lua Engine. With this code, no errors occur but I'm unable to see the scene. Any suggestions why?

AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64.

Link to comment
Share on other sites

No difference, I've tried shifting the camera too.

I'm wondering if the scene is even loading. There's no mention of it in the log.

 

Update: This works.

 

--Register abstract path

RegisterAbstractPath("")

 

--Set graphics mode

if Graphics(1024,768)==0 then

Notify("Failed to set graphics mode.",1)

return

end

 

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,1,0))

 

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

 

while AppTerminate()==0 do

 

UpdateAppTime()

world:Update(AppSpeed())

 

SetBuffer(gbuffer)

world:Render()

SetBuffer(BackBuffer())

world:RenderLights(gbuffer)

 

DrawText(UPS(),0,0)

Flip(0)

end

AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64.

Link to comment
Share on other sites

Yeah, I discovered the scene name was misspelt . Anyway, it is showing up now but of course I can't look around because my next mountain to climb is to get some controller code working. Mouselook and movement. :huh: I've tried adapting from the fpscontroller.lua code but what I have just produces errors.

AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64.

Link to comment
Share on other sites

  • 3 weeks later...

I'm testing lua and i have the same kind of problem (a black screen) with this code

 

--Register abstract path
RegisterAbstractPath("D:\Leadwerks\LPisland")

--Set graphics mode
if Graphics(1024,768)==0 then
Notify("Failed to set graphics mode.",1)
return
end

--Create framewerk object and set it to a global object so other scripts can access it
framework=CreateFramework()
if framework==nil then
Notify("Failed to initialize engine.",1)
return
end
SetGlobalObject("framewerk",framework)

camera=framework.main.camera

scene=LoadScene("abstract::islands3.sbx")
if scene==nil then
AppLog('***************** NULL')
return
end

light=CreateDirectionalLight()
light:SetRotationf(45,45,0)

while AppTerminate()==0 do
  framework:Update()
  framework:Render()

  Flip(0)
end

the console says ***************** NULL and the script ends.

 

- if i use "abstract::tunnels.sbx" like gordon it works.

- my RegisterAbstractPath is correct and points to my islands3.sbx directory

- islands3.sbx spelling is correct, and the path "D:\Leadwerks\LPisland" also.

- the same kind of code in pascal works fine, only my full lua experiment fails

- if i specify the full path like scene=LoadScene("D:\Leadwerks\LPisland\islands3.sbx") i still get the ********* NULL console message

 

Can someone try to do a LoadScene from a custom sbx file located elsewhere than in LE maps folder ?

 

if you have ideas how to solve this, you're welcome ;)

 

i also wonder how actionsnake is loading it's sbx files ? i did not find any loadscene in actionsnake lua files ? :(

 

Thank you

 

EDIT : okey it's m fault :), it works, the camera is just misplaced and i should not have tested "if scene==nil then", but rather "if scene==0 then" or maybe "if scene==nul then" because CreateFramework returns a pointer ... and loadscene a handle.

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

you need to set the position of the camera... more than likely you are spawning the camera in the ground at (0,0,0)

try this or some variation:

camera=framework.main.camera
camera:SetPosition(Vec3(0,3,-2))

 

as far as the null... not sure... i took this code and and placed it into the root of my game directory and changed the abstractpath to "". Changed the name of the scene to my scene and then dragged and dropped the lua script onto the Engine.EXE and it worked just fine after I positioned the camera...

 

this could be an issue with the slashes... i think its supposed to be a forward slash in the abstractpath not a backward slash... but I never hardcode my paths, so I am not sure...

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

as far as the null... not sure... i took this code and and placed it into the root of my game directory and changed the abstractpath to "". Changed the name of the scene to my scene and then dragged and dropped the lua script onto the Engine.EXE and it worked just fine after I positioned the camera...

You're right it works now with "if scene=nil then", no more message in the log window :( maybe vista was locking the sbx file :)

 

I feel more at home with pascal than lua yet, so when something goes wrong i panic ;)

 

Thank you

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

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...