Page 13 of 19

Posted: Wed Sep 15, 2004 2:09 am
by ZDimitor
Here you go!
It take not more than a half hour, and here is my new implementation of MeshLoader (Irr.0.6), example and test scene (ss you have seen).

http://zdimitor.nm.ru/MY3DExample.zip

Have fun :lol: .....

Posted: Wed Sep 15, 2004 2:17 am
by afecelis
whoa, great!

I got your source to compile ok. I also created my own 3d format. Your plugin exports ok, but I couldn't use the loader for Irrlicht. Let's see if your example makes things easier!!

many thnx for your help!

Posted: Wed Sep 15, 2004 2:24 am
by afecelis
Just ran your example, amazing!!! Beautigul lightmaps, congrats for the job.

I'll use your bin version of the dle to get things running and try to load my own model with lightmaps.

ps. Have you tried collision with your model format?

cheers, and thnx!

Posted: Wed Sep 15, 2004 2:38 am
by ZDimitor
Collision works fine (just like with Q3 BSP). I have not problems with it.

But as i told many things has to be done, to be able export from MAX (lights, transparent materials, animation!!!! e.t.c).

Its possible create in max transparent stuff (like portals, flame or other) an then get them into Irrlicht.

Posted: Wed Sep 15, 2004 2:44 am
by etcaptor
Great!!!
keep your good working.

Posted: Wed Sep 15, 2004 2:51 am
by afecelis
works like a charm. Even with Irr0.7 and VC7. I got a question though, what's the Ilogger for?

I made some changes to your main.cpp file:

Code: Select all

        #include <irrlicht.h>
	#include <stdio.h>
	#include <windows.h> 
	#include "CMY3DMeshFileLoader.h"	
	
	using namespace irr;
	using namespace irr;	
	using namespace core;
	using namespace scene;
	using namespace video;
	using namespace io;
	using namespace gui;
	
	#pragma comment(lib, "Irrlicht.lib")
	
	ILogger* logger=NULL;

//-----------------------------------------------------------------------------------------------//	
	int main()
	{
	    IrrlichtDevice *device =
	   createDevice(video::EDT_DIRECTX9, core::dimension2d<s32>(640, 480),false,false,false,0);
	
	    video::IVideoDriver* driver = device->getVideoDriver();
	    scene::ISceneManager* smgr = device->getSceneManager();
	    io::IFileSystem *fs = device->getFileSystem();
	    logger = device->getLogger();

//-----------------------------------------------------------------------------------------------//	
    scene::IMeshLoader *my3dloader = new scene::CMY3DMeshFileLoader(fs,driver);
    smgr->addExternalMeshLoader(my3dloader);

    scene::IAnimatedMesh* mesh = smgr->getMesh("test/test.my3d");
    scene::ISceneNode* node = 0;

    if (mesh)
        node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
//-----------------------------------------------------------------------------------------------//	
	//wasd navigation
	SKeyMap keyMap[8];

	keyMap[1].Action = EKA_MOVE_FORWARD;
	keyMap[1].KeyCode = KEY_KEY_W;

	keyMap[3].Action = EKA_MOVE_BACKWARD;
	keyMap[3].KeyCode = KEY_KEY_S;

	keyMap[5].Action = EKA_STRAFE_LEFT;
	keyMap[5].KeyCode = KEY_KEY_A;

	keyMap[7].Action = EKA_STRAFE_RIGHT;
	keyMap[7].KeyCode = KEY_KEY_D;

//-----------------------------------------------------------------------------------------------//    
    scene::ICameraSceneNode* camera = 0; 
    camera = smgr->addCameraSceneNodeFPS(0,80.0f,300.0f,-1, keyMap, 8); //1st value= obligatory 0-2nd value= mouse sensitivity-3rd value handles cam speed
	 camera->setPosition(core::vector3df(-150,70,-70)); //1st=pos in x-2nd value= spawn height-3rd=pos in y
	 camera->setFarValue (  50000.0f  ) ; //sets the distance for the clipping plane, the bigger the farther
	 camera->setFOV(1.1f); // a value of 0.5 makes it look alienish
	 camera->setTarget( core::vector3df(-150,70,0)); //target camera position-3rd value negative =90, positive=0 -1st value (-) rotates camera
	 camera->setRotation(core::vector3df(0,90,0)); //rotate the camera x,y,z degrees
//-----------------------------------------------------------------------------------------------//
    device->getCursorControl()->setVisible(false);
//-----------------------------------------------------------------------------------------------//	
    int lastFPS = -1;

    while(device->run())
    {
        driver->beginScene(true, true, video::SColor(0,0,0,0));
        smgr->drawAll();
        driver->endScene();

        int fps = driver->getFPS();

        if (lastFPS != fps)
        {
            wchar_t tmp[1024];
            swprintf(tmp, 1024, L"MY3D Mesh Loader Example - Irrlicht Engine v.0.7 (fps:%d) Triangles:%d", 
                fps, driver->getPrimitiveCountDrawn());

            device->setWindowCaption(tmp);
            lastFPS = fps;
        }
    }
    device->drop();    
    return 0;
}

