BBPro ver.1.069
I've created a function to push out the normals on an object to give it a cartoon like outline.
I had to negatively scale the object to achieve this, as for some reason I couldn't manipulate the normals using the vertexdata commands, so the object will be mirrored along every axis. The only way I can think to get around this is to edit the object file directly.
`Cartoon outline by The thing
`Note that the object is negatively scaled, so backface culling is off and the scale -100
`Standard setup
set display mode 1280,800,32,1
sync on
sync rate 0
autocam off
hide mouse
````````````Variables
`Set line thickness
thickness#=0.8
`The object you want outlined
object=1
`Specify a free object number for the outline
outline=6
`Specify a free mesh number, this will be used every time the function is called
mesh=1
`Setup scene
make object sphere 1,20
make object cube 2,20
make object cone 3,20
make object plain 7,200,200
rotate object 7,-90,0,0
position object 7,0,-20,0
position camera 0,5,-70
hide light 0
make light 1
set point light 1,15,80,-10
set light range 1,1000
`Call function
for object=1 to 3
toon_outline(object,object+3,thickness#,mesh)
next object
`For shadowing, turn off for performance gain
for object=1 to 3
set shadow shading on object,-1,1000,1
next object
lightmode=1
set shadow position lightmode,0,0,0
`Positioning the objects and their outlines
position object 1,0,0,0
position object 4,0,0,0
position object 2,40,0,0
position object 5,40,0,0
position object 3,-40,0,0
position object 6,-40,0,0
do
`Check if the mouse hits the edge
if mousex()=>361
position mouse 1,mousey()
endif
if mousey()=>361
position mouse mousex(),1
endif
if mousex()=0
position mouse 360,mousey()
endif
if mousey()=0
position mouse mousex(),360
endif
`rotate the normal object
for object=1 to 6
rotate object object,mousey(),mousex(),0
next object
sync
loop
function toon_outline(object_number,outline_object,thickness#,outline_mesh)
`Maske sure the normals are smoothed so that when the vertexs are "pushed" outwrds that they do not seperate.
set object normals object_number
set object smoothing object_number,100
set normalization on
make mesh from object outline_mesh,object_number
delete object object_number
`Rereate the orignal object
make object object_number,outline_mesh,0
scale object object_number,-100,-100,-100
set object cull object_number,0
`Push the vertexes outwards in the direction of their normals
lock vertexdata for mesh 1
for edit=0 to get vertexdata index count()
set vertexdata position edit,get vertexdata position x(edit)+(get vertexdata normals x(edit)*thickness#),get vertexdata position y(edit)+(get vertexdata normals y(edit)*thickness#),get vertexdata position z(edit)+(get vertexdata normals z(edit)*thickness#)
next edit
unlock vertexdata
`Create the outline object
make object outline_object,outline_mesh,0
scale object outline_object,-100,-100,-100
color object outline_object,rgb(0,0,0)
set object ambient outline_object,0
endfunction
The downloadable version uses a model to better example the effect.