Latch,

**Quote: **"it would be good to use but might make it more difficult to determine visible versus non-visible vertices"

I know a way to determine this, maybe it will be useful:

sync on
sync rate 30
`#InitLibraryStart
`Init FUNCTIONS for vertexdata manipulation
dim sf_currentmemblockmesh(1)
`#InitLibraryEnd
autocam off
position camera 0,0,-100
`our object
obj=1
make object sphere obj,100
rotate object obj,10,40,0
set object obj,0,1,0
`null object for 2D vertex position
nullobject=100
make object triangle nullobject,0,0,0,0,0,0,0,0,0
`make memblock and mesh from object
MAKE MEMBLOCKMESH FROM OBJECT(obj)
mem = GET MEMBLOCK NUMBER()
mesh = GET MESH NUMBER()
vertices = GET VERTEXDATA VERTEX COUNT()
`2D coordinates
dim screenX#(vertices)
dim screenY#(vertices)
`!
scrH=screen height()
ink rgb(255,255,0),0
do
turn object left obj,1
`update object
UPDATE MEMBLOCKMESH FROM OBJECT(mem,mesh,obj)
`get 2D vertex
for vertex_number=0 to vertices-1
x# = GET VERTEXDATA POSITION X(vertex_number)
y# = GET VERTEXDATA POSITION Y(vertex_number)
z# = GET VERTEXDATA POSITION Z(vertex_number)
position object nullobject,x#, y#, z#
screenX#(vertex_number) = object screen x(nullobject)
screenY#(vertex_number) = scrH-object screen y(nullobject)
next vertex_number
`check triangles and display visible vertex
trianglesvertices = GET VERTEXDATA INDEX COUNT()
`
for index=0 to trianglesvertices-1 step 3
index0 = GET INDEXDATA(index)
index1 = GET INDEXDATA(index+1)
index2 = GET INDEXDATA(index+2)
tmpxv1#=screenX#(index1)-screenX#(index0) : tmpyv1#=screenY#(index1)-screenY#(index0)
tmpxv2#=screenX#(index2)-screenX#(index0) : tmpyv2#=screenY#(index2)-screenY#(index0)
`cross product : if counter clockwise>0 then triangle is not visible
ccw=(tmpxv1#*tmpyv2#)-(tmpxv2#*tmpyv1#)
if CCW<0
`display vertex
sbx=3
box screenX#(index0)-sbx,(scrH-screenY#(index0))-sbx,screenX#(index0)+sbx,(scrH-screenY#(index0))+sbx
box screenX#(index1)-sbx,(scrH-screenY#(index1))-sbx,screenX#(index1)+sbx,(scrH-screenY#(index1))+sbx
box screenX#(index2)-sbx,(scrH-screenY#(index2))-sbx,screenX#(index2)+sbx,(scrH-screenY#(index2))+sbx
endif
next index
set cursor 0,0
print screen fps()
sync
loop
END
rem FUNCTIONS
`###############################################################################
`# #
`# lib_vertexdata.dba #
`# #
`###############################################################################
Remstart
List of Function(s):
MAKE MEMBLOCKMESH FROM OBJECT(obj)
UPDATE MEMBLOCKMESH FROM OBJECT(memb,mesh,obj)
UPDATE OBJECT FROM MESH(obj,mesh)
mem = GET MEMBLOCK NUMBER()
mesh = GET MESH NUMBER()
result = GET VERTEXDATA VERTEX COUNT()
result# = GET VERTEXDATA POSITION X(vertex_number)
result# = GET VERTEXDATA POSITION Y(vertex_number)
result# = GET VERTEXDATA POSITION Z(vertex_number)
result# = GET VERTEXDATA NORMALS X(num)
result# = GET VERTEXDATA NORMALS Y(num)
result# = GET VERTEXDATA NORMALS Z(num)
result# = GET VERTEXDATA U(vertex_number)
result# = GET VERTEXDATA V(vertex_number)
result = GET VERTEXDATA INDEX COUNT()
result = GET INDEXDATA(index)
SET CURRENT MEMBLOCK(mem)
SET CURRENT MESH(mesh)
SET VERTEXDATA POSITION X(vertex_number,X#)
SET VERTEXDATA POSITION Y(vertex_number,Y#)
SET VERTEXDATA POSITION Z(vertex_number,Z#)
SET VERTEXDATA NORMAL X(num, X#)
SET VERTEXDATA NORMAL Y(num, Y#)
SET VERTEXDATA NORMAL Z(num, Z#)
SET VERTEXDATA UV(vertex_number, U#, V#)
SET INDEXDATA(indice,vertex)
DISPLAYDATAHEADER()
DISPLAYDATAPOLYS(poly_nb,value)
Remend
`###############################################################################
`
`
`
REM read
function MAKE MEMBLOCKMESH FROM OBJECT(obj)
mesh=0
repeat
inc mesh
meshexist=mesh exist(mesh)
until meshexist=0 or mesh=65535
if meshexist=1 then DISPLAYERROR(1)
mem=0
repeat
inc mem
memexist=memblock exist(mem)
until memexist=0 or mem=255
if meshexist=1 then DISPLAYERROR(2)
make mesh from object mesh,obj
make memblock from mesh mem,mesh
sf_currentmemblockmesh(0)=mem
sf_currentmemblockmesh(1)=mesh
endfunction
function UPDATE MEMBLOCKMESH FROM OBJECT(memb,mesh,obj)
make mesh from object mesh,obj
make memblock from mesh memb,mesh
endfunction
function UPDATE OBJECT FROM MESH(obj,mesh)
`WIP !
mem=sf_currentmemblockmesh(0)
change mesh from memblock mesh,mem
change mesh obj,0,mesh
endfunction
function UPDATE LIMB FROM MESH(obj,limb,mesh)
`WIP !
mem=sf_currentmemblockmesh(0)
change mesh from memblock mesh,mem
change mesh obj,limb,mesh
endfunction
`#InsertRow
function GET MEMBLOCK NUMBER()
mem=sf_currentmemblockmesh(0)
endfunction mem
function GET MESH NUMBER()
mesh=sf_currentmemblockmesh(1)
endfunction mesh
function GET VERTEXDATA VERTEX COUNT()
mem=sf_currentmemblockmesh(0)
result=memblock dword(mem,0)
endfunction result
`GET VERTEXDATA POSITION
function GET VERTEXDATA POSITION X(vertex_number)
mem=sf_currentmemblockmesh(0)
offset=32
result#=memblock float(mem,offset+(12*vertex_number))
endfunction result#
function GET VERTEXDATA POSITION Y(vertex_number)
mem=sf_currentmemblockmesh(0)
offset=36
result#=memblock float(mem,offset+(12*vertex_number))
endfunction result#
function GET VERTEXDATA POSITION Z(vertex_number)
mem=sf_currentmemblockmesh(0)
offset=40
result#=memblock float(mem,offset+(12*vertex_number))
endfunction result#
`GET VERTEXDATA NORMALS
function GET VERTEXDATA NORMALS X(num)
mem=sf_currentmemblockmesh(0)
offset=12
pos=memblock dword(mem,12)+(offset*num)
result#=memblock float(mem,pos)
endfunction result#
function GET VERTEXDATA NORMALS Y(num)
mem=sf_currentmemblockmesh(0)
offset=12
pos=memblock dword(mem,12)+(offset*num)
result#=memblock float(mem,pos+4)
endfunction result#
function GET VERTEXDATA NORMALS Z(num)
mem=sf_currentmemblockmesh(0)
offset=12
pos=memblock dword(mem,12)+(offset*num)
result#=memblock float(mem,pos+8)
endfunction result#
`GET VERTEXDATA TEXTURE COORDINATE
function GET VERTEXDATA U(vertex_number)
mem=sf_currentmemblockmesh(0)
offset=memblock dword(mem,28)
result#=memblock float(mem,offset+(8*vertex_number))
endfunction result#
function GET VERTEXDATA V(vertex_number)
mem=sf_currentmemblockmesh(0)
offset=memblock dword(mem,28)+4
result#=memblock float(mem,offset+(8*vertex_number))
endfunction result#
`GET VERTEXDATA DATA VERTEX
function GET VERTEXDATA INDEX COUNT()
mem=sf_currentmemblockmesh(0)
result=memblock dword(mem,16)*3
endfunction result
function GET INDEXDATA(index)
entier=index/3
value=index-(entier*3)
`
mem=sf_currentmemblockmesh(0)
offset=28
pos=memblock dword(mem,20)+(offset*entier)
select value
case 0
result=memblock dword(mem,pos+4)
endcase
case 1
result=memblock dword(mem,pos+12)
endcase
case 2
result=memblock dword(mem,pos+20)
endcase
endselect
endfunction result
`#InsertRow
REM write
function SET CURRENT MEMBLOCK(mem)
sf_currentmemblockmesh(0)=mem
endfunction
function SET CURRENT MESH(mesh)
sf_currentmemblockmesh(1)=mesh
endfunction
`SET VERTEXDATA POSITION
function SET VERTEXDATA POSITION X(vertex_number,X#)
mem=sf_currentmemblockmesh(0)
offset=32
write memblock float mem,offset+(12*vertex_number),X#
endfunction
function SET VERTEXDATA POSITION Y(vertex_number,Y#)
mem=sf_currentmemblockmesh(0)
offset=36
write memblock float mem,offset+(12*vertex_number),Y#
endfunction
function SET VERTEXDATA POSITION Z(vertex_number,Z#)
mem=sf_currentmemblockmesh(0)
offset=40
write memblock float mem,offset+(12*vertex_number),Z#
endfunction
`SET VERTEXDATA NORMALS
function SET VERTEXDATA NORMAL X(num, X#)
mem=sf_currentmemblockmesh(0)
offset=12
pos=memblock dword(mem,12)+(offset*num)
write memblock float mem,pos,X#
endfunction
function SET VERTEXDATA NORMAL Y(num, Y#)
mem=sf_currentmemblockmesh(0)
offset=12
pos=memblock dword(mem,12)+(offset*num)
write memblock float mem,pos+4,Y#
endfunction
function SET VERTEXDATA NORMAL Z(num, Z#)
mem=sf_currentmemblockmesh(0)
offset=12
pos=memblock dword(mem,12)+(offset*num)
write memblock float mem,pos+8,Z#
endfunction
`SET VERTEXDATA TEXTURE COORDINATE
function SET VERTEXDATA UV(vertex_number, U#, V#)
mem=sf_currentmemblockmesh(0)
offsetU=memblock dword(mem,28)
offsetV=memblock dword(mem,28)+4
write memblock float mem,offsetU+(8*vertex_number),U#
write memblock float mem,offsetV+(8*vertex_number),V#
endfunction
function SET INDEXDATA(indice,vertex)
entier=indice/3
value=indice-(entier*3)
`
mem=sf_currentmemblockmesh(0)
offset=28
pos=memblock dword(mem,20)+(offset*entier)
select value
case 0
write memblock dword mem,pos+4,vertex
endcase
case 1
write memblock dword mem,pos+12,vertex
endcase
case 2
write memblock dword mem,pos+20,vertex
endcase
endselect
endfunction
`#InsertRow
`
function DISPLAYDATAHEADER()
mem=sf_currentmemblockmesh(0)
pos=0
nbv=GET VERTEXDATA VERTEX COUNT()
deknbv=memblock dword(mem,pos+4)
nno=memblock dword(mem,pos+8)
deknno=memblock dword(mem,pos+12)
nf=GET VERTEXDATA INDEX COUNT()/3
deknf=memblock dword(mem,pos+20)
sf=memblock dword(mem,pos+24)
dektex=memblock dword(mem,pos+28)
print "size memblock = ",get memblock size(mem)
print "nb Vertex = ",str$(nbv)
`print "offset vertex = ",str$(deknbv)
print "nb normals = ",str$(nno)
`print "offset normals = ",str$(deknno)
print "nb polygon(s) = ",str$(nf)
`print "offset data polygon(s) = ",str$(deknf)
`print "size data polygon(s) = ",str$(sf)
`print "offset texture = ",str$(dektex)
endfunction
function DISPLAYDATAPOLYS(poly_nb,value)
`A=1, B=2, C=4
`to display verticeA, verticeB, verticeC : value = 1 + 2 + 4
`to display verticeA, verticeC : value = 1 + 4
`....
print "polygon=",poly_nb
if value&1
va=GET INDEXDATA((poly_nb*3))
pxA#=GET VERTEXDATA POSITION X(va)
pyA#=GET VERTEXDATA POSITION Y(va)
pzA#=GET VERTEXDATA POSITION Z(va)
nxA#=GET VERTEXDATA NORMALS X(va)
nyA#=GET VERTEXDATA NORMALS Y(va)
nzA#=GET VERTEXDATA NORMALS Z(va)
uA#=GET VERTEXDATA U(va)
vA#=GET VERTEXDATA V(va)
print "verticeA:",va," X=",pxA#,", Y=",pyA#,", Z=",pzA#," / nX=",nxA#,", nY=",nyA#,", nZ=",nzA#," / u=",uA#,", v=",vA#
endif
if value&2
vb=GET INDEXDATA((poly_nb*3)+1)
pxB#=GET VERTEXDATA POSITION X(vb)
pyB#=GET VERTEXDATA POSITION Y(vb)
pzB#=GET VERTEXDATA POSITION Z(vb)
nxB#=GET VERTEXDATA NORMALS X(vb)
nyB#=GET VERTEXDATA NORMALS Y(vb)
nzB#=GET VERTEXDATA NORMALS Z(vb)
uB#=GET VERTEXDATA U(vb)
vB#=GET VERTEXDATA V(vb)
print "verticeB:",vb," X=",pxB#,", Y=",pyB#,", Z=",pzB#," / nX=",nxB#,", nY=",nyB#,", nZ=",nzB#," / u=",uB#,", v=",vB#
endif
if value&4
vc=GET INDEXDATA((poly_nb*3)+2)
pxC#=GET VERTEXDATA POSITION X(vc)
pyC#=GET VERTEXDATA POSITION Y(vc)
pzC#=GET VERTEXDATA POSITION Z(vc)
nxC#=GET VERTEXDATA NORMALS X(vc)
nyC#=GET VERTEXDATA NORMALS Y(vc)
nzC#=GET VERTEXDATA NORMALS Z(vc)
uC#=GET VERTEXDATA U(vc)
vC#=GET VERTEXDATA V(vc)
print "verticeC:",vc," X=",pxC#,", Y=",pyC#,", Z=",pzC#," / nX=",nxC#,", nY=",nyC#,", nZ=",nzC#," / u=",uC#,", v=",vC#
endif
endfunction
`#ExcludeFunctionStart
REM INTERNALS FUNCTIONS, DO NOT USE !!!
function DISPLAYERROR(code)
unlock cli
select code
case 1
mess$="no mesh available"
endcase
case 2
mess$="no memblock available"
endcase
endselect
break mess$
end
endfunction
`#ExcludeFunctionEnd
remstart
DBPro command:
LOCK VERTEXDATA FOR LIMB : LOCK VERTEXDATA FOR LIMB Object Number, Limb Number
UNLOCK VERTEXDATA : UNLOCK VERTEXDATA
* SET VERTEXDATA POSITION X: SET VERTEXDATA POSITION Vertex Index, X
* SET VERTEXDATA POSITION Y: SET VERTEXDATA POSITION Vertex Index, Y
* SET VERTEXDATA POSITION Z: SET VERTEXDATA POSITION Vertex Index, Z
* SET VERTEXDATA NORMALS X: SET VERTEXDATA NORMALS Vertex Index, NX
* SET VERTEXDATA NORMALS Y: SET VERTEXDATA NORMALS Vertex Index, NY
* SET VERTEXDATA NORMALS Z: SET VERTEXDATA NORMALS Vertex Index, NZ
* SET VERTEXDATA U : SET VERTEXDATA UV Vertex Index, U
* SET VERTEXDATA V : SET VERTEXDATA UV Vertex Index, V
LOCK VERTEXDATA FOR MESH : LOCK VERTEXDATA FOR MESH Mesh Number
ADD MESH TO VERTEXDATA : ADD MESH TO VERTEXDATA Mesh Number
DELETE MESH FROM VERTEXDATA : DELETE MESH FROM VERTEXDATA Vertex Start, Vertex End, Index Start, Index End
CONVERT MESH TO VERTEXDATA : CONVERT MESH TO VERTEXDATA Mesh Number
* GET VERTEXDATA VERTEX COUNT : Return Integer=GET VERTEXDATA VERTEX COUNT()
* GET VERTEXDATA POSITION X : Return Float=GET VERTEXDATA POSITION X(Vertex Index)
* GET VERTEXDATA POSITION Y : Return Float=GET VERTEXDATA POSITION Y(Vertex Index)
* GET VERTEXDATA POSITION Z : Return Float=GET VERTEXDATA POSITION Z(Vertex Index)
* GET VERTEXDATA NORMALS X : Return Float=GET VERTEXDATA NORMALS X(Vertex Index)
* GET VERTEXDATA NORMALS Y : Return Float=GET VERTEXDATA NORMALS Y(Vertex Index)
* GET VERTEXDATA NORMALS Z : Return Float=GET VERTEXDATA NORMALS Z(Vertex Index)
* GET VERTEXDATA U : Return Float=GET VERTEXDATA U(Vertex Index)
* GET VERTEXDATA V : Return Float=GET VERTEXDATA V(Vertex Index)
* SET INDEXDATA : SET INDEXDATA Indice Index, Vertex Index
* GET INDEXDATA : Return Integer=GET INDEXDATA(Index Number)
* GET VERTEXDATA INDEX COUNT : Return Integer=GET VERTEXDATA INDEX COUNT()
DBClassic memblock object structure:
Memblock-Mesh (En-tête 32 Octets)
-Header
--4 OCTETS (DWORD) Nombre de Vecteurs (vertices)
--4 OCTETS (DWORD) Décalage vers les données des vecteurs (en octets)
--4 OCTETS (DWORD) Nombre de Normales
--4 OCTETS (DWORD) Décalage vers les données des Normales (en octets)
--4 OCTETS (DWORD) Nombre de Faces
--4 OCTETS (DWORD) Décalage vers les données des Faces (en octets)
--4 OCTETS (DWORD) Taille des données des Faces
--4 OCTETS (DWORD) Décalage vers les données de Textures (en octets)
-Data
--Donnée Vecteur
---Pour chaque vecteur(vertex)
----4 OCTETS (FLOAT) - Position en X en géométrie 3D
----4 OCTETS (FLOAT) - Position en Y en géométrie 3D
----4 OCTETS (FLOAT) - Position en Z en géométrie 3D
--Données des Normales
---Pour chaque Normale
----4 OCTETS (FLOAT) - Normale projetée sur X en géométrie 3D
----4 OCTETS (FLOAT) - Normale projetée sur Y en géométrie 3D
----4 OCTETS (FLOAT) - Normale projetée sur Z en géométrie 3D
--Données des Faces
---Pour Chaque Face (une face est constituée d'un polygone de points A,B et C comme vecteurs)
----4 OCTETS (DWORD) - Nombre de vecteurs dans la Face (toujours 3)
----4 OCTETS (DWORD) - Numéro du vecteur dans la table des vecteurs pour le vecteur A
----4 OCTETS (DWORD) - Numéro de la Normale dans la table des vecteurs pour le vecteur A
----4 OCTETS (DWORD) - Numéro du vecteur dans la table des vecteurs pour le vecteur B
----4 OCTETS (DWORD) - Numéro de la Normale dans la table des vecteurs pour le vecteur B
----4 OCTETS (DWORD) - Numéro du vecteur dans la table des vecteurs pour le vecteur C
----4 OCTETS (DWORD) - Numéro de la Normale dans la table des vecteurs pour le vecteur C
--Données de Texture
---Pour chaque Vecteur
----4 OCTETS (FLOAT) - Valeur U de la Texture
----4 OCTETS (FLOAT) - Valeur V de la Texture
remend

DirectX 9.0c (February 2010)/ DBClassic v1.20