Jump to content

Problems loading scenes..


Carve
 Share

Recommended Posts

I can load the demo scene "tunnels" just fine, but when trying to load any of the other scenes it seems to just stay black?

 

I have tried using different camera + player positions, and everything, the only one that I can get working is the tunnels.sbx

 

I renamed this to testScene.sbx and it still works fine, creating a new scene, then adding a 128x128 or w/e size terrain, painting the terrain, adding a camera, and light.. then saving the scene as testSceneTwo.sbx ..

 

There is nothing in the logs to suggest anything went wrong, and it acts as if it's loaded everything correctly.

 

Code below:

#include <Main.h>

int WINAPI WinMain( HINSTANCE hInstance,
			   HINSTANCE hPrevInstance,
			   LPSTR lpCmdLine,
			   int nShowCmd ) 
{
Initialize() ;
RegisterAbstractPath("C:/Leadwerks");
SetAppTitle( "Test FPS" );
Graphics( 1024, 768 );
AFilter();
TFilter();

mWorld = CreateWorld();
if (!mWorld) {
	MessageBoxA(0,"Error","Failed to create mWorld.",0);
	return Terminate();
}

mBuffer = CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);

// Setup Cameras
mCamera = CreateCamera();
PositionEntity(mCamera, Vec3(-3, 2, -18));

Collisions(1,2,true);

//	mMiniMapCam = CreateCamera();

// Load Sandbox Scene
mScene = LoadScene("abstract::testScene.sbx");
MessageBoxA(0,"Loaded scene..","",0);
ProcessScene(mScene);

// Setup the spectator (player)
mPlayer = CreateController(1.8,0.4,0.5,45.01);
EntityType(mPlayer, 1);
SetBodyMass(mPlayer, 1);
PositionEntity(mPlayer, Vec3(-3, 2, -18));

float move=0.0;
float strafe=0.0;
TVec3 camrotation=Vec3(0);
float mx=0;
float my=0;

// Setup the mouse
HideMouse();
MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2);

//	mMiniMap.CreateMinimap(128); // Create the Minimap

// ** Game loop ***********************************************
while( !KeyHit() && !AppTerminate() )
{
	if( !AppSuspended() ) // We are not in focus!
	{
		// camera looking
		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(mCamera, camrotation);

		// player movement
		move=(KeyDown(KEY_W)-KeyDown(KEY_S))*2.0;
		strafe=(KeyDown(KEY_D)-KeyDown(KEY_A))*2.0;

		// player jump
		float jump=0.0;
		if (KeyHit(KEY_SPACE)) {
			if (!ControllerAirborne(mPlayer)) {
				jump=4.0;
			}
		}

		// player run
		if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) {
			if (!ControllerAirborne(mPlayer)) {
				move*=2.0;
				strafe*=2.0;
			}
		}

		// Set controller input
		UpdateController(mPlayer, camrotation.Y, move, strafe, jump);

		// Update timing and mWorld
		UpdateAppTime();
		UpdateWorld(AppSpeed()) ;

		// Position the camera
		TVec3 playerpos = EntityPosition(mPlayer);
		TVec3 camerapos = EntityPosition(mCamera);
		camerapos.Y = Curve(playerpos.Y+1.75*0.5, camerapos.Y,2.0);
		camerapos = Vec3(playerpos.X, camerapos.Y, playerpos.Z);
		PositionEntity(mCamera, camerapos);

		// Render Main
		SetBuffer(mBuffer);
		RenderWorld();

		// Render lightning
		SetBuffer(BackBuffer());
		RenderLights(mBuffer);

		// Render Minimap
		//mMiniMap.Update(mMiniMapCam); // Update the Minimap

		// Send to screen
		Flip(0) ;
	}
}

// Done
return Terminate() ;
}

 

Thanks ahead of time!

Link to comment
Share on other sites

Instead of hardcoding the player position in your code, you should find a player entity from the map and position your player there.

Basically FindChild(scene,"playerstart"); is enough.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Instead of hardcoding the player position in your code, you should find a player entity from the map and position your player there.

Basically FindChild(scene,"playerstart"); is enough.

 

I've tried what you suggested, added a playerstart to the scene, and then use the position of it.

 

The test scene I made now loads, but I can only see the Firepit, no textures for the ground and if i attempt to move I fall.

Why would the ground be black?

Link to comment
Share on other sites

