PDA

View Full Version : Loading scenes in runtime?



Bylkki
06-10-2003, 11:40 AM
How to do this correctly? I tried the example at caperaven.co.za but it didn't work at all.
Now could someone explain how to do this. For example if my base scene has a cube and a camera and I want to load my level1.gls witch has the cube and the camera and some other objects. Now if I call glscene1.loadfromfile('level1.gls');
It gives me an error "invalid enumerant". What's going wrong?

orwa
08-10-2003, 07:12 PM
Hi Bylkki ..


i don't know exactly whay your code doesn't work . ?
but i think maybe there are a small mistake .

You can TRY :

1- Add "ExtractFilePath(ParamStr(0))" to your Path , to be shore that you are working in the curint path ..
Like this :
GLScene1.LoadFromFile(ExtractFilePath(ParamStr(0)+ '\Levels\Level1.Gls');

2- you must reDefine some Parameters after calling ..:. (( GLNavigators for example)) :
Like This :
GLNavigator1.MovingObject:=actor;

my be there are some other things ......
but at any rate this is a code i wrote .. and it is working correctly :


if IsKeyDown('s') then begin
GLScene1.LoadFromFile(ExtractFilePath(ParamStr(0)) +'\Levels\Level1.Gls');
GLNavigator1.MovingObject:=actor;
GLNavigator2.MovingObject:=Actorvert;
end;



God Luck.


.

Bylkki
01-11-2003, 07:29 PM
A bit of an improvement. Just downloaded the newest CVS-version of glscene and now it loads my scene well without errors but...
The problem now is that glscene doesn't referr to my newly loaded objects. It loads the scene but all the positions I have set in code wont work. For example I have a hudtext and in code i set its position to
hudtext.position.y := 5;
Now when i load the scene it doesn't set the position. :cry:
I tried to do like in the demo at caperaven.co.za
hudtext := glscene1.findsceneobject('hudtext');
If i do that the code wont compile and it says: " incompatible types: TGLHUDText and TGLBaseSceneObject "
How can they be incompatible? :x

Could someone help me?

Thanks in advance.

orwa
02-11-2003, 06:09 PM
where you put the position code ... ?

if the code is in (Form create) ,
simply separate the position code Lines on a new procedure .
and recall the procedure after loading the new scene .
i think that will be usefull .

Bylkki
03-11-2003, 05:43 AM
recall the procedure after loading the new scene .

No luck. I tried that too but it just wont work. :(

The actors wont load even if I load them after the scene loading.

orwa
05-11-2003, 11:31 AM
hi
this code from my game and it work so good
try some think like it >> it must work ?


// we also call this procedure on form create
////////////////////////
procedure Tform1.loadsceneactors;
begin
Actor1.LoadFromFile(exepath+'\actor\gun.md2');
Actor1.Material.Texture.Image.LoadFromFile(exepath +'\Actor\gun.jpg');
Actor1.Scale.SetVector(0.01, 0.02, 0.02, 0);


Actor2.LoadFromFile(exepath+'\actor\other\Misdun.M D2');
Actor2.Material.Texture.Image.LoadFromFile(exepath +'\Actor\other\Misdun.jpg');
Actor2.Scale.SetVector(0.06, 0.06, 0.06, 0);

Actor3.LoadFromFile(exepath+'\actor\other\Mrbat.MD 2');
Actor3.Material.Texture.Image.LoadFromFile(exepath +'\Actor\other\Mrbat.jpg');
Actor3.Scale.SetVector(0.06, 0.06, 0.06, 0);

Actor4.LoadFromFile(exepath+'\actor\other\sold.MD2 ');
Actor4.Material.Texture.Image.LoadFromFile(exepath +'\Actor\other\sold.jpg');
Actor4.Scale.SetVector(0.06, 0.06, 0.06, 0);

Actor5.LoadFromFile(exepath+'\actor\other\sold.md2 ');
Actor5.Material.Texture.Image.LoadFromFile(exepath +'\Actor\other\sold.jpg');
Actor5.Scale.SetVector(0.06, 0.06, 0.06, 0);

end;
// ////////////////////////////////////////
///////////////////////////////////////////
//////////////////////////////////////////
// the load scene procedure

if IsKeyDown(VK_F5) then begin
GLScene1.LoadFromFile(exepath+'\levels\level1.gls' );
GLNavigator1.MovingObject:=actorcube;
GLNavigator2.MovingObject:=vertactorcube;
playsound('back.wav',actor,2);
GLSMBASS.Listener:=GLCamera1;
loadsceneactors;
end;

Bylkki
05-11-2003, 05:22 PM
Yeah! got it working :D . Thanks orwa. I tried again to load and set everything again and it worked. I wonder why it didn't work before :?

BTW: If you want to check what the game looks like then heres a couple of pictures.
ingame:
http://www.bylkkisoft.vze.com/images/game/leizoor.jpg
Gui:
http://www.bylkkisoft.vze.com/images/game/ingamegui.jpg
config window:
http://www.bylkkisoft.vze.com/images/game/leizconfig.jpg

orwa
06-11-2003, 06:27 PM
Great work ...[/img]

Bylkki
07-11-2003, 05:19 PM
Having minor problems, again. Now the scene loads but the Gui isn't working correctly. You can drag the gui around but the buttons dont react. What i mean that the buttons dont have their events anymore. How can I assign them again?