better said, I added some stuff (the usual stuff I use) and separated the code into parts.

great work. This option as a lightmapper was completely unexpected! Tomorrow I'll have fun with this!!!

cheers!
ps. I created it as a new project in Relo and linked everything to the 0.7 source and evrything is working fine. Very good job.

Posted: Wed Sep 15, 2004 3:00 am
by ZDimitor
One last thing:

MAX creating cool lighting maps, but..... not all shadows info included in it (you'll see that some shadows messed up).
MAX creating cool shadowmap textures, but.... not all lighting info included in it.

What we have to do in that case???

Simple!!!!

In MAX/images after rendering into (lightingmaps and shadowmaps) textures we have *LightingMap.tga and *ShadowMap.tga.

And to get best quality lightingmaps we have to do this:

*LightingMap.tga + *ShadowMap.tga -> *LightingMap.tga( super quality lighting maps with cool shadows)

You can do this in Photoshop,
or write you own convertion utility, which allowed you merge two images into one.

The formula you needed for that:
(R1,G1,B1,A1) - pixel color in the 1st map (lightings);
(R2,G2,B2,A2) - pixel color in the 2st map (shadows);
(Rc, Gc, Bc, Ac) - - pixel color in the complex map (lighting+shadows);

Rc = R1*R2/255; Gc = G1*G2/255; Bc = B1*B2/255; Ac = A1*A2/255;

Its a last step :wink:

--------------------------------------------------------------------------------
@LordTrancos: Why did you sayd that it will be last version of LMTools???

Posted: Wed Sep 15, 2004 3:03 am
by afecelis
oh yes, and the obligatory screenie!

Image

nice nice.

Posted: Wed Sep 15, 2004 3:21 am
by ZDimitor
afecelis wrote:.... I got a question thought, what's the Ilogger for?
Its needed in file CMY3DMeshFileLoader.cpp to get access to the console logging.

Posted: Wed Sep 15, 2004 3:28 am
by afecelis
Thnx for the explanation. Please keep us informed of any updates.

you just gave the Irrlicht community a great tool.

Posted: Wed Sep 15, 2004 6:33 am
by Captain_Kill
ZDimitor: Awesome work :D I'm no artist but I can appreciate the programming :lol: I got a potentially better solution to that problem you mentioned... Instead of combining 2 images, why not just load them both? ;) It's definatly possible and would be a cool addition to Irrlicht. Actually... I think Irrlicht can already load multiple images per mesh... Isn't that done in the SpecialFX demo?

Posted: Wed Sep 15, 2004 6:40 am
by ZDimitor
More textures - more time to load them.
And explain me how you be able to render 3rd texture unit?
1st - main texture;
2nd - lightings;
3rd - shadows;

Posted: Wed Sep 15, 2004 8:21 am
by vermeer
looks like merging em in adobe ps or gimp would rather easy, if is actually possible is seconds for any artist....


congrats

Posted: Wed Sep 15, 2004 1:31 pm
by Acki
ZDimitor wrote:Here you go!
It take not more than a half hour, and here is my new implementation of MeshLoader (Irr.0.6), example and test scene (ss you have seen).

http://zdimitor.nm.ru/MY3DExample.zip

Have fun :lol: .....
Well, I'm very interested in your example, but this link doesn't seem to work (for me)... :cry:

Posted: Wed Sep 15, 2004 2:15 pm
by ZDimitor
@Acki: Give me you mail, i'll sent it you tomorrow.