Interior Instances?
by Neil Marshall · in Torque Game Engine · 11/14/2005 (7:17 pm) · 5 replies
I'm trying to modify the textures that are on an interior at runtime. I figured by looking at the code I could detect a click, find a face, find its texturemap and swap it and I would be good.
In my first test I changed the texture in the RenderARP function of InteriorRender and every time I clicked on a new poly the change was registered. The problem was when I placed a second copy of the same DIF in the same world the texturemap changes registered there. I can work around that but I wanted to see if I could get it working on each instance, so I then changed the code so that when you click on the mesh it calls a function in interiorInstance which I made and it finds the poly and swaps the texture. That works as far as I can tell (I still have one more test to do tomorrow) but as soon as I click on a second polygon the material that had changed now changes back to its default texture.
My question is, how are instances stored? Does it revert back to the original textures on every frame or do instances hold their own information perminatly? The results I had were kind of unexpected.
In my first test I changed the texture in the RenderARP function of InteriorRender and every time I clicked on a new poly the change was registered. The problem was when I placed a second copy of the same DIF in the same world the texturemap changes registered there. I can work around that but I wanted to see if I could get it working on each instance, so I then changed the code so that when you click on the mesh it calls a function in interiorInstance which I made and it finds the poly and swaps the texture. That works as far as I can tell (I still have one more test to do tomorrow) but as soon as I click on a second polygon the material that had changed now changes back to its default texture.
My question is, how are instances stored? Does it revert back to the original textures on every frame or do instances hold their own information perminatly? The results I had were kind of unexpected.
#2
11/15/2005 (9:51 am)
Yeah that "one thing" that I had left to check confirmed what you just said. Oh well, it's no big deal.
#3
It's a good way to shave a few hundred megs off your memory usage in complex scenes. ;)
But obviously sometimes you have to change it to do what you want. Like in this sort of situation. Aren't you glad you get the source? :)
11/15/2005 (10:27 am)
Some info is in instance, some is in the Interior resource that's shared. Nothing is copied (would be incredibly slow). Just some stuff is shared, some is per-instance.It's a good way to shave a few hundred megs off your memory usage in complex scenes. ;)
But obviously sometimes you have to change it to do what you want. Like in this sort of situation. Aren't you glad you get the source? :)
#5
08/29/2006 (5:23 am)
Awesome, thanks.
Torque Owner Brian Richardson
So, if you want unique texture info per instance, you'll have to add a data structure to the interior instance to hold that info, then modify the interior rendering functions to use the interior instance data structures to get texture info.
Hope that helps..