Your picture of the "in editor" view shows your player start ... the blue icon? if thats it then why is your in app picture showing what it does? are you sure your controller is being placed at the player start position? it does not look like it and given the view of the in app shot are you sure your controlloer is not below the terrain? are you still using the same code as posted or have you changed it?

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

The FPS display in the screenshot says that you are using Framework also. So you are rendering the scene twice, and your own rendering fails because Framework has already rendered it.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Your picture of the "in editor" view shows your player start ... the blue icon? if thats it then why is your in app picture showing what it does? are you sure your controller is being placed at the player start position? it does not look like it and given the view of the in app shot are you sure your controlloer is not below the terrain? are you still using the same code as posted or have you changed it?

 

I have the code for the PlayerStart portion, but I am using hardcoded variables for the time being

 

 

The FPS display in the screenshot says that you are using Framework also. So you are rendering the scene twice, and your own rendering fails because Framework has already rendered it.

 

Could you explain further?

 

New Code (now using Gamelib)

#include <Main.h>

int main()
{
   if (!Initialize())
       return 1;

   mGame.Initialize(1024, 768, 0, 0, 0);
   mScene.Initialize();

   SetAppTitle("FPS v0.0.1 - using gamelib v" gamelibver);
   RegisterAbstractPath("C:/Leadwerks");

   mBuffer = CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);

   // Setup Cameras
   if (mCamera != NULL)
   {
       mCamera = mGame.scene.cam;
   }
   else
   {
       mCamera = CreateCamera();
   }

   PositionEntity(mCamera, Vec3(-3, 2, -18));

//    mMiniMapCam = CreateCamera();

   // Load Sandbox Scene
   mScene.LoadMap("abstract::testMap.sbx");
   AppLog("Loaded scene..");

   // Setup the mouse
   HideMouse();
   MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2);

   //mMiniMap.CreateMinimap(128); // Create the Minimap

   // ** Game loop ***********************************************
   while( !KeyHit() && !AppTerminate() )
   {
       if( !AppSuspended() ) // We are not in focus!
       {
           mGame.scene.Update(); // Update

           mGame.scene.Render(); // Render

           // Rendering of the 2D stuff
           mGame.DrawCrosshair(GraphicsWidth() / 2, GraphicsHeight() / 2);
           DrawText(0, 0, "FPS : %.3f", UPS());
           DrawText(0,15, "Tris: %d", TrisRendered());

           // Render Minimap
           //mMiniMap.Update(mMiniMapCam); // Update the Minimap

           // Send to screen
           Flip(0);
       }
   }

   // Done
   return Terminate();
}

Link to comment
Share on other sites

You don't need mScene, as it's already part of mGame. And you don't need mBuffer either.

 

I dropped those already, and cleaned the code up more. I removed mBuffer and mScene.

 

also I removed the DrawText for FPS, and it removes the overlay for FPS (You referred to it as another render) - So now it shows the FPS and Tris correctly.

 

Still the same issue though.. the terrain and everything is black, this is never ending!

Link to comment
Share on other sites

well at least try changing the positon ...

 

PositionEntity(mCamera, Vec3(-3, Y, -18));

 

make Y larger than 2, say 50 ... you can pan the camera I take it?

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Does any folder besides the Scripts folder (and the dll's / paks (shaders) obviously) need to be in the application.exe's ROOT folder as well?

 

Like Models / Materials, should they be copied over as well, or shouldn't the abstract path to c:/leadwerks take care of that?

Link to comment
Share on other sites

The Scripts folder needs only to be in the current working dir, the dlls need to be in the exe dir or in the path, shaders.pak and other asset folders needs to be in the abstract path.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

The Scripts folder needs only to be in the current working dir, the dlls need to be in the exe dir or in the path, shaders.pak and other asset folders needs to be in the abstract path.

 

That's how it is setup, and I still get none of the Terrain loading, this is quite strange..

 

I'm using 2.4, would that matter?

Link to comment
Share on other sites

Editor doesn't use engine.dll, although it uses the same engine code. Maybe you should post a demo of your problem.

 

Here ya go, I didn't use anything but what came with LW SDK (2.4.0).

 

- Put the FPS.zip contents in your Leadwerks SDK root folder (you have the .dll's i'm sure, so dont write over!)

 

I attached the testMap as well - it needs to go in /Maps

 

Thanks again Lumooja

testMap.zip

Link to comment
Share on other sites

Somehow you managed to upload all the files which you don't need to upload and forgot the files which you should upload, like the exe, sln, suo, vcproj, cpp. The exe alone would be enough, since then I can see if it works for me.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

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