GLBasic User Manual

Main sections

X_GETFACE

X_GETFACE obj#, frame#, index#, face[]



With this command you can get information about a triangle in the 3D model obj# in animation frame frame#.
index# is the index of the triangle in the model and must be within the range 0 and X_NUMFACES(obj#)-1.
The information is written to the array face[] which gets dimensioned to [3][9] internally. The first array dimension is the index of the node (i.e. triangle corner 0,1 or 2).
The second array dimension is responsible for the data:
face[i][0] = x
face[i][1] = y
face[i][2] = z
face[i][3] = tx
face[i][4] = ty
face[i][5] = color
face[i][6] = nx
face[i][7] = ny
face[i][8] = nz

x,y,z = Coordinates of the point
tx,ty = Texture-coordinates of the point
nx,ny,nz = normal vector direction of point

This command allows you to do a full analysis of a 3D object.
LOCAL face[]
    X_LOADOBJ "wumbo.ddd", 0

    X_MAKE3D 1,500,45
    X_CAMERA 10,2,-1, 0,2,0
    X_DRAWOBJ 0, 2
    count = X_NUMFACES(0)
    FOR i=0 TO count-1
        X_GETFACE 0, 2, i, face[]
        // face[node 0..2][x,y,z,tx,ty,col]
        X_LINE face[0][0], face[0][1], face[0][2], face[1][0], face[1][1], face[1][2], 4, RGB(0,0,255)
        X_LINE face[2][0], face[2][1], face[2][2], face[1][0], face[1][1], face[1][2], 4, RGB(0,0,255)
        X_LINE face[0][0], face[0][1], face[0][2], face[2][0], face[2][1], face[2][2], 4, RGB(0,0,255)
        
        X_DOT face[0][0], face[0][1], face[0][2], 8, RGB(0,255,0)
        X_DOT face[1][0], face[1][1], face[1][2], 8, RGB(0,255,0)
        X_DOT face[2][0], face[2][1], face[2][2], 8, RGB(0,255,0)
    NEXT

    SHOWSCREEN
    MOUSEWAIT

See also...