Creating a KCL with Wiimms Tools/Script Example

From Custom Mario Kart
Jump to navigation Jump to search

The tool wkclt, part of Wiimms SZS Tools, can execute scripts to modify the faces (triangles), remove them or to add new faces. On this page you find a little collection of script examples.



Item jump over choropu dirt

Related track
DS Luigi's Mansion (zilly)
Problem
If a shell touches the choropu[1] dirt (trace of the moving trees), it is disintegrated. That's bad for the gameplay.
Solution
Create little bridges for items only by inserting faces with KCL type 0x09.
The script
# Statistics (only a gimmick to show, how fast the script work)
@def start	= uSec()	# start time, for the status line
@def n_tri	= tri$n()	# number of triangles

#--------------------------------------------------
# Here we define a macro

@macro itemjump
    # The macro expects 2 points as parameters
    @param a1, a2

    # make the line 20% longer on each side
    @pdef b1 = pos(-0.2,a1,a2)
    @pdef b2 = pos( 1.2,a1,a2)

    # calculate a delta value:
    #   hrot() calculates the horizontal direction.
    #   sub 90 degree.
    #   vz(500) creates a vector with z length of 500
    #   hRot() rotates the vector horizontally by the above calculated angle
    @pdef delta = hRot(vz(500),hDir(a1,a2)-90)

    # setup the 6 points for the 2 rectangles
    @pdef p1 = b1 - vy(200) - delta
    @pdef p2 = b2 - vy(200) - delta
    @pdef p3 = b1 + vy(300)
    @pdef p4 = b2 + vy(300)
    @pdef p5 = b1 - vy(200) + delta
    @pdef p6 = b2 - vy(200) + delta
    
    # draw rectangles with flag 0x09
    @pdef stat = tri$create(0x09,p2,p1,p3,p4)
    @pdef stat = tri$create(0x09,p4,p3,p5,p6)

@endmacro

#--------------------------------------------------
# Call the macro for all 4 choropu routes.
# The points are copies of end points of the choropu routes, found in KMP/POTI.

@:itemjump( v( -13623, 1403,   510 ), v( -14563, 1403, -2067 ) )
@:itemjump( v( -12303, 1403, 16108 ), v( -12532, 1403, 18858 ) )
@:itemjump( v(   2499, 1403, 13931 ), v(   3270, 1403, 16566 ) )
@:itemjump( v(  15809, 1403, 28372 ), v(  15251, 1403, 31058 ) )

#--------------------------------------------------
# Print out the statistics

@echo (tri$n()-n_tri) " triangles added in " (uSec()-start) " µsec."
Command to call
wkclt encode orig.kcl -od course.kcl --kcl-script item-jump.script

Links

Wiiki
References
  1. Wiimms Object Query: Object choropu