Okay. Not gonna argue with you, so lets just drop the whole thread bump even though I waited more then 48 hours and spent those days browsing for answers.
Here is what I thought my code was doing.
Make an image
Enter image into memblock
Make an object
apply image after altering by:
Gather UV Data via Vertexdata and scale to the image width and height
Scale the Pick vectors (X and Z) to match the image width and height
Report the pixel being edited
Change the color (eventually paint a texture)
Unlock the vertexdata
Make the image from memblock
Delete the memblock.
It is exactly the same as the above, minus the advanced terrain.
Is the error in the pick command usage I have posted in the code above, or is it relative to the uv usage in vertexdata. Did I make a mathematical error? I don't know. I look at it, I run it - it works but it doesn't... So confused...
Oh...
global Dist# as float
Global Object as integer
Global PX# as float
Global PY# as float
Global PZ# as float
for a=0 to 256
for b=0 to 256
dot a,b,RGB(rnd(255), Rnd(255), Rnd(255))
NEXT
NEXT
GET IMAGE 1, 0,0,256,256
MAKE MEMBLOCK FROM IMAGE 1, 1
cls 0
SYNC ON : SYNC RATE 0
Size=Get memblock size(1)
sync
cls 0
text 10,10, "The memblock's size is : "+Str$(Size)
text 10, 25, "Press any key to check"
sync
WAIT KEY
For Check = 12 to size-12 step 4
PixelX=((check-8)/4)/IMAGE WIDTH(1)
PixelY=((check-8)/4)/IMAGE Height(1)
NEXT
sync
MAKE OBJECT PLAIN 1, 1000, 1000
ROTATE OBJECT 1, 90, 180, 180
COLOR BACKDROP 0
TEXTURE OBJECT 1, 1
AUTOCAM OFF
SET CAMERA RANGE 0.001, 1000
position camera 500, 300, 0
POINT CAMERA 0,0,0
do
sync
Color=Rnd(255)
if mouseclick()=1
DivX#=(Object Size X(1)/IMAGE WIDTH(1))
DivY#=(Object Size Z(1)/IMAGE HEIGHT(1))
for U#=0.0 to 1.0 step 0.125
For V#=0.0 to 1.0 step 0.125
Obj=location()
if Obj>0
X=Convert3dto2dX(1,1,U#, V#, -PX#)
Y=Convert3dto2dZ(1,1,U#, V#, PZ#)
Paint(1, 1, 1, Color,0,0, X, Y)
endif
if escapekey()=1 then end
If Mouseclick()=0 then exit
NEXT V#
NEXT U#
endif
If Obj>0
Handle$=Report3D()
HandleB$=Report2D(1, 1, int(U#), int(V#))
Text mouseX(), mouseY(), Handle$
Text mouseX(), mouseY()+10, HandleB$
TEXT mouseX(), MouseY()+20, "UV locations are: U= "+Str$((U#))+ ", V= "+Str$((V#))
endif
LOOP
end
function location()
Dist#=Get pick Distance()
Object=Pick object(MouseX(), MouseY(), 1, 1)
PX#=Get pick Vector X()+Camera Position X()
PY#=Get pick Vector Y()+Camera Position Y()
PZ#=Get pick Vector Z()+Camera Position Z()
ENDFUNCTION Object
Function Report3D()
Answer$="The current position in 3D - X= "+Str$(int(PX#))+", Y= "+Str$(int(PY#))+", Z= "+Str$(int(PZ#))
ENDFUNCTION Answer$
Function Report2D(ImgNum, ObjNum, U, V)
ScaleX#=Get2DscaleX(ImgNum, ObjNum)
ScaleY#=Get2DscaleY(ImgNum, ObjNum)
Answer$="The current position in 2D - X= "+Str$((int(PX#/ScaleX#)+IMAGE WIDTH(imgnum)/2))+", Y= "+Str$((int(PZ#/ScaleY#)+IMAGE HEIGHT(imgnum)/2))
ENDFUNCTION Answer$
function Convert3dto2dX(ImgNum, ObjNum, U, V, PickX# as float)
ScaleX#=Get2DscaleX(ImgNum, ObjNum)
X=(int(PICKX#/ScaleX#)+IMAGE WIDTH(imgnum)/2)
ENDFUNCTION X
function Convert3dto2dZ(ImgNum, ObjNum, U, V, PickZ# as float)
ScaleZ#=Get2DscaleY(ImgNum, ObjNum)
Y=(int(PICKZ#/ScaleZ#)+IMAGE HEIGHT(imgnum)/2)
ENDFUNCTION Y
Function Get2DscaleX(ImgNum, ObjNum)
Scale#=(Object Size X(ObjNum)/IMAGE WIDTH(ImgNum))
ENDFUNCTION Scale#
Function Get2DscaleY(ImgNum, ObjNum)
Scale#=(Object Size y(ObjNum)/IMAGE HEIGHT(ImgNum))
ENDFUNCTION Scale#
function paint(memblock, imgnum, ObjNum, Red, Green, Blue, CursorX, CursorY)
For X=0 to image width(imgnum)-1
For y=0 to image height(imgnum)-1
MemLoc=(IMAGE WIDTH(imgnum)*y+x)*4+12
D#=Distance2D(CursorX, CursorY, X, y)
if D#<10
write memblock byte memblock, Memloc + 0, Blue
write memblock byte memblock, Memloc + 1, Green
write memblock byte memblock, Memloc + 2, Red
write memblock byte memblock, memloc + 3, 128
ENDIF
NEXT y
NEXT x
If IMAGE EXIST(imgnum)=1
DELETE IMAGE imgnum
MAKE IMAGE FROM MEMBLOCK imgnum, memblock
TEXTURE OBJECT objnum, imgnum
sync
ENDIF
ENDFUNCTION
function Distance2D(X1, Y1, X2, Y2)
if VECTOR EXIST(1)=0
temp=MAKE VECTOR2(1)
ENDIF
SET VECTOR2 1, X2-X1, Y2-Y1
Distance#=LENGTH VECTOR2(1)
ENDFUNCTION Distance#
Turns out I had parenthesis in the wrong spot in the equation. But, this doesn't solve my problem. I need to figure out how to make the location of the pixel static with the object - so that a uv loop isn't used like the one I currently am.
EDIT2: Again... an edit... much smoother.
global Dist# as float
Global Object as integer
Global PX# as float
Global PY# as float
Global PZ# as float
for a=0 to 256
for b=0 to 256
dot a,b,RGB(rnd(255), Rnd(255), Rnd(255))
NEXT
NEXT
GET IMAGE 1, 0,0,256,256
MAKE MEMBLOCK FROM IMAGE 1, 1
cls 0
SYNC ON : SYNC RATE 0
Size=Get memblock size(1)
sync
cls 0
text 10,10, "The memblock's size is : "+Str$(Size)
text 10, 25, "Press any key to check"
sync
WAIT KEY
For Check = 12 to size-12 step 4
PixelX=((check-8)/4)/IMAGE WIDTH(1)
PixelY=((check-8)/4)/IMAGE Height(1)
NEXT
sync
MAKE OBJECT PLAIN 1, 1000, 1000
ROTATE OBJECT 1, 90, 180, 180
COLOR BACKDROP 0
TEXTURE OBJECT 1, 1
AUTOCAM OFF
SET CAMERA RANGE 0.001, 1000
position camera 500, 300, 0
POINT CAMERA 0,0,0
do
sync
Color=Rnd(255)
DivX#=(Object Size X(1)/IMAGE WIDTH(1))
DivY#=(Object Size Z(1)/IMAGE HEIGHT(1))
if mouseclick()=1
Obj=location()
if Obj>0
X=Convert3dto2dX(1,1, -PX#)
Y=Convert3dto2dZ(1,1, PZ#)
Size#=10.0+Brush(1.0)
Paint(1, 1, 1, Color,0,0, X, Y, Size#)
endif
sync
endif
If Obj>0
Handle$=Report3D()
HandleB$=Report2D(1, 1, int(U#), int(V#))
Text mouseX(), mouseY(), Handle$
Text mouseX(), mouseY()+10, HandleB$
TEXT mouseX(), MouseY()+20, "UV locations are: U= "+Str$((U#))+ ", V= "+Str$((V#))
endif
LOOP
end
function location()
Dist#=Get pick Distance()
Object=Pick object(MouseX(), MouseY(), 1, 1)
PX#=Get pick Vector X()+Camera Position X()
PY#=Get pick Vector Y()+Camera Position Y()
PZ#=Get pick Vector Z()+Camera Position Z()
ENDFUNCTION Object
Function Report3D()
Answer$="The current position in 3D - X= "+Str$(int(PX#))+", Y= "+Str$(int(PY#))+", Z= "+Str$(int(PZ#))
ENDFUNCTION Answer$
Function Report2D(ImgNum, ObjNum, U, V)
ScaleX#=Get2DscaleX(ImgNum, ObjNum)
ScaleY#=Get2DscaleY(ImgNum, ObjNum)
Answer$="The current position in 2D - X= "+Str$((int(PX#/ScaleX#)+IMAGE WIDTH(imgnum)/2))+", Y= "+Str$((int(PZ#/ScaleY#)+IMAGE HEIGHT(imgnum)/2))
ENDFUNCTION Answer$
function Convert3dto2dX(ImgNum, ObjNum, PickX# as float)
ScaleX#=Get2DscaleX(ImgNum, ObjNum)
X=(int(PICKX#/ScaleX#)+IMAGE WIDTH(imgnum)/2)
ENDFUNCTION X
function Convert3dto2dZ(ImgNum, ObjNum, PickZ# as float)
ScaleZ#=Get2DscaleY(ImgNum, ObjNum)
Y=(int(PICKZ#/ScaleZ#)+IMAGE HEIGHT(imgnum)/2)
ENDFUNCTION Y
Function Get2DscaleX(ImgNum, ObjNum)
Scale#=(Object Size X(ObjNum)/IMAGE WIDTH(ImgNum))
ENDFUNCTION Scale#
Function Get2DscaleY(ImgNum, ObjNum)
Scale#=(Object Size y(ObjNum)/IMAGE HEIGHT(ImgNum))
ENDFUNCTION Scale#
function paint(memblock, imgnum, ObjNum, Red, Green, Blue, CursorX, CursorY, Size#)
For X=0 to image width(imgnum)-1
For y=0 to image height(imgnum)-1
MemLoc=(IMAGE WIDTH(imgnum)*y+x)*4+12
D#=Distance2D(CursorX, CursorY, X, y)
if D#<Size#
write memblock byte memblock, Memloc + 0, Blue
write memblock byte memblock, Memloc + 1, Green
write memblock byte memblock, Memloc + 2, Red
write memblock byte memblock, memloc + 3, 128
ENDIF
NEXT y
NEXT x
If IMAGE EXIST(imgnum)=1
DELETE IMAGE imgnum
MAKE IMAGE FROM MEMBLOCK imgnum, memblock
TEXTURE OBJECT objnum, imgnum
ENDIF
ENDFUNCTION
Function Brush(Speed)
Newmousez = MousemoveZ()
If oldmousez <> newmousez
If oldmousez < newmousez
mousezz=speed
endif
If oldmousez > newmousez
mousezz=-speed
endif
Oldmousez=Mousemovez()
Mousezz=0
endif
ENDFUNCTION Mousezz
function Distance2D(X1, Y1, X2, Y2)
if VECTOR EXIST(1)=0
temp=MAKE VECTOR2(1)
ENDIF
SET VECTOR2 1, X2-X1, Y2-Y1
Distance#=LENGTH VECTOR2(1)
ENDFUNCTION Distance#
Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
