Bzw 2.0 3d transformations 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
  • Changes

    In version 1.10.8 and older bzflag, objects position, rotation and size where defined by, logically, position, rotation and size keywords. When 2.0 introduced 3d rotation, this had to change. Position and rotation have been obsoleted by their superiors, shift and spin. Size could be replaced with scale, but there is no need for that on traditional objects (mesh are a bit different).

    box
    	position 50 100 0
    	size 20 20 5
    	rotation 45
    end
    
    can now be written:
    
    meshbox
    	size 20 20 5
    	spin 45 0 0 1
    	shift 50 100 0
    end
    

    All keywords are order-specific. If you do shift before spin, it will still spin the object around 0 0 0, moving it somewhere else than what it was ment to.

    Effects if you spin after shift

    Spin

    Spin can be used to rotate object around a specific axis. First value after spin-keyword is rotation in degrees. Axis is a line, defined by two points. Other one is always 0 0 0, other one is defined by the three values after rotation. It is usually simple to think rotation around the standard axises. They are defined as:

  • X-axis eg. spin 45 1 0 0
  • Y-axis eg. spin 45 0 1 0
  • Z-axis, normal rotation, eg. spin 45 0 0 1
  • You can spin around any axis, diagonal or anything. Anyway, all rotations can be made by rotating around standard axises, and they are usually most simple to think of.

    Axis of spinning

    Shifting

    Shifting means moving the object. It is used in same manner as old position-keyword. Without position-keyword, object is placed around 0 0 0. When shift moves it from origo, coordinates are just like with position. However, shift is repeatable, and sequent moves will use last point as origo.

    Multiple shifts

    Shearing

    Shearing is, as ibot knows, "a deformation of an object in which parallel planes remain parallel but are shifted in a direction parallel to themselves." If you don't understand, look at the image below. In next example, we use shear to make an escalator with nice ends.

    physics
    	name escalator
    	linear 15 0 15
    end
    meshbox
    	size 10 10 100
    	shear 2 0 0
    	phydrv escalator
    end
    

    The three values after shear-keyword define a vector. Vectors lenght represents change per Z-axis unit. If you have 10 units high meshbox, and shear it by 1 0 0, top will move 10 * 1 away from the bottom in X-axis direction.

    meshbox
    	size 10 10 10
    	shear 1 0 0
    end
    
    Would be like:
    
    Shearing

    Scaling

    Scale is simple. It scales object by specific amount. It is useful mostly with groups and meshes. Attention must be paid to order - If you shift before scale, scale will scale the distance from origo too. Example:

    define MyBox
    	meshbox  # Really complicated box - we don't want to type this more than once
    		size 5 5 10 
    		# We could have phydrv, matref etc. here.
    	end
    enddef
    
    group MyBox
    	scale 2 2 2 # Double the size, 10 10 20
    	shift -50 0 0 # Our box was around 0 0 0, so this translates to position -50 0 0
    end
    
    group MyBox
    	# No shift - position is 0 0 0
    	# No scale - defined size ( 5 5 10 )
    end
    
    group MyBox
    	scale 0.5 0.5 0.5 # Half the size, 2.5 2.5 5
    	shift 50 0 0 # Position 50 0 0
    end # Nice line of boxes is ready.
    
    group MyBox
    	shift 0 50 0 # Notice order
    	scale 2 2 2 # This goes much farther than others, because 50 * 2 = 100
    end
    
    ©Petteri Aimonen 2005