INSTALL "Make3dLib.BBC" capped%=TRUE :REM Include ends on the cylinder nf%=20 :REM Number of faces startface%=1 :REM Include the whole cylinder, or only part of it? endface%=10 REM Coordinates to map a texture to the shape. You might want to use only a small part of a texture texminu=0 texmaxu=1 texminv=0 texmaxv=1 maxnv%=FNGetNumVerts("sphere",nf%,1,nf%,TRUE) DIM v(maxnv%,2),vn(maxnv%,2),t(maxnv%,1) :REM hold vertex, normal, and texture data DIM vr(maxnv%,2),vnr(maxnv%,2) :REM These are only needed for the display routine nf%=10 REM We need to count up all the vertices that will be used in all the sections, so that we can put it at the beginning of the file tnv%=4*FNGetNumVerts("trunccone",nf%,1,nf%,TRUE)+1*FNGetNumVerts("sphere",nf%,1,nf%,FALSE)+4*FNGetNumVerts("sphere",nf%,6,nf%,FALSE)+4*FNGetNumVerts("prism",5,1,5,FALSE) vform%=&152 :REM Here I'm making a file with vertex, normal, and colour data fh%=FNOpenFVF("Enterprise",tnv%,vform%) nv%=FNGetNumVerts("trunccone",nf%,1,nf%,TRUE) PROCMake3D_TruncCone(1.0,0.5,nf%,v(),vn(),t(),1,nf%,TRUE,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),-0.5,1,1) REM Normals for smooth shapes are initially generated as their endpoints, so that can be scaled etc, REM So we need to carry out any transformations on them in parallel PROCStretch(nv%,vn(),-0.5,1,1) REM Now we need to convert the normals to normalised vectors vn()=vn()-v() PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nv%=FNGetNumVerts("trunccone",nf%,1,nf%,TRUE) PROCMake3D_TruncCone(1.0,0.5,nf%,v(),vn(),t(),1,nf%,TRUE,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),4,1,1) PROCStretch(nv%,vn(),4,1,1) vn()=vn()-v() :REM "Normals" are initially generated as their endpoints, so that can be scaled etc, but now need to be converted to vectors PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nv%=FNGetNumVerts("trunccone",nf%,1,nf%,TRUE) PROCMake3D_TruncCone(0.5,0.4,nf%,v(),vn(),t(),1,nf%,TRUE,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),4,1,1) PROCStretch(nv%,vn(),4,1,1) PROCShift(v(),2,2.5,2.5,nv%) PROCShift(vn(),2,2.5,2.5,nv%) vn()=vn()-v() :REM "Normals" are initially generated as their endpoints, so that can be scaled etc, but now need to be converted to vectors PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nv%=FNGetNumVerts("trunccone",nf%,1,nf%,TRUE) PROCMake3D_TruncCone(0.5,0.4,nf%,v(),vn(),t(),1,nf%,TRUE,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),4,1,1) PROCStretch(nv%,vn(),4,1,1) PROCShift(v(),2,2.5,-2.5,nv%) PROCShift(vn(),2,2.5,-2.5,nv%) vn()=vn()-v() :REM "Normals" are initially generated as their endpoints, so that can be scaled etc, but now need to be converted to vectors PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nv%=FNGetNumVerts("sphere",nf%,1,nf%,TRUE) PROCMake3D_Sphere(nf%,v(),vn(),t(),1,nf%,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),3,0.2,3) PROCStretch(nv%,vn(),3,0.2,3) PROCShift(v(),-2.1,1.5,0,nv%) PROCShift(vn(),-2.1,1.5,0,nv%) vn()=vn()-v() :REM "Normals" are initially generated as their endpoints, so that can be scaled etc, but now need to be converted to vectors PROCNormalise(nv%,vn()) PROCFindNormals(nv%,v(),vn()) :REM Cheat: something is going wrong with normals of sphere by flattening it so much: cheat by using triangles directly - OK when this flat PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nf%=4 nv%=FNGetNumVerts("prism",nf%,1,nf%,FALSE) PROCMake3D_Prism(nf%,v(),t(),1,nf%,FALSE,texminu,texmaxu,texminv,texmaxv) PROCRotate(v(),PI/4,0,0) PROCStretch(nv%,v(),3.5,0.5,0.2) PROCRotate(v(),0,0,-PI/2) PROCRotate(v(),-PI/4,0,0) PROCShift(v(),2.5,0,0,nv%) PROCFindNormals(nv%,v(),vn()) :REM With facetted shapes we can simply calculate the normals after all the messing around PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nv%=FNGetNumVerts("prism",nf%,1,nf%,FALSE) PROCMake3D_Prism(nf%,v(),t(),1,nf%,FALSE,texminu,texmaxu,texminv,texmaxv) PROCRotate(v(),PI/4,0,0) PROCStretch(nv%,v(),3.5,0.5,0.2) PROCRotate(v(),0,0,-PI/2) PROCRotate(v(),PI/4,0,0) PROCShift(v(),2.5,0,0,nv%) PROCFindNormals(nv%,v(),vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nv%=FNGetNumVerts("prism",nf%,1,nf%,FALSE) PROCMake3D_Prism(nf%,v(),t(),1,nf%,FALSE,texminu,texmaxu,texminv,texmaxv) PROCRotate(v(),PI/4,0,0) PROCStretch(nv%,v(),1.5,1,0.3) PROCShear(nv%,v(),2,0,1) PROCRotate(v(),0,0,-PI/2) PROCShift(v(),1.8,0,0,nv%) PROCFindNormals(nv%,v(),vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) nv%=FNGetNumVerts("prism",nf%,1,nf%,FALSE) PROCMake3D_Prism(nf%,v(),t(),1,nf%,FALSE,texminu,texmaxu,texminv,texmaxv) PROCRotate(v(),PI/4,0,0) PROCStretch(nv%,v(),0.5,0.1,0.1) PROCShift(v(),-1,0,0,nv%) PROCFindNormals(nv%,v(),vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF804040,&FFFFFFFF) nf%=10 nv%=FNGetNumVerts("sphere",nf%,6,nf%,TRUE) PROCMake3D_Sphere(nf%,v(),vn(),t(),6,nf%,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),0.2,0.5,0.5) PROCStretch(nv%,vn(),0.2,0.5,0.5) PROCShift(v(),-0.8,0,0,nv%) PROCShift(vn(),-0.8,0,0,nv%) vn()=vn()-v() PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF804040,&FFFFFFFF) nv%=FNGetNumVerts("sphere",nf%,1,5,TRUE) PROCMake3D_Sphere(nf%,v(),vn(),t(),1,5,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),0.4,0.4,0.4) PROCStretch(nv%,vn(),0.4,0.4,0.4) PROCShift(v(),2,2.5,-2.5,nv%) PROCShift(vn(),2,2.5,-2.5,nv%) vn()=vn()-v() PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FFF04040,&FFFFFFFF) nv%=FNGetNumVerts("sphere",nf%,1,5,TRUE) PROCMake3D_Sphere(nf%,v(),vn(),t(),1,5,texminu,texmaxu,texminv,texmaxv) PROCStretch(nv%,v(),0.4,0.4,0.4) PROCStretch(nv%,vn(),0.4,0.4,0.4) PROCShift(v(),2,2.5,2.5,nv%) PROCShift(vn(),2,2.5,2.5,nv%) vn()=vn()-v() PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FFF04040,&FFFFFFFF) nv%=FNGetNumVerts("sphere",nf%,6,nf%,TRUE) PROCMake3D_Sphere(nf%,v(),vn(),t(),6,nf%,texminu,texmaxu,texminv,texmaxv) PROCRotate(v(),0,0,-PI/2) PROCRotate(vn(),0,0,-PI/2) PROCStretch(nv%,v(),1,0.3,0.5) PROCStretch(nv%,vn(),1,0.3,0.5) PROCShear(nv%,v(),-0.3,1,0) PROCShift(v(),-1.7,1.7,0,nv%) PROCShift(vn(),-1.7,1.7,0,nv%) vn()=vn()-v() PROCNormalise(nv%,vn()) PROCExtendFVF(fh%,vform%,nv%,v(),vn(),t(),&FF808080,&FFFFFFFF) PROCCloseFVF(fh%) PRINT "Success!" END