Decal System / Manager

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Decal System / Manager

Post by ACE247 »

WoW! Only discovered this now, many thanks for sharing it. Will surely use this for my project. :)
jorgerosa
Competition winner
Posts: 117
Joined: Wed Jun 30, 2010 8:44 am
Location: Portugal
Contact:

Re: Decal System / Manager

Post by jorgerosa »

From the first post, by RdR: "How to use"

Code: Select all

 
// Create decal manager
DecalManager* decalManager = new DecalManager(smgr);
 
// Set terrain and add some meshes where decals can be placed
decalManager->setTerrain(terrain);
decalManager->addMesh(wallNode);
decalManager->addMesh(rockNode);
 
// Create a decal
irr::core::vector3df position = irr::core::vector3df(123, 10, 123);     // Position to place the decal
irr::core::vector3df dimension = irr::core::vector3df(2, 2, 2);         // Dimension of decal 
irr::core::vector3df normal = irr::core::vector3df(0, 1, 0);            // Orientation of the decal
irr::f32 textureRotation = 45;                                          // Rotation in degrees
irr::scene::ISceneNode* parent = 0;                                     // Parent
irr::f32 lifeTime = 0;                                                  // Time to life
irr::f32 distance = 250;                                                // Max viewing distance
 
decalManager->("mydecal.png", position, dimension, normal, textureRotation, parent, lifeTime, distance);
 
Just in case, this could be an issue to anyone else... This line of code doesnt worked with me:

Code: Select all

decalManager->("mydecal.png", position, dimension, normal, textureRotation, parent, lifeTime, distance); 
I had to change it, this way, seems to work fine now:

Code: Select all

decalManager->addDecal("mydecal.png", position, dimension, normal, textureRotation, parent, lifeTime, distance); 
Thanks again, RdR, for share this :)
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Decal System / Manager

Post by RdR »

jorgerosa wrote: Just in case, this could be an issue to anyone else... This line of code doesnt worked with me:

Code: Select all

decalManager->("mydecal.png", position, dimension, normal, textureRotation, parent, lifeTime, distance); 
I had to change it, this way, seems to work fine now:

Code: Select all

decalManager->addDecal("mydecal.png", position, dimension, normal, textureRotation, parent, lifeTime, distance); 
Thanks again, RdR, for share this :)
Thanks for noticing, I will edit my start post.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Decal System / Manager

Post by RdR »

Updated DecalSceneNode with Z-fighting fix, thanks to Lonesome Ducky.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Decal System / Manager

Post by RdR »

Fixt some stuff in the DecalManager and added it to the IrrExt project
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: Decal System / Manager

Post by netpipe »

in revision of the trunk 4047 the pack_textureblendfunct will no longer compile
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Decal System / Manager

Post by CuteAlien »

tecan wrote:in revision of the trunk 4047 the pack_textureblendfunct will no longer compile
That one got renamed (it missed the t before I think).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Decal System / Manager

Post by christianclavet »

Humm! Did not notice this before today! Good job! I think I will use this for projecting "blob" shadows on the ground in my project. Really nice work!
arascii
Posts: 3
Joined: Sun Mar 24, 2013 6:14 pm

Re: Decal System / Manager

Post by arascii »

This is a really cool system, thank you for providing it. I'm running into this strange error and I was hoping you could help me with it.
I am using scaled/rotated/textured cubeSceneNodes as walls in a simple 3d game. When I shoot a bullet, I use ray tracing to keep the point of intersection with scene objects, and when the bullet hits the object I'm using

Code: Select all

decals->addDecal(splat,btarget,core::vector3df(10,10,10));
(obviously, the texture is splat, btarget is the intersection point). This works fine on my "floor" object, which is an IMeshSceneNode of a HillPlaneNode. But when I fire a bullet at a "wall" node I get the following:
Image
(I included the splat on the floor for reference, the problem is on the wall).
Any ideas why this could be happening? Here is how I'm adding the walls to the decal manager:
(walls is a core::array<IMeshSceneNode*>)

Code: Select all

 
for (int i=0; i<walls->size(); ++i)
    {
        scene::IMeshSceneNode* w = (*walls)[i]; 
        decals->addMesh(w->getMesh(),w);
        w->setMaterialFlag(video::EMF_FOG_ENABLE, true);
        scene::ITriangleSelector* wallSelector = smgr->createTriangleSelectorFromBoundingBox(w);
        w->setTriangleSelector(wallSelector);
        metaSelector->addTriangleSelector(wallSelector);
        wallSelector->drop();
    }
 
Thanks in advance!
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Decal System / Manager

Post by RdR »

Hey arascii,

Are you using the metaSelector in the above code for the decal manager ?
Could you create a screenshot with the wireframe of the decal?
arascii
Posts: 3
Joined: Sun Mar 24, 2013 6:14 pm

Re: Decal System / Manager

Post by arascii »

Nope, I'm adding each wall and the floor nodes individually in a loop.
Here is the wireframe image:
Image
arascii
Posts: 3
Joined: Sun Mar 24, 2013 6:14 pm

Re: Decal System / Manager

Post by arascii »

Haven't heard anything about this in a while. I may have to move away from Irrlicht if I can't fix this issue. Any suggestions, anyone?
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Decal System / Manager

Post by christianclavet »

For me this look like a UV stretching issue with the decal projection.

I havent checked the source of this yet, but can you try changing the orientation of the decal? I see this as a parameter now and the parameter orientation is from the top. (The parameter ask for an orientation vector) It's good for the floor but bad for the wall. (Would surely cause that stretching).

You should try to use a "ray" (weapon projectile) direction instead. Are you using your "gun reticle" to get the collision point with the object? You could use the orientation of this ray for the orientation vector.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Decal System / Manager

Post by RdR »

christianclavet wrote:For me this look like a UV stretching issue with the decal projection.

I havent checked the source of this yet, but can you try changing the orientation of the decal? I see this as a parameter now and the parameter orientation is from the top. (The parameter ask for an orientation vector) It's good for the floor but bad for the wall. (Would surely cause that stretching).

You should try to use a "ray" (weapon projectile) direction instead. Are you using your "gun reticle" to get the collision point with the object? You could use the orientation of this ray for the orientation vector.
Thats sounds about right indeed. Haven't checked this code in a while either :D
You prob use the wrong normal, if you use the gun inverse direction it should be correct.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Decal System / Manager

Post by Granyte »

I have just integrated this to my game and while it looks great the performance can quite fast become terrible when I have a lot of object colliding.

so I was wondering how does the decal manager make use of the batching and if it could be improved further by batching and using shaders to move the decals group to their proper meshes
Post Reply