Creating a basic trigger volume

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
SoulRider
Posts:95
Joined:2014-04-06, 00:16
Creating a basic trigger volume

Post by SoulRider » 2014-08-18, 04:35

I would like to create a basic trigger component. This will be used as a base for death triggers, team join triggers amongst other things.

I have read through the collision model code, but that doesn't seem to cover exactly what I want. I understand triggers are passive, but I need a generic map placeable entity.

I want a simple non-textured entity that is scalable. It must be visible in CaWE when placed in a map, but not visible in game. It will trigger events when entered by an entity. Could you give me some advice on how I would create such an entity?
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Creating a basic trigger volume

Post by Carsten » 2014-08-18, 11:47

Please have a look at the "TestPatches" map for an example.

It contains two volume triggers that you can see in the Map Editor (in the 3D views, use the Tab key or the right mouse button context menu to toggle the 3D render modes), but not in the game.

In "TestPatches", the trigger's script code is put inline into the "ScriptCode" field of the Script components, but you can of course put it into a separate file as well.

Please note that I'm currently making changes to the way how the Map Editor renders entities, their primitives such as brushes, how selection clicks affect the parts of an entity, and similar things. If something in this regard is not working as expected, please let me know, but don't worry -- it's work in progress.
Best regards,
Carsten
SoulRider
Posts:95
Joined:2014-04-06, 00:16

Re: Creating a basic trigger volume

Post by SoulRider » 2014-08-18, 21:31

That looks great, the only thing it is missing is a scale component, so I can scale trigger size. Is there any scale tools already written within cafu? or do I need to make separate scale component?
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Creating a basic trigger volume

Post by Carsten » 2014-08-18, 23:29

Just click the related brush as any other brush, and click-drag it to the desired size...

Oh, maybe this is one of the issues that I mentioned before: right now, it is difficult or impossible to see which brush relates to which entity... but they have the same color in the 2D views, and in the flat-color modes in the 3D views as well.
Also, if you delete the entity (then restore with Undo), the brush disappears as well.

Sorry for the inconvenience, this is one of the issues I'm currently working on! :sorry:

To assign a new brush (that is part of the topmost "Map" entity) to a new entity (the trigger entity with the "Script" component), select both at the same time (e.g. hold down the Ctrl key to select multiple items in the 2D or 3D views), then select menu item "Tools > Tie to Entity".
It will assign the brush to the entity, indicated by a "(1)" (number of primitives) after the name in the Enity Hierarchy dialog.
Best regards,
Carsten
SoulRider
Posts:95
Joined:2014-04-06, 00:16

Re: Creating a basic trigger volume

Post by SoulRider » 2014-08-19, 02:33

I am aware the entity disappears when I deselect it, that is not an issue,as I just reselect the entity from the entity list.

I am not trying to assign a brush to an entity, I am trying to rescale the 16x16x16 entity marker that appears when a new entity is created. I can succesfully transform it (move and rotate), However there is no option to scale the object.

I was thinking about creating a scale component, but was wondering if it was worth adding it to the transform component. Most component systems I have seen online have a scale included in the transform component.

I have noticed a slightly different problem, with compiling maps and auto-running the engine from CaWE.

When I compile maps and run from the editor, under the deathmatch mode, all works fine. When I configure the editor to work on the duel path(which is initially a copy of deathmatch), then compile and run the map from the editor, it launches the engine with the correct parameters:

Code: Select all

Map compilation: Running command 'build/win32/vc10/x86/release/Ca3DE/Cafu.exe -svGame "Duel" -svWorld "aaa"'
However, when clicking new game in the game, the maps listed are only the deathmatch compiled maps, not the duel compiled maps.

To confirm I compiled and tested my map 'aaa' above as well as compiling and running 'testpatches' under the duel path, and compiled the map kidney under the deathmatch path. These are the only compiled (.cw) files in either path.

Every time I launch, I always end up on the main menu with the 'kidney' map displayed, which only exists in the 'deathmatch' path. I can't see anything which would force deathmatch to override the svGame "Duel" setting. Is there direct paths specified in the GUI?

Also, it appears the GameLibs argument in CompilerSetup.py is no longer used?

Sorry for the long posts and questions, they will ease off eventually :D
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Creating a basic trigger volume

Post by Carsten » 2014-08-19, 16:07

SoulRider wrote:I am aware the entity disappears when I deselect it, that is not an issue,as I just reselect the entity from the entity list.

I am not trying to assign a brush to an entity, I am trying to rescale the 16x16x16 entity marker that appears when a new entity is created. I can succesfully transform it (move and rotate), However there is no option to scale the object.

I was thinking about creating a scale component, but was wondering if it was worth adding it to the transform component. Most component systems I have seen online have a scale included in the transform component.
Well... the cubic entity marker that you see is just an indicator for the presence of the entity, that is, it's origin point. I would have preferred to render an icon instead (e.g. a light bulb icon if the first component is a Light component), and in fact it is on my TODO list, but this has to wait until more pressing things are done.

With the Selection tool you can move the entity (its origin), and rotate it (change its orientation). The Selection tool also supports scaling, but as you have already found out, the cubic box refuses to scale, because it seems like scaling an entity's representation, which underneath is nothing but an origin point and an orientation, is little useful.

In order words: What do you want to achieve with a scaling operation?

