Bzw 2.0 Physics drivers howto

  • Bzw man page (external link)
  • Bzw 2.0 texturing howto
  • Bzw 2.0 Physics drivers howto
  • Bzw 2.0 3d transformations howto
  • Introduction to bzmap 2.0
  • Physics drivers

    Note: It is recommended to read my textures tutorial before this, since I'm not going to explain twice :)

    Physics drivers are objects that affect tanks. They are used with objects, and like textures, only new objects support them. From bzw man page:

    physics
    	name example_phydrv
    	linear  0.0 0.0 0.0  # x/y/z linear velocities
    	angular 0.0 0.0 0.0  # rotation freq, x/y coordinates
    	slide 0.0            # time until max velocity  (> 0.0 enables)
    	death Message goes here.
    	# the 'death' property requires a non-blank message
    end
    

    Death is simple - it kills the tank and gives specific message. Example:

    physics
    	name landmine
    	death Oops, you hit a mine
    end
    meshbox
    	position 0 0 0
    	size 10 10 5
    	phydrv landmine
    end
    

    Slide is simple, too. It reduces the friction of surface. Value specified determines time to reach full speed. If you set value of 1, it takes one second to reach maximum speed on surface. Slide feels like slippery ice and makes accurate shooting difficult.

    Linear motion

    Linear and angular make tank move. Linear motion can be used to make escalators, trampolines etc. Values given are motion in x/y/z. Usually, you want Z to be zero, so that it won't throw tank into air. Simple box with horizontal physics driver:

    physics
    	name moving
    	linear 10 0 0
    end
    meshbox
    	position 0 0 0
    	size 200 10 5
    	phydrv moving
    end
    

    Note that physics driver does not imply moving texture - we will do that later. What we just did was making physics driver, moving 10 units per second in x-axis direction, and applying it to meshbox 200 units long in x direction.

    Trampolines

    Setting Z axis motion to higher value than zero makes a trampoline. Example:

    physics
    	name trampoline
    	linear 0 0 50
    end
    meshbox
    	position 0 0 0
    	size 10 10 5
    	phydrv trampoline
    end
    

    Value defines the initial vertical velocity tank gets. You can calculate how high tank goes as follows:

    Height = ( velocity ^ 2 ) / ( 2 * gravity )
    
    Default gravity is 9.81, so in our example:
    
    Height = ( 50 ^ 2 ) / ( 2 * 9.81 ) = 2500 / 19.62 = ~ 127 units
    
    Note that it is relational to the height of the trampoline.
    

    Escalators

    Special type of linear motion are the escalators. When using physics drivers, you must notify that object rotation or spin don't affect them. If you want mirrored escalators, you must have two physic drivers. Escalators need both vertical and horizontal movement, and you must experiement a bit to have suitable values.

    physics
    	name escalator
    	linear 10 0 10
    end
    meshbox
    	size 100 10 5
    	spin -45 0 1 0 #spin -45 degrees around y-axis
    	shift 0 0 71 #shift is like position, but works better with spin.
    	phydrv escalator
    end
    

    You might need to move backwards a bit on the escalator to get up - this depends on how well the movement values fit together. To have nice looking escalators you should use shear (described in 3d transformations) so that the ends don't "stick" out of ground. Spin or mesh won't be described here.

    Angular movement

    After linear one, angular movement is simple.

    physics
    	name spin
    	angular 0.1 0 0
    end
    arc
    	position 0 0 0
    	size 50 50 5
    	phydrv spin
    end
    

    First of three values after angular-keyword tells the rotation speed per second. Second and third are the x/y position of center point. To get actual movement speed, use:

    Speed = Rotation * 2 * Distance from center * PI
    
    Pi is approximately 3.14159, and the speed on the outer edge in our example is:
    
    Speed = 0.1 * 2 * 50 * 3.14159 = ~ 31 units per second
    
    ©Petteri Aimonen 2005