I shouldn't of used the word scale and specifically said size at creation meaning whatever size I created the plane but that's a good point, scaling will need to be added, thanks for the reminder
Okie dokie, your correction has corrected the code

awesome and thanks. I can see how this really works now and what else I could use this for cause at the mo I was only going to use it for surfaces guilds, mesh manipulation and etc...
Also has an alternative use, you can easily find the UV's of the plane by doing and XY distance check, makes interaction with a flat plane simple. Though looking at the code now, I'm thinking there might be other ways to work out UV's specifically on a plain. Since we know how big the object is and where each vert is we don't need to check each triangle. Just need to project a point onto that plane... I think (I will look into this)
Anyway example:
Code needs IanM's Matrix Plugin
// setup scene
sync on : sync rate 0 : sync
autocam off
local planeWidth as float
local planeHeight as float
planeWidth = 2
planeHeight = 2
make object plane 1, planeWidth, planeHeight, 1
position object 1,0,0,3
rotate object 1,0,0,0
set object light 1,0
SC_setupComplexObject 1 , 0 , 2
imageWidth = 128
imageHeight = 128
make image 1, imageWidth, imageHeight
texture object 1, 0, 1
vCamPos = new vector3()
_rotationMat = new matrix4()
_transMat = new matrix4()
_worldMat = new matrix4()
do
rotate object 1, 0, 0, object angle z(1)+.2
SC_updateObject 1
// populate globals
set vector3 vCamPos, camera position x(), camera position y(), camera position z()
// raycast from mouse
pick screen mousex(), mousey(), 64
x# = get pick vector x() + x vector3(vCamPos)
y# = get pick vector y() + y vector3(vCamPos)
z# = get pick vector z() + z vector3(vCamPos)
vRayPos = new vector3( x#, y#, z# )
rayCollision = vector3_rayCast( vCamPos, vRayPos )
delete vector3 vRayPos
// update collision
if rayCollision
// build world limb matrix
rotate xyz matrix4 _rotationMat, degToRad(object angle x(1)), degToRad(object angle y(1)), degToRad(object angle z(1))
translate matrix4 _transMat, object position x(1), object position y(1), object position z(1)
multiply matrix4 _worldMat, _rotationMat, _transMat
// collision point
p = new vector3( SC_getStaticCollisionX(), SC_getStaticCollisionY(), SC_getStaticCollisionZ() )
// work out X distance
v1 = new vector3( -planeWidth/2, planeHeight/2, 0 )
transform coords vector3 v1, v1, _worldMat
v2 = new vector3( -planeWidth/2, -planeHeight/2, 0 )
transform coords vector3 v2, v2, _worldMat
b = new vector3() : subtract vector3 b, p, v1
a = new vector3() : subtract vector3 a, v2, v1
x# = dot product vector3( b, a ) / ( length vector3(a)^2 ) * x vector3(a)
y# = dot product vector3( b, a ) / ( length vector3(a)^2 ) * y vector3(a)
z# = dot product vector3( b, a ) / ( length vector3(a)^2 ) * z vector3(a)
set vector3 b, x#, y#, z#
v3 = new vector3() : add vector3 v3, v1, b : subtract vector3 v3, v3, p
U = int( imageWidth * ( length vector3(v3) / planeWidth) )
// probably don't need to delete them but this is just test work
delete vector3 v1
delete vector3 v2
delete vector3 v3
delete vector3 b
delete vector3 a
// work out Y distance
v1 = new vector3( -planeWidth/2, planeHeight/2, 0 )
transform coords vector3 v1, v1, _worldMat
v2 = new vector3( planeWidth/2, planeHeight/2, 0 )
transform coords vector3 v2, v2, _worldMat
b = new vector3() : subtract vector3 b, p, v1
a = new vector3() : subtract vector3 a, v2, v1
x# = dot product vector3( b, a ) / ( length vector3(a)^2 ) * x vector3(a)
y# = dot product vector3( b, a ) / ( length vector3(a)^2 ) * y vector3(a)
z# = dot product vector3( b, a ) / ( length vector3(a)^2 ) * z vector3(a)
set vector3 b, x#, y#, z#
v3 = new vector3() : add vector3 v3, v1, b : subtract vector3 v3, v3, p
V = int( imageHeight * ( length vector3(v3) / planeHeight) )
if mouseclick()
draw to image 1
box U,V,U+1,V+1
draw to bitmap 0
endif
delete vector3 v1
delete vector3 v2
delete vector3 v3
delete vector3 b
delete vector3 a
delete vector3 p
endif
text 0,0,"hold mouse button to draw"
sleep 1
sync
loop
// SC Wrappers
function vector3_rayCast( v0, v1 )
out = SC_rayCast( 0, x vector3(v0), y vector3(v0), z vector3(v0), x vector3(v1), y vector3(v1), z vector3(v1), 0)
endfunction out
"Get in the Van!" - Van B