polygon font demo + 3d text demo

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
CoreDumped
Gremlin
Posts: 177
Joined: Sun Aug 05, 2007 3:55 pm
x 14

Re: polygon font demo + 3d text demo

Post by CoreDumped »

Nice. I've been working on mesh generation from point clouds recently. You might want to check out Constrained Delaunay Triangulation for generating a much cleaner mesh
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39

Re: polygon font demo + 3d text demo

Post by Beauty »

By random I discovered this interesting code.
To push it into the public, I suggest to create a wiki page for that.
Even if it contains just little information (e.g. link to here and download link), it would be much better than hidden in an old forum topic.
The wiki is an important place to figure out existing Ogre additions.
I would be happy to see a wiki page about this. :mrgreen:

... Ok, now it's a half (or full?) hour later.

I know most people are lazy ... ehm, busy.
So I myself created a wiki page:
http://www.ogre3d.org/tikiwiki/PolygonFont

Your task:
I only added links of the first posts.
There are further download links, which could contain newer code.
Please go through this whole post and make the further additions.
Start with this post, which contains links, which aren't added yet.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: polygon font demo + 3d text demo

Post by Assaf Raman »

Done.
Watch out for my OGRE related tweets here.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39

Re: polygon font demo + 3d text demo

Post by Beauty »

Strange - there is no change in the wiki page history.
But comparing the link URLs I recognised, that you updated the links of your forum post, instead of updating the wiki page. :lol:

Before your forum post updates, there were (at least) 6 different download links (bin + mesh + code, for 2D and 3D).
Now there are only 2 links.

Shall I replace all the old links in the wiki by the 2 new ones from here?
I suppose there is everything inside what is needed.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: polygon font demo + 3d text demo

Post by Assaf Raman »

Not sure, is there something missing in the two links?
Watch out for my OGRE related tweets here.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39

Re: polygon font demo + 3d text demo

Post by Beauty »

I didn't download it. So I do't know the content - only your download description.
I just created the wiki page and put the links there, although I was very tired.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80

Re: polygon font demo + 3d text demo

Post by duststorm »

I was just thinking this could be a great part of an Ogre visual debugging library, much like what is explained here.
Developer @ MakeHuman.org
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: polygon font demo + 3d text demo

Post by Assaf Raman »

I don't know, better to render to texture and use that... or a bitmap font...
Watch out for my OGRE related tweets here.
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80

Re: polygon font demo + 3d text demo

Post by duststorm »

Yeah, looking at the code it is indeed a bit dependency-heavy for a debug tool.
A font texture atlas or a pre-defined library of polygon fonts might be a better solution. Still, if you want a polygon alphabet this tool could be used to generate all of the characters.
Developer @ MakeHuman.org
Valdemar
Gnoblar
Posts: 5
Joined: Fri Nov 23, 2012 9:32 am

Re: polygon font demo + 3d text demo

Post by Valdemar »

Hello Guys,
I'm developing an application, which needs to display polygon text meshes. I must admit that i'm relatively new to OGRE and also 3d graphics in general.
So i tried the code from this topic. Precompiled windows binaries crash. I also tried to compile samples from source on Linux but one file from FTGL was missing. I've found the file in FTGL repository, then it compiled but sample still crashed. So finally i extended a couple of classes from the newest version of FTGL and it worked.
I pass the Ogre::ManualObject to FTGL classes which generates the font glyph and build Ogre::ManualObject from vertices provided by FTGL. All code can be found at https://github.com/Ramedlaw/ogreftgl.

Here's the most important chunk of code i added to FTGL:

Code: Select all

void OgreFTPolygonGlyphImpl::DoRender(const FTPoint& pen)
{    
    vectoriser->MakeMesh(1.0, 1, outset);

    const FTMesh *mesh = vectoriser->GetMesh();
    
    for(unsigned int t = 0; t < mesh->TesselationCount(); ++t)
    {
        const FTTesselation* subMesh = mesh->Tesselation(t);
        unsigned int polygonType = subMesh->PolygonType();
        
        Ogre::RenderOperation renderOperation;
        switch (polygonType) {
            case GL_TRIANGLE_STRIP:
                renderOperation.operationType = Ogre::RenderOperation::OT_TRIANGLE_STRIP;
                break;
            case GL_TRIANGLE_FAN:
                renderOperation.operationType = Ogre::RenderOperation::OT_TRIANGLE_FAN;
                break;
        }
        
        
        manualObject->begin("BaseWhite", renderOperation.operationType);
        for(unsigned int i = 0; i < subMesh->PointCount(); ++i)
        {
            FTPoint point = subMesh->Point(i);
            manualObject->index(i);
            manualObject->textureCoord(pen.Xf() + (point.Xf() / hscale), pen.Yf() + (point.Yf() / vscale));
            manualObject->position(pen.Xf() + (point.Xf() / 64.0f), pen.Yf() + (point.Yf() / 64.0f), 0.0f);   
        }
        manualObject->end();
    }
}
Now i have the performance problem, the longer text is, the worse performance.
Here's an image. Image
As you can see, OGRE says there are 20.606 triangles and 32 fps. On this thread images show ~1000 fps with ~4000 triangles.
So how can i optimize the code to run faster?
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: polygon font demo + 3d text demo

Post by Assaf Raman »

Running in release and not in debug may be a good start.
Watch out for my OGRE related tweets here.
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99

Re: polygon font demo + 3d text demo

Post by Wolfmanfx »

Looking at your batch count i assume you have a draw call per character which is very bad - try to batch the characters per material so if all characters have the same material the result should be one vertexbuffer / indexbuffer and you just need one draw call instead 3000K ;)
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: polygon font demo + 3d text demo

Post by Assaf Raman »

Wolfmanfx is right.
The original code used to create a single mesh - meaning a single batch - are you sure you are not creating and adding new batches every frame?
Watch out for my OGRE related tweets here.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39

Re: polygon font demo + 3d text demo

Post by Beauty »

Valdemar wrote:Now i have the performance problem
Each ManualObject can contain several sections. Sections are like "data blocks", with the same material and rendering type.

In your loop each cycle creates a new section by manualObject->begin(...).
I suppose your ManualObject has several sections and each of them contains only a vertices.
This is very bad for performance.
The best case would be to have only 2 sections for each line of text.
One for all triangles and one for lines. (Or more sections if you use mixed materials)
Then it should be faster.

Additionally the usage of rendering types OT_xxx_STRIP and OT_TRIANGLE_FAN can cause performance problems.
This is the reason of your huge batch count. I don't want to write details (because I don't have much time at the moment).
So you should use only the rendering types OT_xxx_LIST. For this you need more memory (on the graphic card), but this shouldn't be a problem in your case.

I hope I could help you.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
doup
Gnoblar
Posts: 3
Joined: Thu Aug 07, 2014 10:02 am

Re: polygon font demo + 3d text demo

Post by doup »

How can i do two materials in a text?
This is my text " hello word" and i want to set material "hello" Examples/Rockwall and "word" Examples/Grass.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: polygon font demo + 3d text demo

Post by Assaf Raman »

There is no such option for now, you can change the code or create two meshes.
Watch out for my OGRE related tweets here.