![]() TGE Version 1.5.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SimObject Class Reference#include <simBase.h>
Inheritance diagram for SimObject: ![]() Detailed DescriptionBase class for objects involved in the simulation.
IntroductionSimObject is a base class for most of the classes you'll encounter working in Torque. It provides fundamental services allowing "smart" object referencing, creation, destruction, organization, and location. Along with SimEvent, it gives you a flexible event-scheduling system, as well as laying the foundation for the in-game editors, GUI system, and other vital subsystems.SubclassingYou will spend a lot of your time in Torque subclassing, or working with subclasses of, SimObject. SimObject is designed to be easy to subclass.You should not need to override anything in a subclass except:
Of course, if you know what you're doing, go nuts! But in most cases, you shouldn't need to touch things not on that list. When you subclass, you should define a typedef in the class, called Parent, that references the class you're inheriting from.
Then, when you override a method, put in:
bool mySubClass::onAdd() { if(!Parent::onAdd()) return false; // ... do other things ... } Of course, you want to replace onAdd with the appropriate method call. A SimObject's Life CycleSimObjects do not live apart. One of the primary benefits of using a SimObject is that you can uniquely identify it and easily find it (using its ID). Torque does this by keeping a global hierarchy of SimGroups - a tree - containing every registered SimObject. You can then query for a given object using Sim::findObject() (or SimSet::findObject() if you want to search only a specific set).
// Three examples of registering an object. // Method 1: AIClient *aiPlayer = new AIClient(); aiPlayer->registerObject(); // Method 2: ActionMap* globalMap = new ActionMap; globalMap->registerObject("GlobalActionMap"); // Method 3: bool reg = mObj->registerObject(id); Registering a SimObject performs these tasks:
Calling registerObject() and passing an ID or a name will cause the object to be assigned that name and/or ID before it is registered. Congratulations, you have now registered your object! What now? Well, hopefully, the SimObject will have a long, useful life. But eventually, it must die. There are a two ways a SimObject can die.
When you unregister a SimObject, the following tasks are performed:
If you call deleteObject(), all of the above tasks are performed, in addition to some sanity checking to make sure the object was previously added properly, and isn't in the process of being deleted. After the object is unregistered, it deallocates itself. Torque EditorsSimObjects are one of the building blocks for the in-game editors. They provide a basic interface for the editor to be able to list the fields of the object, update them safely and reliably, and inform the object things have changed.This interface is implemented in the following areas:
(Note: you can check the variable gEditingMission to see if the mission editor is running; if so, you may want to render special indicators. For instance, the fxFoliageReplicator renders inner and outer radii when the mission editor is runnning.) The ConsoleSimObject extends ConsoleObject by allowing you to to set arbitrary dynamic fields on the object, as well as statically defined fields. This is done through two methods, setDataField and getDataField, which deal with the complexities of allowing access to two different types of object fields.Static fields take priority over dynamic fields. This is to be expected, as the role of dynamic fields is to allow data to be stored in addition to the predefined fields. The fields in a SimObject are like properties (or fields) in a class. Some fields may be arrays, which is what the array parameter is for; if it's non-null, then it is parsed with dAtoI and used as an index into the array. If you access something as an array which isn't, then you get an empty string. You don't need to read any further than this. Right now, set/getDataField are called a total of 6 times through the entire Torque codebase. Therefore, you probably don't need to be familiar with the details of accessing them. You may want to look at Con::setData instead. Most of the time you will probably be accessing fields directly, or using the scripting language, which in either case means you don't need to do anything special. The functions to get/set these fields are very straightforward:
setDataField(StringTable->insert("locked", false), NULL, b ? "true" : "false" ); curObject->setDataField(curField, curFieldArray, STR.getStringValue()); setDataField(slotName, array, value); For advanced users: There are two flags which control the behavior of these functions. The first is ModStaticFields, which controls whether or not the DataField functions look through the static fields (defined with addField; see ConsoleObject for details) of the class. The second is ModDynamicFields, which controls dynamically defined fields. They are set automatically by the console constructor code.
Member Typedef Documentation
Reimplemented in AudioEnvironment, AudioSampleEnvironment, AudioDescription, AudioProfile, ConsoleLogger, SimDataBlock, SimSet, SimGroup, SimChunk, UnknownChunk, FileObject, MaterialPropertyMap, CreatorTree, EditManager, EditTSCtrl, GuiTerrPreviewCtrl, MissionAreaEditor, Terraformer, TerrainEditor, WorldEditor, WorldEditor::Selection, AIClient, AIConnection, AIPlayer, AIWheeledVehicle, AudioEmitter, BanList, CameraData, Camera, DebrisData, Debris, DebugView, FireballAtmosphereData, FireballAtmosphere, ExplosionData, Explosion, fxFoliageReplicator, fxLightData, fxLight, fxRenderObject, fxShapeReplicatedStatic, fxShapeReplicator, fxSunLight, LightningData, Lightning, ParticleEmitterNodeData, ParticleEmitterNode, ParticleData, ParticleEmitterData, ParticleEmitter, PrecipitationData, Precipitation, SplashData, Splash, WeatherLightningData, WeatherLightning, GameBaseData, GameBase, GameConnection, GameTSCtrl, GuiPlayerView, ItemData, Item, MissionArea, MissionMarkerData, MissionMarker, SpawnSphere, HTTPObject, TCPObject, PathCameraData, PathCamera, PhysicalZone, PlayerData, Player, ProjectileData, Projectile, RigidShapeData, RigidShape, ShapeBaseImageData, ShapeBaseData, ShapeBase, ShowTSShape, StaticShapeData, StaticShape, Trigger, TSStatic, FlyingVehicleData, FlyingVehicle, HoverVehicleData, HoverVehicle, VehicleData, Vehicle, VehicleBlocker, WheeledVehicleTire, WheeledVehicleSpring, WheeledVehicleData, WheeledVehicle, GuiControlArrayControl, GuiFrameSetCtrl, GuiPaneControl, GuiScrollCtrl, GuiStackControl, GuiTabBookCtrl, GuiWindowCtrl, GuiBackgroundCtrl, GuiBitmapButtonCtrl, GuiBitmapButtonTextCtrl, GuiBitmapCtrl, GuiButtonBaseCtrl, GuiButtonCtrl, GuiCheckBoxCtrl, GuiColorPickerCtrl, GuiConsole, GuiConsoleEditCtrl, GuiConsoleTextCtrl, GuiDirectoryFileListCtrl, GuiDirectoryTreeCtrl, GuiListBoxCtrl, GuiMLTextCtrl, GuiMLTextEditCtrl, GuiPopUpTextListCtrl, GuiPopUpMenuCtrl, GuiRadioCtrl, GuiSliderCtrl, GuiTabPageCtrl, GuiTextCtrl, GuiTextEditCtrl, GuiTextEditSliderCtrl, GuiTextListCtrl, GuiTreeViewCtrl, GuiArrayCtrl, GuiCanvas, GuiControl, GuiTSCtrl, GuiCursor, GuiControlProfile, DbgFileView, GuiEditCtrl, GuiFilterCtrl, GuiGraphCtrl, GuiInspector, GuiInspectorField, GuiInspectorGroup, GuiInspectorDynamicField, GuiInspectorDynamicGroup, GuiInspectorDatablockField, GuiInspectorTypeEnum, GuiInspectorTypeCheckBox, GuiInspectorTypeGuiProfile, GuiInspectorTypeFileName, GuiInspectorTypeColor, GuiInspectorTypeColorI, GuiInspectorTypeColorF, GuiMenuBackgroundCtrl, GuiSubmenuBackgroundCtrl, GuiMenuTextListCtrl, GuiMenuBar, GuiAviBitmapCtrl, GuiMessageVectorCtrl, GuiProgressCtrl, GuiEffectCanvas, GuiTheoraCtrl, GuiTickCtrl, GuiBubbleTextCtrl, GuiInputCtrl, GuiMouseEventCtrl, GuiVectorFieldCtrl, MessageVector, LangTable, InteriorInstance, InteriorMap, InteriorSubObject, MirrorSubObject, PathedInteriorData, PathedInterior, sgLightObjectData, sgLightObject, sgMissionLightingFilterData, sgMissionLightingFilter, SceneLighting, volumeLight, DInputManager, UInputManager, SceneRoot, ActionMap, DecalData, DecalManager, NetConnection, NetObject, SceneObject, Path, Marker, Sky, Sun, TerrainBlock, WaterBlock, and TSShapeConstructor.
Member Enumeration Documentation
Flags for use in mFlags.
Constructor & Destructor Documentation
Member Function Documentation
Mark a Notify structure as free.
Get the value of a field on the object. See here for a detailed discussion of what this function does.
Set the value of a field on the object. See here for a detailed discussion of what this function does.
Get reference to the dictionary containing dynamic fields. See here for a detailed discussion of what this function does. This dictionary can be iterated over using a SimFieldDictionaryIterator.
Set whether fields created at runtime should be saved. Default is true.
Get whether fields created at runtime should be saved. Default is true.
These functions support internal naming that is not namespace bound for locating child controls in a generic way. Set the internal name of this control (Not linked to a namespace)
Get the internal of of this control.
Save object as a TorqueScript File.
Check if a method exists in the objects current namespace.
added this so that you can print the entire class hierarchy, including script objects,
Process constructor options. (ie, new SimObject(1,2,3)).
Reimplemented in ConsoleLogger, SimGroup, TCPObject, and Sky.
Called when the object is added to the sim.
Reimplemented in AudioDescription, AudioProfile, SimDataBlock, EditManager, EditTSCtrl, MissionAreaEditor, TerrainEditor, WorldEditor, AudioEmitter, Camera, DebrisData, Debris, FireballAtmosphereData, FireballAtmosphere, ExplosionData, Explosion, fxFoliageReplicator, fxLightData, fxLight, fxRenderObject, fxShapeReplicator, fxSunLight, LightningData, Lightning, ParticleEmitterNodeData, ParticleEmitterNode, ParticleData, ParticleEmitterData, ParticleEmitter, PrecipitationData, Precipitation, SplashData, Splash, WeatherLightningData, WeatherLightning, GameBaseData, GameBase, GameConnection, Item, MissionArea, MissionMarker, SpawnSphere, TCPObject, PathCamera, PhysicalZone, Player, ProjectileData, Projectile, RigidShapeData, RigidShape, ShapeBaseImageData, ShapeBase, ShowTSShape, StaticShape, Trigger, TSStatic, FlyingVehicle, HoverVehicleData, HoverVehicle, Vehicle, VehicleBlocker, WheeledVehicle, GuiFrameSetCtrl, GuiTabBookCtrl, GuiDirectoryTreeCtrl, GuiMLTextCtrl, GuiPopUpMenuCtrl, GuiTextCtrl, GuiTextEditCtrl, GuiControl, GuiCursor, GuiControlProfile, GuiInspector, GuiInspectorField, GuiInspectorGroup, GuiInspectorDynamicField, GuiMessageVectorCtrl, GuiVectorFieldCtrl, MessageVector, InteriorInstance, InteriorMap, PathedInterior, sgLightObject, sgMissionLightingFilter, volumeLight, DInputManager, UInputManager, ActionMap, NetObject, SceneObject, Path, Marker, Sky, Sun, TerrainBlock, WaterBlock, and TSShapeConstructor.
Called when the object is removed from the sim.
Reimplemented in SimSet, SimGroup, AudioEmitter, Camera, Debris, FireballAtmosphere, Explosion, fxFoliageReplicator, fxLight, fxRenderObject, fxShapeReplicator, fxSunLight, Lightning, ParticleEmitterNode, ParticleEmitter, Precipitation, Splash, WeatherLightning, GameBase, GameConnection, Item, MissionMarker, PathCamera, PhysicalZone, Player, Projectile, RigidShape, ShapeBase, ShowTSShape, StaticShape, Trigger, TSStatic, FlyingVehicle, HoverVehicle, Vehicle, VehicleBlocker, WheeledVehicle, GuiTabBookCtrl, GuiTextListCtrl, GuiControl, GuiCursor, GuiMessageVectorCtrl, GuiVectorFieldCtrl, MessageVector, InteriorInstance, InteriorMap, PathedInterior, sgMissionLightingFilter, volumeLight, DInputManager, UInputManager, NetConnection, NetObject, SceneObject, Path, Marker, Sky, TerrainBlock, and WaterBlock.
Called when the object is removed from a SimGroup.
Called when the object's name is changed.
Called when a static field is modified. Specifically, this is called by setDataField when a static field is modified, see the console details. Reimplemented in SimDataBlock, GuiTextEditCtrl, and InteriorInstance.
Called before any property of the object is changed in the world editor. The calling order here is:
Reimplemented in AudioEmitter, GuiControl, and InteriorInstance.
Called after any property of the object is changed in the world editor.
Reimplemented in AudioEmitter, fxFoliageReplicator, fxLight, fxRenderObject, fxShapeReplicator, fxSunLight, Precipitation, GameBase, MissionMarker, SpawnSphere, StaticShape, TSStatic, GuiControlArrayControl, GuiBitmapButtonCtrl, GuiBitmapCtrl, GuiMLTextCtrl, GuiTextCtrl, GuiControl, GuiMessageVectorCtrl, GuiTheoraCtrl, InteriorInstance, InteriorMap, sgLightObject, sgMissionLightingFilter, volumeLight, SceneObject, Marker, Sky, Sun, TerrainBlock, and WaterBlock. Called when a SimObject is deleted. When you are on the notification list for another object and it is deleted, this method is called. Reimplemented in SimSet, TerrainEditor, WorldEditor::Selection, Camera, Item, ShapeBase, Trigger, DInputManager, and UInputManager.
Called when the editor is activated.
Reimplemented in WorldEditor, Camera, fxFoliageReplicator, fxRenderObject, fxShapeReplicator, MissionMarker, PathCamera, Trigger, InteriorMap, Marker, and TerrainBlock.
Called when the editor is deactivated.
Reimplemented in Camera, fxFoliageReplicator, fxRenderObject, fxShapeReplicator, MissionMarker, PathCamera, Trigger, InteriorMap, Marker, and TerrainBlock.
Remove a notification from the list.
Remove all notifications for this object.
Send out deletion notifications.
Register a reference to this object. You pass a pointer to your reference to this object. When the object is deleted, it will null your pointer, ensuring you don't access old memory.
Unregister a reference to this object. Remove a reference from the list, so that it won't get nulled inappropriately. Call this when you're done with your reference to the object, especially if you're going to free the memory. Otherwise, you may erroneously get something overwritten.
Register an object with the object system. This must be called if you want to keep the object around. In the rare case that you will delete the object immediately, or don't want to be able to use Sim::findObject to locate it, then you don't need to register it. registerObject adds the object to the global ID and name dictionaries, after first assigning it a new ID number. It calls onAdd(). If onAdd fails, it unregisters the object and returns false. If a subclass's onAdd doesn't eventually call SimObject::onAdd(), it will cause an assertion.
Register the object, forcing the id.
Register the object, assigning the name.
Register the object, assigning a name and ID.
Unregister the object from Sim. This performs several operations:
Unregister, mark as deleted, and free the object. This helper function can be used when you're done with the object and don't want to be bothered with the details of cleaning it up.
Reimplemented in ShapeBase.
Determine whether or not a field should be written.
Output the TorqueScript to recreate this object. This calls writeFields internally.
Reimplemented in SimSet, and GuiControl. Write the fields of this object in TorqueScript.
Copy fields from another object onto this one. Objects must be of same type. Everything from obj will overwrite what's in this object; extra fields in this object will remain.
Return the object's namespace.
Get next matching item in namespace. This wraps a call to Namespace::tabComplete; it gets the next thing in the namespace, given a starting value and a base length of the string. See Namespace::tabComplete for details.
Called to register the object's lights, if any, with the LightManager.
Reimplemented in Explosion, fxLight, Item, Projectile, ShapeBase, sgLightObject, and Sun.
Register dynamic fields in a subclass of ConsoleObject.
Reimplemented from ConsoleObject. Reimplemented in AudioEnvironment, AudioSampleEnvironment, AudioDescription, AudioProfile, ConsoleLogger, EditTSCtrl, GuiTerrPreviewCtrl, MissionAreaEditor, TerrainEditor, WorldEditor, AudioEmitter, CameraData, Camera, DebrisData, Debris, FireballAtmosphereData, FireballAtmosphere, ExplosionData, Explosion, fxFoliageReplicator, fxLightData, fxLight, fxRenderObject, fxShapeReplicator, fxSunLight, LightningData, Lightning, ParticleEmitterNodeData, ParticleEmitterNode, ParticleData, ParticleEmitterData, PrecipitationData, Precipitation, SplashData, WeatherLightningData, WeatherLightning, GameBaseData, GameBase, ItemData, Item, MissionArea, MissionMarker, SpawnSphere, PathCameraData, PathCamera, PhysicalZone, PlayerData, ProjectileData, Projectile, RigidShapeData, RigidShape, ShapeBaseImageData, ShapeBaseData, StaticShapeData, StaticShape, Trigger, TSStatic, FlyingVehicleData, FlyingVehicle, HoverVehicleData, VehicleData, Vehicle, VehicleBlocker, WheeledVehicleTire, WheeledVehicleSpring, WheeledVehicleData, WheeledVehicle, GuiControlArrayControl, GuiFrameSetCtrl, GuiPaneControl, GuiScrollCtrl, GuiStackControl, GuiTabBookCtrl, GuiWindowCtrl, GuiBitmapButtonCtrl, GuiBitmapCtrl, GuiButtonBaseCtrl, GuiCheckBoxCtrl, GuiColorPickerCtrl, GuiConsoleEditCtrl, GuiConsoleTextCtrl, GuiListBoxCtrl, GuiMLTextCtrl, GuiMLTextEditCtrl, GuiPopUpMenuCtrl, GuiSliderCtrl, GuiTabPageCtrl, GuiTextCtrl, GuiTextEditCtrl, GuiTextEditSliderCtrl, GuiTextListCtrl, GuiTreeViewCtrl, GuiControl, GuiTSCtrl, GuiCursor, GuiControlProfile, GuiFilterCtrl, GuiInspectorGroup, GuiMenuBar, GuiAviBitmapCtrl, GuiMessageVectorCtrl, GuiTheoraCtrl, GuiMouseEventCtrl, MessageVector, InteriorInstance, InteriorMap, MirrorSubObject, PathedInteriorData, PathedInterior, sgLightObjectData, sgLightObject, sgMissionLightingFilterData, sgMissionLightingFilter, volumeLight, DecalData, NetObject, SceneObject, Path, Marker, Sky, Sun, TerrainBlock, WaterBlock, and TSShapeConstructor.
Friends And Related Function Documentation
Reimplemented in SimGroup.
Field DocumentationSimGroup we're contained in, if any.
Reimplemented in AudioEnvironment, AudioSampleEnvironment, and GuiTreeViewCtrl.
Id number for this object.
Storage for dynamic fields.
true if dynamic fields (added at runtime) should be saved, defaults to true
Stores object Internal Name.
|