Having troube with getTerrainMapIndex.
by Caleb · in Torque Game Engine · 07/16/2008 (11:18 am) · 2 replies
I seem to be having some trouble when getting a color I've assigned to a texture via the material property map. I have code inside the "missionAreaEditor.cc" file that covers a portion of the missionArea map with pixels.
Now I'm trying to use the following code segment to color the pixels with a color that I've assigned to texture below the pixels.
Anyways, I get no errors when I compile, and I can't see any obvious reason for this not to work.
Thanks for any help.
Now I'm trying to use the following code segment to color the pixels with a color that I've assigned to texture below the pixels.
Point3F pixel3F;
Point2F pixel2F = screenToWorld(Point2F(posX, posY));
pixel3F.set(pixel2F.x, pixel2F.y, 0);
S32 mapIndex = terrain->getTerrainMapIndex(pixel3F);
MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>(Sim::findObject("MaterialPropertyMap"));
const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(mapIndex);
glColor3f(pEntry->groundColor.red, pEntry->groundColor.green, pEntry->groundColor.blue);
glVertex2f(posX, posY);I believe my problem dwells within this bit of code because of several tests. In "materialPropertyMap.cc", I have groundColor initialized to black. However, when I manually change it to something like red or blue, the drawn pixels are still black. So I believe either mapIndex, pMatMap, or pEntry are not getting there correct values. I'm gonna do some more testing to try and find which one.Anyways, I get no errors when I compile, and I can't see any obvious reason for this not to work.
Thanks for any help.
#2
I've spent the last two days going over all the code I've added related to my current project. I fixed many small errors in my code, but none that caused this problem. Finally, I found some errors in terrData.cc. It almost appears as if some of the code was incomplete. I found it quite strange, but fortunately it didn't take too long to finish up.
Everything works great now! :D
07/20/2008 (6:59 pm)
My problem has been solved!I've spent the last two days going over all the code I've added related to my current project. I fixed many small errors in my code, but none that caused this problem. Finally, I found some errors in terrData.cc. It almost appears as if some of the code was incomplete. I found it quite strange, but fortunately it didn't take too long to finish up.
Everything works great now! :D
Torque Owner Caleb
Default Studio Name
I'm not sure why it's not working, but feel free to chime in if you do. :)