Hi there
I've seen lot of people asking this question. Some time ago, I made some little 3D programs for my purposes . I took part of the vertex selecction system to show how we can do that .I hope this can be useful for some friends .
`some texture
ink rgb(0,100,0),0
box 0,0,100,100
ink rgb(100,100,0)
box 30,30,70,70
ink rgb(255,0,0),0
set cursor 0,45 :print "CHAFARI"
get image 1,0,0,100,100,1
autocam off
sync on
`FIRST OF ALL WE CREATE THE VERTEX ...AT THE MOMENT JUST 999 (YOU MUST ADJUST THIS PART)
for i= 1 to 999
make object sphere i,3,3,3:
position object i,10000,0,0
next
`WE CAN LOAD OUR OBJECT, BUT FOR THIS EXAMPLE WE MAKE NORMAL PRIMITIVES
`WE MAKE SOME DIFFERENT MESHES
make object sphere 1000,50,10,10
set object wireframe 1000,1
color object 1000,rgb(0,255,0)
make mesh from object 1000,1000
make object cylinder 1001,50 :make mesh from object 1001,1001:delete object 1001
make object box 1002,40,40,40 :make mesh from object 1002,1002:delete object 1002
make object cone 1003,50 :make mesh from object 1003,1003:delete object 1003
position camera 0,0,-350
point camera 0,0,0
`OBJETS IN THE SCENE
make object box 3000,50,50,50:position object 3000,-30,-100,0
make object sphere 3001,50,10,10 :position object 3001,60,-100,0
make object cone 3002,50 :position object 3002,150,-100,0
make object cylinder 3003,50:set object cull 3003,0:position object 3003,-120,-100,0
ob=1001
dim selec(999)
mesh=1000
gosub reset
do
ink rgb(255,255,0)
set cursor 0,0
print "Select object with mouse to change shape"
print "Press Controlkey to create a copy of the object"
print "Select vertex with mouse and move them with arrowkeys"
print "Press SPACEKEY to save a copy of your object in .x"
`salecting primitives to make a mesh from ...and changing the original object mesh (this is just to see how the program works )
obt=pick object(mousex(),mousey(),3000,3500)
if obt>0 and mouseclick() then make mesh from object mesh,obt:gosub reset
`create a copy to show in screen
if controlkey()=1 then clone object ob,1000 :texture object ob,1:position object ob,-120+rnd(300),50,20 :set object wireframe ob,0:inc ob: sleep 300
`saving a copy to test
if ob>1001 and spacekey()
make mesh from object 300,ob-1:
save mesh "My_object.x",300
sleep 500
endif
if mouseclick()
r=r+1
if r=1
mx=mousex()
my=mousey()
endif
line mx,my,mousex(),my
line mx,my,mx,mousey()
line mx,mousey(),mousex(),mousey()
line mousex(),mousey(),mousex(),my
else
r=0
endif
lock vertexdata for limb 1000,0
v = get vertexdata vertex count()
for i = 1 to v
x# = object position x(i)
y# = object position y(i)
z# = object position z(i)
set vertexdata position i-1,x#,y#,z#
next i
unlock vertexdata
`colouring vertex into selecction box
for i= 1 to v
if mouseclick()
set object emissive i,rgb(20,20,20) :selec(i)=0 `reset vertex
if object screen x(i)>mx and object screen y(i)>my and object screen x(i)<mousex() and object screen y(i)< mousey()
color object i,rgb(255,0,0)
selec(i)=1
else
color object i,rgb(255,255,255)
endif
endif
if selec(i)=1 and mouseclick()=0
if leftkey() then move object left i,0.1
if rightkey() then move object right i,0.1
if upkey() then move object up i,0.1
if downkey() then move object up i,-0.1
endif
next
g#=g#+0.5
if object exist(ob-1) and ob>1001 then yrotate object ob-1,g#
sync
loop
reset:
for i= 1 to 999
position object i,10000,0,0
next
change mesh 1000,0,mesh
lock vertexdata for limb 1000,0
vertices=get vertexdata vertex count()
for i= 0 to vertices-1
x#=get vertexdata position x(i)
y#=get vertexdata position y(i)
z#=get vertexdata position z(i)
position object i+1,x#,y#,z#
next
unlock vertexdata
set object cull 1000,0
return
I don't know what happens with my abatar ....??
I'm not a grumpy grandpa