Dynamic 3D text

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mrAlmond
Posts: 15
Joined: Fri Nov 23, 2007 9:47 am

Dynamic 3D text

Post by mrAlmond »

Hi all,

I've searched in the forum about this issue but no results...
I need to put dynamic 3D text on a 3D panel...a sort of custom 3D window that shows text on it...
I've tried with ITextSceneNode but is not what I need...
Is there someone who could give me some hints?

Thank you!
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

I had this thing too, the only result I found was to make my text in some 3d modeling tool then load it as static mesh..

P.S:
If you're crazy enough you can make a static mesh of each letter 'a'-'z' and 'A'-'Z' then in irrlicht you can scale and rotate'em..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
mrAlmond
Posts: 15
Joined: Fri Nov 23, 2007 9:47 am

Post by mrAlmond »

I must admit that for a while I've thought to implement that "crazy" solution you suggested me...but I think it will be very hard to handle...
And what about using RTT?
My idea is to render dynamic text in an offscreen buffer (texture) that will be applied to the 3D face...do you think it's possible?

Is there someone who could explain me how to do this?
Searching on the net I've found some examples but none of them uses irrlicht...

Here is explained (more or less) what I want to do:
http://www.opengl.org/resources/code/sa ... ode74.html
mrAlmond
Posts: 15
Joined: Fri Nov 23, 2007 9:47 am

Post by mrAlmond »

Ok...this time I really need your "irrlicht guru" help...
I'm very near to obtain what I need...dynamic text rendered on a texture,

The solution for now is to render some text on a texture (using RTT) and then apply this texture to the mesh.

Sounds easy to do...but not for me! ;-)

This is what I'm doing now:

Code: Select all

    gui::IGUIFont* font = guienv->getFont("../../media/fonthaettenschweiler.bmp");

    scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/panel-061207-1.x");
        
    scene::ISceneNode* node = 0;
    node = smgr->addAnimatedMeshSceneNode(mesh);

    if (node)

    {
        node->setPosition(core::vector3df(-20,0,-20));

smgr->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.100f);

        node->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting
        node->setMaterialTexture(0, driver->getTexture("../../media/terrain-heightmap.bmp") );
		
        node->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);

    }

    video::ITexture* rt = 0;

    //scene::ICameraSceneNode* fixedCam = 0;

	

    if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET))

    {

        rt = driver->createRenderTargetTexture(core::dimension2d<s32>(256, 256));

        node->setMaterialTexture(0, rt); // set material of cube to render target



    }
    else
    {
        printf("RTT not supported!\n");
        device->closeDevice();
        return 0;
    }

    if (rt)

    {

  

        driver->setRenderTarget(rt, false, true, video::SColor(255, 50, 50, 50));     


        if (font)
        {
            font->draw(L"this is my first string",
                                  core::rect<s32>(130, 200, 300, 50), video::SColor(255, 255, 255, 255));

            font->draw(L"this is my second string",
                                  core::rect<s32>(130, 220, 300, 50), video::SColor(255, 255, 255, 255));

            font->draw(L"this is my third string",
                                  core::rect<s32>(130, 240, 300, 50), video::SColor(255, 255, 255, 255));
        }


        // draw whole scene into render buffer

        smgr->drawAll();                 



        // set back old render target

        driver->setRenderTarget(0);
    

}

    scene::ICameraSceneNode * cam = smgr->addCameraSceneNodeFPS(0, 100.0f, 50.0f);

    device->getCursorControl()->setVisible(false);


    while(device->run())
    {
        if (device->isWindowActive())

	{

            driver->beginScene(true, true, 0);
	

            // draw scene normally

            smgr->drawAll(); 

            guienv->drawAll();


            driver->endScene();

	}
    }


    if (rt)
        rt->drop(); // drop render target because we created if with a create() method



    device->drop(); // drop device


    return 0;

}
I hope to have posted all the right code...

I don't know if what I'm doing is good...I write text on screen using font->draw, I render it on the texture that is associated with my mesh and then I display it...

I used also a fixed camera to get the "screenshot" for the texture but I've seen that using 2D text a camera is not needed...

I've also set the second parameter of "setRenderTarget" to false so I can use a "background" texture for my strings...

The problem is that I really don't know how to fit this dynamic texture on my mesh.

This mesh is a sort of rounded 3D panel that should be used as a 3D window.
I've done it using blender.

Now I can see text on the mesh but is not centered and it seems to be rendered on each face...

Is there someone who could help me? Pleaaaaseeeee!!!
Post Reply