ohh sorry ...
ok this is what i have.
i have a mouse pointer as a sprite that is becouse i have also a 2d sprite base top and side menu so i use the same cursor for drawing and selecting a button a 2d button.
then i have a 3d object plane with a texture that takes a renderToimage texture. when i press the mouse button and only when the cursor throws a 3d ray cast from its position and hit the 3d object plane it starts drawing inside the RenderToImage then the 3d plane object updates its own texture with the rendertoimage id.
so what im trying to do is:
where ever the 3d raycast hits it should paint in that location of the image.
so if im clicking and the raycast shows your on x150 y 100 you take those vars and you turn them into Screen Coords and now when you paint it will paint exactly where the raycast hit.
the problem im facing is:
diffrent Virtual Resolutions
diffrent Device Resolutions
diffrent RenderToImage resolution
and
diffrent 3d object plane sizes
i know its tricky , here is a simple code of what im talking about.
SetWindowTitle( "3dimagetest" )
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
rImg = CreateRenderImage(1024,1024,0,0)
rOBj = CreateObjectPlane(100,100)
dSpr = CreateSprite(0)
bSpr = CreateSprite(0)
SetSpriteSize(dSpr,15,15)
SetSpriteSize(bSpr,1024,768)
SetspriteColor(bSpr,0,255,0,255)
SetSpriteDepth(bSpr,9999)
MoveCameraLocalZ(1,-150)
SetObjectLookAt(rObj,GetCameraX(1),GetCameraY(1),GetCameraZ(1),0)
global hit3d as integer
do
px# = GetPointerX()
py# = GetPointerY()
ps = GetPointerState()
SetSpritePositionByOffset(dspr,px#,py#)
hit3d = 1
/*
x1# = 100*Get3DVectorXFromScreen(px#,py#)+GetCameraX(1)
y1# = 100*Get3DVectorYFromScreen(px#,py#)+GetCameraY(1)
z1# = 100*Get3DVectorZFromScreen(px#,py#)+GetcameraZ(1)
ObjectRayCast(0,GetCameraX(1),GetcameraY(1),GetCameraZ(1),x1#,y1#,z1#)
hit3d = GetObjectRayCastHitID(0)
*/
SetSpriteVisible(dspr,0)
SetOBjectVisible(rObj,0)
SetSpriteVisible(bSpr,1)
SetRenderToImage(rImg,0)
ClearScreen()
if ps= 1
if hit3d > 0
SetSpriteColor(dspr,255,0,0,255)
SetSpriteVisible(dspr,1)
DrawSprite(dSpr)
/*
newx# = GetObjectRayCastX(0)
newY# = GetObjectRayCasty(0)
newZ# = GETObjectRayCastZ(0)
*/
//a = CreateObjectBox(10,10,10)
//SetOBjectPosition(a,newX#,newY#,newZ#-1)
//SetObjectColor(a,random(1,255),random(1,255),random(1,255),0)
endif
//SetSpriteVisible(dspr,0)
endif
render()
SetRenderToScreen()
SetSpriteVisible(bSpr,0)
SetOBjectImage(rObj,rImg,0)
SetSpriteVisible(dspr,1)
SetSpriteColor(dspr,0,0,255,255)
drawSprite(dspr)
SetOBjectVisible(rObj,1)
render()
swap()
loop
for some reason the 3d ray cast dosent work very well.. in other projects it does... dont know what happend to it..
any help will be highly appreciated.
thank you for your time.
haliop.