Page 2 of 3

Re: Decal System / Manager

Posted: Fri Oct 28, 2011 7:40 pm
by ACE247
WoW! Only discovered this now, many thanks for sharing it. Will surely use this for my project. :)

Re: Decal System / Manager

Posted: Mon Nov 07, 2011 5:24 pm
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 :)

Re: Decal System / Manager

Posted: Mon Nov 07, 2011 9:35 pm
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.

Re: Decal System / Manager

Posted: Thu Nov 24, 2011 8:57 pm
by RdR
Updated DecalSceneNode with Z-fighting fix, thanks to Lonesome Ducky.

Re: Decal System / Manager

Posted: Sun Feb 12, 2012 12:38 pm
by RdR
Fixt some stuff in the DecalManager and added it to the IrrExt project

Re: Decal System / Manager

Posted: Tue Feb 21, 2012 4:37 am
by netpipe
in revision of the trunk 4047 the pack_textureblendfunct will no longer compile

Re: Decal System / Manager

Posted: Tue Feb 21, 2012 9:23 am
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).

Re: Decal System / Manager

Posted: Sat Mar 17, 2012 2:51 am
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!

Re: Decal System / Manager

Posted: Sun Mar 24, 2013 6:26 pm
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!

Re: Decal System / Manager

Posted: Mon Mar 25, 2013 9:44 am
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?

Re: Decal System / Manager

Posted: Tue Mar 26, 2013 4:31 am
by arascii
Nope, I'm adding each wall and the floor nodes individually in a loop.
Here is the wireframe image:
Image

Re: Decal System / Manager

Posted: Sun May 19, 2013 12:46 am
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?

Re: Decal System / Manager

Posted: Mon May 20, 2013 12:34 pm
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.

Re: Decal System / Manager

Posted: Tue May 21, 2013 8:38 pm
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.

Re: Decal System / Manager

Posted: Sat Jan 11, 2014 9:00 pm
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