Game Development Community

Detecting decals in scene

by Ronald J Nelson · in Torque Game Engine · 10/19/2007 (11:09 pm) · 5 replies

Is there some way to detect a decal in a scene that can be accessed by another function?

I have tried doing a list of all items in a mission cleanup with decals with a very long lifespan. I had no luck.

Frankly I just need to be able to detect decal instances in a given area so I can either clear them or force them to change their position.

Thanks in advance.

#1
10/20/2007 (1:36 am)
Decals are stored in a single list. To 'detect' them in an area you need to iterate thru the list and check the position of each.
#2
10/20/2007 (7:07 am)
OK keeping in mind that due to certain requirements for other decal enhancements I am using that are just not compatible with the Batched Decal System in 1.5.2, I made this:

for(U32 i=0; i<mDecalQueue.size(); i++)
	{
		DecalInstance *inst = mDecalQueue[i];

		MatrixF mat = getRenderTransform();
		Point3F pos;
		mat.getColumn(3, &pos);
		
		Con::errorf(ConsoleLogEntry::General, "Decal pos.x: %f", pos.x);
		Con::errorf(ConsoleLogEntry::General, "Decal pos.y: %f", pos.y);
		Con::errorf(ConsoleLogEntry::General, "Decal pos.z: %f", pos.z);
	}

Since the decal is a rendered thing, I really thought this could give me the decal's position, I was wrong.

Does anyone have a suggestion on how I can get the decal's position from the instance in the manner I am using?
#3
10/20/2007 (1:43 pm)
OK I am getting really agravated here. I have actually figured out how to detect the darned decals in the specified radius radius. I can't get the code to clear the darned things though. Can someone look and see what I am doing wrong?

void DecalManager::checkForDecalTD(Point3F pos, F32 off)
{
	Point3F pOne;
	Point3F pTwo;
	Point3F pThree;
	Point3F pFour;

	F32 XMin = pos.x - off;
	F32 XMax = pos.x + off;

	F32 YMin = pos.y - off;
	F32 YMax = pos.y + off;

	for(U32 i=0; i<mDecalQueue.size(); i++)
	{
		DecalInstance *inst = mDecalQueue[i];

		bool flag = false;


		pOne = inst->point[0];
		pTwo = inst->point[1];
		pThree = inst->point[2];
		pFour = inst->point[3];

		if((pOne.x >= XMin) && (pOne.x <= XMax) && (pOne.y >= YMin) && (pOne.y <= YMax))
			flag = true;

		if((pTwo.x >= XMin) && (pTwo.x <= XMax) && (pTwo.y >= YMin) && (pTwo.y <= YMax))
			flag = true;

		if((pThree.x >= XMin) && (pThree.x <= XMax) && (pThree.y >= YMin) && (pThree.y <= YMax))
			flag = true;

		if((pFour.x >= XMin) && (pFour.x <= XMax) && (pFour.y >= YMin) && (pFour.y <= YMax))
			flag = true;

		if(flag)
		{
			Con::errorf(ConsoleLogEntry::General, "Decal Detected");
			freeDecalInstance(mDecalQueue[i]);
			mDecalQueue.erase(i);

			mQueueDirty = true;

			if (mQueueDirty == true)
			{
				// Sort the decals based on the data pointers...
				dQsort(mDecalQueue.address(),
					mDecalQueue.size(),
					sizeof(DecalInstance*),
					cmpDecalInstance);
				mQueueDirty = false;
			}
		}
		
	}
}

Thanks in advance.
#4
10/20/2007 (7:12 pm)
Aw come on. No one out there has a good ole "You are an idiot, and this is why..." ?
#5
10/21/2007 (8:15 pm)
Well I figured it out one my own. It is amazing that one stupid symbol can screw up an entire function. ;)