Creating trigger with new editor
by David Dougher · in Torque Game Engine · 01/01/2002 (12:15 pm) · 26 replies
I think this one may be for Mark. I created a new trigger for my demo level and did the following things...
1. It created a new subdirectory under torque/example called editor. Into this subdirectory it created a file called newObject.cs. The contents of this file were...
ObjectBuilderGui.newObject = new Trigger(Gateroom) {
dataBlock = "gameTrigger";
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
}
2. It then compiled this object into a .dso and placed the .dso into the same torque/example/editor subdirectory.
3. When I saved my mission it inserted the following code into my mission file...
new Trigger(Gateroom) {
position = "-458.3 162 324.356";
rotation = "1 0 0 0";
scale = "2.5 2.5 13";
dataBlock = "gameTrigger";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 -1.0000000 0.0000000";
};
Note that I positioned and sized the trigger after it was created all in one session.
Two questions.
First, do I need to retain the newObject file for any reason or is is just some intermediate step that is not being properly cleaned up?
Second, (and the reason I filed this in the bug section) If you look carefully at the parameters in the polyhedron code you will notice that they are not the same.
When you eliminate the extra zeroes they are basically
newObject
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
Mission
polyhedron = "0 0 0 1 0 0 0 0 1 0 -1 0";
1. It created a new subdirectory under torque/example called editor. Into this subdirectory it created a file called newObject.cs. The contents of this file were...
ObjectBuilderGui.newObject = new Trigger(Gateroom) {
dataBlock = "gameTrigger";
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
}
2. It then compiled this object into a .dso and placed the .dso into the same torque/example/editor subdirectory.
3. When I saved my mission it inserted the following code into my mission file...
new Trigger(Gateroom) {
position = "-458.3 162 324.356";
rotation = "1 0 0 0";
scale = "2.5 2.5 13";
dataBlock = "gameTrigger";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 -1.0000000 0.0000000";
};
Note that I positioned and sized the trigger after it was created all in one session.
Two questions.
First, do I need to retain the newObject file for any reason or is is just some intermediate step that is not being properly cleaned up?
Second, (and the reason I filed this in the bug section) If you look carefully at the parameters in the polyhedron code you will notice that they are not the same.
When you eliminate the extra zeroes they are basically
newObject
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
Mission
polyhedron = "0 0 0 1 0 0 0 0 1 0 -1 0";
About the author
Owner - Pariah Games, Adjunct Professor - Bristol Community College, Mentor - Game Design - Met School Newport, Mentor - Game Design - Met School Providence
#3
01/02/2002 (3:23 pm)
I am running the head version. The problem is reported against it.
#4
I also tried adding a trigger entity via the map2dif route. It is not in the SimGroup either.
01/03/2002 (7:26 am)
What happened to adding triggers with the in-game editor (HEAD release)? When I click on WorldEditorCreator|MissionObjects|Mission|Trigger, I get the window to name the Trigger object (it also shows the datablock and polyhedron data). But when I click OK it is not added to the SimGroup. I also tried adding a trigger entity via the map2dif route. It is not in the SimGroup either.
#5
I also added a new fps/server/sripts/trigger.cs file which contains the missing DefaultTrigger need to create triggers in the mission editor. The file also contains some documentation on triggers in general.
The only wierd thing left is that when you create a trigger in the mission editor, it isn't place in front of you, it's stuck at the origin. Mark knows more about the mission editor than I do, I'll see if he'll look into it :)
01/03/2002 (1:46 pm)
Fixed the trigger write method, which was the culprit. It was flipping the sign of the coordinates for some reason, I think whoever wrote that was a little confused :) I also setup the trigger to render when the mission editor is running. It currently renders as a set of line-segments, be nice to change have it do translucent faces at some point.I also added a new fps/server/sripts/trigger.cs file which contains the missing DefaultTrigger need to create triggers in the mission editor. The file also contains some documentation on triggers in general.
The only wierd thing left is that when you create a trigger in the mission editor, it isn't place in front of you, it's stuck at the origin. Mark knows more about the mission editor than I do, I'll see if he'll look into it :)
#6
01/03/2002 (3:57 pm)
Big help. Thanks Tim.
#7
01/03/2002 (6:14 pm)
Many thx
#8
01/08/2004 (4:15 pm)
Tim, seems to be a problem still when bringing in triggers as sub-objects; this is coming from adding Mark Harmon's pathedInteriors and the triggers only working once (prior to saving the scene and exiting--after restarting the scene they don't work).
#9
01/08/2004 (4:57 pm)
Heh seems this bug is finally gettins some attention!!
#10
vectors in the setDataTypeTriggerPolyhedron.
from
This allows the triggers to work after reentering mission; but, we had seen a post from Joel Baxter that alluded to problems with physical zones....so, we don't know if those are broken by making this trigger change. For this stuff see: www.garagegames.com/mg/forums/result.thread.php?qt=3373
BTW-we don't need physical zones now since forcefields are not in use.
01/08/2004 (5:11 pm)
Ok, in trigger.cc function (getDataTypeTriggerPolyhedron) we reversed vec 2 and 1 to match the vectors in the setDataTypeTriggerPolyhedron.
from
dSprintf(retBuf, 1023, "%7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f",
origin.x, origin.y, origin.z,
vecs[0].x, vecs[0].y, vecs[0].z,
vecs[2].x, vecs[2].y, vecs[2].z,
vecs[1].x, vecs[1].y, vecs[1].z);to:dSprintf(retBuf, 1023, "%7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f %7.5f",
origin.x, origin.y, origin.z,
vecs[0].x, vecs[0].y, vecs[0].z,
vecs[1].x, vecs[1].y, vecs[1].z,
vecs[2].x, vecs[2].y, vecs[2].z);This allows the triggers to work after reentering mission; but, we had seen a post from Joel Baxter that alluded to problems with physical zones....so, we don't know if those are broken by making this trigger change. For this stuff see: www.garagegames.com/mg/forums/result.thread.php?qt=3373
BTW-we don't need physical zones now since forcefields are not in use.
#12
05/11/2004 (9:43 am)
I know this post is a couple months old, but I'm still running into a problem with triggers. I updated that code, but everytime I load the mission a second time my trigger stops working.
#13
05/11/2004 (10:01 am)
Got the problem too Mark.
#14
05/11/2004 (10:52 am)
Glad I'm not alone, but from the forum searches I've done this has been on ongoing problem for a long time. I even tried changing the trigger poly manually in the mission file and it still doesn't want to work. Works like a charm the first time and that's it.
#15
05/12/2004 (1:10 pm)
I think I might have gotten somewhere with this. I managed to find some older trigger.cc and .h files and loaded those in. Had what seemed liked success and then it started acting up again. I then noticed that my turrets trigger was basically consuming my whole level so I deleted the turret and it's triggers and now my triggers don't invert and they work on a reload. Seems like there might be a problem with triggers inside of another trigger. Will examine further.
#16
07/20/2004 (11:04 pm)
Any news?
#17
07/27/2004 (7:24 pm)
In collision/earlyOutPolyList.cc, in EarlyOutPolyList::end(), if you replace the lines frontMask |= mask; backMask |= ~mask;with
backMask |= mask; frontMask |= ~mask;the triggers will work... but I don't really understand this code, so I'm not sure that's the good thing to do...
#18
That worked for me.
07/28/2004 (5:10 am)
I hade this problem that trigger overided each other,so i started to place my triggers in separate simgroups even if they didnt have any slaves.That worked for me.
#19
08/05/2004 (5:28 am)
My triggers broke again... I came back to the release code, always broken... reverse vec2 and vec1 to getDataTypeTriggerPolyhedron match the vectors in setDataTypeTriggerPolyhedron : always broken. So I reverse vec2 and vec1 to setDataTypeTriggerPolyhedron match the vectors in getDataTypeTriggerPolyhedron and it works! I don't find why they work when they are in separate simgroup...
#20
08/09/2004 (4:57 am)
Ok, seems like some edges are not the good ones, try :pPoly->edgeList[4].vertex[0] = 3; pPoly->edgeList[4].vertex[1] = 6; //pPoly->edgeList[4].face[0] = 3; //pPoly->edgeList[4].face[1] = 2; pPoly->edgeList[4].face[0] = 2; pPoly->edgeList[4].face[1] = 3; pPoly->edgeList[8].vertex[0] = 4; pPoly->edgeList[8].vertex[1] = 2; //pPoly->edgeList[8].face[0] = 1; //pPoly->edgeList[8].face[1] = 5; pPoly->edgeList[8].face[0] = 5; pPoly->edgeList[8].face[1] = 1;
Torque Owner Chris "Dark" Evans
The example/editor directory is temporary. I think it's for the copy/paste commands. You can delete it, I did and it works fine.
Dark