Download IRIS Performer™ Programmer`s Guide
Transcript
Chapter 5: Nodes and Node Types
Example 5-12 demonstrates the construction of a pfBillboard node. The code
can be found in /usr/share/Performer/src/pguide/libpf/C/billboard.c.
Example 5-12
Setting Up a pfBillboard
static pfVec2 BBTexCoords[] ={{0.0f,
{1.0f,
{1.0f,
{0.0f,
0.0f},
0.0f},
1.0f},
1.0f}};
static pfVec3 BBVertCoords[4] = /* XZ plane for pt bboards */
{{-0.5f, 0.0f, 0.0f},
{ 0.5f, 0.0f, 0.0f},
{ 0.5f, 0.0f, 1.0f},
{-0.5f, 0.0f, 1.0f}};
static pfVec3 BBAxes[4] = {{1.0f,
{0.0f,
{0.0f,
{0.0f,
0.0f,
1.0f,
0.0f,
0.0f,
0.0f}, /* X */
0.0f}, /* Y */
1.0f}, /* Z */
1.0f}}; /*world Zup*/
static int BBPrimLens[] = { 4 };
static pfVec4 BBColors[] = {{1.0, 1.0, 1.0, 1.0}};
/* Convert static data to pfMalloc’ed data */
static void*
memdup(void *mem, size_t bytes, void *arena)
{
void *data = pfMalloc(bytes, arena);
memcpy(data, mem, bytes);
return data;
}
/* For pedagogical use only. Reasonable performance
* requires more then one pfGeoSet per pfBillboard.
*/
pfBillboard*
MakeABill(pfVec3 pos, pfGeoState *gst, long bbType)
{
pfGeoSet *gset;
pfGeoState *gstate;
pfBillboard *bill;
142