Un-ignored: the dev drive is the ground truth the restoration and emulator work constantly reference (DPL3/LIBDPL + VRENDER i860 renderer source, BT/RP live+dev game trees, VGL_LABS pod boot, scene/audio content). Kept in-repo for the pod-owner community. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3828 lines
83 KiB
C++
3828 lines
83 KiB
C++
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#include <dpl.h>
|
|
#include <matrix.h>
|
|
#include <dpl_host.h>
|
|
|
|
/*{{{ banner*/
|
|
/* **************************************************
|
|
|
|
Copyright DIVISION Limited (c) 1994
|
|
All rights reserved
|
|
|
|
|
|
File : dpl.c
|
|
Project : dpl interface
|
|
host / platform independent section
|
|
Author : PJA
|
|
Date : 22/06/94
|
|
|
|
Function: Implements the host section of the dpl
|
|
interface
|
|
|
|
History : Rev 1.1, 22 / 06 / 1994
|
|
|
|
**************************** */
|
|
/*}}} */
|
|
|
|
/*{{{ statics holding dpl state*/
|
|
|
|
static dpl_SCENE the_scene;
|
|
|
|
static dpl_cache_mode __dpl_cache_mode;
|
|
|
|
static dpl_FILEPATH *geometry_filepath=NULL;
|
|
static dpl_FILEPATH *texture_filepath =NULL;
|
|
|
|
/* needs to be visible to dpl_host */
|
|
int32 dpl_WarningLevel=0;
|
|
static int32 dpl_inited=0;
|
|
|
|
static char dpl_errmess[256];
|
|
static int dpl_err=0;
|
|
/*}}} */
|
|
/*{{{ errors*/
|
|
|
|
#define check_inited(ret) if (dpl_inited == 0) return ret
|
|
#define check_inited_noret() if (dpl_inited == 0) return
|
|
|
|
/* interface should just STOP on error */
|
|
|
|
#define dpl_error dpl_inited=0; dpl_err=1; sprintf
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ support functions*/
|
|
#define inc_ref(node) if (node) ((dpl_node *) node)->ref_count++;
|
|
#define dec_ref(node) if (node) ((dpl_node *) node)->ref_count--;
|
|
|
|
#define uncover(n) \
|
|
if (((dpl_node *)(n))->hidden) dpl_Unhide(n)
|
|
|
|
#define do_flush (__dpl_cache_mode == dpl_cache_mode_write_thru)
|
|
#define flush_node(n) if (do_flush) dpl_Flush(n)
|
|
|
|
/*{{{ static dpl_list *new_list ( dpl_node *item )*/
|
|
static dpl_list *new_list ( dpl_node *item )
|
|
{
|
|
dpl_list *l;
|
|
l=malloc(sizeof(dpl_list));
|
|
if (l) {
|
|
init_list (l, item );
|
|
return l;
|
|
}
|
|
else return NULL;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ void init_list ( dpl_list *list, dpl_node *item )*/
|
|
static
|
|
void init_list ( dpl_list *list, dpl_node *item )
|
|
{
|
|
if (list) {
|
|
list->next=NULL;
|
|
list->prev=NULL;
|
|
list->item=item;
|
|
list->type_check=item->type_check;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to init NULL list\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ void init_superlist ( dpl_superlist *list, dpl_type type )*/
|
|
static void init_superlist ( dpl_node *node, dpl_superlist *list, dpl_type type )
|
|
{
|
|
if (list) {
|
|
list->dplnode=node;
|
|
list->last_accessed=NULL;
|
|
list->tail=NULL;
|
|
list->head=NULL;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to init NULL superlist\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ static dpl_node *get_first ( dpl_superlist *list )*/
|
|
static dpl_node *get_first ( dpl_superlist *list )
|
|
{
|
|
if (list) {
|
|
list->last_accessed=list->head;
|
|
if (list->head)
|
|
return list->head->item;
|
|
else
|
|
return NULL;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to get first on NULL superlist\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void *get_next ( dpl_superlist *list )*/
|
|
static void *get_next ( dpl_superlist *list )
|
|
{
|
|
dpl_list *last=list->last_accessed;
|
|
|
|
if (last) {
|
|
last=last->next;
|
|
list->last_accessed=last;
|
|
if (last)
|
|
return last->item;
|
|
else
|
|
return NULL;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to get next on NULL superlist\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ static void add_item ( dpl_superlist *list, dpl_node *item )*/
|
|
static void add_item ( dpl_superlist *list, dpl_node *item )
|
|
{
|
|
if (list) {
|
|
dpl_list *l=new_list(item);
|
|
|
|
/* do ghost operation */
|
|
ghost_dpl_add_list_item ( list, item );
|
|
|
|
/* add to tail */
|
|
if (list->head == list->tail) {
|
|
if (list->head) {
|
|
/* just one item in list - make me tail */
|
|
list->tail->next=l;
|
|
l->next=NULL;
|
|
l->prev=list->tail;
|
|
list->tail=l;
|
|
}
|
|
else {
|
|
/* no items in list - make me head and tail */
|
|
list->head=l;
|
|
list->tail=l;
|
|
}
|
|
}
|
|
else {
|
|
list->tail->next=l;
|
|
l->prev=list->tail;
|
|
l->next=NULL;
|
|
list->tail=l;
|
|
}
|
|
l->item=item;
|
|
item->ref_count++;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to add to NULL superlist\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ static dpl_list *find_item ( dpl_superlist *list, dpl_node *item )*/
|
|
static dpl_list *
|
|
find_item ( dpl_superlist *list, dpl_node *item )
|
|
{
|
|
if (list) {
|
|
dpl_list *l=list->head;
|
|
|
|
if (l) {
|
|
while (l->item != item) {
|
|
l=l->next;
|
|
if (l==NULL) {
|
|
return NULL;
|
|
}
|
|
}
|
|
return l;
|
|
}
|
|
return NULL;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to find item in NULL superlist\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ unlink_superlist_item ( dpl_superlist *list, dpl_list *l )*/
|
|
static void
|
|
unlink_superlist_item ( dpl_superlist *list, dpl_list *l )
|
|
{
|
|
/* l points at list item to remove */
|
|
if (l==list->head) {
|
|
/* I am head of list */
|
|
if (list->head == list->tail) {
|
|
list->head=NULL;
|
|
list->tail=NULL;
|
|
}
|
|
else {
|
|
/* I am head of list */
|
|
list->head=l->next;
|
|
if (l->next)
|
|
l->next->prev=NULL;
|
|
}
|
|
}
|
|
else {
|
|
l->prev->next=l->next;
|
|
if (l->next) {
|
|
l->next->prev=l->prev;
|
|
}
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void remove_item ( dpl_superlist *list, dpl_node *item )*/
|
|
static void remove_item ( dpl_superlist *list, dpl_node *item )
|
|
{
|
|
if (list) {
|
|
dpl_list *l;
|
|
|
|
if (l=find_item(list, item )) {
|
|
|
|
ghost_dpl_remove_list_item ( list, item );
|
|
|
|
unlink_superlist_item ( list, l );
|
|
|
|
item->ref_count--;
|
|
|
|
free(l);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "item 0x%x type %d not found in list\n",
|
|
item, item->type_check );
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to remove from NULL superlist\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
|
|
/*{{{ static dpl_node *new_node ( int size_in_bytes, dpl_type type )*/
|
|
static dpl_node *new_node ( int32 size_in_bytes, dpl_type type,
|
|
int32 (*init)( struct s_dplnode *))
|
|
{
|
|
dpl_node *new=(dpl_node *) malloc(size_in_bytes);
|
|
new->type_check=type;
|
|
new->hidden=0;
|
|
new->ref_count=0;
|
|
|
|
ghost_dpl_bind_functions ( new );
|
|
|
|
new->ghost_create(new);
|
|
init(new);
|
|
new->flush(new);
|
|
|
|
new->app_specific=NULL;
|
|
|
|
return new;
|
|
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void free_node ( dpl_node *n)*/
|
|
static int free_node ( dpl_node *n)
|
|
{
|
|
if (n->ref_count==0) {
|
|
(n->ghost_delete)(n);
|
|
free ( n );
|
|
return 0;
|
|
}
|
|
else {
|
|
if (dpl_WarningLevel > 1)
|
|
printf ("Not deleting node 0x%x, %d refs remain\n", n, n->ref_count );
|
|
|
|
return n->ref_count;
|
|
}
|
|
}
|
|
|
|
/*}}} */
|
|
|
|
#define dpl_name_hash 16
|
|
|
|
static dpl_superlist super_hash[dpl_name_hash];
|
|
|
|
/*{{{ dpl_hash_name ( char *name )*/
|
|
static dpl_superlist *
|
|
dpl_hash_name ( char *name )
|
|
{
|
|
check_inited(NULL);
|
|
|
|
if (name) {
|
|
int hash, l=strlen(name);
|
|
|
|
hash=((int) name[0] + (int) name[l] + (int) name[l/2]);
|
|
hash&=(dpl_name_hash-1);
|
|
|
|
return &super_hash[hash];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to hash NULL name\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_init_nametable ( void )*/
|
|
static void
|
|
dpl_init_nametable ( void )
|
|
{
|
|
int i;
|
|
for (i=0; i<dpl_name_hash; i++ ) {
|
|
init_superlist ( NULL, &(super_hash[i]), dpl_type_nameitem );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ char *dpl_TypeToString ( dpl_type t )*/
|
|
static char useful[4][64];
|
|
int useful_index=0;
|
|
|
|
char *dpl_TypeToString ( dpl_type t )
|
|
{
|
|
char *ret;
|
|
char *cpy=&useful[useful_index][0];
|
|
|
|
useful_index++;
|
|
useful_index&=3;
|
|
|
|
switch (t) {
|
|
case dpl_type_zone :
|
|
ret="zone";
|
|
break;
|
|
case dpl_type_view :
|
|
ret="view";
|
|
break;
|
|
case dpl_type_instance :
|
|
ret="instance";
|
|
break;
|
|
case dpl_type_lmodel :
|
|
ret="lmodel";
|
|
break;
|
|
case dpl_type_light :
|
|
ret="light";
|
|
break;
|
|
case dpl_type_dcs :
|
|
ret="dcs";
|
|
break;
|
|
case dpl_type_object :
|
|
ret="object";
|
|
break;
|
|
case dpl_type_lod :
|
|
ret="lod";
|
|
break;
|
|
case dpl_type_geogroup :
|
|
ret="geogroup";
|
|
break;
|
|
case dpl_type_geometry :
|
|
ret="geometry";
|
|
break;
|
|
case dpl_type_material :
|
|
ret="material";
|
|
break;
|
|
case dpl_type_texmap :
|
|
ret="texmap";
|
|
break;
|
|
case dpl_type_texture :
|
|
ret="texture";
|
|
break;
|
|
case dpl_type_nameitem :
|
|
ret="nametable entry";
|
|
break;
|
|
case dpl_type_extnitem :
|
|
ret="filepath extn";
|
|
break;
|
|
case dpl_type_pathitem :
|
|
ret="filepath";
|
|
break;
|
|
default :
|
|
ret="not implemented!";
|
|
break;
|
|
}
|
|
|
|
strcpy ( cpy, ret );
|
|
|
|
return cpy;
|
|
}
|
|
|
|
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ static initialization functions*/
|
|
#define typeize(type,node) type *t=(type *) node
|
|
|
|
/*{{{ static void identity ( dpl_MATRIX *m )*/
|
|
static void identity ( dpl_MATRIX m )
|
|
{
|
|
int i, j;
|
|
|
|
for (i=0; i<4; i++ ) {
|
|
for (j=0; j<4; j++ ) {
|
|
m[i][j]=0;
|
|
if (i==j) m[i][j]=1;
|
|
}
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_init_scene ( dpl_node * node)*/
|
|
dpl_init_scene ( dpl_node * node)
|
|
{
|
|
typeize(dpl_SCENE, node);
|
|
|
|
init_superlist ( node, &t->zone_list, dpl_type_zone );
|
|
init_superlist ( node, &t->view_list, dpl_type_view );
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_zone ( dpl_node * node)*/
|
|
dpl_init_zone ( dpl_node * node)
|
|
{
|
|
typeize(dpl_ZONE, node);
|
|
|
|
|
|
t->root = NULL;
|
|
t->lmodel = NULL;
|
|
t->enable = 1;
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_view ( dpl_node * node)*/
|
|
dpl_init_view ( dpl_node * node)
|
|
{
|
|
typeize(dpl_VIEW, node);
|
|
|
|
|
|
t->enable=1;
|
|
t->x1 = 1;
|
|
t->x0 =-1;
|
|
t->y1 = 1;
|
|
t->y0 =-1;
|
|
t->zeye= 1;
|
|
|
|
init_superlist ( node, &t->zone_list, dpl_type_zone );
|
|
identity (t->matrix);
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_lmodel ( dpl_node * node)*/
|
|
dpl_init_lmodel ( dpl_node * node)
|
|
{
|
|
typeize(dpl_LMODEL, node);
|
|
|
|
|
|
init_superlist ( node, &t->light_list, dpl_type_light );
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_light ( dpl_node * node)*/
|
|
dpl_init_light ( dpl_node * node)
|
|
{
|
|
typeize(dpl_LIGHT, node);
|
|
|
|
|
|
t->dcs=NULL;
|
|
t->light_type=dpl_light_type_disable;
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_ramp ( dpl_node * node)*/
|
|
dpl_init_ramp ( dpl_node * node)
|
|
{
|
|
typeize(dpl_RAMP, node);
|
|
|
|
|
|
t->color0[0]=0.0f;
|
|
t->color0[1]=0.0f;
|
|
t->color0[2]=0.0f;
|
|
|
|
t->color1[0]=0.999f;
|
|
t->color1[1]=0.999f;
|
|
t->color1[2]=0.999f;
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_material ( dpl_node * node)*/
|
|
dpl_init_material ( dpl_node * node)
|
|
{
|
|
typeize(dpl_MATERIAL, node);
|
|
|
|
|
|
t->texture = NULL;
|
|
|
|
t->ambient[0]=1.0f;
|
|
t->ambient[1]=0.0f;
|
|
t->ambient[2]=0.0f;
|
|
|
|
t->diffuse[0]=1.0f;
|
|
t->diffuse[1]=0.0f;
|
|
t->diffuse[2]=0.0f;
|
|
|
|
t->opacity[0]=1.0f;
|
|
t->opacity[1]=1.0f;
|
|
t->opacity[2]=1.0f;
|
|
|
|
t->specular[0]=0.0f;
|
|
t->specular[1]=0.0f;
|
|
t->specular[2]=0.0f;
|
|
t->specular[3]=0.0f;
|
|
|
|
t->ramp=NULL;
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_texmap ( dpl_node * node)*/
|
|
dpl_init_texmap ( dpl_node * node)
|
|
{
|
|
typeize(dpl_TEXMAP, node);
|
|
|
|
|
|
t->texels=NULL;
|
|
t->u_size=0;
|
|
t->v_size=0;
|
|
t->bits_per_texel=0;
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_texture ( dpl_node * node)*/
|
|
dpl_init_texture ( dpl_node * node)
|
|
{
|
|
typeize(dpl_TEXTURE, node);
|
|
|
|
|
|
t->texmap=NULL;
|
|
t->minify=0;
|
|
t->magnify=0;
|
|
t->alpha=0;
|
|
t->wrap_u=0;
|
|
t->wrap_v=0;
|
|
t->detail=0;
|
|
t->u0=0.0f;
|
|
t->v0=0.0f;
|
|
t->du=0.0f;
|
|
t->dv=0.0f;
|
|
t->animate_time=0.0f;
|
|
t->animate_behaviour=0;
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_instance ( dpl_node * node)*/
|
|
dpl_init_instance ( dpl_node * node)
|
|
{
|
|
typeize(dpl_INSTANCE, node);
|
|
|
|
|
|
t->dcs=NULL;
|
|
t->billboard=0;
|
|
t->intersectmode=dpl_isect_mode_none;
|
|
t->object=NULL;
|
|
t->forcelod=NULL;
|
|
t->f_material=NULL;
|
|
t->b_material=NULL;
|
|
t->f_texture=NULL;
|
|
t->b_texture=NULL;
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_object ( dpl_node * node)*/
|
|
dpl_init_object ( dpl_node * node)
|
|
{
|
|
typeize(dpl_OBJECT, node);
|
|
|
|
|
|
init_superlist ( node, &t->lod_list, dpl_type_lod );
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_lod ( dpl_node * node)*/
|
|
dpl_init_lod ( dpl_node * node)
|
|
{
|
|
typeize(dpl_LOD, node);
|
|
|
|
t->switch_in =-1.0f;
|
|
t->switch_out=-1.0f;
|
|
t->parent=NULL;
|
|
|
|
t->bounds[0][0] = 0.0f;
|
|
t->bounds[0][1] = 0.0f;
|
|
t->bounds[0][2] = 0.0f;
|
|
t->bounds[0][3] = 1.0f;
|
|
t->bounds[1][0] = 0.0f;
|
|
t->bounds[1][1] = 0.0f;
|
|
t->bounds[1][2] = 0.0f;
|
|
t->bounds[1][3] = 1.0f;
|
|
|
|
init_superlist ( node, &t->geogroup_list, dpl_type_geogroup );
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_geogroup ( dpl_node * node)*/
|
|
dpl_init_geogroup ( dpl_node * node)
|
|
{
|
|
typeize(dpl_GEOGROUP, node);
|
|
|
|
t->f_material=NULL;
|
|
t->b_material=NULL;
|
|
t->bounds[0][0] = 0.0f;
|
|
t->bounds[0][1] = 0.0f;
|
|
t->bounds[0][2] = 0.0f;
|
|
t->bounds[0][3] = 1.0f;
|
|
t->bounds[1][0] = 0.0f;
|
|
t->bounds[1][1] = 0.0f;
|
|
t->bounds[1][2] = 0.0f;
|
|
t->bounds[1][3] = 1.0f;
|
|
t->parent=NULL;
|
|
init_superlist ( node, &t->geometry_list, dpl_type_geometry );
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_geometry ( dpl_node * node)*/
|
|
dpl_init_geometry ( dpl_node * node)
|
|
{
|
|
typeize(dpl_GEOMETRY, node);
|
|
|
|
t->geometry_type = dpl_g_type_empty;
|
|
t->connections = NULL;
|
|
t->vertices = NULL;
|
|
t->parent = NULL;
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_dcs ( dpl_node * node)*/
|
|
dpl_init_dcs (dpl_node * node)
|
|
{
|
|
typeize(dpl_DCS, node);
|
|
|
|
t->parent = NULL;
|
|
t->child = NULL;
|
|
t->sibling = NULL;
|
|
t->node = NULL;
|
|
t->identity = 0;
|
|
t->enable = dcs_node_enable | dcs_subtree_enable;
|
|
identity (t->matrix);
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_init_nameitem ( dpl_node * node)*/
|
|
dpl_init_nameitem ( dpl_node * node)
|
|
{
|
|
typeize(dpl_NAME, node);
|
|
|
|
|
|
t->item=NULL;
|
|
t->name=NULL;
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_filepath ( dpl_node *node )*/
|
|
static void dpl_init_filepath ( dpl_node *node )
|
|
{
|
|
typeize(dpl_FILEPATH, node);
|
|
|
|
init_superlist ( NULL, &t->path_list, dpl_type_pathitem );
|
|
init_superlist ( NULL, &t->extn_list, dpl_type_extnitem );
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void dpl_init_pathitem ( dpl_node *node )*/
|
|
static void dpl_init_pathitem ( dpl_node *node )
|
|
{
|
|
typeize(dpl_PATHITEM, node);
|
|
t->path=NULL;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void dpl_init_extnitem ( dpl_node *node )*/
|
|
static void dpl_init_extnitem ( dpl_node *node )
|
|
{
|
|
typeize(dpl_EXTNITEM, node);
|
|
|
|
t->extn=NULL;
|
|
t->load_ext=NULL;
|
|
}
|
|
/*}}} */
|
|
/*}}} */
|
|
/*{{{ bounding geometry*/
|
|
/*{{{ static void minimax_point ( dpl_POINT mini, dpl_POINT maxi, dpl_POINT p )*/
|
|
static void minimax_point ( dpl_POINT mini, dpl_POINT maxi, dpl_POINT p )
|
|
{
|
|
if (p[0] < mini[0]) mini[0]=p[0];
|
|
if (p[1] < mini[1]) mini[1]=p[1];
|
|
if (p[2] < mini[2]) mini[2]=p[2];
|
|
|
|
if (p[0] > maxi[0]) maxi[0]=p[0];
|
|
if (p[1] > maxi[1]) maxi[1]=p[1];
|
|
if (p[2] > maxi[2]) maxi[2]=p[2];
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void mini_point ( dpl_POINT mini, dpl_POINT p )*/
|
|
static void mini_point ( dpl_POINT mini, dpl_POINT p )
|
|
{
|
|
if (p[0] < mini[0]) mini[0]=p[0];
|
|
if (p[1] < mini[1]) mini[1]=p[1];
|
|
if (p[2] < mini[2]) mini[2]=p[2];
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void maxi_point ( dpl_POINT maxi, dpl_POINT p )*/
|
|
static void maxi_point ( dpl_POINT maxi, dpl_POINT p )
|
|
{
|
|
if (p[0] > maxi[0]) maxi[0]=p[0];
|
|
if (p[1] > maxi[1]) maxi[1]=p[1];
|
|
if (p[2] > maxi[2]) maxi[2]=p[2];
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ static void bound_geometry ( dpl_POINT mini, dpl_POINT maxi,*/
|
|
static void bound_geometry ( dpl_POINT mini, dpl_POINT maxi,
|
|
dpl_GEOMETRY *geo, int first )
|
|
{
|
|
if (geo) {
|
|
uncover(geo);
|
|
if (geo->geometry_type==dpl_g_type_spheres) {
|
|
dpl_error ( dpl_errmess, "cant bound spheres yet\n" );
|
|
return;
|
|
}
|
|
else if (geo->geometry_type==dpl_g_type_string) {
|
|
dpl_error ( dpl_errmess, "cant bound spheres yet\n" );
|
|
return;
|
|
}
|
|
else {
|
|
dpl_VERTEX_LIST *vl=geo->vertices;
|
|
dpl_VERTEX *vert;
|
|
if (vl) {
|
|
while (vl) {
|
|
int i;
|
|
vert=&vl->vertices[0];
|
|
for (i=0; i<vl->n_vertices;i++ ) {
|
|
if (first) {
|
|
first=0;
|
|
memcpy ( mini, vert->position, sizeof(dpl_POINT));
|
|
memcpy ( maxi, mini, sizeof(dpl_POINT));
|
|
}
|
|
else {
|
|
minimax_point ( mini, maxi, vert->position );
|
|
}
|
|
vert++;
|
|
}
|
|
vl=vl->next;
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to bound geometry with NULL vertices\n" );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to bound NULL geometry\n" );
|
|
return;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*}}} */
|
|
|
|
/*{{{ DPL API ====> list management*/
|
|
/*{{{ dpl_AddZoneToScene ( dpl_ZONE *z )*/
|
|
void
|
|
dpl_AddZoneToScene ( dpl_ZONE *z )
|
|
{
|
|
add_item ( &the_scene.zone_list, (dpl_node *) z );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddViewToScene ( dpl_VIEW *v )*/
|
|
void
|
|
dpl_AddViewToScene ( dpl_VIEW *v )
|
|
{
|
|
add_item ( &the_scene.view_list, (dpl_node *) v );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddZoneToView ( dpl_VIEW *v, dpl_ZONE *z )*/
|
|
void
|
|
dpl_AddZoneToView ( dpl_VIEW *v, dpl_ZONE *z )
|
|
{
|
|
add_item ( &v->zone_list, (dpl_node *) z );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddLightToLmodel ( dpl_LMODEL *lm, dpl_LIGHT *l )*/
|
|
void
|
|
dpl_AddLightToLmodel ( dpl_LMODEL *lm, dpl_LIGHT *l )
|
|
{
|
|
add_item ( &lm->light_list, (dpl_node *) l );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddLodToObject ( dpl_OBJECT *o, dpl_LOD *lod )*/
|
|
void
|
|
dpl_AddLodToObject ( dpl_OBJECT *o, dpl_LOD *lod )
|
|
{
|
|
add_item ( &o->lod_list, (dpl_node *) lod );
|
|
lod->parent=o;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddGeogroupToLod ( dpl_LOD *l, dpl_GEOGROUP *gg )*/
|
|
void
|
|
dpl_AddGeogroupToLod ( dpl_LOD *l, dpl_GEOGROUP *gg )
|
|
{
|
|
add_item ( &l->geogroup_list, (dpl_node *) gg );
|
|
gg->parent=l;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddGeometryToGeogroup ( dpl_GEOGROUP *gg, dpl_GEOMETRY *g )*/
|
|
void
|
|
dpl_AddGeometryToGeogroup ( dpl_GEOGROUP *gg, dpl_GEOMETRY *g )
|
|
{
|
|
add_item ( &gg->geometry_list, (dpl_node *) g );
|
|
g->parent=gg;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddPathToFilepath ( dpl_FILEPATH *fp, dpl_PATHITEM *pi )*/
|
|
void
|
|
dpl_AddPathToFilepath ( dpl_FILEPATH *fp, dpl_PATHITEM *pi )
|
|
{
|
|
add_item ( &fp->path_list, (dpl_node *) pi );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_AddExtToFilepath ( dpl_FILEPATH *fp, dpl_EXTNITEM *ei )*/
|
|
void
|
|
dpl_AddExtToFilepath ( dpl_FILEPATH *fp, dpl_EXTNITEM *ei )
|
|
{
|
|
add_item ( &fp->extn_list, (dpl_node *) ei );
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_RemoveZoneFromScene ( dpl_ZONE *z )*/
|
|
void
|
|
dpl_RemoveZoneFromScene ( dpl_ZONE *z )
|
|
{
|
|
remove_item ( &the_scene.zone_list, (dpl_node *) z );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveViewFromScene ( dpl_VIEW *v )*/
|
|
void
|
|
dpl_RemoveViewFromScene ( dpl_VIEW *v )
|
|
{
|
|
remove_item ( &the_scene.view_list, (dpl_node *) v );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveZoneFromView ( dpl_VIEW *v, dpl_ZONE *z )*/
|
|
void
|
|
dpl_RemoveZoneFromView ( dpl_VIEW *v, dpl_ZONE *z )
|
|
{
|
|
remove_item ( &v->zone_list, (dpl_node *) z );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveLightFromLmodel ( dpl_LMODEL *lm, dpl_LIGHT *l )*/
|
|
void
|
|
dpl_RemoveLightFromLmodel ( dpl_LMODEL *lm, dpl_LIGHT *l )
|
|
{
|
|
remove_item ( &lm->light_list, (dpl_node *) l );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveLodFromObject ( dpl_OBJECT *o, dpl_LOD *lod )*/
|
|
void
|
|
dpl_RemoveLodFromObject ( dpl_OBJECT *o, dpl_LOD *lod )
|
|
{
|
|
remove_item ( &o->lod_list, (dpl_node *) lod );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveGeogroupFromLod ( dpl_LOD *l, dpl_GEOGROUP *gg )*/
|
|
void
|
|
dpl_RemoveGeogroupFromLod ( dpl_LOD *l, dpl_GEOGROUP *gg )
|
|
{
|
|
remove_item ( &l->geogroup_list, (dpl_node *) gg );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveGeometryFromGeogroup ( dpl_GEOGROUP *gg, dpl_GEOMETRY *g )*/
|
|
void
|
|
dpl_RemoveGeometryFromGeogroup ( dpl_GEOGROUP *gg, dpl_GEOMETRY *g )
|
|
{
|
|
remove_item ( &gg->geometry_list, (dpl_node *) g );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemovePathFromFilepath ( dpl_FILEPATH *fp, dpl_PATHITEM *pi )*/
|
|
void
|
|
dpl_RemovePathFromFilepath ( dpl_FILEPATH *fp, dpl_PATHITEM *pi )
|
|
{
|
|
remove_item ( &fp->path_list, (dpl_node *) pi );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveExtFromFilepath ( dpl_FILEPATH *fp, dpl_EXTNITEM *ei )*/
|
|
void
|
|
dpl_RemoveExtFromFilepath ( dpl_FILEPATH *fp, dpl_EXTNITEM *ei )
|
|
{
|
|
remove_item ( &fp->extn_list, (dpl_node *) ei );
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> tree management*/
|
|
/*{{{ dpl_NestDCS ( dpl_DCS *parent, dpl_DCS *child )*/
|
|
void
|
|
dpl_NestDCS ( dpl_DCS *parent, dpl_DCS *child )
|
|
{
|
|
if (parent) {
|
|
if (child) {
|
|
uncover ( parent );
|
|
uncover ( child );
|
|
if (parent->child) {
|
|
dpl_error ( dpl_errmess, "parent 0x%x already has child 0x%x in NestDCS\n",
|
|
parent, child );
|
|
return;
|
|
}
|
|
if (child->parent) {
|
|
dpl_error ( dpl_errmess, "child 0x%x already has parent 0x%x in NestDCS\n",
|
|
child, parent );
|
|
}
|
|
child->parent=parent;
|
|
parent->child=child;
|
|
|
|
parent->dplnode.ref_count++;
|
|
child->dplnode.ref_count++;
|
|
|
|
/* do ghost operation */
|
|
ghost_dpl_nest_dcs ( parent, child );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to Nest 0x%x with a NULL child\n", parent );
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to Nest 0x%x to a NULL parent\n", child );
|
|
return;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_LinkDCS ( dpl_DCS *bro, dpl_DCS *sis )*/
|
|
void
|
|
dpl_LinkDCS ( dpl_DCS *bro, dpl_DCS *sis )
|
|
{
|
|
if (bro) {
|
|
if (sis) {
|
|
uncover ( bro );
|
|
uncover ( sis );
|
|
if (bro->sibling) {
|
|
dpl_error ( dpl_errmess, "bro 0x%x already has sibling 0x%x in LinkDCS\n",
|
|
bro, sis );
|
|
return;
|
|
}
|
|
if (sis->parent) {
|
|
dpl_error ( dpl_errmess, "sis 0x%x already has bro 0x%x in LinkDCS\n",
|
|
sis, bro );
|
|
}
|
|
sis->parent=bro;
|
|
bro->sibling=sis;
|
|
sis->dplnode.ref_count++;
|
|
bro->dplnode.ref_count++;
|
|
/* do ghost operation */
|
|
ghost_dpl_link_dcs ( bro, sis );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to Link 0x%x with a NULL sis\n", bro );
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to Link 0x%x to a NULL bro\n", sis );
|
|
return;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_PruneDCS ( dpl_DCS *node )*/
|
|
void
|
|
dpl_PruneDCS ( dpl_DCS *node )
|
|
{
|
|
if (node) {
|
|
dpl_DCS *daddy;
|
|
|
|
uncover ( node );
|
|
daddy=node->parent;
|
|
|
|
if (daddy) {
|
|
daddy->dplnode.ref_count--;
|
|
node->dplnode.ref_count--;
|
|
|
|
if (daddy->child == node) {
|
|
node->parent=NULL;
|
|
daddy->child=NULL;
|
|
}
|
|
else if (daddy->sibling == node) {
|
|
node->parent =NULL;
|
|
daddy->sibling=NULL;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "badly formed tree discovered in PruneDCS 0x%x\n", node );
|
|
return;
|
|
}
|
|
ghost_dpl_prune_dcs ( daddy, node );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to prune DCS 0x%x has no parent\n", node );
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to prune NULL DCS\n" );
|
|
return;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ DPL API ====> SCENE functions*/
|
|
|
|
/*{{{ dpl_DrawScene ( void )*/
|
|
void
|
|
dpl_DrawScene ( int32 double_buffered )
|
|
{
|
|
check_inited_noret();
|
|
|
|
ghost_dpl_draw_scene ( double_buffered );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DrawSceneComplete ( void )*/
|
|
int32
|
|
dpl_DrawSceneComplete ( void )
|
|
{
|
|
check_inited(1);
|
|
|
|
return ghost_dpl_draw_scene_complete ();
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_WaitSceneComplete ( void )*/
|
|
void
|
|
dpl_WaitSceneComplete ( void )
|
|
{
|
|
check_inited_noret();
|
|
ghost_dpl_wait_draw_scene_complete ();
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetSceneFirstZone ( void )*/
|
|
dpl_ZONE *
|
|
dpl_GetSceneFirstZone ( void )
|
|
{
|
|
check_inited(NULL);
|
|
|
|
uncover ( &the_scene );
|
|
return (dpl_ZONE *) get_first ( &the_scene.zone_list );
|
|
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetSceneNextZone ( void )*/
|
|
dpl_ZONE *
|
|
dpl_GetSceneNextZone ( void )
|
|
{
|
|
check_inited(NULL);
|
|
uncover ( &the_scene );
|
|
return (dpl_ZONE *) get_next ( &the_scene.zone_list );
|
|
}
|
|
/*}}} */
|
|
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> ZONE functions*/
|
|
|
|
/*{{{ dpl_NewZone ( void )*/
|
|
dpl_ZONE *
|
|
dpl_NewZone ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_ZONE*) new_node ( sizeof(dpl_ZONE), dpl_type_zone, dpl_init_zone );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteZone ( dpl_ZONE *z )*/
|
|
void
|
|
dpl_DeleteZone ( dpl_ZONE *z )
|
|
{
|
|
check_inited_noret();
|
|
if (z) {
|
|
uncover ( z );
|
|
|
|
dec_ref ( z->root );
|
|
dec_ref ( z->lmodel );
|
|
|
|
free_node ( (dpl_node *) z );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL zone\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetZoneRootDcs ( dpl_ZONE *z )*/
|
|
dpl_DCS *
|
|
dpl_GetZoneRootDcs ( dpl_ZONE *z )
|
|
{
|
|
check_inited(NULL);
|
|
if (z) {
|
|
uncover ( z );
|
|
return z->root;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetZoneRootDcs NULL zone\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetZoneRootDcs ( dpl_ZONE *z, dpl_DCS *h )*/
|
|
void
|
|
dpl_SetZoneRootDcs ( dpl_ZONE *z, dpl_DCS *h )
|
|
{
|
|
check_inited_noret();
|
|
if (z) {
|
|
uncover ( z );
|
|
z->root=h;
|
|
flush_node(z);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "SetZoneRootDcs on NULL zone\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetZoneLmodel ( dpl_ZONE *z )*/
|
|
dpl_LMODEL *
|
|
dpl_GetZoneLmodel ( dpl_ZONE *z )
|
|
{
|
|
check_inited(NULL);
|
|
if (z)
|
|
return (dpl_LMODEL *) z->lmodel;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetZoneLmodel on NULL zone\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetZoneLmodel ( dpl_ZONE *z, dpl_LMODEL *lm )*/
|
|
void
|
|
dpl_SetZoneLmodel ( dpl_ZONE *z, dpl_LMODEL *lm )
|
|
{
|
|
check_inited_noret();
|
|
if (z) {
|
|
z->lmodel=lm;
|
|
flush_node(z);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetZoneLmodel on NULL zone\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetZoneEnable ( dpl_ZONE *z )*/
|
|
int32
|
|
dpl_GetZoneEnable ( dpl_ZONE *z )
|
|
{
|
|
check_inited(0);
|
|
if (z)
|
|
return z->enable;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetZoneEnable on NULL zone\n" );
|
|
return 0;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetZoneEnable ( dpl_ZONE *z, int32 i )*/
|
|
void
|
|
dpl_SetZoneEnable ( dpl_ZONE *z, int32 i )
|
|
{
|
|
check_inited_noret();
|
|
if (z) {
|
|
z->enable=i;
|
|
flush_node(z);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetZoneEnable on NULL zone\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> DCS functions*/
|
|
|
|
/*{{{ dpl_NewDcs ( void )*/
|
|
dpl_DCS *
|
|
dpl_NewDcs ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_DCS *) new_node ( sizeof(dpl_DCS), dpl_type_dcs, dpl_init_dcs );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteDcs ( dpl_DCS *h )*/
|
|
void
|
|
dpl_DeleteDcs ( dpl_DCS *h )
|
|
{
|
|
check_inited_noret();
|
|
if (h) {
|
|
uncover(h);
|
|
|
|
dec_ref(h->node);
|
|
dec_ref(h->parent);
|
|
dec_ref(h->sibling);
|
|
dec_ref(h->child);
|
|
|
|
free_node ( (dpl_node *) h );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to Delete NULL DCS\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetDcsLinkage ( dpl_DCS *node, dpl_DCS **parent,*/
|
|
void
|
|
dpl_GetDcsLinkage ( dpl_DCS *node, dpl_DCS **parent,
|
|
dpl_DCS **child, dpl_DCS **sibling )
|
|
{
|
|
check_inited_noret();
|
|
if (node) {
|
|
uncover ( node );
|
|
*child =node->child;
|
|
*sibling=node->sibling;
|
|
*parent =node->parent;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetDcsLinkage on NULL DCS\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetDcsNode ( dpl_DCS *hnode, dpl_node *cnode )*/
|
|
void
|
|
dpl_SetDcsNode ( dpl_DCS *hnode, dpl_node *cnode )
|
|
{
|
|
dpl_LIGHT *l=(dpl_LIGHT *) cnode;
|
|
dpl_INSTANCE *i=(dpl_INSTANCE *) cnode;
|
|
|
|
check_inited_noret();
|
|
|
|
if (hnode) {
|
|
uncover ( hnode );
|
|
dec_ref ( hnode->node );
|
|
if (cnode) {
|
|
switch (cnode->type_check) {
|
|
case dpl_type_light:
|
|
uncover ( cnode );
|
|
l->dcs=hnode;
|
|
break;
|
|
case dpl_type_instance:
|
|
uncover ( cnode );
|
|
i->dcs=hnode;
|
|
break;
|
|
default:
|
|
dpl_error ( dpl_errmess,
|
|
"wrong type 0x%x for SetDcsNode\n", cnode->type_check );
|
|
break;
|
|
}
|
|
}
|
|
hnode->node=cnode;
|
|
flush_node(hnode);
|
|
inc_ref ( cnode );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetDcsNode on NULL DCS\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetDcsNode ( dpl_DCS *hnode )*/
|
|
dpl_node *
|
|
dpl_GetDcsNode ( dpl_DCS *hnode )
|
|
{
|
|
check_inited(NULL);
|
|
if (hnode) {
|
|
uncover(hnode);
|
|
return hnode->node;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetDcsNode on NULL DCS\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetDcsMatrix ( dpl_DCS *hnode, dpl_MATRIX *m )*/
|
|
void
|
|
dpl_SetDcsMatrix ( dpl_DCS *hnode, dpl_MATRIX *m )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (hnode) {
|
|
uncover ( hnode );
|
|
if (m) {
|
|
memcpy ( hnode->matrix, m, sizeof(dpl_MATRIX));
|
|
flush_node(hnode);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetDcsMatrix with NULL matrix\n" );
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetDcsMatrix on NULL DCS\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetDcsMatrix ( dpl_DCS *hnode, dpl_MATRIX m )*/
|
|
void
|
|
dpl_GetDcsMatrix ( dpl_DCS *hnode, dpl_MATRIX m )
|
|
{
|
|
check_inited_noret();
|
|
if (hnode) {
|
|
uncover(hnode);
|
|
|
|
if (m) {
|
|
memcpy ( m, hnode->matrix, sizeof(dpl_MATRIX));
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetDcsMatrix into NULL matrix\n" );
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetDcsMatrix on NULL DCS\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetDcsNodeType ( dpl_DCS *hnode )*/
|
|
dpl_type
|
|
dpl_GetDcsNodeType ( dpl_DCS *hnode )
|
|
{
|
|
check_inited(dpl_type_error);
|
|
if (hnode) {
|
|
uncover (hnode);
|
|
if (hnode->node) {
|
|
uncover (hnode->node);
|
|
return hnode->node->type_check;
|
|
}
|
|
else
|
|
return dpl_type_error;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetDcsNodeType on NULL DCS\n" );
|
|
return dpl_type_error;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetDcsNodeEnable ( dpl_DCS *hnode, int32 enable )*/
|
|
void
|
|
dpl_SetDcsNodeEnable ( dpl_DCS *hnode, int32 enable )
|
|
{
|
|
check_inited_noret();
|
|
if (hnode) {
|
|
if (enable)
|
|
hnode->enable|= dcs_node_enable;
|
|
else
|
|
hnode->enable&=~dcs_node_enable;
|
|
|
|
flush_node(hnode);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetDcsNodeEnable on NULL DCS\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetDcsSubtreeEnable ( dpl_DCS *hnode, int32 enable )*/
|
|
void
|
|
dpl_SetDcsSubtreeEnable ( dpl_DCS *hnode, int32 enable )
|
|
{
|
|
check_inited_noret();
|
|
if (hnode) {
|
|
if (enable)
|
|
hnode->enable|= dcs_subtree_enable;
|
|
else
|
|
hnode->enable&=~dcs_subtree_enable;
|
|
|
|
flush_node(hnode);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetDcsSubtreeEnable on NULL DCS\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetDcsNodeEnable ( dpl_DCS *hnode )*/
|
|
int32
|
|
dpl_GetDcsNodeEnable ( dpl_DCS *hnode )
|
|
{
|
|
check_inited(0);
|
|
if (hnode) {
|
|
if (hnode->enable & dcs_node_enable)
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetDcsNodeEnable on NULL DCS\n" );
|
|
return 0;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetDcsSubtreeEnable ( dpl_DCS *hnode )*/
|
|
int32
|
|
dpl_GetDcsSubtreeEnable ( dpl_DCS *hnode )
|
|
{
|
|
check_inited(0);
|
|
if (hnode) {
|
|
if (hnode->enable & dcs_subtree_enable)
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetDcsSubtreeEnable on NULL DCS\n" );
|
|
return 0;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> INSTANCE functions*/
|
|
|
|
/*{{{ dpl_NewInstance ( void )*/
|
|
dpl_INSTANCE *
|
|
dpl_NewInstance ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_INSTANCE *) new_node ( sizeof(dpl_INSTANCE), dpl_type_instance, dpl_init_instance );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteInstance ( dpl_INSTANCE *i )*/
|
|
void
|
|
dpl_DeleteInstance ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
|
|
dec_ref(i->object);
|
|
dec_ref(i->forcelod);
|
|
dec_ref(i->f_material);
|
|
dec_ref(i->b_material);
|
|
dec_ref(i->f_texture );
|
|
dec_ref(i->b_texture );
|
|
|
|
free_node ( (dpl_node *) i);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to Delete NULL instance\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceObject ( dpl_INSTANCE *i, dpl_OBJECT *o )*/
|
|
void
|
|
dpl_SetInstanceObject ( dpl_INSTANCE *i, dpl_OBJECT *o )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
dec_ref (i->object);
|
|
i->object=o;
|
|
flush_node(i);
|
|
inc_ref ( o );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstanceObject on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceObject ( dpl_INSTANCE *i )*/
|
|
dpl_OBJECT *
|
|
dpl_GetInstanceObject ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(NULL);
|
|
if (i)
|
|
return (i->object);
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstanceObject on NULL object\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceFrontMaterial ( dpl_INSTANCE * i, dpl_MATERIAL *m )*/
|
|
void
|
|
dpl_SetInstanceFrontMaterial ( dpl_INSTANCE * i, dpl_MATERIAL *m )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
dec_ref (i->f_material);
|
|
i->f_material=m;
|
|
flush_node(i);
|
|
inc_ref ( m );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstanceFrontMtl on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceFrontMaterial ( dpl_INSTANCE *i )*/
|
|
dpl_MATERIAL *
|
|
dpl_GetInstanceFrontMaterial ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(NULL);
|
|
if (i)
|
|
return i->f_material;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstFrontMtl on NULL inst\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceBackMaterial ( dpl_INSTANCE *i, dpl_MATERIAL *m )*/
|
|
void
|
|
dpl_SetInstanceBackMaterial ( dpl_INSTANCE *i, dpl_MATERIAL *m )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
dec_ref (i->b_material);
|
|
i->b_material=m;
|
|
inc_ref ( m );
|
|
flush_node(i);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstanceBackMtl on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceBackMaterial ( dpl_INSTANCE *i )*/
|
|
dpl_MATERIAL *
|
|
dpl_GetInstanceBackMaterial ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(NULL);
|
|
if (i)
|
|
return i->b_material;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstFrontMtl on NULL inst\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceFrontTexture ( dpl_INSTANCE *i, dpl_TEXTURE *t )*/
|
|
void
|
|
dpl_SetInstanceFrontTexture ( dpl_INSTANCE *i, dpl_TEXTURE *t )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
dec_ref (i->f_texture);
|
|
i->f_texture=t;
|
|
inc_ref ( t );
|
|
flush_node(i);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstanceFrontTex on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceFrontTexture ( dpl_INSTANCE *i )*/
|
|
dpl_TEXTURE *
|
|
dpl_GetInstanceFrontTexture ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(NULL);
|
|
if (i)
|
|
return i->f_texture;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstFrontTex on NULL inst\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceBackTexture ( dpl_INSTANCE *i, dpl_TEXTURE *t )*/
|
|
void
|
|
dpl_SetInstanceBackTexture ( dpl_INSTANCE *i, dpl_TEXTURE *t )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
dec_ref (i->b_texture);
|
|
i->b_texture=t;
|
|
inc_ref ( t );
|
|
flush_node(i);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstanceBackTex on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceBackTexture ( dpl_INSTANCE *i )*/
|
|
dpl_TEXTURE *
|
|
dpl_GetInstanceBackTexture ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(NULL);
|
|
if (i)
|
|
return i->b_texture;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstBackTex on NULL inst\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceForceLOD ( dpl_INSTANCE *i, dpl_LOD *l )*/
|
|
void
|
|
dpl_SetInstanceForceLOD ( dpl_INSTANCE *i, dpl_LOD *l )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
dec_ref (i->forcelod);
|
|
i->forcelod=l;
|
|
inc_ref ( l );
|
|
flush_node(i);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstForceLOD on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceForceLOD ( dpl_INSTANCE *i )*/
|
|
dpl_LOD *
|
|
dpl_GetInstanceForceLOD ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(NULL);
|
|
if (i) {
|
|
uncover(i);
|
|
return i->forcelod;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstForceLOD on NULL inst\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceBillboard ( dpl_INSTANCE *i, int32 b )*/
|
|
void
|
|
dpl_SetInstanceBillboard ( dpl_INSTANCE *i, int32 b )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
i->billboard=b;
|
|
flush_node(i);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstBillboard on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceBillboard ( dpl_INSTANCE *i )*/
|
|
int32
|
|
dpl_GetInstanceBillboard ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(0);
|
|
if (i) {
|
|
uncover(i);
|
|
return i->billboard;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstBillboard on NULL inst\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetInstanceIntersect ( dpl_INSTANCE *i, dpl_isect_mode m )*/
|
|
void
|
|
dpl_SetInstanceIntersect ( dpl_INSTANCE *i, dpl_isect_mode m )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
i->intersectmode=m;
|
|
flush_node(i);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetInstIntersect on NULL inst\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetInstanceIntersect ( dpl_INSTANCE *i )*/
|
|
dpl_isect_mode
|
|
dpl_GetInstanceIntersect ( dpl_INSTANCE *i )
|
|
{
|
|
check_inited(0);
|
|
if (i) {
|
|
uncover(i);
|
|
return i->intersectmode;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetInstIntersect on NULL inst\n" );
|
|
return dpl_isect_mode_error;
|
|
}
|
|
if (i)
|
|
return i->intersectmode;
|
|
else
|
|
return dpl_isect_mode_none;
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> LIGHT functions*/
|
|
|
|
/*{{{ dpl_NewLmodel ( void )*/
|
|
dpl_LMODEL *
|
|
dpl_NewLmodel ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_LMODEL *) new_node ( sizeof(dpl_LMODEL), dpl_type_lmodel, dpl_init_lmodel );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteLmodel ( dpl_LMODEL *lm )*/
|
|
void
|
|
dpl_DeleteLmodel ( dpl_LMODEL *lm )
|
|
{
|
|
check_inited_noret();
|
|
if (lm) {
|
|
uncover ( lm );
|
|
|
|
free_node ( (dpl_node *) lm );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL Lmodel\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetLmodelFirstLight ( dpl_LMODEL *lm )*/
|
|
dpl_LIGHT *
|
|
dpl_GetLmodelFirstLight ( dpl_LMODEL *lm )
|
|
{
|
|
check_inited(NULL);
|
|
if (lm) {
|
|
uncover(lm);
|
|
return (dpl_LIGHT *) get_first ( &lm->light_list );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetLmodelFirstLight on NULL Lmodel\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetLmodelNextLight ( dpl_LMODEL *lm )*/
|
|
dpl_LIGHT *
|
|
dpl_GetLmodelNextLight ( dpl_LMODEL *lm )
|
|
{
|
|
check_inited(NULL);
|
|
if (lm) {
|
|
uncover (lm);
|
|
return (dpl_LIGHT *) get_next ( &lm->light_list );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetLmodelNextLight on NULL Lmodel\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewLight ( void )*/
|
|
dpl_LIGHT *
|
|
dpl_NewLight ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_LIGHT *) new_node ( sizeof(dpl_LIGHT), dpl_type_light, dpl_init_light );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteLight ( dpl_LIGHT *l )*/
|
|
void
|
|
dpl_DeleteLight ( dpl_LIGHT *l )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (l) {
|
|
uncover ( l );
|
|
|
|
dec_ref ( l->dcs );
|
|
|
|
free_node ( (dpl_node *) l );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetLightType ( dpl_LIGHT *l, dpl_light_type t )*/
|
|
void
|
|
dpl_SetLightType ( dpl_LIGHT *l, dpl_light_type t )
|
|
{
|
|
check_inited_noret();
|
|
if (l) {
|
|
uncover(l);
|
|
l->light_type=t;
|
|
flush_node(l);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetLightType on NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetLightType ( dpl_LIGHT *l )*/
|
|
dpl_light_type
|
|
dpl_GetLightType ( dpl_LIGHT *l )
|
|
{
|
|
check_inited(dpl_light_type_error);
|
|
if (l) {
|
|
uncover(l);
|
|
return l->light_type;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetLightType on NULL light\n" );
|
|
return dpl_light_type_error;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetLightColor ( dpl_LIGHT *l, float32 r, float32 g, float32 b )*/
|
|
void
|
|
dpl_SetLightColor ( dpl_LIGHT *l, float32 r, float32 g, float32 b )
|
|
{
|
|
check_inited_noret();
|
|
if (l) {
|
|
uncover(l);
|
|
l->color[0]=r;
|
|
l->color[1]=g;
|
|
l->color[2]=b;
|
|
flush_node(l);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetLightColor on NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetLightColor ( dpl_LIGHT *l, float32 *r, float32 *g, float32 *b )*/
|
|
void
|
|
dpl_GetLightColor ( dpl_LIGHT *l, float32 *r, float32 *g, float32 *b )
|
|
{
|
|
check_inited_noret();
|
|
if (l) {
|
|
uncover(l);
|
|
*r=l->color[0];
|
|
*g=l->color[1];
|
|
*b=l->color[2];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetLightColor on NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetLightRadii ( dpl_LIGHT *l, float32 r0, float32 r1 )*/
|
|
void
|
|
dpl_SetLightRadii ( dpl_LIGHT *l, float32 r0, float32 r1 )
|
|
{
|
|
check_inited_noret();
|
|
if (l) {
|
|
uncover(l);
|
|
l->radius[0]=r0;
|
|
l->radius[1]=r1;
|
|
flush_node(l);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetLightRadii on NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetLightRadii ( dpl_LIGHT *l, float32 *r0,float32 *r1 )*/
|
|
void
|
|
dpl_GetLightRadii ( dpl_LIGHT *l, float32 *r0,float32 *r1 )
|
|
{
|
|
check_inited_noret();
|
|
if (l) {
|
|
uncover(l);
|
|
*r0=l->radius[0];
|
|
*r1=l->radius[1];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetLightRadii on NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetLightUmbra ( dpl_LIGHT *l, float32 th1, float32 th2 )*/
|
|
void
|
|
dpl_SetLightUmbra ( dpl_LIGHT *l, float32 th1, float32 th2 )
|
|
{
|
|
check_inited_noret();
|
|
if (l) {
|
|
uncover(l);
|
|
l->umbra[0]=th1;
|
|
l->umbra[1]=th2;
|
|
flush_node(l);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetLightUmbra on NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetLightUmbra ( dpl_LIGHT *l, float32 *th1, float32 *th2 )*/
|
|
void
|
|
dpl_GetLightUmbra ( dpl_LIGHT *l, float32 *th1, float32 *th2 )
|
|
{
|
|
check_inited_noret();
|
|
if (l) {
|
|
uncover(l);
|
|
*th1=l->umbra[0];
|
|
*th2=l->umbra[1];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetLightUmbra on NULL light\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> VIEW functions*/
|
|
|
|
/*{{{ dpl_NewView ( void )*/
|
|
dpl_VIEW *
|
|
dpl_NewView ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_VIEW *) new_node ( sizeof(dpl_VIEW), dpl_type_view, dpl_init_view );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteView ( dpl_VIEW *v )*/
|
|
void
|
|
dpl_DeleteView ( dpl_VIEW *v )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover ( v );
|
|
|
|
free_node ( (dpl_node *) v );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL view\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetViewMatrix ( dpl_VIEW *v, dpl_MATRIX m )*/
|
|
void
|
|
dpl_SetViewMatrix ( dpl_VIEW *v, dpl_MATRIX m )
|
|
{
|
|
check_inited_noret();
|
|
if (v && m) {
|
|
uncover ( v );
|
|
memcpy ( v->matrix, m, sizeof(dpl_MATRIX));
|
|
flush_node(v);
|
|
}
|
|
else if (m) {
|
|
dpl_error ( dpl_errmess, "Attempt to SetViewMatrix on NULL view\n" );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetViewMatrix on NULL matrix\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetViewMatrix ( dpl_VIEW *v, dpl_MATRIX m )*/
|
|
void
|
|
dpl_GetViewMatrix ( dpl_VIEW *v, dpl_MATRIX m )
|
|
{
|
|
check_inited_noret();
|
|
if (v && m) {
|
|
uncover ( v );
|
|
memcpy ( v, v->matrix, sizeof(dpl_MATRIX));
|
|
}
|
|
else if (m) {
|
|
dpl_error ( dpl_errmess, "Attempt to GetViewMatrix on NULL view\n" );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetViewMatrix on NULL matrix\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetViewClipPlanes ( dpl_VIEW *v, float32 hither, float32 yon )*/
|
|
void
|
|
dpl_SetViewClipPlanes ( dpl_VIEW *v, float32 hither, float32 yon )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover(v);
|
|
v->hither_clip=hither;
|
|
v->yon_clip =yon;
|
|
flush_node(v);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetViewClipplanes on NULL matrix\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetViewClipPlanes ( dpl_VIEW *v, float32 *hither, float32 *yon )*/
|
|
void
|
|
dpl_GetViewClipPlanes ( dpl_VIEW *v, float32 *hither, float32 *yon )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover(v);
|
|
*hither=v->hither_clip;
|
|
*yon =v->yon_clip;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetViewClipplanes on NULL matrix\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetViewBackGround ( dpl_VIEW *v, float32 r, float32 g, float32 b )*/
|
|
void
|
|
dpl_SetViewBackGround ( dpl_VIEW *v, float32 r, float32 g, float32 b )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover(v);
|
|
|
|
v->back_color[0]=r;
|
|
v->back_color[1]=g;
|
|
v->back_color[2]=b;
|
|
flush_node(v);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetViewBackGround on NULL view\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetViewBackGround ( dpl_VIEW *v, float32 *r, float32 *g, float32 *b )*/
|
|
void
|
|
dpl_GetViewBackGround ( dpl_VIEW *v, float32 *r, float32 *g, float32 *b )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover(v);
|
|
|
|
*r=v->back_color[0];
|
|
*g=v->back_color[1];
|
|
*b=v->back_color[2];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetViewBackGround on NULL view\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetViewFog ( dpl_VIEW *v, int32 enable,*/
|
|
void
|
|
dpl_SetViewFog ( dpl_VIEW *v, int32 enable,
|
|
float32 r,
|
|
float32 g,
|
|
float32 b,
|
|
float32 neer,
|
|
float32 phar )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover(v);
|
|
|
|
v->fog_enable=enable;
|
|
v->fog[0]=neer;
|
|
v->fog[1]=phar;
|
|
|
|
v->fog[2]=r;
|
|
v->fog[3]=g;
|
|
v->fog[4]=b;
|
|
|
|
flush_node(v);
|
|
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetViewFog on NULL view\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetViewFog ( dpl_VIEW *v, int32 *enable,*/
|
|
void
|
|
dpl_GetViewFog ( dpl_VIEW *v, int32 *enable,
|
|
float32 *r, float32 *g, float32 *b,
|
|
float32 *neer, float32 *phar )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover(v);
|
|
*enable=v->fog_enable;
|
|
*neer=v->fog[0];
|
|
*phar=v->fog[1];
|
|
|
|
*r=v->fog[2];
|
|
*g=v->fog[3];
|
|
*b=v->fog[4];
|
|
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetViewFog on NULL view\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetViewProjection ( dpl_VIEW *v,*/
|
|
void
|
|
dpl_SetViewProjection ( dpl_VIEW *v,
|
|
float32 x_size, float32 y_size,
|
|
float32 x0, float32 y0,
|
|
float32 x1, float32 y1,
|
|
float32 zeye )
|
|
{
|
|
check_inited_noret();
|
|
if (v) {
|
|
uncover(v);
|
|
v->x_size=x_size;
|
|
v->y_size=y_size;
|
|
v->x0=x0;
|
|
v->y0=y0;
|
|
v->x1=x1;
|
|
v->y1=y1;
|
|
v->zeye=zeye;
|
|
flush_node(v);
|
|
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetViewProjn on NULL view\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetViewProjection ( dpl_VIEW *v,*/
|
|
void
|
|
dpl_GetViewProjection ( dpl_VIEW *v,
|
|
float32 *x_size, float32 *y_size,
|
|
float32 *x0, float32 *y0,
|
|
float32 *x1, float32 *y1,
|
|
float32 *zeye )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (v) {
|
|
uncover(v);
|
|
*x_size=v->x_size;
|
|
*y_size=v->y_size;
|
|
*x0=v->x0;
|
|
*y0=v->y0;
|
|
*x1=v->x1;
|
|
*y1=v->y1;
|
|
*zeye =v->zeye;
|
|
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetViewProjn on NULL view\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> MATERIAL functions*/
|
|
|
|
/*{{{ dpl_NewMaterial ( void )*/
|
|
dpl_MATERIAL *
|
|
dpl_NewMaterial ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_MATERIAL *) new_node ( sizeof(dpl_MATERIAL), dpl_type_material, dpl_init_material );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteMaterial ( dpl_MATERIAL *m )*/
|
|
void
|
|
dpl_DeleteMaterial ( dpl_MATERIAL *m )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover ( m );
|
|
|
|
dec_ref ( m->ramp );
|
|
dec_ref ( m->texture );
|
|
|
|
free_node ( (dpl_node *) m );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetMaterialEmissive ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )*/
|
|
void
|
|
dpl_SetMaterialEmissive ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
m->emissive[0]=r;
|
|
m->emissive[1]=g;
|
|
m->emissive[2]=b;
|
|
flush_node(m);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetMtlEmissive on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetMaterialEmissive ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )*/
|
|
void
|
|
dpl_GetMaterialEmissive ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
*r=m->emissive[0];
|
|
*g=m->emissive[1];
|
|
*b=m->emissive[2];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetMtlEmissive on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetMaterialAmbient ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )*/
|
|
void
|
|
dpl_SetMaterialAmbient ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
m->ambient[0]=r;
|
|
m->ambient[1]=g;
|
|
m->ambient[2]=b;
|
|
flush_node(m);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetMtlAmbient on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetMaterialAmbient ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )*/
|
|
void
|
|
dpl_GetMaterialAmbient ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
*r=m->ambient[0];
|
|
*g=m->ambient[1];
|
|
*b=m->ambient[2];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetMtlAmbient on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetMaterialDiffuse ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )*/
|
|
void
|
|
dpl_SetMaterialDiffuse ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
m->diffuse[0]=r;
|
|
m->diffuse[1]=g;
|
|
m->diffuse[2]=b;
|
|
flush_node(m);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetMtlDiffuse on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetMaterialDiffuse ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )*/
|
|
void
|
|
dpl_GetMaterialDiffuse ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
*r=m->diffuse[0];
|
|
*g=m->diffuse[1];
|
|
*b=m->diffuse[2];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetMtlDiffuse on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetMaterialSpecular ( dpl_MATERIAL *m, float32 r, float32 g, float32 b,*/
|
|
void
|
|
dpl_SetMaterialSpecular ( dpl_MATERIAL *m, float32 r, float32 g, float32 b,
|
|
float32 shininess )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
m->specular[0]=r;
|
|
m->specular[1]=g;
|
|
m->specular[2]=b;
|
|
m->specular[3]=shininess;
|
|
flush_node(m);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetMtlSpecular on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetMaterialSpecular ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b,*/
|
|
void
|
|
dpl_GetMaterialSpecular ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b,
|
|
float32 *shininess )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
*r=m->specular[0];
|
|
*g=m->specular[1];
|
|
*b=m->specular[2];
|
|
*shininess=m->specular[3];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetMtlSpecular on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetMaterialOpacity ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )*/
|
|
void
|
|
dpl_SetMaterialOpacity ( dpl_MATERIAL *m, float32 r, float32 g, float32 b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
m->opacity[0]=r;
|
|
m->opacity[1]=g;
|
|
m->opacity[2]=b;
|
|
flush_node(m);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetMtlOpacity on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetMaterialOpacity ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )*/
|
|
void
|
|
dpl_GetMaterialOpacity ( dpl_MATERIAL *m, float32 *r, float32 *g, float32 *b )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
*r=m->opacity[0];
|
|
*g=m->opacity[1];
|
|
*b=m->opacity[2];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetMtlOpacity on NULL material\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetMaterialTexture ( dpl_MATERIAL *m, dpl_TEXTURE *t )*/
|
|
void
|
|
dpl_SetMaterialTexture ( dpl_MATERIAL *m, dpl_TEXTURE *t )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover ( m );
|
|
dec_ref ( m->texture );
|
|
m->texture=t;
|
|
inc_ref ( t );
|
|
flush_node(m);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetZoneRootDcs NULL zone\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetMaterialTexture ( dpl_MATERIAL *m )*/
|
|
dpl_TEXTURE *
|
|
dpl_GetMaterialTexture ( dpl_MATERIAL *m )
|
|
{
|
|
check_inited(NULL);
|
|
if (m) {
|
|
uncover ( m );
|
|
return m->texture;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetMaterialTexture on NULL mtl\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> RAMP functions*/
|
|
|
|
/*{{{ dpl_NewRamp ( void )*/
|
|
dpl_RAMP *
|
|
dpl_NewRamp ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_RAMP *) new_node ( sizeof(dpl_RAMP), dpl_type_ramp, dpl_init_ramp );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteRamp ( dpl_RAMP *m )*/
|
|
void
|
|
dpl_DeleteRamp ( dpl_RAMP *m )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover ( m );
|
|
|
|
free_node ( (dpl_node *) m );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL ramp\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetRampColors ( dpl_RAMP *m, float r0,float g0, float b0,*/
|
|
void
|
|
dpl_SetRampColors ( dpl_RAMP *m, float r0,float g0, float b0,
|
|
float r1, float g1, float b1 )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
m->color0[0]=r0;
|
|
m->color0[1]=g0;
|
|
m->color0[2]=b0;
|
|
m->color1[0]=r1;
|
|
m->color1[1]=g1;
|
|
m->color1[2]=b1;
|
|
flush_node(m);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetRampColors on NULL ramp\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetRampColors ( dpl_RAMP *m, float *r0,float *g0, float *b0,*/
|
|
void
|
|
dpl_GetRampColors ( dpl_RAMP *m, float *r0,float *g0, float *b0,
|
|
float *r1, float *g1, float *b1 )
|
|
{
|
|
check_inited_noret();
|
|
if (m) {
|
|
uncover(m);
|
|
|
|
*r0=m->color0[0];
|
|
*g0=m->color0[1];
|
|
*b0=m->color0[2];
|
|
|
|
*r1=m->color1[0];
|
|
*g1=m->color1[1];
|
|
*b1=m->color1[2];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetRampColors on NULL ramp\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> TEXTURE functions*/
|
|
|
|
/*{{{ dpl_NewTexMap ( void )*/
|
|
dpl_TEXMAP *
|
|
dpl_NewTexMap ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_TEXMAP *) new_node ( sizeof(dpl_TEXMAP), dpl_type_texmap, dpl_init_texmap );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteTexMap ( dpl_TEXMAP *tm )*/
|
|
void
|
|
dpl_DeleteTexMap ( dpl_TEXMAP *tm )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (tm) {
|
|
uncover ( tm );
|
|
if (tm->texels) free(tm->texels);
|
|
|
|
free_node ( (dpl_node *) tm );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL texmap\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetTexMapEdgeSize ( dpl_TEXMAP *tm, int32 u, int32 v )*/
|
|
void
|
|
dpl_SetTexMapEdgeSize ( dpl_TEXMAP *tm, int32 u, int32 v )
|
|
{
|
|
check_inited_noret();
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetTexMapEdgeSize ( dpl_TEXMAP *tm, int32 *u, int32 *v )*/
|
|
void
|
|
dpl_GetTexMapEdgeSize ( dpl_TEXMAP *tm, int32 *u, int32 *v )
|
|
{
|
|
check_inited_noret();
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetTexMapTexelSize ( dpl_TEXMAP *tm, int32 bytes_per_pixel )*/
|
|
void
|
|
dpl_SetTexMapTexelSize ( dpl_TEXMAP *tm, int32 bytes_per_pixel )
|
|
{
|
|
check_inited_noret();
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetTexMapTexelSize ( dpl_TEXMAP *tm )*/
|
|
int32
|
|
dpl_GetTexMapTexelSize ( dpl_TEXMAP *tm )
|
|
{
|
|
check_inited(0);
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetTexMapTexels ( dpl_TEXMAP *tm,*/
|
|
void
|
|
dpl_SetTexMapTexels ( dpl_TEXMAP *tm,
|
|
int32 *texels,
|
|
int32 u_size,
|
|
int32 v_size,
|
|
int32 mode )
|
|
{
|
|
if (tm) {
|
|
uncover ( tm );
|
|
if (tm->texels) free(tm->texels);
|
|
|
|
if (ghost_dpl_set_texmap_texels ( tm, texels, u_size, v_size, mode ) == 0) {
|
|
dpl_error ( dpl_errmess, "Failed to perform remote set_texmap_texels\n" );
|
|
return;
|
|
}
|
|
tm->texels=texels;
|
|
tm->u_size=u_size;
|
|
tm->v_size=v_size;
|
|
|
|
flush_node(tm);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetTexmapTexels on NULL texmap\n" );
|
|
}
|
|
check_inited_noret();
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewTexture ( void )*/
|
|
dpl_TEXTURE *
|
|
dpl_NewTexture ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_TEXTURE *) new_node ( sizeof(dpl_TEXTURE), dpl_type_texture, dpl_init_texture );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteTexture ( dpl_TEXTURE *t )*/
|
|
void
|
|
dpl_DeleteTexture ( dpl_TEXTURE *t )
|
|
{
|
|
check_inited_noret();
|
|
if (t) {
|
|
uncover ( t );
|
|
|
|
dec_ref ( t->texmap );
|
|
|
|
free_node ( (dpl_node *) t );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL texture\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetTextureMode ( dpl_TEXTURE *t, int32 m )*/
|
|
void
|
|
dpl_SetTextureMode ( dpl_TEXTURE *t, int32 m )
|
|
{
|
|
check_inited_noret();
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetTextureMode ( dpl_TEXTURE *t )*/
|
|
int32
|
|
dpl_GetTextureMode ( dpl_TEXTURE *t )
|
|
{
|
|
check_inited(0);
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_LoadTexmap ( dpl_TEXMAP *o, char *fname )*/
|
|
int32
|
|
dpl_LoadTexmap ( dpl_TEXMAP *o, char *fname )
|
|
{
|
|
char *full_name;
|
|
load_function load;
|
|
|
|
check_inited(0);
|
|
|
|
if (full_name = dpl_FindTextureFile(fname, &load)) {
|
|
if (load)
|
|
return load ( &o->dplnode, full_name);
|
|
else
|
|
return load_svt ( &o->dplnode, full_name );
|
|
}
|
|
else return 0;
|
|
}
|
|
/*}}} */
|
|
/*}}} */
|
|
/*{{{ DPL API ====> FILEPATH CONTROL functions*/
|
|
|
|
/*{{{ dpl_NewFilePath ( void )*/
|
|
dpl_FILEPATH *
|
|
dpl_NewFilePath ( void )
|
|
{
|
|
check_inited(NULL);
|
|
|
|
return (dpl_FILEPATH*) new_node ( sizeof(dpl_FILEPATH),
|
|
dpl_type_filepath, dpl_init_filepath );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewPathItem ( void )*/
|
|
dpl_PATHITEM *
|
|
dpl_NewPathItem ( void )
|
|
{
|
|
check_inited(NULL);
|
|
|
|
return (dpl_PATHITEM*) new_node ( sizeof(dpl_PATHITEM),
|
|
dpl_type_pathitem, dpl_init_pathitem );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewExtnItem ( void )*/
|
|
dpl_EXTNITEM *
|
|
dpl_NewExtnItem ( void )
|
|
{
|
|
check_inited(NULL);
|
|
|
|
return (dpl_EXTNITEM*) new_node ( sizeof(dpl_EXTNITEM),
|
|
dpl_type_extnitem, dpl_init_extnitem );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteFilePath ( dpl_FILEPATH *fp )*/
|
|
void
|
|
dpl_DeleteFilePath ( dpl_FILEPATH *fp )
|
|
{
|
|
check_inited_noret();
|
|
if (fp) {
|
|
uncover ( fp );
|
|
|
|
free_node ( (dpl_node *) fp );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL filepath\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeletePathItem ( dpl_PATHITEM *fp )*/
|
|
void
|
|
dpl_DeletePathItem ( dpl_PATHITEM *fp )
|
|
{
|
|
check_inited_noret();
|
|
if (fp) {
|
|
uncover ( fp );
|
|
|
|
free_node ( (dpl_node *) fp );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL pathitem\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteExtnItem ( dpl_PATHITEM *fp )*/
|
|
void
|
|
dpl_DeleteExtnItem ( dpl_PATHITEM *fp )
|
|
{
|
|
check_inited_noret();
|
|
if (fp) {
|
|
uncover ( fp );
|
|
|
|
free_node ( (dpl_node *) fp );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL extnitem\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_SetPathItemPath ( dpl_PATHITEM *i, char *s )*/
|
|
void
|
|
dpl_SetPathItemPath ( dpl_PATHITEM *i, char *s )
|
|
{
|
|
check_inited_noret();
|
|
if (i) {
|
|
uncover(i);
|
|
i->path=s;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetPathItemPath on NULL item\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetPathItemPath ( dpl_PATHITEM *p )*/
|
|
char *
|
|
dpl_GetPathItemPath ( dpl_PATHITEM *p )
|
|
{
|
|
check_inited(NULL);
|
|
if (p) {
|
|
uncover(p);
|
|
return (p->path);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetPthItemPath on NULL item\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetExtnItemExtn ( dpl_EXTNITEM *p, char *s )*/
|
|
void
|
|
dpl_SetExtnItemExtn ( dpl_EXTNITEM *p, char *s )
|
|
{
|
|
check_inited_noret();
|
|
if (p) {
|
|
uncover(p);
|
|
p->extn=s;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetExtnItemExtn on NULL item\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetExtnItemExtn ( dpl_EXTNITEM *p )*/
|
|
char *
|
|
dpl_GetExtnItemExtn ( dpl_EXTNITEM *p )
|
|
{
|
|
check_inited(NULL);
|
|
if (p) {
|
|
uncover(p);
|
|
return (p->extn);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetExtnItemExtn on NULL item\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetExtnItemLoadFunc ( dpl_EXTNITEM *p, load_function l )*/
|
|
void
|
|
dpl_SetExtnItemLoadFunc ( dpl_EXTNITEM *p, load_function l )
|
|
{
|
|
check_inited_noret();
|
|
if (p) {
|
|
uncover(p);
|
|
p->load_ext=l;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetExtnItemLoadFunc on NULL item\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetExtnItemLoadFunc ( dpl_EXTNITEM *p )*/
|
|
load_function
|
|
dpl_GetExtnItemLoadFunc ( dpl_EXTNITEM *p )
|
|
{
|
|
check_inited(NULL);
|
|
if (p)
|
|
return (p->load_ext);
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetExtnItemLoadFunc on NULL item\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_SetGeometryFilePath ( dpl_FILEPATH *fp )*/
|
|
void
|
|
dpl_SetGeometryFilePath ( dpl_FILEPATH *fp )
|
|
{
|
|
check_inited_noret();
|
|
if (fp)
|
|
geometry_filepath=fp;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetFilePath with NULL\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetGeometryFilePath ( void )*/
|
|
dpl_FILEPATH *
|
|
dpl_GetGeometryFilePath ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return geometry_filepath;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetTextureFilePath ( dpl_FILEPATH *fp )*/
|
|
void
|
|
dpl_SetTextureFilePath ( dpl_FILEPATH *fp )
|
|
{
|
|
check_inited_noret();
|
|
if (fp)
|
|
texture_filepath=fp;
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetFilePath with NULL\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetTextureFilePath ( void )*/
|
|
dpl_FILEPATH *
|
|
dpl_GetTextureFilePath ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return texture_filepath;
|
|
}
|
|
/*}}} */
|
|
|
|
static char *found=NULL;
|
|
|
|
/*{{{ dpl_FindFile ( dpl_FILEPATH *fp, char *root_name )*/
|
|
char *
|
|
dpl_FindFile ( dpl_FILEPATH *filepath, char *root_name, load_function *load )
|
|
{
|
|
dpl_list *extn_list, *path_list;
|
|
dpl_EXTNITEM *extn_item;
|
|
dpl_PATHITEM *path_item;
|
|
FILE *fp;
|
|
char *path_str,
|
|
*extn_str;
|
|
|
|
check_inited(NULL);
|
|
|
|
if (found==NULL)
|
|
found=malloc(256);
|
|
|
|
if (filepath == NULL) {
|
|
if (load) *load=NULL;
|
|
printf ("returning null due to null filepath\n" );
|
|
return root_name;
|
|
}
|
|
if (root_name) {
|
|
for (path_list=filepath->path_list.head;
|
|
path_list;
|
|
path_list=path_list->next ) {
|
|
path_item=(dpl_PATHITEM *) path_list->item;
|
|
if (path_item) {
|
|
for (extn_list=filepath->extn_list.head;
|
|
extn_list;
|
|
extn_list=extn_list->next ) {
|
|
extn_item=(dpl_EXTNITEM *) extn_list->item;
|
|
if (extn_item) {
|
|
if (path_item->path)
|
|
path_str=path_item->path;
|
|
else
|
|
path_str="";
|
|
|
|
if (extn_item->extn)
|
|
extn_str=extn_item->extn;
|
|
else
|
|
extn_str="";
|
|
|
|
/* does path:root:extn exist? */
|
|
if (strstr( root_name, ".")) {
|
|
sprintf ( found, "%s%c%s",
|
|
path_str,
|
|
dpl_path_separator,
|
|
root_name );
|
|
}
|
|
else {
|
|
sprintf ( found, "%s%c%s.%s",
|
|
path_str,
|
|
dpl_path_separator,
|
|
root_name,
|
|
extn_str );
|
|
}
|
|
|
|
if (fp=fopen ("rb", found )) {
|
|
char t[16];
|
|
|
|
fread ( t, 1, 16, fp );
|
|
|
|
fclose(fp);
|
|
*load=extn_item->load_ext;
|
|
|
|
return found;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to FindFile from NULL root\n");
|
|
if (load) *load=NULL;
|
|
return NULL;
|
|
}
|
|
printf ("returning root due to failure to find\n" );
|
|
return root_name;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_FindGeometryFile ( char *root_name )*/
|
|
char *
|
|
dpl_FindGeometryFile ( char *root_name, load_function *load )
|
|
{
|
|
char *name;
|
|
|
|
check_inited(NULL);
|
|
|
|
printf ("find geometry file %s\n", root_name );
|
|
|
|
return dpl_FindFile ( geometry_filepath, root_name, load );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_FindTextureFile ( char *root_name )*/
|
|
char *
|
|
dpl_FindTextureFile ( char *root_name, load_function *load )
|
|
{
|
|
check_inited(NULL);
|
|
printf ("find texture file %s\n", root_name );
|
|
return dpl_FindFile ( texture_filepath, root_name, load );
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> GEOMETRY functions*/
|
|
|
|
/*{{{ dpl_NewObject ( void )*/
|
|
dpl_OBJECT *
|
|
dpl_NewObject ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_OBJECT *) new_node ( sizeof(dpl_OBJECT), dpl_type_object, dpl_init_object );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewLod ( void )*/
|
|
dpl_LOD *
|
|
dpl_NewLod ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_LOD *) new_node ( sizeof(dpl_LOD), dpl_type_lod, dpl_init_lod );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewGeogroup ( void )*/
|
|
dpl_GEOGROUP *
|
|
dpl_NewGeogroup ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_GEOGROUP *) new_node ( sizeof(dpl_GEOGROUP), dpl_type_geogroup,
|
|
dpl_init_geogroup );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewGeometry ( void )*/
|
|
dpl_GEOMETRY *
|
|
dpl_NewGeometry ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_GEOMETRY *) new_node ( sizeof(dpl_GEOMETRY), dpl_type_geometry,
|
|
dpl_init_geometry );
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_GetObjectFirstLod ( dpl_OBJECT *o )*/
|
|
dpl_LOD *
|
|
dpl_GetObjectFirstLod ( dpl_OBJECT *o )
|
|
{
|
|
check_inited(NULL);
|
|
|
|
if (o) {
|
|
uncover ( o );
|
|
return (dpl_LOD *) get_first ( &o->lod_list );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to get LOD from NULL object\n" );
|
|
return NULL;
|
|
}
|
|
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetObjectNextLod ( dpl_OBJECT *o )*/
|
|
dpl_LOD *
|
|
dpl_GetObjectNextLod ( dpl_OBJECT *o )
|
|
{
|
|
check_inited(NULL);
|
|
|
|
if (o) {
|
|
uncover ( o );
|
|
return (dpl_LOD *) get_next ( &o->lod_list );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to get LOD from NULL object\n" );
|
|
return NULL;
|
|
}
|
|
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_DeleteObject ( dpl_OBJECT *o )*/
|
|
void
|
|
dpl_DeleteObject ( dpl_OBJECT *o )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (o) {
|
|
uncover ( o );
|
|
|
|
free_node ( (dpl_node *) o );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL object\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteLod ( dpl_LOD *o )*/
|
|
void
|
|
dpl_DeleteLod ( dpl_LOD *o )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (o) {
|
|
uncover ( o );
|
|
|
|
free_node ( (dpl_node *) o );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL lod\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteGeogroup ( dpl_GEOGROUP *o )*/
|
|
void
|
|
dpl_DeleteGeogroup ( dpl_GEOGROUP *o )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (o) {
|
|
uncover ( o );
|
|
|
|
free_node ( (dpl_node *) o );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL geogroup\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteGeometry ( dpl_GEOMETRY *o )*/
|
|
void
|
|
dpl_DeleteGeometry ( dpl_GEOMETRY *o )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (o) {
|
|
uncover ( o );
|
|
|
|
free_node ( (dpl_node *) o );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL geometry\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_SetGeometryGeotype ( dpl_GEOMETRY *g, dpl_geo_type gt )*/
|
|
void
|
|
dpl_SetGeometryGeotype ( dpl_GEOMETRY *g, dpl_geo_type gt )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (g) {
|
|
uncover(g);
|
|
g->geometry_type=gt;
|
|
flush_node(g);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetGeometryGeotype on NULL geometry\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetGeometryGeotype ( dpl_GEOMETRY *g )*/
|
|
dpl_geo_type
|
|
dpl_GetGeometryGeotype ( dpl_GEOMETRY *g )
|
|
{
|
|
check_inited(NULL);
|
|
if (g)
|
|
return (g->geometry_type);
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetGeometryGeotype on NULL geometry\n" );
|
|
return dpl_g_type_error;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_SetGeometryVertices ( dpl_GEOMETRY *g, dpl_VERTEX_LIST *v )*/
|
|
int32
|
|
dpl_SetGeometryVertices ( dpl_GEOMETRY *g,
|
|
dpl_VERTEX_LIST *v,
|
|
dpl_CONNECTION_LIST *con )
|
|
{
|
|
/*
|
|
the call to SetGeometryVertices squirts the geometric data
|
|
at the i860
|
|
*/
|
|
int nv=0, nc=0;
|
|
dpl_VERTEX_LIST *vv=v;
|
|
dpl_CONNECTION_LIST *cc=con;
|
|
|
|
check_inited(0);
|
|
|
|
if (g) {
|
|
uncover(g);
|
|
|
|
while (vv) {
|
|
nv+=vv->n_vertices;
|
|
vv=vv->next;
|
|
}
|
|
while (cc) {
|
|
nc+=cc->n_connections;
|
|
cc=cc->next;
|
|
}
|
|
|
|
if (ghost_dpl_set_geometry_vertices ( g, v, con, nv, nc ) == 0) {
|
|
dpl_error ( dpl_errmess, "Failed to perform remote set_geometry_vertices\n" );
|
|
return 0;
|
|
}
|
|
g->vertices=v;
|
|
g->connections=con;
|
|
|
|
return 1;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetGeometryVertices on NULL geometry\n" );
|
|
return 0;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_NewVertices ( int n_vertices )*/
|
|
dpl_VERTEX_LIST *
|
|
dpl_NewVertices ( int n_vertices )
|
|
{
|
|
dpl_VERTEX_LIST *head=NULL, *prevl=NULL, *vl;
|
|
dpl_VERTEX *v, *prev=NULL;
|
|
int i;
|
|
|
|
if (n_vertices > 0) {
|
|
while (n_vertices > 0) {
|
|
vl=(dpl_VERTEX_LIST *) malloc(sizeof(dpl_VERTEX_LIST));
|
|
|
|
if (vl == NULL) {
|
|
dpl_error ( dpl_errmess, "Failed to allocate vertex list\n" );
|
|
return NULL;
|
|
}
|
|
|
|
vl->next=NULL;
|
|
|
|
if (prevl == NULL) {
|
|
head=vl;
|
|
}
|
|
else {
|
|
prevl->next=vl;
|
|
}
|
|
prevl=vl;
|
|
|
|
if (n_vertices > DPL_VERTICES_PER_BLOCK)
|
|
vl->n_vertices=DPL_VERTICES_PER_BLOCK;
|
|
else
|
|
vl->n_vertices=n_vertices;
|
|
|
|
n_vertices-=DPL_VERTICES_PER_BLOCK;
|
|
|
|
/* now chain together vertices in this block */
|
|
|
|
for (i=0; i<vl->n_vertices; i++ ) {
|
|
v=&vl->vertices[i];
|
|
if (prev) prev->next=v;
|
|
prev=v;
|
|
v->next=NULL;
|
|
}
|
|
}
|
|
return head;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to allocate 0 vertices\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_NewConnections ( int n_connections )*/
|
|
dpl_CONNECTION_LIST *
|
|
dpl_NewConnections ( int n_connections )
|
|
{
|
|
dpl_CONNECTION_LIST *head=NULL, *prevcl=NULL, *cl;
|
|
dpl_CONNECTION *c, *prev=NULL;
|
|
|
|
int i;
|
|
|
|
if (n_connections > 0) {
|
|
while (n_connections > 0) {
|
|
cl=(dpl_CONNECTION_LIST *) malloc(sizeof(dpl_CONNECTION_LIST));
|
|
|
|
if (cl == NULL) {
|
|
dpl_error ( dpl_errmess, "Failed to allocate connection list\n" );
|
|
return NULL;
|
|
}
|
|
|
|
cl->next=NULL;
|
|
|
|
if (prevcl == NULL)
|
|
head=cl;
|
|
else
|
|
prevcl->next=cl;
|
|
|
|
prevcl=cl;
|
|
|
|
if (n_connections > DPL_CONNECTIONS_PER_BLOCK)
|
|
cl->n_connections=DPL_CONNECTIONS_PER_BLOCK;
|
|
else
|
|
cl->n_connections=n_connections;
|
|
|
|
n_connections-=DPL_CONNECTIONS_PER_BLOCK;
|
|
|
|
/* now chain together vertices in this block */
|
|
|
|
for (i=0; i<cl->n_connections; i++ ) {
|
|
c=&cl->connections[i];
|
|
if (prev) prev->next=c;
|
|
prev=c;
|
|
c->next=NULL;
|
|
}
|
|
}
|
|
return head;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to allocate 0 connections\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetGeometryNumVertices ( dpl_GEOMETRY *g )*/
|
|
int32
|
|
dpl_GetGeometryNumVertices ( dpl_GEOMETRY *g )
|
|
{
|
|
int32 nv=0;
|
|
dpl_VERTEX_LIST *vl;
|
|
|
|
if (g) {
|
|
uncover ( g );
|
|
|
|
vl=g->vertices;
|
|
|
|
while (vl) {
|
|
nv+=vl->n_vertices;
|
|
vl=vl->next;
|
|
}
|
|
return nv;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetGeometryNumVertices on NULL geometry\n" );
|
|
return 0;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetGeometryVertex ( dpl_GEOMETRY *g, int vertex_index )*/
|
|
dpl_VERTEX *
|
|
dpl_GetGeometryVertex ( dpl_GEOMETRY *g, int vertex_index )
|
|
{
|
|
dpl_VERTEX_LIST *vl;
|
|
|
|
if (g) {
|
|
uncover ( g );
|
|
|
|
vl=g->vertices;
|
|
|
|
if (vl) {
|
|
while (vertex_index>vl->n_vertices) {
|
|
vertex_index-=vl->n_vertices;
|
|
vl=vl->next;
|
|
if (vl==NULL) {
|
|
dpl_error ( dpl_errmess, "GetGeometryVertex : index beyond end of list\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
return &vl->vertices[vertex_index];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetGeometryVertex on NULL vertices\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetGeometryVertex on NULL geometry\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetGeometryNumConnections ( dpl_GEOMETRY *g )*/
|
|
int32
|
|
dpl_GetGeometryNumConnections ( dpl_GEOMETRY *g )
|
|
{
|
|
int32 nv=0;
|
|
dpl_CONNECTION_LIST *vl;
|
|
|
|
if (g) {
|
|
uncover ( g );
|
|
|
|
vl=g->connections;
|
|
|
|
while (vl) {
|
|
nv+=vl->n_connections;
|
|
vl=vl->next;
|
|
}
|
|
return nv;
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetGeometryNumConnections on NULL geometry\n" );
|
|
return 0;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetGeometryConnection ( dpl_GEOMETRY *g, int vertex_index )*/
|
|
dpl_CONNECTION *
|
|
dpl_GetGeometryConnection ( dpl_GEOMETRY *g, int vertex_index )
|
|
{
|
|
dpl_CONNECTION_LIST *vl;
|
|
|
|
if (g) {
|
|
uncover ( g );
|
|
|
|
vl=g->connections;
|
|
|
|
if (vl) {
|
|
while (vertex_index>vl->n_connections) {
|
|
vertex_index-=vl->n_connections;
|
|
vl=vl->next;
|
|
if (vl==NULL) {
|
|
dpl_error ( dpl_errmess, "GetGeometryConnection : index beyond end of list\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
return &vl->connections[vertex_index];
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetGeometryConnection on NULL connection\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to GetGeometryConnection on NULL geometry\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_BoundGeogroup ( dpl_GEOGROUP *gg )*/
|
|
void
|
|
dpl_BoundGeogroup ( dpl_GEOGROUP *gg )
|
|
{
|
|
dpl_POINT mini={0,0,0,0}, maxi={0,0,0,0};
|
|
dpl_GEOMETRY *geo;
|
|
int first=1;
|
|
|
|
check_inited_noret();
|
|
|
|
if (gg) {
|
|
uncover(gg);
|
|
|
|
geo=(dpl_GEOMETRY *) get_first ( &gg->geometry_list );
|
|
while (geo) {
|
|
bound_geometry ( mini, maxi, geo, first );
|
|
first=0;
|
|
geo=(dpl_GEOMETRY *) get_next ( &gg->geometry_list );
|
|
}
|
|
memcpy ( gg->bounds[0], mini, sizeof(dpl_POINT));
|
|
memcpy ( gg->bounds[1], maxi, sizeof(dpl_POINT));
|
|
|
|
flush_node(gg);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to Bound NULL geogroup\n" );
|
|
}
|
|
|
|
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_BoundLod ( dpl_LOD *lod )*/
|
|
void
|
|
dpl_BoundLod ( dpl_LOD *lod )
|
|
{
|
|
dpl_GEOGROUP *geo;
|
|
|
|
check_inited_noret();
|
|
|
|
if (lod) {
|
|
uncover(lod);
|
|
|
|
geo=(dpl_GEOGROUP *) get_first ( &lod->geogroup_list );
|
|
|
|
if (geo) {
|
|
uncover(geo);
|
|
|
|
memcpy ( lod->bounds[0], geo->bounds[0], sizeof(dpl_POINT));
|
|
memcpy ( lod->bounds[1], geo->bounds[1], sizeof(dpl_POINT));
|
|
|
|
geo=(dpl_GEOGROUP *) get_next ( &lod->geogroup_list );
|
|
|
|
while (geo) {
|
|
uncover(geo);
|
|
|
|
mini_point ( lod->bounds[0], geo->bounds[0] );
|
|
maxi_point ( lod->bounds[1], geo->bounds[1] );
|
|
|
|
geo=(dpl_GEOGROUP *) get_next ( &lod->geogroup_list );
|
|
}
|
|
}
|
|
|
|
flush_node(lod);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to Bound NULL lod\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_LoadObject ( dpl_OBJECT *o, char *fname )*/
|
|
int32
|
|
dpl_LoadObject ( dpl_OBJECT *o, char *fname )
|
|
{
|
|
char *full_name;
|
|
load_function load=NULL;
|
|
|
|
check_inited(0);
|
|
|
|
if (o) {
|
|
if (full_name = dpl_FindGeometryFile(fname, &load)) {
|
|
printf ("dpl_LoadObject - name=%s\n", full_name );
|
|
if (load) {
|
|
printf ("calling embedded function\n");
|
|
return load ( &o->dplnode, full_name);
|
|
}
|
|
else {
|
|
return load_b2z ( &o->dplnode, full_name );
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "FindGeometryFile returned NULL\n");
|
|
return 0;
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "attempt to dpl_LoadObject into a NULL object\n");
|
|
return 0;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_MorphObject ( dpl_OBJECT *morphed,*/
|
|
void
|
|
dpl_MorphObject ( dpl_OBJECT *morphed,
|
|
dpl_OBJECT *a,
|
|
dpl_OBJECT *b, float32 alpha )
|
|
{
|
|
check_inited_noret();
|
|
|
|
ghost_dpl_morph_object ( morphed, a, b, alpha );
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> 2-D DISPLAYLIST functions*/
|
|
/*}}} */
|
|
/*{{{ DPL API ====> NAMETABLE ACCESS functions*/
|
|
/*{{{ dpl_NewName ( void )*/
|
|
dpl_NAME *
|
|
dpl_NewName ( void )
|
|
{
|
|
check_inited(NULL);
|
|
return (dpl_NAME *) new_node ( sizeof(dpl_NAME),
|
|
dpl_type_nameitem, dpl_init_nameitem );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_DeleteName ( dpl_NAME *n )*/
|
|
void
|
|
dpl_DeleteName ( dpl_NAME *n )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (n) {
|
|
uncover ( n );
|
|
if (n->name) free ( n->name);
|
|
dec_ref ( n->item );
|
|
|
|
free_node ( (dpl_node *) n );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to delete NULL name\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_SetNameString ( dpl_NAME *n, char * s )*/
|
|
void
|
|
dpl_SetNameString ( dpl_NAME *n, char * s )
|
|
{
|
|
check_inited_noret();
|
|
if (n) {
|
|
uncover(n);
|
|
|
|
if (n->name) free(n->name);
|
|
|
|
if (s) {
|
|
n->name=malloc ( 1 + strlen(s));
|
|
strcpy ( n->name, s );
|
|
}
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetNameString on NULL name\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SetNameNode ( dpl_NAME *n, dpl_node *dn )*/
|
|
void
|
|
dpl_SetNameNode ( dpl_NAME *n, dpl_node *dn )
|
|
{
|
|
check_inited_noret();
|
|
if (n) {
|
|
uncover(n);
|
|
dec_ref (n->item );
|
|
n->item=dn;
|
|
inc_ref (dn);
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to SetNameNode on NULL name\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_AddNameToNametable ( dpl_NAME *n )*/
|
|
void
|
|
dpl_AddNameToNametable ( dpl_NAME *n )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (n->name) {
|
|
dpl_superlist *sl=dpl_hash_name ( n->name );
|
|
|
|
add_item ( sl, (dpl_node *) n );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess,
|
|
"Attempt to add name with NULL string to name table\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_RemoveNameFromNametable ( dpl_NAME *n )*/
|
|
void
|
|
dpl_RemoveNameFromNametable ( dpl_NAME *n )
|
|
{
|
|
if (n->name) {
|
|
dpl_superlist *sl=dpl_hash_name ( n->name );
|
|
|
|
remove_item ( sl, (dpl_node *) n );
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess,
|
|
"Attempt to remove name with NULL string from name table\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_NameNode ( dpl_node *n, char *s )*/
|
|
void
|
|
dpl_NameNode ( dpl_node *n, char *s )
|
|
{
|
|
check_inited_noret();
|
|
|
|
if (n && s) {
|
|
dpl_NAME *name = dpl_NewName();
|
|
|
|
dpl_SetNameNode ( name, n );
|
|
dpl_SetNameString ( name, s );
|
|
dpl_AddNameToNameTable ( name );
|
|
|
|
}
|
|
else {
|
|
dpl_error ( dpl_errmess, "Attempt to name NULL node\n" );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_ClearNameTable ( void )*/
|
|
void
|
|
dpl_ClearNameTable ( void )
|
|
{
|
|
int i;
|
|
|
|
for (i=0; i<dpl_name_hash; i++ ) {
|
|
dpl_superlist *sl=&super_hash[i];
|
|
dpl_list *l;
|
|
|
|
for (l=sl->head; l; l=l->next ) {
|
|
dec_ref(l->item);
|
|
|
|
dpl_DeleteName ( (dpl_NAME *) l->item );
|
|
|
|
free(l);
|
|
}
|
|
init_superlist ( NULL, sl, dpl_type_nameitem );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_FindNamedNode ( char *str )*/
|
|
dpl_node *
|
|
dpl_FindNamedNode ( char *str )
|
|
{
|
|
dpl_superlist *sl;
|
|
dpl_list *l;
|
|
dpl_NAME *n;
|
|
int look=1;
|
|
|
|
check_inited(NULL);
|
|
|
|
sl=dpl_hash_name ( str );
|
|
|
|
n=(dpl_NAME *) get_first ( sl );
|
|
|
|
while (n) {
|
|
if (strcmp(n->name, str) == 0)
|
|
return n->item;
|
|
n=(dpl_NAME *) get_next ( sl );
|
|
}
|
|
return NULL;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_FindNamedTypedNode ( dpl_type t, char *str )*/
|
|
dpl_node *
|
|
dpl_FindNamedTypedNode ( dpl_type t, char *str )
|
|
{
|
|
dpl_superlist *sl;
|
|
dpl_list *l;
|
|
dpl_NAME *n;
|
|
int look=1;
|
|
|
|
check_inited(NULL);
|
|
|
|
sl=dpl_hash_name ( str );
|
|
|
|
n=(dpl_NAME *) get_first ( sl );
|
|
|
|
while (n) {
|
|
if (strcmp(n->name, str) == 0) {
|
|
if (n->item->type_check == t) return n->item;
|
|
}
|
|
n=(dpl_NAME *) get_next ( sl );
|
|
}
|
|
return NULL;
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ DPL API ====> GENERAL CONTROL functions*/
|
|
|
|
/*{{{ dpl_SetWarningLevel ( int32 w )*/
|
|
void
|
|
dpl_SetWarningLevel ( int32 w )
|
|
{
|
|
dpl_WarningLevel=w;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetWarningLevel ( void )*/
|
|
int32
|
|
dpl_GetWarningLevel ( void )
|
|
{
|
|
check_inited(0);
|
|
|
|
return dpl_WarningLevel;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_Init ( int32 argc, char **argv )*/
|
|
int32
|
|
dpl_Init ( char *dpl_arg )
|
|
{
|
|
|
|
if (dpl_inited) return 0;
|
|
else {
|
|
/* allow any host functions I call to operate ! */
|
|
dpl_inited=1;
|
|
|
|
/* do ghost operation */
|
|
ghost_dpl_init ( dpl_arg );
|
|
|
|
/* init SCENE structure */
|
|
dpl_init_scene ((dpl_node *) (&the_scene) );
|
|
/* init nametable stuff */
|
|
dpl_init_nametable ();
|
|
|
|
__dpl_cache_mode=dpl_cache_mode_write_thru;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_Exit ( int32 exit_code )*/
|
|
void
|
|
dpl_Exit ( int32 exit_code )
|
|
{
|
|
check_inited_noret();
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_SetCacheMode ( dpl_cache_mode m )*/
|
|
void
|
|
dpl_SetCacheMode ( dpl_cache_mode m )
|
|
{
|
|
check_inited_noret();
|
|
__dpl_cache_mode=m;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_GetCacheMode ()*/
|
|
dpl_cache_mode
|
|
dpl_GetCacheMode ()
|
|
{
|
|
check_inited(dpl_cache_mode_error);
|
|
return __dpl_cache_mode;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_Statistics ( void )*/
|
|
dpl_STATISTICS
|
|
dpl_Statistics ( void )
|
|
{
|
|
dpl_STATISTICS fred;
|
|
|
|
check_inited(fred);
|
|
ghost_dpl_statistics ( &fred );
|
|
|
|
return fred;
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_Version ( void )*/
|
|
dpl_VERSION
|
|
dpl_Version ( void )
|
|
{
|
|
dpl_VERSION version;
|
|
|
|
version.major_version=1;
|
|
version.minor_version=0;
|
|
|
|
strcpy ( version.detailed, "dpl 05/jul/94" );
|
|
ghost_dpl_version ( & version );
|
|
|
|
return version;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_Status ( void )*/
|
|
char *
|
|
dpl_Status ( void )
|
|
{
|
|
static char *dpl_ok_mess = "dpl status is dpl_ok\n";
|
|
|
|
if (dpl_err)
|
|
return dpl_errmess;
|
|
else
|
|
return dpl_ok_mess;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_ReadFrameStore ( int32 *pixels, int32 x, int32 y, int32 n_pixels )*/
|
|
void
|
|
dpl_ReadFrameStore ( int32 *pixels, int32 x, int32 y, int32 n_pixels )
|
|
{
|
|
check_inited_noret();
|
|
ghost_dpl_readpixels ( pixels, x, y, n_pixels );
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ dpl_SectVector ( float32 x0, float32 y0, float32 z0,*/
|
|
dpl_INSTANCE *
|
|
dpl_SectVector ( dpl_POINT sect,
|
|
float32 x0, float32 y0, float32 z0,
|
|
float32 x1, float32 y1, float32 z1 )
|
|
{
|
|
check_inited(NULL);
|
|
return ghost_dpl_sectvector ( sect, x0, y0, z0, x1, y1, z1 );
|
|
}
|
|
/*}}} */
|
|
/*{{{ dpl_SectPixel ( int32 x, int32 y )*/
|
|
dpl_INSTANCE *
|
|
dpl_SectPixel ( dpl_POINT sect, float32 x, float32 y )
|
|
{
|
|
check_inited(NULL);
|
|
return ghost_dpl_sectpixel ( sect, x, y );
|
|
}
|
|
/*}}} */
|
|
/*}}} */
|
|
|