Interior SimGroup
by Desmond Fletcher · in Torque Game Engine · 07/09/2004 (12:08 pm) · 20 replies
Is it possible to add interiors without making them part of the mission file; that is, without adding them to a SimGroup during loadMission? Hope I asked that correctly.
#2
07/09/2004 (12:46 pm)
Actualy you can. The editor does just want you want, the interiors are not saved into the mission file until you save it. So take a look though the editor and see how it places the interiors. Should be easy as adding an object.
#3
07/09/2004 (9:41 pm)
I did this once, but you'll have to bother me later... maybe tomorrow or monday I'll have it for you. There is a small engine change related to texturing that you need to make so the engine won't crash. It checks to see if the editor is running to assign the texture or something like that, but if it's not, things don't load properly. I still have the code lying around, but I'll have to dig a little. It's not very difficult, though. Feel free to email me as a reminder tomorrow and/or monday.
#4
Now for the script. I was lazy and just put these into game.cs, but they will work anywhere, as long as the script is executed :)
You really only need one function there, but I guess I was going to have it spawn dts shapes along with the interior at some point (before I dropped this project). I never got to the point of making the position dynamic (like where the player is looking). I can't imagine that being too terribly difficult.
BTW, thanks for your quark tutorials... I've been referring to them the past couple days again. It's time to make buildings!
07/10/2004 (6:11 am)
Ok Desmond, here's the one major code change... in interiorInstance.cc, starting at line 530 (or close there), inside the onAdd function, there's this little block:if (gEditingMission) {
gInteriorLMManager.useBaseTextures(pInterior->getLMHandle(), mLMHandle);
gInteriorLMManager.downloadGLTextures(pInterior->getLMHandle());
}Simply comment out the if statement. So I guess it's lightmaps, not textures :)Now for the script. I was lazy and just put these into game.cs, but they will work anywhere, as long as the script is executed :)
function createInteriorShape( %shapeName )
{
%obj = new InteriorInstance()
{
position = "262.037 -33.8626 210.041";
rotation = "1 0 0 0";
scale = "1 1 1";
showTerrainInside = "0";
interiorFile = %shapeName;
};
if(%obj == -1 || %obj == 0)
return;
MissionGroup.add(%obj);
}
function spawnBuilding()
{
createInteriorShape("starter.fps/data/interiors/newmap.dif");
echo("Building spawned.");
}You really only need one function there, but I guess I was going to have it spawn dts shapes along with the interior at some point (before I dropped this project). I never got to the point of making the position dynamic (like where the player is looking). I can't imagine that being too terribly difficult.
BTW, thanks for your quark tutorials... I've been referring to them the past couple days again. It's time to make buildings!
#5
07/10/2004 (9:27 am)
Great! I think that something along these lines is exactly what I'm looking for. Thx. Question about Save: once the interior is added to MissionGroup and say you do a Save, will the Save (or SaveAs) function find this addition since it's looking for MissionGroup items. I'm guessing it would and then it would be part of the mission file after that point....which raises the problem of having duplicate interiors the next time the mission is loaded. So I guess the script would have to search the mission file first to make sure the interior is not already loaded??
#6
07/10/2004 (9:30 am)
Hmmm. Maybe that update block should be a separate method. It could be exposed to the console so editors could use them.
#7
07/10/2004 (9:34 am)
What do you mean Bill?
#8
Seems to me this is redundant; perhaps was used at some point in time for distinguishing between client and server but no longer.
07/10/2004 (11:27 am)
While wading thru the onAdd function in interiorInstance.cc I came across this:if (isClientObject()) {
// create all the subObjects
mInteriorSubObjects.setSize(mInteriorRes->getNumDetailLevels());
for (i = 0; i < mInteriorRes->getNumDetailLevels(); i++) {
constructInPlace(&mInteriorSubObjects[i]);
Interior* pInterior = mInteriorRes->getDetailLevel(i);
for (U32 j = 0; j < pInterior->mSubObjects.size(); j++)
mInteriorSubObjects[i].push_back(pInterior->mSubObjects[j]->clone(this));
}
} else {
// creates all subobjects
mInteriorSubObjects.setSize(mInteriorRes->getNumDetailLevels());
for (i = 0; i < mInteriorRes->getNumDetailLevels(); i++) {
constructInPlace(&mInteriorSubObjects[i]);
Interior* pInterior = mInteriorRes->getDetailLevel(i);
for (U32 j = 0; j < pInterior->mSubObjects.size(); j++)
mInteriorSubObjects[i].push_back(pInterior->mSubObjects[j]->clone(this));
}
}Seems to me this is redundant; perhaps was used at some point in time for distinguishing between client and server but no longer.
#9
I'll explain my purpose in doing this spawning of interiors. I was prototyping a strategy game where you would construct buildings in game time (I guess somewhat like sim city... and also like the modern Battlezone). I eventually wanted to have a cursor show up on the terrain, then press a key or click the mouse to construct the building at that point. In my case, saving the interiors with a mission save would be a bonus. This script is all the further I got since I got distracted with other things. I will probably eventually come back to it... I love the game concept (been working on it for about 4 years). It's just such a large-scale game that I don't think is practical for me to do lone-wolf style. So I moved on to a smaller-scale game.
Oh, one thing I forgot to tell you... the lightmaps come in just fine, but they are not run through the engine lighting calculation. If you place lights in Quark, they work just fine with this method. Sure, the in-engine lighting looks a lot better, but also takes time to calculate. There has been talk of doing a local lightmap recalculation, but that's some bit of work.
07/10/2004 (11:36 am)
I'm not actually positive it needs to be added to the MissionGroup... I just put that in there to follow convention. I'm also not sure that save grabs it, though it seems like it would. This was written while I was still moderately young with torque (and I'm still young).I'll explain my purpose in doing this spawning of interiors. I was prototyping a strategy game where you would construct buildings in game time (I guess somewhat like sim city... and also like the modern Battlezone). I eventually wanted to have a cursor show up on the terrain, then press a key or click the mouse to construct the building at that point. In my case, saving the interiors with a mission save would be a bonus. This script is all the further I got since I got distracted with other things. I will probably eventually come back to it... I love the game concept (been working on it for about 4 years). It's just such a large-scale game that I don't think is practical for me to do lone-wolf style. So I moved on to a smaller-scale game.
Oh, one thing I forgot to tell you... the lightmaps come in just fine, but they are not run through the engine lighting calculation. If you place lights in Quark, they work just fine with this method. Sure, the in-engine lighting looks a lot better, but also takes time to calculate. There has been talk of doing a local lightmap recalculation, but that's some bit of work.
#10
So, what I'm trying to do is possibly "constructInPlace" the pathedInteriors the same way the interior subObjects are constructed in place. My first question in this thread was trying to understand how the missionGroup worked thinking that might be a solution. John, your response definately is something I'd like to integrate to create more real-time collaborative design environements. I think we should start another thread following that thought process!!!!
With respect to the pathedInteriors, I've discovered that the triggers are not created equally during creation in map2dif and then loading a mission...this is why so many people have problems with triggers. It's real annoying to have a door trigger work during the first add but not work the next time loaded. So I was hoping to solve two problems at once: fix the trigger problem and remove the need for interior artists to have to muck with the stupid magicButton-->in other words make TGE as sophisticated as any other AAA engine in this regard.
Geez, I feel like that was almost a rant but I have been trying to fix this for quite a while and would rather get back to making interiors and continue adding tutorials. I haven't even been able to jump into the TSE shaders--and won't until I resolve this. Ok, that was a rant--thanks for listening :)
07/10/2004 (12:00 pm)
This is a concept I'm working on also (adding interiors real-time)...but I got onto this thread mainly to eliminate the addChildren function required to insert doors using the magicButton-->I want the doors to come in automagically with the interior. The problem: using the current approach (including resources from BadGuy, Mark Harmon, and GG's MarbleBlast) requires some form of the magicbutton and the pathedInteriors are placed in a separate SimGroup from the interior supposedly tied to the interior by an InteriorResIndex value. From the vantage point of an interior designer, I find this to be an archaic non-intuitive approach; or stated another way, the interior artist shouldn't have to fool with this stuff :) So, what I'm trying to do is possibly "constructInPlace" the pathedInteriors the same way the interior subObjects are constructed in place. My first question in this thread was trying to understand how the missionGroup worked thinking that might be a solution. John, your response definately is something I'd like to integrate to create more real-time collaborative design environements. I think we should start another thread following that thought process!!!!
With respect to the pathedInteriors, I've discovered that the triggers are not created equally during creation in map2dif and then loading a mission...this is why so many people have problems with triggers. It's real annoying to have a door trigger work during the first add but not work the next time loaded. So I was hoping to solve two problems at once: fix the trigger problem and remove the need for interior artists to have to muck with the stupid magicButton-->in other words make TGE as sophisticated as any other AAA engine in this regard.
Geez, I feel like that was almost a rant but I have been trying to fix this for quite a while and would rather get back to making interiors and continue adding tutorials. I haven't even been able to jump into the TSE shaders--and won't until I resolve this. Ok, that was a rant--thanks for listening :)
#11
07/10/2004 (12:52 pm)
This is a random shot in the dark (not just a shot in the dark, mind you, a random one)... what about adding a door entity to quark and implementing it properly in torque? I know that adding the entity to quark is not overly complicated, but getting torque to process it is tougher. What do you know about this?
#12
07/10/2004 (1:29 pm)
Right now I've got Mark Harmon's resource in...works for the most part. In QuArK are the needed objects, map2dif then adds the InteriorTrigger, PathedInterior, and Path (with markers) into the dif. No problem there...at the other end when adding an interior to the scene, only the main interior, detail levels and subObjects such as mirrors are added to begin with. The pathedInteriors should be treated the same as subObjects and extracted from the dif during the interior onAdd but currently have to be manually added by calling interiorId.magicButton(); function at the console. Aside from being a nuisance, this works ok at this point but is causing a problem with the triggers since the triggers are manufactured differently in map2dif than they are during scene loading. so, I'm trying to fix two problems.
#13
I can add dts vis TTStatic, but adding a .dif crashes the app.
07/14/2004 (9:16 am)
Have you been able to create an Interior dynamcially during game play? I can add dts vis TTStatic, but adding a .dif crashes the app.
#14
07/14/2004 (9:58 am)
Yes, even dynamically lights! Haven't tested server issues yet however.
#15
Is that, "the interiors are re-lit upon insertion" (as Alt+L would do), or "lights can also be added dynamically"?
Either way, it sounds really cool :)
07/14/2004 (10:12 am)
What do you mean by "dynamically lights", Desmond?Is that, "the interiors are re-lit upon insertion" (as Alt+L would do), or "lights can also be added dynamically"?
Either way, it sounds really cool :)
#16
07/14/2004 (10:27 am)
Yes the interiors are re-lit upon insertion...used your script above and change to interiorInstance...but as I said above, I haven't tested any of this across servers
#17
Oh... I'm leaving very soon for a week, so don't be shocked if I don't respond to this for a week or two. Need anything from Portland? :)
07/14/2004 (10:36 am)
Wow, I don't remember them being re-lit on insertion... what did you have to change to get them to re-light?Oh... I'm leaving very soon for a week, so don't be shocked if I don't respond to this for a week or two. Need anything from Portland? :)
#18
07/14/2004 (12:01 pm)
Nope, have fun!
#19
07/14/2004 (1:03 pm)
Hmm... maybe it's because you're using TGERad. Does that light the exterior of interiors? (confused? I mean non-zones... things not enclosed in portals).
#20
07/14/2004 (4:34 pm)
My bad...Testing further->I had some environmental mappings on a texture on an interior that seems to force a light on the texture during load. If there is no env map, the interior is black as normal. Hmmm, possibilities.
Torque Owner Bil Simser