Horde3D

Next-Generation Graphics Engine
It is currently 16.06.2024, 09:38

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 15.11.2008, 12:40 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
Would someone be so kind as to write the Horde 'Hello, world' example?
Thanks.


Top
 Profile  
Reply with quote  
PostPosted: 15.11.2008, 13:59 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
We already have a Hello World Tutorial.


Top
 Profile  
Reply with quote  
PostPosted: 15.11.2008, 15:22 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
I asked for a box from Blender, because it does not work right out of the box even with 'working' Blender exporter (yes, it's not displayed even with wireframe turned on). That would be real "Hello, world". You don't write fancy Output class in C++ for a "Hello, world", neither do you use some pre-built (by someone somehow) skeletal model with animation. Also, a "Hello, world" is a complete application which can be built with no problems (yes, all the #includes and all the stuff).


Top
 Profile  
Reply with quote  
PostPosted: 15.11.2008, 19:10 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
kornerr wrote:
I asked for a box from Blender, because it does not work right out of the box even with 'working' Blender exporter (yes, it's not displayed even with wireframe turned on).
Most likely you have a material problem, check the log file to see if any materials failed to load - the blender exporter sometimes sets up the paths wrong.

Quote:
Also, a "Hello, world" is a complete application which can be built with no problems (yes, all the #includes and all the stuff).
That is a little bit problematic for Horde, as it isn't a standalone framework. One of the main problems is that Horde can be integrated with a variety of platform/windowing frameworks, there are comprehensive samples for several popular frameworks on the wiki page, and the samples demonstrate using GLFW.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 03:36 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
Yes, I've checked logs, no errors. loadResourcesFromDisk returns 1. And I repeat nothing is displayed in wireframe. I don't care be it GLFW or SDL. Both work fine with premade models (yes, platform.scene.xml from Chicago sample works fine, but not my box from Blender).
All I ask for is what you can do in 5 minutes. Is this hard?


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 13:20 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Well I'm always glad to help if asked in such a kindly way! :twisted:

I added additional information to the Blender export page in the wiki and tested the import of the exported cube using the editor. It
was no real problem. You may try to create your scene within the editor. If the scene works fine there, you should be able to load the created .scene.xml file in your application. An additional tutorial how to load a scene created in the editor might follow, but remember that we don't get paid for developing Horde3D and both have full-time jobs that don't allow us to offer support on commercial level.

You could start by posting your attempt of loading your model, perhaps we can then fix the problems together and create a new Hello World wiki article from that.


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 14:18 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
main.cpp
Code:
#include <horde3d/Horde3D.h>
#include <horde3d/Horde3DUtils.h>
#include <SDL.h>
#include <iostream>
#include <cmath>
using namespace std;
using namespace Horde3D;
using namespace Horde3DUtils;

ResHandle model = 0,
          cam = 0;

float rotX = -45,
      rotY = 0,
      posX = 0,
      posY = 40,
      posZ = -40;

inline float deg2Rad(float f) {
    return f * (3.1415926f / 180.0f);
}

int main() {
    SDL_Init(SDL_INIT_VIDEO);
    SDL_WM_SetCaption("Horde3D + SDL", 0);
    int w = 800,
        h = 600;
    SDL_SetVideoMode(w, h, 32, SDL_OPENGL);
    init();
    resize(0, 0, w, h);
    ResHandle pipeRes = addResource(ResourceTypes::Pipeline,
            "forward.pipeline.xml", 0);
    ResHandle modelRes = addResource(ResourceTypes::SceneGraph,
            "untitled.scene.xml", 0);
    ResHandle logoMatRes = addResource(ResourceTypes::Material,
            "logo.material.xml", 0);
    setResourcePath (ResourceTypes::SceneGraph, "models");
    setResourcePath (ResourceTypes::Geometry, "models");
    setResourcePath (ResourceTypes::Animation, "models");
    setResourcePath (ResourceTypes::Material, "materials");
    setResourcePath (ResourceTypes::Code, "shaders");
    setResourcePath (ResourceTypes::Shader, "shaders");
    setResourcePath (ResourceTypes::Texture2D, "textures");
    setResourcePath (ResourceTypes::TextureCube, "textures");
    setResourcePath (ResourceTypes::Effect, "effects");
    setResourcePath (ResourceTypes::Pipeline, "pipelines");
    setOption( EngineOptions::LoadTextures, 1 );
    setOption( EngineOptions::TexCompression, 0 );
    setOption( EngineOptions::FastAnimation, 0 );
    setOption( EngineOptions::AnisotropyFactor, 8 );
    setOption( EngineOptions::ShadowMapSize, 2048 );
    setOption( EngineOptions::WireframeMode, 1);

    cout << "loaded all: " << loadResourcesFromDisk("data") << endl;
    model = addNodes(RootNode, modelRes);
    setNodeTransform(model, 0, 0, 0, 0, 0, 0, 1, 1, 1);
    if(!model)
        cout << "model creation failed\n";
    NodeHandle light = addLightNode(RootNode, "Light1", 0, "LIGHTING",
            "SHADOWMAP");
    setNodeTransform(light, 0, 40, 0, 0, 0, 0, 1, 1, 1);
    setNodeParami(light, LightNodeParams::ShadowMapCount, 3);
    cam = addCameraNode(RootNode, "Camera", pipeRes);
    setNodeTransform(cam, 0, 40, 0, 0, 0, 0, 1, 1, 1);
    cout << "cam setup: " << setupCameraView(cam, 45,
            static_cast<float>(w)/h, 0.1, 1000) << endl;
    //setNodeTransform(cam, 0, 20, -20, 0, 0, 0, 1, 1, 1);
    if(!cam)
        cout << "cam creation failed\n";
    bool running = true;
    SDL_Event event;
    SDL_ShowCursor(SDL_DISABLE);
    SDL_WM_GrabInput(SDL_GRAB_ON);
    setNodeTransform(cam, posX, posY, posZ, rotX, rotY, 0, 1, 1, 1);
    while(running) {
        bool posRotChanged = false;
        if(SDL_PollEvent(&event)) {
            if(event.type == SDL_KEYDOWN) {
                //cout << "keydown event caught\n";
                switch(event.key.keysym.sym) {
                    case SDLK_ESCAPE:
                        running = false;
                        break;
                    // Move forward
                    case SDLK_w:
                        posX -= sinf(deg2Rad(rotY)) * cosf(-deg2Rad(rotX));
                        posY -= sinf(-deg2Rad(rotX));
                        posZ -= cosf(deg2Rad(rotY)) * cosf(-deg2Rad(rotX));
                        posRotChanged = true;
                        break;
                    // Move backward
                    case SDLK_s:
                        posX += sinf(deg2Rad(rotY)) * cosf(-deg2Rad(rotX));
                        posY += sinf(-deg2Rad(rotX));
                        posZ += cosf(deg2Rad(rotY)) * cosf(-deg2Rad(rotX));
                        posRotChanged = true;
                        break;
                    // Strafe left
                    case SDLK_a:
                        posX += sinf(deg2Rad(rotY - 90));
                        posZ += cosf(deg2Rad(rotY - 90));
                        posRotChanged = true;
                        break;
                    // Strafe right
                    case SDLK_d:
                        posX += sinf(deg2Rad(rotY + 90));
                        posZ += cosf(deg2Rad(rotY + 90));
                        posRotChanged = true;
                        break;
                    default:
                        break;
                }
            }
            else if(event.type == SDL_MOUSEMOTION) {
                //cout << "mousemove event caught\n";
                rotY -= event.motion.xrel;
                rotX -= event.motion.yrel;
                posRotChanged = true;
            }
        }
        if(posRotChanged)
            setNodeTransform(cam, posX, posY, posZ, rotX, rotY, 0,
                    1, 1, 1);
        showOverlay(0.75f, 0, 0, 0, 1, 0, 1, 0,
                1, 0.2f, 1, 1, 0.75f, 0.2f, 0, 1,
                7, logoMatRes);
        render(cam);
        SDL_GL_SwapBuffers();
    }
    dumpMessages();
    release();
    SDL_Quit();

    return 0;
}

models/untitled.scene.xml
Code:
<Model name="untitled" geometry="untitled.geo">

   <Mesh name="Cube" material="untitled/Material.material.xml" batchStart="0" batchCount="36" vertRStart="0" vertREnd="23" />

materials/untitled/Material.material.xml
Code:
<Material>
   <Shader source="skinning.shader.xml" />

   <Uniform name="Materialcol" a="0.8" b="0.8" c="0.8" d="1.0" />
</Material>

XMLs created with Blender exporter.


Attachments:
File comment: models/untitled.geo
untitled.geo.zip [333 Bytes]
Downloaded 527 times
Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 16:16 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
kornerr wrote:
models/untitled.scene.xml
Code:
<Model name="untitled" geometry="untitled.geo">

   <Mesh name="Cube" material="untitled/Material.material.xml" batchStart="0" batchCount="36" vertRStart="0" vertREnd="23" />
It may just have been missed when you copy/pasted, but it appears that the model file is missing the closing </Model> tag.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 16:19 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
Yes, missed the tag.


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 23:36 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I've noticed, that you have a Materialcol uniform in your material file. I guess that's because you don't have any texture coordinates defined in your blender model. If you don't have a texture, you can't use the skinning shader. You may try the Materialcol.shader.xml in the Community SVN or create a blender model that uses UV texture mapping.


Top
 Profile  
Reply with quote  
PostPosted: 17.11.2008, 00:30 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
Thanks, the box is finally visible with the above shader. I wonder how 'wireframe' should be affected at all by shaders in the first place. I thought it would always display the box.


Top
 Profile  
Reply with quote  
PostPosted: 17.11.2008, 08:07 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
You have to differ between wireframe and debug mode. In the debug mode you should indeed see the box even if no shader is loaded. In wireframe mode you see the same scene as in normal mode, the only difference is that it is rendered in wireframe mode.


Top
 Profile  
Reply with quote  
PostPosted: 02.02.2009, 18:02 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
I've unwrapped a simple cube in blender 2.48a then textured it, but there isn't any textures in texture folder after exporting :?:


Top
 Profile  
Reply with quote  
PostPosted: 02.02.2009, 19:13 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Siavash wrote:
I've unwrapped a simple cube in blender 2.48a then textured it, but there isn't any textures in texture folder after exporting :?:
You have to export the textures separately - I don't think any of the exporters handle this for you.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 02.02.2009, 19:26 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
swiftcoder wrote:
Siavash wrote:
I've unwrapped a simple cube in blender 2.48a then textured it, but there isn't any textures in texture folder after exporting :?:
You have to export the textures separately - I don't think any of the exporters handle this for you.
Could you explain it a bit more, then how to export and assign textures to models ?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 45 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group