Irrlicht SceneNodes Collection 2012

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Irrlicht SceneNodes Collection 2012

Post by gerdb »

----------------------------------------
LAST UPDATE 04.03.2013
----------------------------------------
diff to svn-trunk 4461:

http://benjaminhampe.be.ohost.de/Irrlic ... r2013.diff
http://benjaminhampe.be.ohost.de/Irrlic ... tlogo4.png
Image

this texture is used with the example.cpp because the trasition from blue to grey is in the middle, to have better visual results
also the text within the texture helped me finding the right uv-coords for all shapes.

-------------------------------------------

i added many new mesh creator functions to the IGeometryCreator Interface

full resolution image http://benjaminhampe.be.ohost.de/Irrlic ... reator.png

preview Image

#1 triangle
#2 rect
#3 roundrect
#4 pioneer-hexagon
#5 circle ( todo: radial segmentation if needed )
#6 ellipse
#7 ring
#8 arc
#9 upperspherehalf
#10 lowerspherehalf
#11 capsule
#12 cylinder ( todo: radial segmentation if needed )
#13 tube ( todo: radial segmentation if needed, inner hull has no vertical segmentation either )
#14 ellipsoid
#15 torus
#16 box ( like inverted skybox with 1 or 3 or 6 individual textures for dices, creates, etc..)

more im working on:

#17 tetraeder
#18 icosaeder ( if allowed to use from ikam )
#19 path2d out of rects (thickness is height of rect) with linejoin (miter,bevel, round)
#20 path3d out of boxes or cylinderhulls (thickness is height of box) with linejoin

with freetype outline renderer
#21 polygonal text (2d)
#22 polygonal extruded text (3d)

http://benjaminhampe.be.ohost.de/Irrlic ... yCreator.h
http://benjaminhampe.be.ohost.de/Irrlic ... yCreator.h
http://benjaminhampe.be.ohost.de/Irrlic ... reator.cpp

i use two new template classes in irrMath.h

CSinTable<T>( elementCount, T startAngle, T endAngle)
CCosTable<T>( elementCount, T startAngle, T endAngle)

http://benjaminhampe.be.ohost.de/Irrlic ... /irrMath.h

( the classes are at the very end of irrMath.h )

i wrote a fully example to test new stuff:

Irrlicht Example 27.GeometryCreator

http://benjaminhampe.be.ohost.de/Irrlic ... reator.cbp
http://benjaminhampe.be.ohost.de/Irrlic ... r/main.cpp
http://benjaminhampe.be.ohost.de/Irrlic ... rToImage.h
http://benjaminhampe.be.ohost.de/Irrlic ... oImage.cpp
http://benjaminhampe.be.ohost.de/Irrlic ... tlogo6.png --> needs to be added to media folder

have fun
----------------------------------------
original
----------------------------------------
hi,

i open this thread to collect new SceneNodes for the irrlicht-community. :-)

all SceneNodes will have some additional rendering styles set with setPrimitiveType()
e.g. Circle with just an outline through EPT_LINE_LOOP
and filled with EPT_POLYGON or EPT_TRIANGLES
or EPT_QUADS instead EPT_TRIANGLES

#1 Capsule (requested by another thread)

Image
http://benjaminhampe.be.ohost.de/Irrlic ... ceneNode.h
http://benjaminhampe.be.ohost.de/Irrlic ... neNode.cpp
for use with IMeshSceneNode:
http://benjaminhampe.be.ohost.de/Irrlic ... suleMesh.h
http://benjaminhampe.be.ohost.de/Irrlic ... leMesh.cpp

#2 Teapot
Image
http://benjaminhampe.be.ohost.de/Irrlic ... ceneNode.h
http://benjaminhampe.be.ohost.de/Irrlic ... neNode.cpp

#3 Tube
Image
http://benjaminhampe.be.ohost.de/Irrlic ... TubeMesh.h
http://benjaminhampe.be.ohost.de/Irrlic ... beMesh.cpp

#4 CNormalSceneNode
Image
http://benjaminhampe.be.ohost.de/Irrlic ... ceneNode.h
http://benjaminhampe.be.ohost.de/Irrlic ... neNode.cpp

#5 RoundRect:

Rx & Ry did work out of the box -> so elliptic rounded rect is also possible with this function

Image
http://benjaminhampe.be.ohost.de/Irrlic ... RectMesh.h
http://benjaminhampe.be.ohost.de/Irrlic ... ctMesh.cpp
http://benjaminhampe.be.ohost.de/Irrlic ... ndRect.pdf

#6 createRainbowTexture + createArcMesh:
# Arc