Initially I thought you'd like to (re-)shape the trigger volume, but that is done with the "brush" map primitives that in turn are associated with / are a part of the trigger entity.
As another example, if you consider an entity with a Model component, you will find a Scale variable that, as one expects, allows to set the scale of the model.

Maybe I misunderstood you, but I cannot quite see how a generic support for scaling (e.g. at the level of the Transform component) would be useful? Or were you looking for a "gizmo" that could be used to increase the size (scale) of the trigger volume?

I have noticed a slightly different problem, with compiling maps and auto-running the engine from CaWE.

[...]

Every time I launch, I always end up on the main menu with the 'kidney' map displayed, which only exists in the 'deathmatch' path. I can't see anything which would force deathmatch to override the svGame "Duel" setting. Is there direct paths specified in the GUI?
That is unfortunately right. The by far easiest and quickest solution to this problem is to open file Games/Duel/GUIs/MainMenu/MainMenu_main.cgui in the text editor, and search for all occurrences of "DeathMatch", replacing them accordingly.
Also, it appears the GameLibs argument in CompilerSetup.py is no longer used?
That's right, this is no longer needed because thanks to the component system, there is no longer any game-specific C++ code that must be linked to the core engine executable. In the template file CompilerSetup.py.tmpl, the relevant section was removed in commit 7eb638b, and you can remove these portions from the CompilerSetup.py file too if you wish.
Sorry for the long posts and questions, they will ease off eventually :D
No problem at all, don't worry about many or long questions, I'm happy to help! :up:
Best regards,
Carsten
SoulRider
Posts:95
Joined:2014-04-06, 00:16

Re: Creating a basic trigger volume

Post by SoulRider » 2014-08-19, 19:33

It may be a mis-understanding on my part here, but if I make an entity from a brush, will that brush be visible in world? If not, do I need to use a specific texture on the brush, or does making it an entity remove the brush from the world automatically?

EDIT----

Ignore that question, of course it won't show as in game without a model component. Sometimes it is not until I ask the question to someone else that I realise the answer!!
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Creating a basic trigger volume

Post by Carsten » 2014-08-20, 00:21

Slow! Go slow! :cheesy:

Entities can have:
  • components,
  • map primitives (brushes, Bezier patches, etc.),
  • other (child) entities.
Regarding visibility, these are all independent of each other, and normally, each of these parts is visible in the game.

Model components are for defining models only (e.g. cmdl files), they are not related to the brushes at all. Normally, a brush is always visible, no matter what entity it is a part of. What makes the trigger brushes special both regarding their visibility (note how you can see them in 3D views only in some of the "flat" render modes, but not in others) and regarding their collision behavior is their material, but not a magic property of the entity.

Considering a newly created, minimal entity that has no components but the built-in Basics and Transform, and no map primitives, the entity is actually invisible (it's just the Map Editor that force-renders the colored cubes that you have seen, so that the user knows that the entity exists and can be clicked). The entity normally becomes only visible "indirectly" via its components (e.g. Model) or its map primitives that are associated to it.

Ohhhh, and I just realize that it really might be a problem with the current Map Editor's rendering code that may give you the impression that things "disappear". The Map Editor attempts to hide the colored cube when it thinks that the entity has another, "proper" visual representation (e.g. a Model component or a map primitive), but it is well possible that there is a bug with that at this time.

In any case, don't worry, and don't get confused. It's really the Map Editor that's wrong! :cheesy: :oops:
I'll fix that as soon as I can!

(By the way, in this regard and also about the changes that I'm currently making, I plan to remove the "Groups" feature soon. This is possible because entities have become a lot more powerful than they were when the Groups feature was invented, and now brushes can be kept in arbitrary entities as explained above. That is, entities already provide natural grouping for brushes. In fact, grouping brushes in entities is more natural than grouping them in the still existing, explicit Groups, and all features that Groups currently have (single vs. all-in-one selection, locked/unlocked) will be moved to the Entity Hierarchy, so that feature duplicity is avoided and the user interface is simplified.)
Best regards,
Carsten
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Creating a basic trigger volume

Post by Carsten » 2014-08-22, 13:59

Btw., I just pushed a change regarding entity visibility as mentioned above.

Entities should now no longer "disappear": Instead, in the Map Editor, they should always have a visible representation (usually a colored box, but optionally also a model if they have a Model component, and in the future, other possible representations such as icons are possible as well).

Besides and independent of that, it will soon be possible to "hide" entities in the Map Editor in order to facilitate map editing, e.g. entities that are in the way while editing other entities can be hidden. Such entities will be hidden in the Map Editor only, but normally processed and be visible in the game.

Also independently of the above, an entity that is visible in the Map Editor may still be invisible in the game, e.g. in the case of trigger volumes where the related brushes may have special materials that cause them to be processed specially regarding 3D rendering, collision detection, etc.

I hope this helps clarifying things!

:up:
Best regards,
Carsten
SoulRider
Posts:95
Joined:2014-04-06, 00:16

Re: Creating a basic trigger volume

Post by SoulRider » 2014-08-22, 19:30

Thanks, that's great. I realised that by using the trigger material on the brush entity, it worked.

I will update my working version now. I am currently working on an old laptop, which is just capable of running the game at 23fps. I am not actually back online properly until late september at least, so I am working through things in a simple fashion to get as wide an understanding as possible. It's great fun, but sometimes really confusing :D
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests