In this tutorial we will continue from the previous Entity State - Basic tutorial and examine the remaining fields that were not covered.
The entity appearance is a series of bit flags/values that communicate various elements of an entities appearance.
The entity appearance is actually just a single unsigned int (KUINT32) with the first(least significant) 16 bits representing the general appearance which applies to all entity types and the last(most significant) 16 bits representing a specific appearance who’s bits are interpreted differently depending on the type of entity. This can become confusing knowing which bits to use and what values are valid. Fortunately KDIS abstracts away from this problem and allows programmers to treat the entity appearance like all other data types by providing simple get/set functions to handle the correct appearance values.
The land platform appearance contains values that can be applied to a land vehicle.
Describes the paint scheme of an entity.
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityPaintScheme( Camouflage ); |
Does the vehicles mobility kill?
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityMobilityKill( true ); |
Does the entities fire power kill?
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityFirePower( true ); |
Is the entity damaged?
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityDamage( NoDamage ); |
Is any smoke emitting from the entity?
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntitySmoke( NotSmoking ); |
Describes the size of the dust cloud trailing effect.
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityTrailingEffect( Small ); |
The state of the entities primary hatch.
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityHatchState( PrimaryHatchIsClosed ); |
The status of the entities lights.
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityLights( NavigationLightsOn); |
Are flames rising from the entity.
1 | MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityFlamingEffect( false ); |
It is important to use the correct specific appearance data type. If you are unsure what type to use for you entity it can be determined from looking at the first 2 values of the entity type.
Entity Kind | Entity Domain | Specific Appearance |
---|---|---|
1 | 1 | LandPlatformAppearance |
1 | 2 | AirPlatformAppearance |
1 | 3 | SurfacePlatformAppearance |
1 | 4 | SubSurfacePlatformAppearance |
1 | 5 | SpacePlatformAppearance |
2 | Any | GuidedMunitionsAppearance |
3 | Any | LifeFormAppearance |
4 | Any | EnvironmentalsAppearance |
For our M1A1 tank entity we created in the previous example:
1 2 | // We will turn the tanks engine on. MyPDU.GetEntityAppearance().GetAppearanceAsLandPlatform().SetEntityPowerPlantOn( true ); |
Dead Reckoning is used to provide an estimate of an entities position between PDU's. Using dead reckoning an entity can be given the appearance that it is moving smoothly in an environment. The dead reckoning values are used to predict where the entity will be within the foreseeable future.
Contained within the Dead Reckoning Parameter we have 3 values that allow us to customise the dead reckoning of our entity.
This is the algorithm that will be used to calculate the entities next position whilst we wait for the next update PDU.
The algorithms are represented using 3 letters:
DRM_X_Y_Z
There are 9 possible algorithms to choose from:
Algorithm Description
Static(0)
No movement
DRM_F_P_W(1)
Constant velocity (or low acceleration) linear motion
DRM_R_P_W(2)
Similar to F_P_W but where orientation is required (e.g. visual simulation)
DRM_R_V_W(3)
Similar to F_V_W but where orientation is required (e.g. visual simulation)
DRM_F_V_W(4)
High speed or manoeuvring at any speed (e.g. TBM, ICBM, SAM, SSM, and ASM weapons
DRM_F_P_B(5)
Similar to R_P_W but when body-centred calculation is preferred
DRM_R_P_B(6)
Similar to R_V_W but when body-centred calculation is preferred
DRM_R_V_B(7)
Similar to F_V_W but when body-centred calculation is preferred
DRM_F_V_B(8)
Similar to F_P_B but when body-centred calculation is preferred
1 | MyPDU.GetDeadReckoningParameter().SetDeadReckoningAlgorithm( DRM_F_P_W ); |
The linear acceleration of the entity in meters per second (m/s).
This parameter is required for some of the dead reckoning algorithms.
1 | MyPDU.GetDeadReckoningParameter().SetLinearAcceleration( Vector( 0.0f, 1.5f, 0.0f ) ); |
The angular velocity of the entity is required for some of the dead reckoning algorithms.
1 | MyPDU.GetDeadReckoningParameter().SetAngularVelocity( EulerAngles( 0.1f, 0.0f, 0.0f ) ); |
Please note that some of the dead reckoning algorithms also use the entity velocity and orientation to perform their calculations.
This is a collection of boolean flags to describe the capabilities of the entity.
You can add/remove the following capabilities:
If our entity was a fuel truck we would want to inform the simulation that it has a fuel supply.
1 | MyPDU.GetEntityCapabilities().SetHasFuelSupply( true ); |
<TBC>
The Entity Appearance portion of the wiki appears to be out of date. A EntityAppearance::GetGeneralAppearance() method is cited which does not appear to be in the current codebase. I was hoping to find a method that would easily allow checking of the "state" (bit 23) across a range of different entity types.
Ah yes. I removed the general and specific apearances last year. They were incorrect.
To do what you want I would suggest you just pick one of the specific ones and test aginast that as it will be using the same bit for all.
For example.
I will update the wiki example.
Thanks
Last edit: Karl Jones 2017-04-13
Mmmm, I'm sure I can do it that way but I'm not a fan of that approach. It would be confusing for anyone else picking up the code to determine why I was using a random specific record to perform a more general check.
I guess ideally there would be some kind of CheckAndTest() function. First, a Check using the EntityType record to determine whether a particular appearance code was relevant to the particular entity you were checking and next a Test to determine whether that particular code was set.
It sounds much easier than it probably is though.
Yeah its tricky ;)
When I looked at the general class last year I realised that several of the values were not actually shared and some were using different bits. So I had to get rid of the general approach.
You could also call GetData() and do a bit comparison on that if you dont want to grab a specific.
I thought about doing some error checking against the EntityType however that would require coupling the EntityAppearance class to the PDU and would require me to make some assumptions on how people are using it or what is and is not ok. It seemed messy.
Ill make a note to go back over the appearance and see If I bring some of it out into a general class again.
How about helper class (or a namespace with helper functions) instead to avoid tying the EntityAppearance and the EntityType together in the EntityAppearance class?
I also just noticed that there are not specific appearance classes for Supply, Radio, and Expendable, nor is the Lifeform class broken out into Human and Non-Human bits. I think some of these changes are based on the recent versions of the SISO-REF-10, version 22.