Jump to content

LoadScene?


Benton
 Share

Recommended Posts

LoadScene() is not working for me?

 

require("Scripts/constants/keycodes")
require("Scripts/linkedlist")
require("Scripts/filesystem")
require("scripts/math/math")
require("scripts/constants/engine_const")

ScreenWidth = 1200
ScreenHeight =  720

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

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

FlushKeys()
--HideMouse()
local camera = fw.main.camera
local scene = LoadScene("abstract::mountianvalley.sbx")
chassis=LoadModel("abstract::vehicle_monstertruck.gmf")
carobject=objecttable[chassis]
car=carobject.vehicle
if car==nil then
Notify("Vehicle object not found.",1)
chassis:Free()
return
end
chassis:SetPositionf(130, 5, 690)
chassis:SetRotationf(0,camera.rotation.y+180.0,0)
--Variables
local dx=0.0
local dy=0.0
local camerapitch=camera.rotation.x
local camerayaw=camera.rotation.y
local move=0.0
local strafe=0.0
local steering = 0.0
local torque = 0.0
local steerlimit = 30.0
local steerrate = 2.0
local steerangle=0.0
local prevmouseX = 750
local changemouseX
MoveMouse(Round(GraphicsWidth()/2),Round(GraphicsHeight()/2))
while KeyHit(KEY_ESCAPE)==0 do

--Camera look
gx=Round(GraphicsWidth()/2)
gy=Round(GraphicsHeight()/2)
--dx=Curve((MouseX()-gx)/4.0,dx,3.0/AppSpeed())
--dy=Curve((MouseY()-gy)/4.0,dy,3.0/AppSpeed())
--MoveMouse(gx,gy)
camerapitch=camerapitch+dy
camerayaw=camerayaw-dx
camerapitch=math.min(camerapitch,45)
camerapitch=math.max(camerapitch,10)
fw.main.camera:SetRotationf(camerapitch,chassis.rotation.y-180,0,1)

local tirespeed=-(KeyDown(KEY_UP)-KeyDown(KEY_DOWN))*1.0
car:AddTireTorque(tirespeed,0)
car:AddTireTorque(tirespeed,1)
car:AddTireTorque(tirespeed,2)
car:AddTireTorque(tirespeed,3)

steermode=0
changemouseX = MouseX() - prevmouseX
turnrad = changemouseX/10
steerangle=steerangle-turnrad*AppSpeed()
steerangle=Clamp(steerangle,-5,5)
car:SetSteerAngle(steerangle,0)
car:SetSteerAngle(steerangle,1)
steerangle=Clamp(steerangle,-25,25)
car:SetSteerAngle(steerangle,0)
car:SetSteerAngle(steerangle,1)
fw:Update()


local campos=TFormPoint(Vec3(0,1,0),chassis,nil)

fw.main.camera:SetPosition(campos)
fw.main.camera:Move(Vec3(0,0,-10))

local t=TFormVector(Vec3(0,0,1),camera,chassis)
a=-math.deg(math.atan2(t.x,t.z))+180.0



chassis:Hide()
chassis:Show()
fw:Render()
Flip(0)
end
chassis:Free()
chassis=nil
camera=nil
ShowMouse()

 

It does not seem to be loading a scene, its black with the car loaded...no errors...the scene DOES exist...

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 so I made a really simple script:

 

require("Scripts/constants/keycodes")
require("Scripts/linkedlist")
require("Scripts/filesystem")
require("scripts/math/math")
require("scripts/constants/engine_const")

ScreenWidth = 1200
ScreenHeight =  720

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

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

FlushKeys()
--HideMouse()
local camera = fw.main.camera
local scene = LoadScene("abstract::mountianvalley.sbx")

while KeyHit(KEY_ESCAPE)==0 do

--Camera look

fw:Update()

fw:Render()
Flip(0)
end
camera=nil
ShowMouse()

 

No scene gets loaded...

 

engine.log:

 

Leadwerks Engine 2.5
Initializing Renderer...
OpenGL Version: 4.1.0
GLSL Version: 4.10 NVIDIA via Cg compiler
Render device: GeForce GTX 460/PCI/SSE2
Vendor: NVIDIA Corporation
DrawBuffers2 supported: 1
32 texture units supported.
GPU instancing supported: 1
Max batch size: 64
Shader model 4.0 supported: 1
Conditional render supported: 0
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//query.vert", ""...
Invoking script "C:/Users/Benton/Documents/Leadwerk Projects/turning_heads/Scripts/start/collisions.lua"...
Invoking script "C:/Users/Benton/Documents/Leadwerk Projects/turning_heads/Scripts/start/fliphook.lua"...
Invoking script "C:/Users/Benton/Documents/Leadwerk Projects/turning_heads/Scripts/start/globals.lua"...
Loading material "c:/leadwerks engine sdk/materials/cobblestones.mat"...
Loading texture "c:/leadwerks engine sdk/materials/cobblestones.dds"...
Loading texture "c:/leadwerks engine sdk/materials/cobblestonesdot3.dds"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse_bumpmap.vert", "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse_bumpmap_specular.frag"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/clearcolor.frag"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//guide.vert", "zip::c:/leadwerks engine sdk/shaders.pak//editor/guide.frag"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_shadow.vert", ""...
Loading texture "incbin::noise.dds"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/shaders.pak//lighting/directionallight.frag"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/postfilter.frag"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/depthblit.frag"...
Loading texture "incbin::Arial9.dds"...

 

Now one thing I don't understand: why is it looking in c:/leadwerks engine...when it should be looking in the script directory...

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

Is this a bug or...?

 

 

Edit:

 

After playing around with it, It can't seem to find shaders...? I thing the whole project is messed up, so I will create it in a new directory...

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

if you are running that script with the scripteditor.exe, then it probably still has the default engine.exe location set for the LE SDK folder instead of the engine.exe that should be located in your separate project folder. Or just keep everything for test purposes in the LE SDK folder.

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