createRainbowTexture uses algorithm from Bruton, with gamma, also saves transparency value 0..255
createArcMesh can have any value between 0 360 degrees, starting 0 is +X,Y=0,Z=0, going ccw
-> arc has MaterialType EMT_TRANSPARENT_ALPHA_CHANNEL

Image
http://benjaminhampe.be.ohost.de/Irrlic ... nbowMesh.h
http://benjaminhampe.be.ohost.de/Irrlic ... owMesh.cpp

Example Code:

Code: Select all

scene::IMeshSceneNode* node = 0;
for (u32 z=0; z<7; ++z)
{
        node = app->getSceneManager()->addMeshSceneNode(
                scene::createArcMesh(100.0f+100.0f*z, 70.0f+50.0f*(f32)z, 0.0f-(f32)(z*10), 180.0f+(f32)(z*10), 13+4*z),
                app->getRootSceneNode(),
                -1,
                core::vector3df(400,0,100.0f+200.0f*z));
        dbSetObjectWireframe(node, false);
        dbTextureObject(node, 0, video::createRainbowTexture(app->getVideoDriver(), 64,64,200-z*20,1.0));
}
 
coming
# Plane
# Circle
# Ring
# Ellipse
# Torus
# StanfordBunny
# Tetraeder
Last edited by gerdb on Tue Mar 05, 2013 11:44 am, edited 25 times in total.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Irrlicht SceneNodes Sammelthread 2012

Post by ACE247 »

Nur Neue? Oder duerfen hier auch aeltere hin? (vokale wollten nicht)
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Irrlicht SceneNodes Sammelthread 2012

Post by gerdb »

ja alte gehen auch. ich füge oben aber erstmal neue hinzu, die getestet und verbessert werden sollen, ok?
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Irrlicht SceneNodes Sammelthread 2012

Post by ACE247 »

Gut, Ich werd mal anfangen meine alle auf den neusten standpunkt zu bringen. :)
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Irrlicht SceneNodes Sammelthread 2012

Post by Mel »

So, it is a teapot primitive and a capsule primitive?

The code for the teapot would be nicer if it had the posibility to provide the amount of tesellation you want for it. I can't find any source code for the teapot now, but seems that the GLUT library has a parametric teapot.

But definately, the capsule is a nice adition :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Re: Irrlicht SceneNodes Sammelthread 2012

Post by Strong99 »

Those are nice additions,

It would be nice if you could add them to the GeometryGenerator
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Irrlicht SceneNodes Sammelthread 2012

Post by gerdb »

yeah parametric teapot sounds nice, i'll look through the freeglut code when i have time, by the way the 2 above are just the beginning. guess i will finish the ring and tube scenenodes first, i need them :-), the geom-creator class will grow when i find someone who explains svn commits to me. Until then all Classes have their own static methods to create MeshBuffers they need.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Irrlicht SceneNodes Sammelthread 2012

Post by hybrid »

Implementing those elements as part of new scene nodes is basically a no-go, as it implies that one needs to derive a new scene node in order to provide new geometric shapes. Please put these models into their own classes each if you want to, and add the create* methods and a createSceneNode method which puts the geometry into a mesh scene node.

Why would you need SVN commit rights for providing patches against the geometry creator? You won't get direct write to the Irrlicht SVN. If you want to host your code somewhere, you should provide the patches against latest SVN/trunk in our patch tracker. Or I could add you to the irrExt project, wehre such extensions can also be put into. Adding a patch might have higher chances to get into the engine, though.

Please keep all posts in English, except if really important to have something told in a foreign language. Otherwise, most visitors of the forum won't be able to use these things.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Irrlicht SceneNodes Sammelthread 2012

Post by gerdb »

hi,

i forgot the englishness of the forum, when i postet the thread, sry, will translate my posts accordingly.

@ IMeshSceneNode/IMeshBuffer: these classes lack one important information about shapes, the field E_PRIMITIVE_TYPE PrimitiveType,
so i cant rely on them exclusivly.

EDIT: it does work for all EPT_TRIANGLES meshes, so i will add for these objects a function createMesh that can be added to GeometryCreator
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Irrlicht SceneNodes Sammelthread 2012

Post by hybrid »

Yeah, you should only use EPT_TRIANGLES for your geometry, as all Irrlicht methods rely on this.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Irrlicht SceneNodes Collection 2012

Post by christianclavet »

Wow! #5 round rect could be a very nice 2D primitive to add to the Irrlicht GUI. I have not seen the code yet, but how hard would it be to use that with the GUI class as a primitive renderer? (instead of using the IRRlicht rectangle primitive (drawing buttons, windows, etc.)

The capsule primitive would be surely useful a lot with collision response, since it a much better shape than the ellipse.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Irrlicht SceneNodes Collection 2012

Post by gerdb »

