Using VC++ 2008 Express
Use the 2.3 Project Wizard to create a new project
I simply called the example "sceneloading"
Delete the generated example code in sceneloading.cpp
Replace with the following code:
#include "Framewerk.h"
int main(int argc, char** argv)
{
Initialize();
RegisterAbstractPath("PATH TO YOUR SDK FOLDER");
Graphics(800,600);
leadwerks::Framewerk fw;
fw.Create();
// Setup Global Objects
SetGlobalObject ("world_main", fw.GetMain ().GetWorld ());
SetGlobalObject ("world_transparency", fw.GetTransparency ().GetWorld ());
SetGlobalObject ("world_background", fw.GetBackground ().GetWorld ());
SetGlobalObject ("camera_main", fw.GetMain ().GetCamera ());
SetGlobalObject ("camera_transparency", fw.GetTransparency ().GetCamera ());
SetGlobalObject ("camera_background", fw.GetBackground ().GetCamera ());
TListener listener= CreateListener(fw.GetMain ().GetCamera ());
SetGlobalObject("listener", listener);
// Setup Initial Post Processing FX
fw.GetRenderer().SetGodRays(1);
fw.GetRenderer().SetHDR(1);
fw.GetRenderer().SetSSAO(1);
fw.GetRenderer().SetBloom(1);
fw.GetRenderer().SetAntialias(1);
fw.GetRenderer().SetReflectionRenderComponents(ENTITY_RENDERABLE);
// Load Skybox
fw.GetRenderer().SetSkybox(LoadMaterial("abstract::FullskiesBlueClear0016_2_L.mat"));
// Setup On Screen Stats Info
fw.SetStats(2);
// Setup Collisions
Collisions(1, 1, 1);
Collisions(1, 2, 1);
Collisions(1, 3, 1);
Collisions(2, 2, 1);
Collisions(2, 3, 1);
Collisions(3, 3, 1);
LoadScene("abstract::YOUR_SCENE.sbx");
// Setup spectator
TBody spectator=CreateBodySphere();
SetBodyMass(spectator,1);
SetBodyGravityMode(spectator,0);
SetBodyDamping(spectator,1.0);
EntityType(spectator,3);
SetBodyBuoyancyMode(spectator,0);
PositionEntity(spectator,Vec3(0,75,0));
TVec3 camrotation=Vec3(0);
float mx=0;
float my=0;
float move=0;
float strafe=0;
HideMouse();
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
// MAIN LOOP
while (!KeyHit(KEY_ESCAPE))
{
mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);
my=Curve(MouseY()-GraphicsHeight()/2,my,6);
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
camrotation.X=camrotation.X+my/10.0;
camrotation.Y=camrotation.Y-mx/10.0;
RotateEntity(fw.GetMain().GetCamera(),camrotation);
move=KeyDown(KEY_W)-KeyDown(KEY_S);
strafe=KeyDown(KEY_D)-KeyDown(KEY_A);
TVec3 force = Vec3(strafe*10.0,0,move*10.0);
force=TFormVector(force,fw.GetMain().GetCamera(),0);
AddBodyForce(spectator,force);
UpdateAppTime();
UpdateWorld(AppSpeed()) ;
PositionEntity(fw.GetMain().GetCamera(),EntityPosition(spectator));
fw.Update();
fw.Render();
Flip(0);
}
fw.Free();
return Terminate();
}
Add existing items
Framewerk.cpp
Layer.cpp
Renderer.cpp
(Right click on the sceneloading solution, add/existing item and navigate to your SDK's CPP folder)
Copy to the sceneloading project folder
shaders.pak
Scripts folder
from your 2.3 SDK folder
*You will need to make sure you have wobbledot3.dds in the materials folder in your SDK folder. I found without it, using emitters in a scene will casue the app to crash on loading. I am not sure if 2.3 comes with this file and my download just missed it, or its not included. I took mine from a previous install. Simply place it in the root of the materials folder.
I made it so the code points to the SDK folder so nothing, other than the scripts folder and textures.pak need to be moved to the sceneloading app dir.
Create a scene and save it in the maps folder in your SDK folder, note though as far as I can tell you will have to load the skybox manually via code (as per above code) or parse it and the waterplane via a small ProcessScene function.
You need to update the oildrum.lua file with this (Thanks to Macklebee):
dofile('Scripts/base.lua') -- We need the base class entity
--Time between hit noises
hitnoisedelay=100
--Minimum collision speed to make noise
hitthreshhold=3
lasthitnoisetime=0
hitnoisetimevariation=50
maxhitsources=10
--Load some noises to play
hitnoise={}
hitnoise[0]=LoadSound('abstract::impact_metal12.wav')
hitnoise[1]=LoadSound('abstract::impact_metal13.wav')
hitnoise[2]=LoadSound('abstract::impact_metal07.wav')
material_dust=LoadMaterial('abstract::dust.mat')
--Spawn entity
function Spawn(model)
local entity=base_Spawn(model)
return entity
end
--Add collision noise
function Collision(model,entity,position,normal,force,speed)
local entity=entitytable[model]
local time,i
if fw~=nil then
listener = fw.listener
else
listener=GetGlobalObject("listener")
end
if EntityDistance(listener,model)<30 then
if speed>hitthreshhold then
time=AppTime()
if time-lasthitnoisetime>hitnoisedelay then
--Check how many impact noises are already active
local countsources=0
for i=0,2 do
if hitnoise[i]~=nil then
countsources=countsources+hitnoise[i]:ActiveSources()
end
end
--Only emit a sound if there are fewer than the allowed max sources
if countsources<maxhitsources then
i=math.random(0,2)
if hitnoise[i]~=nil then
entity.model:EmitSound(hitnoise[i],30,1.0,0)
end
end
lasthitnoisetime=time+math.random(0,hitnoisetimevariation)
end
end
end
end
This is only a very basic example using framewerk.
Hope this is of some help to someone.