|
Texture Swapping
Modified Animation
|
Texture swapping is a modified animation that assigns normal or damage textures to parts depending on the status of "event triggers."
Any CFS2 non-standard variable with the format [FLAGS] is a potential candidate for a trigger, but only parts_visible ... carries the flags specifying which parts of the model are visible.
| Name |
Mask |
Status |
| VISIBLE_RIGHTWING |
0001h |
If this bit is clear, the right wing is gone. |
| VISIBLE_LEFTWING |
0002h |
If this bit is clear, the left wing is gone. |
| VISIBLE_TAIL |
0004h |
If this bit is clear, the tail is gone. |
| VISIBLE_ALLOTHER |
0008h |
If this bit is clear, the rest of the aircraft is gone. |
| VISIBLE_ENDCAP_LEFT |
0010h |
If this bit is set, the left wing endcap is displayed. |
| VISIBLE_ENDCAP_RIGHT |
0020h |
If this bit is set, the right wing endcap is displayed. |
| VISIBLE_ENDCAP_TAIL |
0040h |
If this bit is set, the tail endcap is displayed. |
| VISIBLE_PILOT |
0080h |
If this bit is clear, the pilot is gone. |
| VISIBLE_LEFTWINGTIP |
0100h |
If this bit is clear, the left wing tip is gone. |
| VISIBLE_RIGHTWINGTIP |
0200h |
If this bit is clear, the right wing tip is gone. |
| VISIBLE_NOSE |
0800h |
If this bit is clear, the nose is gone. |
| VISIBLE_ENGINE0 |
1000h |
If this bit is clear, engine0 is gone. |
| VISIBLE_ENGINE1 |
2000h |
If this bit is clear, engine1 is gone. |
| VISIBLE_ENGINE2 |
4000h |
If this bit is clear, engine2 is gone. |
| VISIBLE_ENGINE3 |
8000h |
If this bit is clear, engine3 is gone. |
This variable is used by the MDL file to decide whether or not to render a particular part. If, for example, the nose is damaged to the point that the DP file triggers the "BREAK,6," event indicating the nose has "broken away" from the aircraft, CFS2 sets the bit for 0800h to 1. Now, when the MDL file tests the visibility of the nose, it sees the nose is not visible and so does not render that part (or any of its child parts). The model is then displayed without its nose.
In texture swapping, you make the same visibility test on the part, but instead of not drawing it, you assign a damage texture to the part and draw it anyway. The result is a part that remains in place, but now shows its "skin damage" texture instead of just disappearing from view.
Template Original SCA Code Edited SCA Code
Note that a part set up to swap textures is always drawn, unlike a normal break away part, which is drawn only if the part has not been flagged to break away.
90 - hex offset to the variable parts_visible.
MASK - hex mask used in the test of parts_visible.
SetMaterial( 0 t ) - Sets the normal texture "texture_t.bmp."
SetMaterial( 0 t ) - Sets the damage texture "texture_d.bmp."
; Part: PARTNAME
:PARTLABEL
IfVarAnd( :DAMAGE_PARTLABEL 90 MASK )
SetMaterial( 0 t )
Jump( :DrawPARTNAME )
:DAMAGE_PARTLABEL
SetMaterial( 0 t )
:DrawPARTNAME
Transform_Mat(
0.000000 0.000000 0.000000
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
)
DrawTriList( index ... vertex indices ... )
TransformEnd
Return
Original SCA Code Template Edited SCA Code
This is the original object source code for texture swapping on the nose section generated by FSDS Pro v2.33 from fxpaint.fsc.
; Part: nose
:Part000010
Transform_Mat(
0.000000 0.000000 789.495422
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
)
SetMaterial( 0 -1 )
DrawTriList( 264
0 1 2
0 2 3
0 3 4
0 4 5
0 5 6
0 6 7
0 7 8
0 8 9
0 9 10
0 10 11
12 13 14
12 14 15
12 15 16
12 16 17
12 17 18
12 18 19
12 19 20
12 20 21
12 21 22
12 22 23
)
SetMaterial( 0 0 )
DrawTriList( 264
28 29 30
29 31 32
29 32 33
29 33 30
31 34 35
31 35 36
31 36 30
31 30 33
31 33 32
34 37 30
34 30 36
34 36 35
37 38 30
38 39 30
40 41 42
41 43 42
43 44 42
44 45 42
45 46 42
46 47 42
36 33 32
36 32 35
48 49 50
49 51 52
49 52 53
49 53 50
51 54 55
51 55 56
51 56 50
51 50 53
51 53 52
54 57 50
54 50 56
54 56 55
57 58 50
58 59 50
60 61 62
61 63 62
63 64 62
64 65 62
65 66 62
66 67 62
24 25 26
24 26 27
)
Call32( :Part000011 ) ;bullet hole
Call32( :Part000012 ) ;bullet hole
Call32( :Part000082 ) ;prop_still
Call32( :Part000083 ) ;prop_slow
Call32( :Part000084 ) ;prop_blurred
TransformEnd
Return
Edited SCA Code Template Original SCA Code
This is the edited object source code that displays the nose damage texture in fxpaint.mdl once the DP file triggers the "BREAK,6," event to indicate the nose should "break away."
NOTE
 |
The part you are swapping textures for may have non-textured polygons. This is indicated by the SetMaterial( 0 -1 ) command preceding a DrawTriList( ... ) command (see Original SCA code above). This "non-textured" part must be moved to the end of the part drawing code. Also, be sure to remove any other SetMaterial( ... ) commands following the TransformMat( ... ) command, or your texture swap will not occur.
| |
; Part: nose
:Part000010
IfVarAnd( :DAMAGE_Nose 90 0x0800 )
SetMaterial( 0 0 )
Jump( :DrawNose )
:DAMAGE_Nose
SetMaterial( 0 2 )
:DrawNose
Transform_Mat(
0.000000 0.000000 789.495422
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
)
DrawTriList( 264
28 29 30
29 31 32
29 32 33
29 33 30
31 34 35
31 35 36
31 36 30
31 30 33
31 33 32
34 37 30
34 30 36
34 36 35
37 38 30
38 39 30
40 41 42
41 43 42
43 44 42
44 45 42
45 46 42
46 47 42
36 33 32
36 32 35
48 49 50
49 51 52
49 52 53
49 53 50
51 54 55
51 55 56
51 56 50
51 50 53
51 53 52
54 57 50
54 50 56
54 56 55
57 58 50
58 59 50
60 61 62
61 63 62
63 64 62
64 65 62
65 66 62
66 67 62
24 25 26
24 26 27
)
SetMaterial( 0 -1 )
DrawTriList( 264
0 1 2
0 2 3
0 3 4
0 4 5
0 5 6
0 6 7
0 7 8
0 8 9
0 9 10
0 10 11
12 13 14
12 14 15
12 15 16
12 16 17
12 17 18
12 18 19
12 19 20
12 20 21
12 21 22
12 22 23
)
Call32( :Part000011 ) ;bullet hole
Call32( :Part000012 ) ;bullet hole
Call32( :Part000082 ) ;prop_still
Call32( :Part000083 ) ;prop_slow
Call32( :Part000084 ) ;prop_blurred
TransformEnd
Return
|