hi,

for 2d i'd try to make the function more efficient, as it does the same thing for all 4 corners 4 times, maybe i save the precalculated dx,dy values,
also allocation of vertices & indices must be optimized, Also bbox can be optimized. But for now it simply works :-)

QUESTION: would you like the cylinderhulls to be more tesselated? also normals arent correct, will check this next week.

cya
ikam
Posts: 46
Joined: Sun Jun 24, 2007 4:46 pm
Location: France

Re: Irrlicht SceneNodes Collection 2012

Post by ikam »

to continue the collection I've made a simple plan mesh, it's based on the createPlaneMesh code from the GeometryCreator but with a different behaviour :

- user parameters are no more tilesSize and tilesCount, but gridSize and tilesCount, difference is that the gridSize is the dimension of the plan (fixed compared to createPlaneMesh) and tiles size are computed from gridsize / tilescount.

Code: Select all

 
// creates a plan 
IMesh* createGridPlan(
        const core::dimension2d<f32>& gridSize,
        const core::dimension2d<u32>& tc, video::SMaterial* material,
        const core::dimension2d<f32>& textureRepeatCount) const
{
    core::dimension2d<u32> tileCount = tc;
 
    // compute tile size
    f32 tileSizeX = gridSize.Width / tileCount.Width;
    f32 tileSizeY = gridSize.Height / tileCount.Height;
 
    // center
    const core::position2d<f32> center((tileSizeX * tileCount.Width) * 0.5f, (tileSizeY * tileCount.Height) * 0.5f);
 
    // texture coord step
    const core::dimension2d<f32> tx(
            textureRepeatCount.Width / tileCount.Width,
            textureRepeatCount.Height / tileCount.Height);
 
    // add one more point in each direction for proper tile count
    ++tileCount.Height;
    ++tileCount.Width;
 
    SMeshBuffer* buffer = new SMeshBuffer();
    video::S3DVertex vtx;
    vtx.Color.set(255,255,255,255);
 
    // create vertices from left-front to right-back
    f32 sx=0.f, tsx=0.f;
    for (u32 x=0; x<tileCount.Width; ++x)
    {
        f32 sy=0.f, tsy=0.f;
        for (u32 y=0; y<tileCount.Height; ++y)
        {
            vtx.Pos.set(sx - center.X, 0, sy - center.Y);
            vtx.TCoords.set(tsx, 1.0f - tsy);
            buffer->Vertices.push_back(vtx);
            sy += tileSizeY;
            tsy += tx.Height;
        }
        sx += tileSizeX;
        tsx += tx.Width;
    }
 
    // create indices
    for (u32 x=0; x<tileCount.Width-1; ++x)
    {
        for (u32 y=0; y<tileCount.Height-1; ++y)
        {
            const s32 current = x*tileCount.Height + y;
 
            buffer->Indices.push_back(current);
            buffer->Indices.push_back(current + 1);
            buffer->Indices.push_back(current + tileCount.Height);
 
            buffer->Indices.push_back(current + 1);
            buffer->Indices.push_back(current + 1 + tileCount.Height);
            buffer->Indices.push_back(current + tileCount.Height);
        }
    }
 
    // recalculate normals
    for (u32 i=0; i<buffer->Indices.size(); i+=3)
    {
        const core::vector3df normal = core::plane3d<f32>(
            buffer->Vertices[buffer->Indices[i+0]].Pos,
            buffer->Vertices[buffer->Indices[i+1]].Pos,
            buffer->Vertices[buffer->Indices[i+2]].Pos).Normal;
 
        buffer->Vertices[buffer->Indices[i+0]].Normal = normal;
        buffer->Vertices[buffer->Indices[i+1]].Normal = normal;
        buffer->Vertices[buffer->Indices[i+2]].Normal = normal;
    }
 
    if (material)
        buffer->Material = *material;
 
    buffer->recalculateBoundingBox();
    buffer->setHardwareMappingHint(EHM_STATIC);
 
    SMesh* mesh = new SMesh();
    mesh->addMeshBuffer(buffer);
    mesh->recalculateBoundingBox();
    buffer->drop();
    return mesh;
}
 
Last edited by ikam on Thu Feb 07, 2013 10:46 pm, edited 1 time in total.
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Re: Irrlicht SceneNodes Collection 2012

Post by Klunk »

The code for the teapot would be nicer if it had the posibility to provide the amount of tesellation you want for it. I can't find any source code for the teapot now, but seems that the GLUT library has a parametric teapot.
there's source code for a parametric teapot in the 3ds Max SDK, it's quite "involved" as it were.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Irrlicht SceneNodes Collection 2012

Post by gerdb »

Update, pls check updated first post.
Post Reply