Jump to content

A Stand-alone basic application without Qt/MFC


photo

Recommended Posts

Hello Everyone,

 

Happy New Year!

 

After the holidays and few days of rest, I'm back and started the evaluation of Unigine binary SDK since last week.

I read through the entire documentation and also looked at the samples in source\samples\App but frankly I'm still terribly confused.

Would greatly appreciate if someone could help me with the following:

 

1. What is the right way to build a simple standalone application with Unigine? It seems most examples in the documentation refer to the evaluation kit, so you are always ending up running the provided app inside world-builder. Even if I do not use any direct C++ API access and use only Unigine Script, I still need to know how to open the basic application window and initialize the engine etc. right? (either openGL or DX9 window but without Qt/MFC etc.)

 

 

2. Is there ANY example anywhere of writing a small basic but fully working stand-alone application? For instance, which opens a Unigine viewport and loads and displays a single mesh? If there is, I have not found it, please point me to it. Perhaps a Unigine-based app would have quite a different structure than the engines I have used in the past (CrystalSpace3d, Irrlicht3d, Torque3d) and that is confusing me, so just to be sure, I write here a code snippet which is opening a window using Irrlicht3d engine and loading mesh. What I'm looking for is an example which does the same thing but using Unigine engine.

 


//include header
#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

//This is the main method.  

int main()
{


//Create irrlicht device which can be D3D8, D3D9, or OpenGL.

       IrrlichtDevice *device =
               createDevice( video::EDT_D3D9, dimension2d<u32>(640, 480), 16,
                       false, false, false, 0);

       if (!device)
               return 1;

//Set the caption of the window to some nice text.  

       device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

//Get a pointer to the VideoDriver, the SceneManager and the graphical user interface environment. 
       IVideoDriver* driver = device->getVideoDriver();
       ISceneManager* smgr = device->getSceneManager();
       IGUIEnvironment* guienv = device->getGUIEnvironment();

//Add a hello world label to the window, using the GUI environment.  

       guienv->addStaticText(L"Hello World! This is the Irrlicht D3D9 renderer!",
               rect<s32>(10,10,260,22), true);

//To show something, load a Quake 2 model and display it.  

       IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
       if (!mesh)
       {
               device->drop();
               return 1;
       }
       IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

//Change its material, set animation and since there are no lights turn lighting to false.  

       if (node)
       {
               node->setMaterialFlag(EMF_LIGHTING, false);
               node->setMD2Animation(scene::EMAT_STAND);
               node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
       }

//To look at the mesh, place a camera into 3d space at the position (0, 30, -40). The camera looks from there to (0,5,0), which is approximately the place where the md2 model is. 

       smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

/Run the main render loop.  

       while(device->run())
       {


               driver->beginScene(true, true, SColor(255,100,101,140));

               smgr->drawAll();
               guienv->drawAll();

               driver->endScene();
       }

//Delete the Irrlicht Device created before with createDevice().  

       device->drop();

       return 0;
}

 

That's it. Here is a complete stand-alone application which opens an Irrlicht DirectX9 window, loads an md3 mesh and displays it.

Can anyone please show me how to achieve the same with Unigine? (and ideally, add such example to documentation)

 

Many thanks in advance!

 

/regards

Link to comment

Thank You binstream and frustum.

 

The sample application you provided makes many things clear, however, I have few more questions.

 

1. The application runs in openGL mode by default. How would you run it in DirectX mode? Neither in sample.cpp nor in main.cpp can I find any method which is telling the app in which mode to run.

 

2. Sample.cpp sets up a default camera with code "PlayerSpectator player = new PlayerSpectator();" and later you define the znear, zfar, position, rotation etc. The PlayerSpectator class provides most all necessary functions, but how do you manipulate "gravity"? i.e. if your camera must have collision detection and must stay on the ground.

 

3. Do I understand correctly that to create a 3rdPerson camera, I should use the provided high-level scripts in data/scripts/character ? Is there an example somewhere how to use it?

 

4. Insted of loading a single mesh, if I wanted to load a whole level, which includes dozens or maybe hundreds of meshes, should I still load each mesh manually one by one? or is it enough to just drop the whole level folder under the "data" folder (including .world and .cpp files) and individual meshes/nodes inside the level can be later accessed from the application by name? Again, could you kindly point me to some example of doing this?

 

5. There is an example provided which shows how to integrate Unigine into a Qt-based aplication. However, the provided example uses Qt's openGL widget. Could you gents provide an example of creating a custom Qt widget which opens a Unigine window in DirectX mode?

EDIT: To be fair, this is not really urgent and can be done after/if we have bought a license.

 

Finally, I appologize in advance if some of my questions appear too basic/elementary in nature. It is true I'm having a rather hard time just grasping the basics of working with Unigine, though most of the advanced stuff seems pretty clear to me.

 

Over and again, I get the feeling something is terribly missing from the documentation. If you could add a set of start-up "tutorials" focused to application development (just like you have a set of beginner tutorials showing how to use the Evaluation kit) it would perhaps save a lot of time for many evaluators and reduce the burden on you to answer repetetively same basic questions. Just a thought! =)

 

Thanks in advance and best regards!

Link to comment
×
×
  • Create New...