Hey guys!
This is v1.01 of my new objects.
(Edit) Don`t copy the code from the code snippet! The TGC server somehow doubled the enters (as you can see) and it will take up 2 times the space. Download the zip file, the code "objects.dba" is in it.
rem *********************************************************************
rem * New DBC objects : Pyramids, Prism, Diamond, Capsules, Disk, Tree *
rem *********************************************************************
rem * author : The Comet Date : ? *
rem *********************************************************************
rem four pyramid
function create object pyramid(obj,size,sides,flag)
rem check if object already exists
if object exist(obj)=1 then backdrop off:input "Runtime Error! Object already exists!",a$ : end
rem make core
make object plain obj,0,0
position object obj,0,0,0
rem find an object not in use
limbobj=0
for t=1 to 65000
if object exist(t)=0 then limbobj=t : exit
next t
rem find 5 meshes not in use
mesh=0
for t=1 to 65000
if mesh exist(t)=0 then mesh=t:exit
next t
if mesh=0 then backdrop off:input "Runtime Error! No More mesh can be made!",a$ : end
rem make base
if sides=3 or sides=4
if sides=3
make object plain limbobj,0,0
position object limbobj,0,0-size/2,0
yrotate object limbobj,0
move object limbobj,size
x1#=object position x(limbobj)
y1#=object position y(limbobj)
z1#=object position z(limbobj)
delete object limbobj
make object plain limbobj,0,0
position object limbobj,0,0-size/2,0
yrotate object limbobj,120
move object limbobj,size
x2#=object position x(limbobj)
y2#=object position y(limbobj)
z2#=object position z(limbobj)
delete object limbobj
make object plain limbobj,0,0
position object limbobj,0,0-size/2,0
yrotate object limbobj,240
move object limbobj,size
x3#=object position x(limbobj)
y3#=object position y(limbobj)
z3#=object position z(limbobj)
delete object limbobj
make object triangle limbobj,x1#,y1#,z1#,x2#,y2#,z2#,x3#,y3#,z3#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,1,mesh
delete mesh mesh
else
rem get all positions needed
x1#=0-size/2
y1#=0-size/2
z1#=size/2
x2#=size/2
y2#=0-size/2
z2#=size/2
x3#=size/2
y3#=0-size/2
z3#=0-size/2
x4#=0-size/2
y4#=0-size/2
z4#=0-size/2
x#=0
y#=size/2
z#=0
rem make the bottom with 2 triangles
make object triangle limbobj,x1#,y1#,z1#,x2#,y2#,z2#,x3#,y3#,z3#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,1,mesh
delete mesh mesh
make object triangle limbobj,x1#,y1#,z1#,x4#,y4#,z4#,x3#,y3#,z3#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,2,mesh
delete mesh mesh
endif
else
backdrop off
set cursor 0,0
input "Syntax Error! Can not have more sides than 4 or less sides than 3",a$ : end
endif
rem make 3 or 4 sides
if sides=3
make object triangle limbobj,x1#,y1#,z1#,x2#,y2#,z2#,0,size/2,0
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,2,mesh
delete mesh mesh
make object triangle limbobj,x1#,y1#,z1#,x3#,y3#,z3#,0,size/2,0
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,3,mesh
delete mesh mesh
make object triangle limbobj,x2#,y2#,z2#,x3#,y3#,z3#,0,size/2,0
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,4,mesh
delete mesh mesh
else
make object triangle limbobj,x1#,y1#,z1#,x2#,y2#,z2#,x#,y#,z#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,3,mesh
delete mesh mesh
make object triangle limbobj,x2#,y2#,z2#,x3#,y3#,z3#,x#,y#,z#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,4,mesh
delete mesh mesh
make object triangle limbobj,x3#,y3#,z3#,x4#,y4#,z4#,x#,y#,z#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,5,mesh
delete mesh mesh
make object triangle limbobj,x4#,y4#,z4#,x1#,y1#,z1#,x#,y#,z#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,6,mesh
delete mesh mesh
endif
rem if flag=1 then make 1 object without limbs
if flag=1
rem create an image
img=0
for t=1 to 65000
if image exist(t)=0 then img=t : exit
next t
create bitmap 1,2,2
for x=0 to 2 : for y=0 to 2 : ink rgb(255,255,255),0 : dot x,y : next y : next x
get image img,0,0,2,2
delete bitmap 1
rem make the pyramid without limbs
make mesh from object mesh,obj
delete object obj
make object obj,mesh,img
delete mesh mesh
delete image img
set object obj,1,1,0
endif
endfunction
function create object prism(obj,size,flag)
rem make core
make object plain obj,0,0
position object obj,0,0,0
rem find an object not in use
limbobj=0
for t=1 to 65000
if object exist(t)=0 then limbobj=t : exit
next t
rem find a mesh not in use
mesh=0
for t=1 to 65000
if mesh exist(t)=0 then mesh=t:exit
next t
if mesh=0 then backdrop off:input "Runtime Error! No More mesh can be made!",a$ : end
rem make three plain objects matched together into a triangle
make object plain limbobj,size,size
position object limbobj,0,0,0
rotate object limbobj,90,0,0
move object limbobj,size/3.47
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,1,mesh
delete mesh mesh
make object plain limbobj,size,size
position object limbobj,0,0,0
rotate object limbobj,210,0,0
move object limbobj,size/3.47
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,2,mesh
delete mesh mesh
make object plain limbobj,size,size
position object limbobj,0,0,0
rotate object limbobj,330,0,0
move object limbobj,size/3.47
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,3,mesh
delete mesh mesh
rem get 3 positions of edges
x1#=size/2.005
x2#=0-size/2.005
y1#=size/1.729
z1#=0
y2#=0-(size/3.47)
z2#=size/2.005
y3#=0-(size/3.47)
z3#=0-size/2.005
rem cover edges with triangles
make object triangle limbobj,x1#,y1#,z1#,x1#,y2#,z2#,x1#,y3#,z3#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,4,mesh
delete mesh mesh
make object triangle limbobj,x2#,y1#,z1#,x2#,y2#,z2#,x2#,y3#,z3#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,5,mesh
delete mesh mesh
rem if flag=1 then make 1 object without limbs
if flag=1
rem create an image
img=0
for t=1 to 65000
if image exist(t)=0 then img=t : exit
next t
create bitmap 1,2,2
for x=0 to 2 : for y=0 to 2 : ink rgb(255,255,255),0 : dot x,y : next y : next x
get image img,0,0,2,2
delete bitmap 1
rem make the pyramid without limbs
make mesh from object mesh,obj
delete object obj
make object obj,mesh,img
delete mesh mesh
delete image img
set object obj,1,1,0
endif
endfunction
function create object diamond(obj,size,stretch,flag)
rem check for syntax
set cursor 0,0
if strech>1 or stretch<0 then backdrop off:input "Syntax Error! Stretch value can not be more than 1 or less than 0",a$:end
rem make core
make object plain obj,0,0
position object obj,0,0,0
rem find an object not in use
limbobj=0
for t=1 to 65000
if object exist(t)=0 then limbobj=t : exit
next t
rem find 1 mesh not in use
mesh=0
for t=1 to 65000
if mesh exist(t)=0 then mesh=t:exit
next t
if mesh=0 then backdrop off:input "Runtime Error! No More mesh can be made!",a$ : end
rem make 8 triangles and position in two pyramids connected together
x1=0-size/2
y1=0
z1=size/2
x2=size/2
y2=0
z2=size/2
x3=size/2
y3=0
z3=0-size/2
x4=0-size/2
y4=0
z4=0-size/2
x=0
if stretch=0 then y=size/1.5
if stretch=1 then y=size
z=0
make object triangle limbobj,x1,y1,z1,x2,y2,z2,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,1,mesh
delete mesh mesh
make object triangle limbobj,x2,y2,z2,x3,y3,z3,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,2,mesh
delete mesh mesh
make object triangle limbobj,x3,y3,z3,x4,y4,z4,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,3,mesh
delete mesh mesh
make object triangle limbobj,x4,y4,z4,x1,y1,z1,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,4,mesh
delete mesh mesh
x=0
if stretch=0 then y=0-size/1.5
if stretch=1 then y=0-size
z=0
make object triangle limbobj,x1,y1,z1,x2,y2,z2,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,5,mesh
delete mesh mesh
make object triangle limbobj,x2,y2,z2,x3,y3,z3,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,6,mesh
delete mesh mesh
make object triangle limbobj,x3,y3,z3,x4,y4,z4,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,7,mesh
delete mesh mesh
make object triangle limbobj,x4,y4,z4,x1,y1,z1,x,y,z
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,8,mesh
delete mesh mesh
rem if flag=1 then make 1 object without limbs
if flag=1
rem create an image
img=0
for t=1 to 65000
if image exist(t)=0 then img=t : exit
next t
create bitmap 1,2,2
for x=0 to 2 : for y=0 to 2 : ink rgb(255,255,255),0 : dot x,y : next y : next x
get image img,0,0,2,2
delete bitmap 1
rem make the pyramid without limbs
make mesh from object mesh,obj
delete object obj
make object obj,mesh,img
delete mesh mesh
delete image img
set object obj,1,1,0
endif
endfunction
function create object capsule(obj,size,type,flag)
rem make core
make object plain obj,0,0
position object obj,0,0,0
rem find an object not in use
limbobj=0:limbobj2=0:limbobj3=0
for t=1 to 65000
if object exist(t)=0 then limbobj=t : exit
next t
rem find 1 mesh not in use
mesh=0
for t=1 to 65000
if mesh exist(t)=0 then mesh=t:exit
next t
rem make rounded capsule
if type=1 or type=2
rem make base
make object cylinder limbobj,size : zrotate object limbobj,90 : scale object limbobj,100,200,100
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,1,mesh
delete mesh mesh
if type=1
sy=0
make object sphere limbobj,size
position object limbobj,size+sy,0,0
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,2,mesh
delete mesh mesh
make object sphere limbobj,size
position object limbobj,0-size-sy,0,0
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,3,mesh
delete mesh mesh
else
make object cone limbobj,size : rotate object limbobj,90,0,270
sy=object size y(limbobj)/2
position object limbobj,size+sy,0,0
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,2,mesh
delete mesh mesh
make object cone limbobj,size : rotate object limbobj,90,0,90
sy=object size y(limbobj)/2
position object limbobj,0-size-sy,0,0
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,3,mesh
delete mesh mesh
endif
else
backdrop off
set cursor 0,0
input "Runtime Error! There is no type <" + str$(type) + ">!",a$:end
endif
rem if flag=1 then make 1 object without limbs
if flag=1
rem create an image
img=0
for t=1 to 65000
if image exist(t)=0 then img=t : exit
next t
create bitmap 1,2,2
for x=0 to 2 : for y=0 to 2 : ink rgb(255,255,255),0 : dot x,y : next y : next x
get image img,0,0,2,2
delete bitmap 1
rem make the pyramid without limbs
make mesh from object mesh,obj
delete object obj
make object obj,mesh,img
delete mesh mesh
delete image img
set object obj,1,1,0
endif
endfunction
function create object tree(obj,size,cones,flag)
rem make sure values aren`t out of bounds
if cones>20 then cones=20
if cones<1 then cones=1
if flag<0 then flag=0
if flag>1 then flag=1
rem make core object
make object plain obj,0,0
position object obj,0,0,0
rem find 1 free object and 1 free mesh
limbobj=0 : mesh=0
for t=1 to 65000
if object exist(t)=0 then limbobj=t : exit
next t
for t=1 to 65000
if mesh exist(t)=0 then mesh=t : exit
next t
rem make the trunk
make object cylinder limbobj,size
position object limbobj,0,size/2,0
color object limbobj,rgb(80,0,0)
scale object limbobj,100,200,100
cy#=object position y(limbobj)
cs#=object size y(limbobj)
cy#=cy#+(cs#*2)
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,1,mesh
delete mesh mesh
color limb obj,1,rgb(80,0,0)
rem add cones
limbsize#=4
for t=2 to cones+1
rem make a cone, position and add limb
make object cone limbobj,size*limbsize#
position object limbobj,0,(cy#+cs#)-(cs#/2),0
cy#=object position y(limbobj)
cs#=object size y(limbobj)
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,t,mesh
delete mesh mesh
color limb obj,t,rgb(0,100,0)
rem devide the size of the cone
limbsize#=limbsize#/1.3
next t
rem if flag=1 then make 1 object without limbs
if flag=1
rem create an image
img=0
for t=1 to 65000
if image exist(t)=0 then img=t : exit
next t
create bitmap 1,2,2
for x=0 to 2 : for y=0 to 2 : ink rgb(255,255,255),0 : dot x,y : next y : next x
get image img,0,0,2,2
delete bitmap 1
rem make the pyramid without limbs
make mesh from object mesh,obj
delete object obj
make object obj,mesh,img
delete mesh mesh
delete image img
set object obj,1,1,0
endif
endfunction
function create object disk(obj,size,poly,flag)
rem make core object
make object plain obj,0,0
position object obj,0,0,0
rem find 1 free object
limbobj=0
for t=1 to 65000
if object exist(t)=0 then limbobj=t : exit
next t
rem find 1 free mesh
mesh=0
for t=1 to 65000
if mesh exist(t)=0 then mesh=t : exit
next t
rem make sure values don`t go out of bounds
if poly<3 then poly=3
if poly>1000 then poly=1000
if flag>1 : flag=1 : else : flag=0 : endif
rem get step value of polygons
stp#=360.0000000/poly
rem make triangles into a dish
start#=0.0000000
for t=1 to poly
rem get outer positions
make object plain limbobj,0,0
yrotate object limbobj,start#
move object limbobj,size/2
x2#=object position x(limbobj)
y2#=object position y(limbobj)
z2#=object position z(limbobj)
delete object limbobj
make object plain limbobj,0,0
yrotate object limbobj,wrapvalue(start#+stp#)
move object limbobj,size/2
x3#=object position x(limbobj)
y3#=object position y(limbobj)
z3#=object position z(limbobj)
delete object limbobj
rem make triangles
make object triangle limbobj,0,0,0,x2#,y2#,z2#,x3#,y3#,z3#
make mesh from object mesh,limbobj
delete object limbobj
add limb obj,t,mesh
delete mesh mesh
rem increment the positions on the outside
inc start#,stp#
rem print how far disk is processed
if poly>100
ink rgb(255,0,0),0
center text 320,80,"You Are Procesing A Lot of Polygons Please Wait"
center text 320,100,"Processing " + str$(poly) + " polygons For Disk Object " + str$(t) + "/" + str$(poly)
sync
endif
next t
rem if flag=1 then make 1 object without limbs
if flag=1
rem create an image
img=0
for t=1 to 65000
if image exist(t)=0 then img=t : exit
next t
create bitmap 1,2,2
for x=0 to 2 : for y=0 to 2 : ink rgb(255,255,255),0 : dot x,y : next y : next x
get image img,0,0,2,2
delete bitmap 1
rem make the pyramid without limbs
make mesh from object mesh,obj
delete object obj
make object obj,mesh,img
delete mesh mesh
delete image img
set object obj,1,1,0
endif
endfunction
Here are my new objects!
Pyramid, Prism, Diamond, Capsule, Tree, Disk(No, I didn`t scale a cylinder 100,0,100)
How to use:
First, you have to include the functions into your program:
#include "objects.dba"
Note that the file "objects.dba" has to be in the same directory as your program!
Create object Pyramid(object,size,sides,flag)
Object=object number
Size=size
sides=3 to 4 sides
flag= if 0, your object will have limbs, if 1, your object will have no limbs
Create object Prism(object,size,flag)
Object=object number
Size=size
flag= if 0, your object will have limbs, if 1, your object will have no limbs
Create object Diamond(object,size,stretch,flag)
Object=object number
Size=size
stretch= if 0, your object will have 8 identical sides, if 1, your object will be stretched
flag= if 0, your object will have limbs, if 1, your object will have no limbs
Create object Capsule(object,size,type,flag)
Object=object number
Size=size
Type= if 1, your capsule will have rounded ends, if 2, your capsule will have pointed ends
flag= if 0, your object will have limbs, if 1, your object will have no limbs
Create object tree(object,size,cones,flag)
Object=object number
Size=size
cones=The number of cones on top of the trunk
flag= if 0, your object will have limbs, if 1, your object will have no limbs
Create object Disk(object,size,polygons,flag)
Object=object number
Size=size
polygons=The number of triangles shaped into a circle
flag= if 0, your object will have limbs, if 1, your object will have no limbs
Have fun!
(File attached)
TheComet
Oooooops!!! I accidentally formated drive c.