Rotate to user (ASM tweak)

From FSDeveloper Wiki
Jump to: navigation, search


This article describes how you can tweak the ASM source code to let an object rotate to the viewpoint to the user. This can be useful to make for example a tree out of a single plane that always faces the viewpoint. Below you find two section that describe how to perform this tweak for the Fs2002 and the Fs2004 gamepack.

Please note that the tweak as described here applies to your total GMax scene and the rotation is done around the 0,0 point.

Fs2002 gamepack

Find the line as indicated below where the BGL_CALL command is:

SCALE_AGL OBJECT_0_RETURN, 10000, 126, 131072, 00043D426h, 038E4h, 0E38E38E3h, 08E39h, 0, 0
BGL_CALL OBJECT_0_BEGIN
OBJECT_0_RETURN label word

If you have added a rotation to your object during export it could also be that the BGL_CALL command is replaced by an INSTANCE_CALL command. But that does not matter for this tweak, you still need to replace that line with the one given below.

SCALE_AGL OBJECT_0_RETURN, 10000, 126, 131072, 00043D426h, 038E4h, 0E38E38E3h, 08E39h, 0, 0
SPRITE_VICALL OBJECT_0_BEGIN, 0, 0, 0, 0, 0, 0, 0, 1, 0
OBJECT_0_RETURN label word

Fs2004 gamepack

For the Fs2004 gamepack you need to find the BGL_CALL_32 command that calls your MasterScale label in the BGL section of your ASM file. This code looks something like this:

; NonAlpha
test_NonAlpha label BGLCODE
BGL_CALL_32 test_MasterScale_1
BGL_END
BGL_RETURN

Then replace the BGL_CALL_32 command with the SPRITE_VICALL command as shown below:

; NonAlpha
test_NonAlpha label BGLCODE
SPRITE_VICALL test_MasterScale_1, 0, 0, 0, 0, 0, 0, 0, 1, 0
BGL_END
BGL_RETURN

Please note that the labels can have slightly different names in your source file. These depend on the name of your project, in my case that was test. Also note that you need the Fs2004 version of BGLC (BGLC_9) to be able to compile the source without errors.

There is one last limitation of this tweak. When you place a tweak MDL object you always need to use heading zero, else the object will get an additional rotation and you are no longer looking at the front side of it all the time. For a heading of 180 for example, this could even mean that you see nothing at all.