
| Tutoial
Examples Plug-in References |
Plug-in InterfaceObjects of vertex, color, and texture coordinate have the function <dll to call dynamic-link library (DLL) functions for importing or generating data. A DLL function must confirm to the C protocol of int (*func) (char **argv, int argc, bool(*callback)(void *data, int n)) When the object function calls the DLL function, the string "p1, p2, ..." will be parsed as argv (a pointer to argc number of strings). A DLL function exchange data with the object through the callback function. When the optional attribute append="true" (this is the default), the object only accept data, which are expected to be in a double pointer to 3 data for vertex object, 4 data for color object, and 2 data for texture coordinate object. The callback function return false when n is differenct from the expected number. When append="false" is used, a zero or positive n indicates a request of the DLL function for data at index n in the object; and a negative n indicates return of data to the object for the index -n-1. The callback return false when the index is out of boundary. The following C++ code demonstrate how to add DLL functions to your own library; and Example07 shows how to call these functions.
#include <vector>
#include <math.h>
#define DEG2RAD 0.017453292519943
using namespace std;
extern "C"
{
__declspec(dllexport)
int make_sphere_vertex(char**, int, bool(*)(void*, int));
__declspec(dllexport)
int sphere_projection(char**, int, bool(*)(void*, int));
}
typedef struct {
double x, y, z;
} XYZ;
/////////////////////////////////////////////////////////////////////
int
make_sphere_vertex(char** argv, int argc, bool(*callback)(void*, int))
{
if (argc < 1) return -1;
int nv = atoi(argv[0]);
int nu = 2 * nv - 1;
if (nu < 5) return -2;
double u, v, xyz[3],
v0 = -1.570796326794900,
d = -v0 * 2 / double(nv - 1);
int i, j;
vector
|