Hi Future, I do this code... it´s based in your code.
The Code it´s attached, don´t care too much to read in these Lines.
// --------------------------------- //
// Project: xcollision
// Start: Thursday, June 14, 2012
// IDE Version: 10.283
// SETCURRENTDIR("Media") // go to media files
GLOBAL M_Hill = 100
GLOBAL Face[]
//X_LOADOBJ "Media/objX_ship_Interior_01.ddd", M_Hill
X_LOADOBJ "Media/Box001.ddd", M_Hill
GLOBAL MouseX,MouseY
GLOBAL b1,b2
WHILE TRUE
MOUSESTATE MouseX,MouseY,b1,b2
render()
//STATIC x,y,z, x2,y2,z2
LOCAL x,y,z, x2,y2,z2
X_SCREEN2WORLD MouseX, MouseY, 0, x, y, z
X_SCREEN2WORLD MouseX, MouseY, -1, x2,y2,z2
// DEBUG M_Hill+","+x+","+y+","+z+","+x2+","+y2+","+z2
// END
STATIC MouseCollisionFace
IF X_COLLISIONRAY(M_Hill, 0, x, y, z, x2-x, y2-y, z2-z)<>0
LOCAL color = RGB(255,0,0)
X_LINE x, y, z, x2-x, y2-y, z2-z, 2,color
MouseCollisionFace=X_GETCOLLISIONFACE() // div by 3 for x_getcollisionface bug, then divide by 2 to get the right triangle
X_GETFACE M_Hill, 0, MouseCollisionFace, Face[]
DEBUG "Collision = "+MouseCollisionFace+",X="+Face[0][0]+",Y="+Face[0][1]+",Z="+Face[0][2]+",nx="+Face[0][6]+",ny="+Face[0][7]+",nz="+Face[0][8]+"\n"
message_Screen()
ELSE
MouseCollisionFace=-1
ENDIF
SHOWSCREEN
WEND
FUNCTION render:
STATIC phi
X_MAKE3D 1,1000,45
X_CAMERA 0,0,40 , _
0,0, 0
IF phi<360
INC phi
ELSE
phi=0
ENDIF
X_MOVEMENT 0+(COS(phi)*100),0,-300
X_ROTATION phi,1,1,1
X_DRAWOBJ M_Hill,0
ENDFUNCTION
FUNCTION message_Screen:
X_MAKE2D
PRINT "Now Have collision" , 0 , 0
ENDFUNCTION
Have a little "more complex" collision becuase the object it´s moving... for me your code works fine, in Debug mode too, I only think in the local variables, I put in static , but I turn again to put in Local and works equal...
I think, but this it´s only a speculaton, perhaps the problem it´s the model, I don´t know if it´s a model from a 3D suite or it´s a runtime model... perhaps can be too the extension... I always use .ddd, and never have troubles...
You have attached the complete Code:
PS: Future only a think try to put in your code, when decalare the array for get the faces, try to put global and not in Local... and we see what´s happend