Horde3D
http://horde3d.org/forums/

Problems with the Tutorial
http://horde3d.org/forums/viewtopic.php?f=2&t=1353
Page 1 of 2

Author:  jamesl22 [ 11.01.2011, 18:46 ]
Post subject:  Problems with the Tutorial

Hi,

I'm trying to make a game using Horde3D. I am trying to follow the tutorial. I am using code::blocks on windows with MinGW and I am using the prebuilt binaries. Here is the code:

Code:
#include <iostream>

#include <Horde3D.h>
#include <Horde3DUtils.h>

using namespace std;

H3DNode model = 0, cam = 0;

void initGame( int winWidth, int winHeight )
{
    // Initialize engine
    h3dInit();
    h3dSetupViewport( 0, 0, winWidth, winHeight, true );
   
    // Add pipeline resource
    H3DRes pipeRes = h3dAddResource( H3DResTypes::Pipeline, "standard.pipeline.xml", 0 );
    // Add model resource
    H3DRes modelRes = h3dAddResource( H3DResTypes::SceneGraph, "character.scene.xml", 0 );
    // Add animation resource
    H3DRes animRes = h3dAddResource( H3DResTypes::Animation, "walk.anim.xml", 0 );
    // Load added resources
    h3dutLoadResourcesFromDisk( "" );
   
    // Add model to scene
    model = h3dAddNodes( H3DRootNode, modelRes );
    // Apply animation
    h3dSetupModelAnimStage( model, 0, animRes, 0, "", false );
   
    // Add light source
    H3DNode light = h3dAddLightNode( H3DRootNode, "Light1", 0, "LIGHTING", "SHADOWMAP" );
    // Set light position and radius
    h3dSetNodeTransform( light, 0, 20, 0, 0, 0, 0, 1, 1, 1 );
    h3dSetNodeParamF( light, H3DLight::RadiusF, 0, 50.0f );
   
    // Add camera
    H3DNode cam = h3dAddCameraNode( H3DRootNode, "Camera", pipeRes );
}

void gameLoop( float fps )
{
    static float t = 0;

    // Increase animation time
    t = t + 10.0f * (1 / fps);

    // Play animation
    h3dSetModelAnimParams( model, 0, t, 1.0f );

    // Set new model position
    h3dSetNodeTransform( model, t * 10, 0, 0,  // Translation
                         0, 0, 0,              // Rotation
                         1, 1, 1 );            // Scale

    // Render scene
    h3dRender( cam );

    // Finish rendering of frame
    h3dFinalizeFrame();
}


void releaseGame()
{
    // Release engine
    h3dRelease();
}

int main()
{
    cout<<"Starting Felix!\n";
    initGame(800,600);
    gameLoop(24);
    cin.get();
    releaseGame();

    return 0;
}


This however, build correctly but segfaults during runtime. GDB backtrace:
Code:
Program received signal SIGSEGV, Segmentation fault.
In h3dHasEmitterFinished () (D:\work\felix\Felix\bin\Debug\Horde3D.dll)


Regards,

James

Author:  phoenix64 [ 11.01.2011, 21:41 ]
Post subject:  Re: Problems with the Tutorial

I think the first thing you should do would be to compile with debug infos and post a full stack trace with line numbers.

This time the solution is simple though: You are not initializing any OpenGL context/render window before using horde3d. Horde3D does not create its own window!

Author:  jamesl22 [ 11.01.2011, 22:44 ]
Post subject:  Re: Problems with the Tutorial

Can you give an example of how to do that?

Thanks,

James

Author:  phoenix64 [ 11.01.2011, 23:08 ]
Post subject:  Re: Problems with the Tutorial

The tutorials all do that, look at their glfw* function calls.

You can use any other OpenGL window toolkit though - glfw, sdl, sfml, Qt, gtk+, whatever you want.

Author:  jamesl22 [ 13.01.2011, 22:33 ]
Post subject:  Re: Problems with the Tutorial

Ok,

Where does Horde3D search for the resources? I have them currently in the same directory as the executable file but it complains in the log file that it cannot find them.

Thanks,
James

Author:  Volker [ 14.01.2011, 15:14 ]
Post subject:  Re: Problems with the Tutorial

Do you load them with h3dutLoadResourcesFromDisk? If yes, you can specify the content directory there.

Author:  jamesl22 [ 14.01.2011, 18:26 ]
Post subject:  Re: Problems with the Tutorial

How can this be formed? Is it like "./"?

Author:  DarkAngel [ 18.01.2011, 05:08 ]
Post subject:  Re: Problems with the Tutorial

jamesl22 wrote:
Where does Horde3D search for the resources? I have them currently in the same directory as the executable file but it complains in the log file that it cannot find them.
What is the working directory when you run your executable?

Author:  johannes [ 22.01.2011, 17:49 ]
Post subject:  Re: Problems with the Tutorial

DarkAngel wrote:
jamesl22 wrote:
Where does Horde3D search for the resources? I have them currently in the same directory as the executable file but it complains in the log file that it cannot find them.
What is the working directory when you run your executable?


Sadly that depends on your OS and compiler. In case of Visual Studio on Windows, if you start your project with the debugger, the working directory is "YourProjectDirectory\Debug\Bin" and you have to place your files there or alter some variable in the compilation options.

The proper cross-platform way to handle this would be to check argv[0] in your main() when starting your project. But then again what you get from that variable is not standardized in any way and depends on the OS. Check the procedures that parse argv[0] in the Horde3D examples, they seem to work pretty well for me.

Author:  jamesl22 [ 23.01.2011, 13:16 ]
Post subject:  Re: Problems with the Tutorial

Ok, I've gotten the program to find the resources but I cant seem to get it to render anything. I just get a black window. I have posted the source code.

\James

Attachments:
Felix.zip [4.09 KiB]
Downloaded 817 times

Author:  jamesl22 [ 27.01.2011, 20:29 ]
Post subject:  Re: Problems with the Tutorial

Anyone?

Author:  Volker [ 28.01.2011, 00:22 ]
Post subject:  Re: Problems with the Tutorial

I would suggest to start with the samples. If they are working you can adjust them step by step to get your things running. Another thing that would often help if you have problems with rendering anything, is to have a look at the log output. Check the samples to find out how you can output the log into a HTML file.

Author:  jamesl22 [ 28.01.2011, 17:58 ]
Post subject:  Re: Problems with the Tutorial

The samples don't work for me as I can't find the resources mentioned it them.

Author:  Volker [ 28.01.2011, 21:14 ]
Post subject:  Re: Problems with the Tutorial

Are you able to use a debugger, to check what's the path that is used when loading the resources, and then compare it to the working directory you are using? Maybe we're then able to fix the problem.

Author:  jamesl22 [ 28.01.2011, 22:29 ]
Post subject:  Re: Problems with the Tutorial

The program finds the resources folder but the resources metioned in the tutorial are not present in the Horde3D SDK download.

Page 1 of 2 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/