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>
2218 lines
54 KiB
C++
2218 lines
54 KiB
C++
/*{{{ includes*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
#include <math.h>
|
|
|
|
#include "dnc.h"
|
|
#include "dpltypes.h"
|
|
#include "vpxtypes.h"
|
|
#include "vr_prot.h"
|
|
#include "matrix.h"
|
|
#include "texture.h"
|
|
#include "names.h"
|
|
/*}}} */
|
|
/*{{{ defines*/
|
|
|
|
#define messages 0
|
|
#define massages 0
|
|
#define dbgtex 0
|
|
/*}}} */
|
|
|
|
int replying=1, view_id=0;
|
|
int _dN_transactions=0;
|
|
static int receive_bytes=0;
|
|
|
|
/*{{{ externs*/
|
|
extern int back_colour;
|
|
extern int my_id;
|
|
extern int *texture_store;
|
|
extern int _processorId;
|
|
extern int recompute_end_of_frame;
|
|
/*}}} */
|
|
|
|
/*{{{ globals*/
|
|
int x_size, y_size, pixels, link_A, link_B, link_C, size=0;
|
|
int init=0, *arg1p, data[256];
|
|
|
|
dpl_SCENE the_scene;
|
|
|
|
void reply(int bytes, int *client, void *data )
|
|
{
|
|
/* printf ("replying == %d\n", replying ); */
|
|
if (replying) dN_send(*client,(bytes)+4,(char *) data,1 );
|
|
}
|
|
|
|
static int *dN_client,
|
|
*dN_data=&data[0];
|
|
|
|
void dN_reply(void)
|
|
{
|
|
reply(4, dN_client, dN_data );
|
|
}
|
|
|
|
int device;
|
|
|
|
static int pxpl5_address, texture_edge,
|
|
texture_mode, texture_ramp,
|
|
texels, texels_left, fx_texels,
|
|
frames_done=0;
|
|
|
|
int recompute_normals=0, smooth=0, cooked=0, textured=0,
|
|
floats_per_vertex, verts_per_strip;
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ static int protocol_error()*/
|
|
static int protocol_error()
|
|
{
|
|
int i;
|
|
printf ("received %d words ...\n", receive_bytes >> 2 );
|
|
|
|
for (i=0; i<(receive_bytes>>2); i++ ) {
|
|
printf ("[%3d]:0x%x\n", i, data[i] );
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
char *current_fn="go man go ";
|
|
|
|
int mess_start=0;
|
|
|
|
static int init_pending=0;
|
|
|
|
/* control */
|
|
int *copy_client;
|
|
int dealt_with=0;
|
|
|
|
unsigned int __trianglesRendered=0;
|
|
unsigned int __frameTime=0;
|
|
|
|
/*{{{ static void do_init()*/
|
|
int my_data[16];
|
|
|
|
static void do_init( void )
|
|
{
|
|
/*{{{ only do it if targetted at me*/
|
|
extern void dN_pxpl5_init ( int magicL, int magicR );
|
|
extern void render_init( int x_size, int y_size );
|
|
int *block, i;
|
|
|
|
device = my_data[1];
|
|
|
|
x_size=my_data[2];
|
|
y_size=my_data[3];
|
|
|
|
link_A=my_data[4];
|
|
link_B=my_data[5];
|
|
link_C=my_data[6];
|
|
|
|
pixels=x_size*y_size;
|
|
back_colour=-1;
|
|
|
|
render_init ( x_size, y_size );
|
|
|
|
if (_processorId==0) {
|
|
printf ("pxpl5 init magicL %d magicR %d\n", my_data[7], my_data[8] );
|
|
dN_pxpl5_init ( my_data[7], my_data[8] );
|
|
}
|
|
|
|
/*
|
|
block=(int *) malloc(64*64*4);
|
|
for (i=0; i<64*64; i++ ) {
|
|
block[i]=i<<16;
|
|
}
|
|
printf ("clearing out texture ram\n" );
|
|
|
|
for (i=0; i<64; i++ )
|
|
dN_pxpl5_texture24 ( block, i*(64*64), 64 );
|
|
|
|
printf ("done\n" );
|
|
*/
|
|
|
|
/*
|
|
PAZinit ( device, x_size, y_size,
|
|
link_A, link_B, link_C, 0, 0, 0, 0 );
|
|
*/
|
|
/*}}} */
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void parse_argv ()*/
|
|
static void parse_argv ( char *argv )
|
|
{
|
|
if (init==0) { /* && (view_id==data[10])) { */
|
|
my_data[1]=0; /* device */
|
|
my_data[2]=832; /* x-size */
|
|
my_data[3]=512; /* y-size */
|
|
my_data[4]=3; /* link_A */
|
|
my_data[5]=-1; /* link_B */
|
|
my_data[6]=-1; /* link_C */
|
|
my_data[7]=0x32c1; /* magic L */
|
|
my_data[8]=my_data[7];
|
|
|
|
printf ("Yes, init is for me\n" );
|
|
init=1;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ static char *type_to_string ( dpl_type t )*/
|
|
static int useful_index=0;
|
|
static char useful[4][128];
|
|
|
|
char *type_to_string ( 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;
|
|
}
|
|
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ local database editing*/
|
|
/*{{{ errors*/
|
|
static int dpl_err=0;
|
|
#define dpl_error dpl_err=1; printf
|
|
|
|
/*}}} */
|
|
/*{{{ support functions*/
|
|
static char dpl_errmess[128];
|
|
|
|
/*{{{ 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_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;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ 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);
|
|
|
|
/* 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;
|
|
}
|
|
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 )) {
|
|
|
|
unlink_superlist_item ( list, l );
|
|
|
|
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)( dpl_node *))
|
|
{
|
|
dpl_node *new=(dpl_node *) malloc(size_in_bytes);
|
|
new->type_check=type;
|
|
|
|
init(new);
|
|
|
|
return new;
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ static initialization functions*/
|
|
#define typeize(type,node) type *t=(type *) node
|
|
|
|
/*{{{ 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 = 0;
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_view ( dpl_node * node)*/
|
|
dpl_init_view ( dpl_node * node)
|
|
{
|
|
typeize(dpl_VIEW, node);
|
|
|
|
|
|
t->enable=0;
|
|
init_superlist ( node, &t->zone_list, dpl_type_zone );
|
|
|
|
|
|
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_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_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_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=32;
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
/*{{{ dpl_init_texture ( dpl_node * node)*/
|
|
dpl_init_texture ( dpl_node * node)
|
|
{
|
|
typeize(dpl_TEXTURE, node);
|
|
|
|
|
|
t->texmap=NULL;
|
|
|
|
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;
|
|
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;
|
|
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->vertices = NULL;
|
|
t->connections = 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->enable = 0;
|
|
|
|
dpl_IdMatrix ( t->matrix );
|
|
|
|
return;
|
|
}
|
|
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ RPC interface to V-render*/
|
|
/* ******************************************
|
|
|
|
The remote procedure call entrypoints for Velocirender
|
|
|
|
*/
|
|
|
|
/* generics */
|
|
/*{{{ static int velocirender_create ( int *data )*/
|
|
static int velocirender_create ( int *data )
|
|
{
|
|
dpl_type type=(dpl_type) *data;
|
|
dpl_node *n;
|
|
|
|
switch (type) {
|
|
case dpl_type_zone :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_ZONE), dpl_type_zone, dpl_init_zone );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_view :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_VIEW), dpl_type_view, dpl_init_view );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_instance :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_INSTANCE), dpl_type_instance, dpl_init_instance );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_dcs :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_DCS), dpl_type_dcs, dpl_init_dcs );
|
|
*data=newName ( n, n->type_check );
|
|
|
|
/*
|
|
NBB we M U S T nullify the tree linkage here since flush does
|
|
not touch it
|
|
*/
|
|
|
|
((dpl_DCS * ) n)->parent =NULL;
|
|
((dpl_DCS *) n)->child =NULL;
|
|
((dpl_DCS *) n)->sibling=NULL;
|
|
|
|
/*
|
|
printf ("new DCS created, name 0x%x address 0x%x\n", *data, n );
|
|
*/
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_lmodel :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_LMODEL), dpl_type_lmodel, dpl_init_lmodel );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_light :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_LIGHT), dpl_type_light, dpl_init_light );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_object :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_OBJECT), dpl_type_object, dpl_init_object );
|
|
*data=newName ( n, n->type_check );
|
|
/* printf ("created object 0x%x name 0x%x\n", n, *data ); */
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_lod :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_LOD), dpl_type_lod, dpl_init_lod );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_geogroup :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_GEOGROUP), dpl_type_geogroup,
|
|
dpl_init_geogroup );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_geometry :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_GEOMETRY), dpl_type_geometry,
|
|
dpl_init_geometry );
|
|
*data=newName ( n, n->type_check );
|
|
/* printf ("new geometry at 0x%x\n", n ); */
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_material :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_MATERIAL), dpl_type_material, dpl_init_material );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_ramp :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_RAMP), dpl_type_ramp, dpl_init_ramp );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_texmap :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_TEXMAP), dpl_type_texmap, dpl_init_texmap );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_texture :
|
|
/*{{{ */
|
|
n=new_node ( sizeof(dpl_TEXTURE), dpl_type_texture, dpl_init_texture );
|
|
*data=newName ( n, n->type_check );
|
|
break;
|
|
/*}}} */
|
|
default :
|
|
/*{{{ */
|
|
printf ("ERROR : Velocirender remote create on unknown or invalid type %s (%d)\n",
|
|
type_to_string(type),
|
|
type );
|
|
protocol_error();
|
|
*data=0x0;
|
|
break;
|
|
/*}}} */
|
|
}
|
|
return 4;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_delete ( int *data )*/
|
|
static int velocirender_delete ( int *data )
|
|
{
|
|
dpl_node *n=(dpl_node *) nameToAddress ( *data, -1 );
|
|
|
|
if (n == NULL) {
|
|
printf ("attempt to delete NULL node 0x%x\n", *data );
|
|
*data=0x1;
|
|
}
|
|
else {
|
|
dpl_type type=n->type_check;
|
|
|
|
switch (type) {
|
|
case dpl_type_zone :
|
|
case dpl_type_view :
|
|
case dpl_type_instance :
|
|
case dpl_type_dcs :
|
|
case dpl_type_lmodel :
|
|
case dpl_type_light :
|
|
case dpl_type_object :
|
|
case dpl_type_lod :
|
|
case dpl_type_geogroup :
|
|
case dpl_type_material :
|
|
case dpl_type_texture :
|
|
/*{{{ */
|
|
/*
|
|
printf ("Velocirender remote delete %s\n",
|
|
type_to_string ( type ));
|
|
deleteName ( *data, n->type_check );
|
|
*/
|
|
free (n);
|
|
*data=0x1;
|
|
break;
|
|
/*}}} */
|
|
case dpl_type_texmap :
|
|
/*{{{ */
|
|
/* printf ("Velocirender remote delete texmap - harder\n" ); */
|
|
deleteName ( *data, n->type_check );
|
|
free (n);
|
|
*data=0x1;
|
|
break;
|
|
|
|
/*}}} */
|
|
case dpl_type_geometry :
|
|
/*{{{ */
|
|
/* printf ("Velocirender remote delete geometry - harder\n" ); */
|
|
deleteName ( *data, n->type_check );
|
|
free (n);
|
|
*data=0x1;
|
|
break;
|
|
|
|
/*}}} */
|
|
case dpl_type_error :
|
|
case dpl_type_scene :
|
|
case dpl_type_filepath :
|
|
case dpl_type_pathitem :
|
|
case dpl_type_extnitem :
|
|
case dpl_type_nameitem :
|
|
/*{{{ */
|
|
printf ("ERROR : Velocirender remote delete on host-only type 0x%x %s\n",
|
|
type, type_to_string ( type ));
|
|
protocol_error();
|
|
*data=0x0;
|
|
break;
|
|
|
|
/*}}} */
|
|
default :
|
|
/*{{{ */
|
|
printf ("ERROR : Velocirender remote create on unknown type %d\n", type );
|
|
protocol_error();
|
|
*data=0x0;
|
|
break;
|
|
/*}}} */
|
|
}
|
|
}
|
|
return 4;
|
|
}
|
|
/*}}} */
|
|
/*{{{ individual flush functions*/
|
|
|
|
/*{{{ some macros to simplify replacement*/
|
|
#define localize(field,dpltype, ctype) replace->field=(ctype *) nameToAddress((int) (from_host->field),dpltype)
|
|
|
|
#define localstr(field,type) memcpy(replace->field,from_host->field,sizeof(type))
|
|
|
|
#define localdata(field,n) memcpy(replace->field,from_host->field,n)
|
|
|
|
#define localtype(field) replace->field=from_host->field
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_zone ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_zone ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_ZONE *from_host=(dpl_ZONE *) n;
|
|
dpl_ZONE *replace=(dpl_ZONE * ) r;
|
|
|
|
localize ( lmodel, dpl_type_lmodel, dpl_LMODEL );
|
|
localize ( root, dpl_type_dcs, dpl_DCS );
|
|
localtype( enable);
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_view ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_view ( dpl_node *n, dpl_node *r )
|
|
{
|
|
extern int eof_FOG_rval,
|
|
eof_FOG_gval,
|
|
eof_FOG_bval,
|
|
eof_doFOG,
|
|
eof_backR,
|
|
eof_backG,
|
|
eof_backB;
|
|
|
|
extern float eof_FOG_near,
|
|
eof_FOG_far ;
|
|
|
|
dpl_VIEW *from_host=(dpl_VIEW *) n;
|
|
dpl_VIEW *replace=(dpl_VIEW * ) r;
|
|
int frval, fgval, fbval;
|
|
|
|
localstr (matrix, dpl_MATRIX);
|
|
localtype(enable);
|
|
localtype(x_size);localtype(y_size);
|
|
localtype(x0);localtype(y0);
|
|
localtype(x1);localtype(y1);
|
|
localtype(zeye);
|
|
localtype(hither_clip);
|
|
localtype(yon_clip);
|
|
localdata(back_color, 3*(sizeof(float)));
|
|
|
|
eof_backR=replace->back_color[0];
|
|
eof_backG=replace->back_color[1];
|
|
eof_backB=replace->back_color[2];
|
|
|
|
localtype(fog_enable);
|
|
localdata(fog, 5*sizeof(float));
|
|
|
|
frval=255.0f * replace->fog[2];
|
|
fgval=255.0f * replace->fog[3];
|
|
fbval=255.0f * replace->fog[4];
|
|
|
|
if (frval != eof_FOG_rval) recompute_end_of_frame=1;
|
|
if (fgval != eof_FOG_gval) recompute_end_of_frame=1;
|
|
if (fbval != eof_FOG_bval) recompute_end_of_frame=1;
|
|
if (replace->fog_enable != eof_doFOG) recompute_end_of_frame=1;
|
|
if (replace->fog[0] != eof_FOG_near) recompute_end_of_frame=1;
|
|
if (replace->fog[1] != eof_FOG_far) recompute_end_of_frame=1;
|
|
|
|
if (recompute_end_of_frame) {
|
|
/* printf ("recompute end of frame\n"); */
|
|
eof_FOG_rval=frval;
|
|
eof_FOG_gval=fgval;
|
|
eof_FOG_bval=fbval;
|
|
eof_FOG_near=replace->fog[0];
|
|
eof_FOG_far =replace->fog[1];
|
|
eof_doFOG =replace->fog_enable;
|
|
}
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_instance ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_instance ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_INSTANCE *from_host=(dpl_INSTANCE *) n;
|
|
dpl_INSTANCE *replace=(dpl_INSTANCE * ) r;
|
|
|
|
/* printf ("flushing instance 0x%x obj 0x%x\n",
|
|
replace, from_host->object );
|
|
*/
|
|
localize(dcs, dpl_type_dcs, dpl_DCS);
|
|
|
|
localtype(billboard);
|
|
localtype(intersectmode);
|
|
|
|
localize(object, dpl_type_object, dpl_OBJECT);
|
|
localize(forcelod, dpl_type_lod, dpl_LOD);
|
|
localize(f_material, dpl_type_material, dpl_MATERIAL);
|
|
localize(b_material, dpl_type_material, dpl_MATERIAL);
|
|
localize(f_texture, dpl_type_texture, dpl_TEXTURE);
|
|
localize(b_texture, dpl_type_texture, dpl_TEXTURE);
|
|
|
|
/* printf ("flushed; obj now 0x%x\n",
|
|
replace->object );
|
|
*/
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_dcs ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_dcs ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_DCS *from_host=(dpl_DCS *) n;
|
|
dpl_DCS *replace =(dpl_DCS *) r;
|
|
|
|
localize ( node, -1, dpl_node );
|
|
|
|
/* PHIL - DONT DELETE THIS COMMENT
|
|
|
|
DONT PLAY WITH DCS TREE LINKAGE - IT IS ALL DONE IN LINK AND NEST,
|
|
AND WILL NOT WORK IF YOU MESS WITH IT HERE
|
|
*/
|
|
|
|
localtype ( identity );
|
|
localtype ( enable );
|
|
|
|
localstr ( matrix, dpl_MATRIX );
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_lmodel ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_lmodel ( dpl_node *n, dpl_node *r )
|
|
{
|
|
/* a light model contains just lists, no data */
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_light ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_light ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_LIGHT *from_host=(dpl_LIGHT *) n;
|
|
dpl_LIGHT *replace = (dpl_LIGHT *) r;
|
|
|
|
localize(dcs, dpl_type_dcs, dpl_DCS);
|
|
localtype(light_type);
|
|
localdata(color,7*sizeof(float)); /* do all floats in one */
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_object ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_object ( dpl_node *n, dpl_node *r )
|
|
{
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_lod ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_lod ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_LOD *from_host=(dpl_LOD *) n;
|
|
dpl_LOD *replace = (dpl_LOD *) r;
|
|
|
|
localize(parent, dpl_type_object, dpl_OBJECT);
|
|
localdata(bounds,(8*sizeof(float)));
|
|
localtype(switch_in);
|
|
localtype(switch_out);
|
|
|
|
/*
|
|
printf ("flushed lod, bounds %f,%f,%f %f,%f,%f\n",
|
|
replace->bounds[0][0],
|
|
replace->bounds[0][1],
|
|
replace->bounds[0][2],
|
|
replace->bounds[1][0],
|
|
replace->bounds[1][1],
|
|
replace->bounds[1][2] );
|
|
*/
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_geogroup ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_geogroup ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_GEOGROUP *from_host=(dpl_GEOGROUP *) n;
|
|
dpl_GEOGROUP *replace = (dpl_GEOGROUP *) r;
|
|
|
|
localtype(draw_mode);
|
|
localize(parent, dpl_type_lod, dpl_LOD);
|
|
localize(f_material, dpl_type_material, dpl_MATERIAL);
|
|
localize(b_material, dpl_type_material, dpl_MATERIAL);
|
|
localdata(bounds,8*sizeof(float));
|
|
|
|
/*
|
|
printf ("flushed geogroup, bounds %f,%f,%f %f,%f,%f\n",
|
|
replace->bounds[0][0],
|
|
replace->bounds[0][1],
|
|
replace->bounds[0][2],
|
|
replace->bounds[1][0],
|
|
replace->bounds[1][1],
|
|
replace->bounds[1][2] );
|
|
*/
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_geometry ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_geometry ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_GEOMETRY *from_host=(dpl_GEOMETRY *) n;
|
|
dpl_GEOMETRY *replace = (dpl_GEOMETRY *) r;
|
|
|
|
localize(parent, dpl_type_geogroup, dpl_GEOGROUP);
|
|
localtype(geometry_type);
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_material ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_material ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_MATERIAL *from_host=(dpl_MATERIAL *) n;
|
|
dpl_MATERIAL *replace = (dpl_MATERIAL *) r;
|
|
|
|
localdata( emissive, 3*sizeof(float));
|
|
localdata( ambient, 3*sizeof(float));
|
|
localdata( diffuse, 3*sizeof(float));
|
|
localdata( opacity, 3*sizeof(float));
|
|
localdata( specular, 4*sizeof(float));
|
|
|
|
localize ( ramp, dpl_type_ramp, dpl_RAMP);
|
|
localize ( texture, dpl_type_texture, dpl_TEXTURE);
|
|
|
|
/*
|
|
printf ("flush material, diffuse=%f %f %f\n",
|
|
replace->diffuse[0],
|
|
replace->diffuse[1],
|
|
replace->diffuse[2] );
|
|
*/
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_texmap ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_texmap ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_TEXMAP *from_host=(dpl_TEXMAP *) n;
|
|
dpl_TEXMAP *replace = (dpl_TEXMAP *) r;
|
|
/*
|
|
typedef struct s_dpltexmap {
|
|
dpl_node dplnode;
|
|
|
|
int32 *texels;
|
|
int32 u_size;
|
|
int32 v_size;
|
|
int32 bits_per_texel;
|
|
} dpl_TEXMAP;
|
|
*/
|
|
|
|
/* urrgh - how to flush a texmap */
|
|
localtype(u_size);
|
|
localtype(v_size);
|
|
localtype(bits_per_texel);
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_texture ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_texture ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_TEXTURE *from_host=(dpl_TEXTURE *) n;
|
|
dpl_TEXTURE *replace = (dpl_TEXTURE *) r;
|
|
|
|
localize(texmap, dpl_type_texmap, dpl_TEXMAP);
|
|
localtype(minify);
|
|
localtype(magnify);
|
|
localtype(alpha);
|
|
localtype(wrap_u);
|
|
localtype(wrap_v);
|
|
localtype(detail);
|
|
localtype(u0);
|
|
localtype(v0);
|
|
localtype(du);
|
|
localtype(dv);
|
|
localtype(animate_time);
|
|
localtype(animate_behaviour);
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ flush_dpl_type_ramp ( dpl_node *from_host, dpl_node *replace )*/
|
|
static void
|
|
flush_dpl_type_ramp ( dpl_node *n, dpl_node *r )
|
|
{
|
|
dpl_RAMP *from_host=(dpl_RAMP *) n;
|
|
dpl_RAMP *replace = (dpl_RAMP *) r;
|
|
|
|
localdata( color0, (6*sizeof(float)));
|
|
/*
|
|
printf ("flushed ramp to %f %f %f %f %f %f\n",
|
|
replace->color0[0],
|
|
replace->color0[1],
|
|
replace->color0[2],
|
|
replace->color1[0],
|
|
replace->color1[1],
|
|
replace->color1[2] );
|
|
*/
|
|
|
|
return;
|
|
}
|
|
/*}}} */
|
|
|
|
/*}}} */
|
|
/*{{{ static int velocirender_flush ( int *data )*/
|
|
static int velocirender_flush ( int *data )
|
|
{
|
|
/* flush send whole structure down to me */
|
|
dpl_node *from_host=(dpl_node *) data;
|
|
dpl_node *replace;
|
|
|
|
/* printf ("vr_flush type %d\n", from_host->type_check ); */
|
|
replace =(dpl_node *) nameToAddress ((int) from_host->remote,
|
|
from_host->type_check );
|
|
|
|
if (replace == NULL) {
|
|
printf ("Velocirender flush failed to find remote node? %s\n",
|
|
type_to_string ( from_host->type_check ));
|
|
}
|
|
/*
|
|
this would work really well as a function if we didnt have to
|
|
avoid corrupting the name fields, which are locally all stored
|
|
as addresses - so here we go, a TON of function calls
|
|
*/
|
|
switch (from_host->type_check) {
|
|
/*{{{ case dpl_type_zone :*/
|
|
case dpl_type_zone :
|
|
flush_dpl_type_zone ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_view :*/
|
|
case dpl_type_view :
|
|
flush_dpl_type_view ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_instance :*/
|
|
case dpl_type_instance :
|
|
flush_dpl_type_instance ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_dcs :*/
|
|
case dpl_type_dcs :
|
|
flush_dpl_type_dcs ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_dcs :*/
|
|
case dpl_type_ramp :
|
|
flush_dpl_type_ramp ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_lmodel :*/
|
|
case dpl_type_lmodel :
|
|
flush_dpl_type_lmodel ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_light :*/
|
|
case dpl_type_light :
|
|
flush_dpl_type_light ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_object :*/
|
|
case dpl_type_object :
|
|
flush_dpl_type_object ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_lod :*/
|
|
case dpl_type_lod :
|
|
flush_dpl_type_lod ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_geogroup :*/
|
|
case dpl_type_geogroup :
|
|
flush_dpl_type_geogroup ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_geometry :*/
|
|
case dpl_type_geometry :
|
|
flush_dpl_type_geometry ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_material :*/
|
|
case dpl_type_material :
|
|
flush_dpl_type_material ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_texmap :*/
|
|
case dpl_type_texmap :
|
|
flush_dpl_type_texmap ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
/*{{{ case dpl_type_texture :*/
|
|
case dpl_type_texture :
|
|
flush_dpl_type_texture ( from_host, replace );
|
|
break;
|
|
/*}}} */
|
|
|
|
case dpl_type_error :
|
|
case dpl_type_scene :
|
|
case dpl_type_filepath :
|
|
case dpl_type_pathitem :
|
|
case dpl_type_extnitem :
|
|
case dpl_type_nameitem :
|
|
printf ("ERROR : Velocirender remote flush on node %d host-only type 0x%x %s\n",
|
|
from_host->remote,
|
|
from_host->type_check,
|
|
type_to_string ( from_host->type_check ));
|
|
break;
|
|
|
|
default :
|
|
printf ("ERROR : Velocirender remote flush node %d unknown type %d\n",
|
|
from_host->remote,
|
|
from_host->type_check );
|
|
protocol_error();
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
|
|
/* scene manipulation */
|
|
/*{{{ static int velocirender_add_list_item ( int *data )*/
|
|
static int velocirender_add_list_item ( int *data )
|
|
{
|
|
int list_name=data[0],
|
|
item_name=data[1];
|
|
dpl_node *list, *item;
|
|
|
|
list=nameToAddress ( list_name, -1 );
|
|
item=nameToAddress ( item_name, -1 );
|
|
|
|
if (item == NULL) {
|
|
printf ( "Attempt to add NULL to a list\n" );
|
|
}
|
|
if (list==NULL) {
|
|
if (item->type_check == dpl_type_view)
|
|
add_item ( &the_scene.view_list, item );
|
|
else if (item->type_check == dpl_type_zone)
|
|
add_item ( &the_scene.zone_list, item );
|
|
else
|
|
printf ("Attempt to add %s to scene\n", type_to_string(item->type_check));
|
|
}
|
|
else {
|
|
switch (list->type_check) {
|
|
case dpl_type_view :
|
|
/*{{{ add zone to view*/
|
|
{
|
|
dpl_VIEW *v=(dpl_VIEW *) list;
|
|
if (item->type_check == dpl_type_zone)
|
|
add_item ( &v->zone_list, item );
|
|
else
|
|
printf ("Attempt to add %s to view\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_lmodel :
|
|
/*{{{ add light to lmodel*/
|
|
{
|
|
dpl_LMODEL *lm=(dpl_LMODEL *) list;
|
|
if (item->type_check == dpl_type_light)
|
|
add_item ( &lm->light_list, item );
|
|
else
|
|
printf ("Attempt to add %s to lmodel\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_object :
|
|
/*{{{ add lod to object*/
|
|
{
|
|
dpl_OBJECT *o=(dpl_OBJECT *) list;
|
|
if (item->type_check == dpl_type_lod)
|
|
add_item ( &o->lod_list, item );
|
|
else
|
|
printf ("Attempt to add %s to view\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_lod :
|
|
/*{{{ add geogroup to lod*/
|
|
{
|
|
dpl_LOD *l=(dpl_LOD *) list;
|
|
if (item->type_check == dpl_type_geogroup)
|
|
add_item ( &l->geogroup_list, item );
|
|
else
|
|
printf ("Attempt to add %s to lod\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_geogroup :
|
|
/*{{{ add geometry to geogroup*/
|
|
{
|
|
dpl_GEOGROUP *gg=(dpl_GEOGROUP *) list;
|
|
if (item->type_check == dpl_type_geometry)
|
|
add_item ( &gg->geometry_list, item );
|
|
else
|
|
printf ("Attempt to add %s to geogroup\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
default :
|
|
printf ("Attempt to add %s to %s?\n",
|
|
type_to_string(list->type_check),
|
|
type_to_string(item->type_check));
|
|
break;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_remove_list_item ( int *data )*/
|
|
static int velocirender_remove_list_item ( int *data )
|
|
{
|
|
int list_name=data[0], item_name=data[1];
|
|
dpl_node *list, *item;
|
|
|
|
list=(dpl_node *) nameToAddress ( list_name, -1 );
|
|
item=(dpl_node *) nameToAddress ( item_name, -1 );
|
|
|
|
if (item == NULL) {
|
|
printf ( "Attempt to remove NULL from a list\n" );
|
|
return;
|
|
}
|
|
if (list==NULL) {
|
|
if (item->type_check == dpl_type_view)
|
|
remove_item ( &the_scene.view_list, item );
|
|
else if (item->type_check == dpl_type_zone)
|
|
remove_item ( &the_scene.zone_list, item );
|
|
else
|
|
printf ("Attempt to remove %s from scene\n", type_to_string(item->type_check));
|
|
}
|
|
else {
|
|
switch (list->type_check) {
|
|
case dpl_type_view :
|
|
/*{{{ add zone to view*/
|
|
{
|
|
dpl_VIEW *v=(dpl_VIEW *) list;
|
|
if (item->type_check == dpl_type_zone)
|
|
remove_item ( &v->zone_list, item );
|
|
else
|
|
printf ("Attempt to remove %s from view\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_lmodel :
|
|
/*{{{ add light to lmodel*/
|
|
{
|
|
dpl_LMODEL *lm=(dpl_LMODEL *) list;
|
|
if (item->type_check == dpl_type_light)
|
|
remove_item ( &lm->light_list, item );
|
|
else
|
|
printf ("Attempt to remove %s from lmodel\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_object :
|
|
/*{{{ add lod to object*/
|
|
{
|
|
dpl_OBJECT *o=(dpl_OBJECT *) list;
|
|
if (item->type_check == dpl_type_lod)
|
|
remove_item ( &o->lod_list, item );
|
|
else
|
|
printf ("Attempt to remove %s from view\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_lod :
|
|
/*{{{ add geogroup to lod*/
|
|
{
|
|
dpl_LOD *l=(dpl_LOD *) list;
|
|
if (item->type_check == dpl_type_geogroup)
|
|
remove_item ( &l->geogroup_list, item );
|
|
else
|
|
printf ("Attempt to remove %s from lod\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
case dpl_type_geogroup :
|
|
/*{{{ add geometry to geogroup*/
|
|
{
|
|
dpl_GEOGROUP *gg=(dpl_GEOGROUP *) list;
|
|
if (item->type_check == dpl_type_geometry)
|
|
remove_item ( &gg->geometry_list, item );
|
|
else
|
|
printf ("Attempt to remove %s from geogroup\n", type_to_string(item->type_check));
|
|
}
|
|
/*}}} */
|
|
break;
|
|
default :
|
|
printf ("Attempt to remove %s from %s?\n",
|
|
type_to_string(list->type_check),
|
|
type_to_string(item->type_check));
|
|
break;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ static int velocirender_nest_dcs ( int *data )*/
|
|
static int velocirender_nest_dcs ( int *data )
|
|
{
|
|
dpl_DCS *parent=(dpl_DCS *) nameToAddress ( data[0], dpl_type_dcs );
|
|
dpl_DCS *child =(dpl_DCS *) nameToAddress ( data[1], dpl_type_dcs );
|
|
|
|
/* printf ("nest 0x%x with child 0x%x\n", parent, child ); */
|
|
|
|
parent->child=child;
|
|
child->parent=parent;
|
|
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_link_dcs ( int *data )*/
|
|
static int velocirender_link_dcs ( int *data )
|
|
{
|
|
dpl_DCS *parent=(dpl_DCS *) nameToAddress ( data[0], dpl_type_dcs );
|
|
dpl_DCS *child =(dpl_DCS *) nameToAddress ( data[1], dpl_type_dcs );
|
|
|
|
/* printf ("link 0x%x with sibling 0x%x\n", parent, child ); */
|
|
|
|
parent->sibling=child;
|
|
child->parent=parent;
|
|
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_prune_dcs ( int *data )*/
|
|
static int velocirender_prune_dcs ( int *data )
|
|
{
|
|
dpl_DCS *parent=(dpl_DCS *) nameToAddress ( data[0], dpl_type_dcs );
|
|
dpl_DCS *child =(dpl_DCS *) nameToAddress ( data[1], dpl_type_dcs );
|
|
|
|
child->parent=NULL;
|
|
if (parent->sibling==child) {
|
|
parent->sibling=NULL;
|
|
}
|
|
else if (parent->child==child) {
|
|
parent->child=NULL;
|
|
}
|
|
else {
|
|
printf ("error, attempt to prune_dcs on unconnected nodes\n" );
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
|
|
/* screen interrogation */
|
|
/*{{{ static int velocirender_readpixels ( int *data )*/
|
|
static int velocirender_readpixels ( int *data )
|
|
{
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_sectvector ( int *data )*/
|
|
static int velocirender_sectvector ( int *data )
|
|
{
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_sectpixel ( int *data )*/
|
|
static int velocirender_sectpixel ( int *data )
|
|
{
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
|
|
/* general control */
|
|
/*{{{ static int velocirender_init ( int *data )*/
|
|
|
|
static int velocirender_init ( int *data )
|
|
{
|
|
char *argv=(char *) data;
|
|
|
|
parse_argv(argv);
|
|
printf ("vr_init argv=%s\n", argv );
|
|
|
|
*data=0x1;
|
|
return 4;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_draw_scene ( int *data )*/
|
|
static int velocirender_draw_scene ( int *data )
|
|
{
|
|
|
|
|
|
*data=vr_draw_scene ( data[1] );
|
|
|
|
return 4;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_morph_object ( int *data )*/
|
|
static int velocirender_morph_object ( int *data )
|
|
{
|
|
return 0;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static int velocirender_statistics ( int *data )*/
|
|
static int velocirender_statistics ( int *data )
|
|
{
|
|
*data=0x1;
|
|
return 4;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ some static functions to support geometry*/
|
|
/*{{{ NewVertices ( int n_vertices )*/
|
|
static dpl_VERTEX_LIST *
|
|
NewVertices ( int n_vertices )
|
|
{
|
|
dpl_VERTEX_LIST *head=NULL, *prevl=NULL, *vl;
|
|
dpl_VERTEX *v, *prev=NULL;
|
|
int i, total_vertices=n_vertices;
|
|
|
|
if (n_vertices > 0) {
|
|
while (n_vertices > 0) {
|
|
vl=(dpl_VERTEX_LIST *) malloc(sizeof(dpl_VERTEX_LIST));
|
|
|
|
if (vl == NULL) {
|
|
printf ( "Failed to allocate vertex list of %d vertices\n", total_vertices );
|
|
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;
|
|
}
|
|
|
|
}
|
|
head->n_vertices=total_vertices;
|
|
return head;
|
|
}
|
|
else {
|
|
printf ( "Attempt to allocate 0 vertices\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ NewConnections ( int n_connections )*/
|
|
static dpl_CONNECTION_LIST *
|
|
NewConnections ( int n_connections )
|
|
{
|
|
dpl_CONNECTION_LIST *head=NULL, *prevcl=NULL, *cl;
|
|
dpl_CONNECTION *c, *prev=NULL;
|
|
|
|
int i, total_connections=n_connections;
|
|
|
|
if (n_connections > 0) {
|
|
while (n_connections > 0) {
|
|
cl=(dpl_CONNECTION_LIST *) malloc(sizeof(dpl_CONNECTION_LIST));
|
|
|
|
if (cl == NULL) {
|
|
printf ( "Failed to allocate connection list of %d connections\n",
|
|
total_connections );
|
|
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;
|
|
}
|
|
}
|
|
|
|
head->n_connections=total_connections;
|
|
return head;
|
|
}
|
|
else {
|
|
printf ( "Attempt to allocate 0 connections\n" );
|
|
return NULL;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/* BEWARE - these 2 functions alone need to understand both
|
|
host and remote data representations */
|
|
/*{{{ replace_vertices ( dpl_REMOTE_VERTEX_LIST *dest, void *vsrc )*/
|
|
static void
|
|
replace_vertices ( dpl_REMOTE_VERTEX_LIST *dest, void *vsrc )
|
|
{
|
|
dpl_HOST_VERTEX_LIST *src=(dpl_HOST_VERTEX_LIST *) vsrc;
|
|
dpl_REMOTE_VERTEX *dest_v =&dest->vertices[0];
|
|
dpl_HOST_VERTEX *src_v =&src->vertices[0];
|
|
int i;
|
|
|
|
for (i=src->n_vertices; i; i--, src_v++, dest_v++ ) {
|
|
dpl_REMOTE_VERTEX *next=dest_v->next;
|
|
memcpy ( dest_v, src_v, sizeof(dpl_HOST_VERTEX));
|
|
/* is this shitty or what? */
|
|
dest_v->texcoords[0]*=0.125f;
|
|
dest_v->texcoords[1]*=0.125f;
|
|
/* even shittier - dont do tex[2], its where i put opacity! */
|
|
/* dest_v->texcoords[2]*=0.125f; */
|
|
/*
|
|
printf ("replaced vertex %d with %f,%f,%f\n",
|
|
i,
|
|
dest_v->position[0],
|
|
dest_v->position[1],
|
|
dest_v->position[2] );
|
|
*/
|
|
dest_v->next=next;
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*{{{ replace_connections ( dpl_REMOTE_CONNECTION_LIST *dest, void *vsrc )*/
|
|
static void
|
|
replace_connections ( dpl_REMOTE_CONNECTION_LIST *dest, void *vsrc )
|
|
{
|
|
dpl_HOST_CONNECTION_LIST *src =(dpl_HOST_CONNECTION_LIST *) vsrc;
|
|
dpl_HOST_CONNECTION *src_v =&src->connections[0];
|
|
dpl_REMOTE_CONNECTION *dest_v =&dest->connections[0];
|
|
int i;
|
|
|
|
for (i=src->n_connections; i; i--, src_v++, dest_v++ ) {
|
|
dpl_REMOTE_CONNECTION *next=dest_v->next;
|
|
memcpy ( dest_v, src_v, sizeof(dpl_HOST_CONNECTION));
|
|
dest_v->next=next;
|
|
}
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ vertex_from_index ( dpl_VERTEX_LIST *vl, int index )*/
|
|
static dpl_VERTEX *
|
|
vertex_from_index ( dpl_VERTEX_LIST *vl, int index )
|
|
{
|
|
while (index >= DPL_VERTICES_PER_BLOCK) {
|
|
vl=vl->next;
|
|
index-=DPL_VERTICES_PER_BLOCK;
|
|
}
|
|
return &vl->vertices[index];
|
|
}
|
|
/*}}} */
|
|
/*{{{ resolve_connections ( dpl_GEOMETRY *g )*/
|
|
static void
|
|
resolve_connections ( dpl_GEOMETRY *g )
|
|
{
|
|
extern void compute_plane_eqn ( dpl_POINT plane, dpl_POINT a, dpl_POINT b, dpl_POINT c );
|
|
|
|
dpl_VERTEX_LIST *vl = g->vertices;
|
|
dpl_CONNECTION_LIST *cl=g->connections;
|
|
dpl_CONNECTION *con=&cl->connections[0];
|
|
int i, j;
|
|
int vari_alpha=0;
|
|
float32 r, x, y, z, w;
|
|
|
|
while (con) {
|
|
dpl_VERTEX *va, *vb, *vc;
|
|
for (i=0;i<con->n_verts;i++ )
|
|
con->indices[i]=vertex_from_index(vl, (int) (con->indices[i]));
|
|
|
|
va=con->indices[0];
|
|
vb=con->indices[1];
|
|
vc=con->indices[2];
|
|
|
|
compute_plane_eqn ( con->planeEqn,
|
|
va->position,
|
|
vb->position,
|
|
vc->position );
|
|
|
|
/* now normalize the planeEqn so it also serves as a facet normal */
|
|
x=con->planeEqn[0];
|
|
y=con->planeEqn[1];
|
|
z=con->planeEqn[2];
|
|
w=con->planeEqn[3];
|
|
|
|
r=1.0f / sqrt((x*x) + (y*y) + (z*z));
|
|
|
|
con->planeEqn[0]=x*r;
|
|
con->planeEqn[1]=y*r;
|
|
con->planeEqn[2]=z*r;
|
|
con->planeEqn[3]=w*r;
|
|
|
|
/*
|
|
printf ("triangle %f,%f,%f, %f,%f,%f %f,%f,%f\n",
|
|
va->position[0],
|
|
va->position[1],
|
|
va->position[2],
|
|
vb->position[0],
|
|
vb->position[1],
|
|
vb->position[2],
|
|
vc->position[0],
|
|
vc->position[1],
|
|
vc->position[2] );
|
|
printf ("plane eqn %f, %f, %f, %f\n",
|
|
con->planeEqn[0],
|
|
con->planeEqn[1],
|
|
con->planeEqn[2],
|
|
con->planeEqn[3] );
|
|
*/
|
|
if ((va->normcol[3] != 1.0f) ||
|
|
(vb->normcol[3] != 1.0f) ||
|
|
(vc->normcol[3] != 1.0f))
|
|
vari_alpha=1;
|
|
|
|
con=con->next;
|
|
}
|
|
g->variable_alpha=vari_alpha;
|
|
}
|
|
/*}}} */
|
|
/*{{{ static void fix_up_geometry ( dpl_GEOMETRY *g )*/
|
|
static void fix_up_geometry ( dpl_GEOMETRY *g, int nv )
|
|
{
|
|
int i, v;
|
|
dpl_CONNECTION_LIST *con_l;
|
|
dpl_CONNECTION *con;
|
|
|
|
if ((g->geometry_type == dpl_g_type_tristrip)) {
|
|
/*{{{ build connections geometry*/
|
|
con_l=NewConnections ( nv-2 );
|
|
g->connections=con_l;
|
|
con=&con_l->connections[0];
|
|
for (i=0, v=0; v<nv-2; i++, v++, con++ ) {
|
|
int *indices;
|
|
if (i==DPL_CONNECTIONS_PER_BLOCK) {
|
|
i=0;
|
|
con_l=con_l->next;
|
|
con=&con_l->connections[0];
|
|
}
|
|
indices=(int *) &con->indices[0];
|
|
|
|
con->n_verts=3;
|
|
if (v&1) {
|
|
indices[1]=v;
|
|
indices[0]=v+1;
|
|
}
|
|
else {
|
|
indices[0]=v;
|
|
indices[1]=v+1;
|
|
}
|
|
indices[2]=v+2;
|
|
}
|
|
resolve_connections ( g );
|
|
/*}}} */
|
|
}
|
|
else if ((g->geometry_type == dpl_g_type_polystrip)) {
|
|
/*{{{ build connections geometry*/
|
|
con_l=NewConnections ( nv-2 );
|
|
g->connections=con_l;
|
|
con=&con_l->connections[0];
|
|
for (i=0, v=0; v<nv-2; i++, v++, con++ ) {
|
|
int *indices;
|
|
if (i==DPL_CONNECTIONS_PER_BLOCK) {
|
|
i=0;
|
|
con_l=con_l->next;
|
|
con=&con_l->connections[0];
|
|
}
|
|
indices=(int *) &con->indices[0];
|
|
con->n_verts=3;
|
|
|
|
indices[0]=0;
|
|
indices[1]=v+1;
|
|
indices[2]=v+2;
|
|
}
|
|
resolve_connections ( g );
|
|
/*}}} */
|
|
}
|
|
else if (g->geometry_type == dpl_g_type_pmesh) {
|
|
resolve_connections ( g );
|
|
}
|
|
}
|
|
/*}}} */
|
|
/*}}} */
|
|
/*{{{ static int velocirender_set_geom_verts ( int *param_data )*/
|
|
static int velocirender_set_geom_verts ( int *param_data )
|
|
{
|
|
dpl_GEOMETRY *g=(dpl_GEOMETRY *) nameToAddress ( param_data[0], dpl_type_geometry );
|
|
dpl_VERTEX_LIST *vl;
|
|
dpl_CONNECTION_LIST *cl;
|
|
int vertex_blocks = param_data[1];
|
|
int connection_blocks = param_data[2];
|
|
int vertex_count = param_data[3];
|
|
int connect_count = param_data[4];
|
|
int receive_bytes, client;
|
|
|
|
/* first free up existing geometry */
|
|
vl=g->vertices;
|
|
g->vertices=NULL;
|
|
while (vl) {
|
|
dpl_VERTEX_LIST *next=vl->next;
|
|
free(vl);
|
|
vl=next;
|
|
}
|
|
|
|
cl=g->connections;
|
|
g->connections=NULL;
|
|
while (cl) {
|
|
dpl_CONNECTION_LIST *next=cl->next;
|
|
free(cl);
|
|
cl=next;
|
|
}
|
|
|
|
if (vertex_count > 0)
|
|
g->vertices=NewVertices ( vertex_count );
|
|
if (connect_count > 0)
|
|
g->connections=NewConnections ( connect_count );
|
|
|
|
vl=g->vertices;
|
|
cl=g->connections;
|
|
|
|
while (vertex_blocks) {
|
|
dN_receive ( &client, &receive_bytes, (char *) data, 1 );
|
|
if ((vr_action) data[0] != vr_set_geom_verts_action) {
|
|
printf ("Unexpected action 0x%x during geometry\n",
|
|
data[0] );
|
|
}
|
|
|
|
replace_vertices ( vl, param_data );
|
|
vl=vl->next;
|
|
|
|
vertex_blocks--;
|
|
}
|
|
|
|
while (connection_blocks) {
|
|
dN_receive ( &client, &receive_bytes, (char *) data, 1 );
|
|
if ((vr_action) data[0] != vr_set_geom_verts_action) {
|
|
printf ("Unexpected action 0x%x during geometry connections\n",
|
|
data[0] );
|
|
}
|
|
|
|
replace_connections ( cl, param_data );
|
|
cl=cl->next;
|
|
|
|
connection_blocks--;
|
|
}
|
|
|
|
fix_up_geometry ( g, vertex_count );
|
|
|
|
*param_data=0x1;
|
|
return 4;
|
|
}
|
|
/*}}} */
|
|
|
|
/*{{{ static int velocirender_set_texmap_texels ( int *param_data )*/
|
|
static int velocirender_set_texmap_texels ( int *param_data )
|
|
{
|
|
dpl_TEXMAP *tm=(dpl_TEXMAP *) nameToAddress ( param_data[0], dpl_type_texmap );
|
|
int n_texels = param_data [1];
|
|
int u_size = param_data [2];
|
|
int v_size = param_data [3];
|
|
int mode = param_data [4];
|
|
texcell *cell;
|
|
char *map, *map_p;
|
|
int receive_bytes, client;
|
|
|
|
n_texels <<= 2; /* make it bytes */
|
|
/*
|
|
printf ("set texmap texels, texmap 0x%x %d bytes, u_size %d mode %d\n",
|
|
tm, n_texels, u_size, mode );
|
|
*/
|
|
map=malloc(n_texels);
|
|
|
|
/*
|
|
if (map == NULL)
|
|
printf ("FAILED TO MALLOC MAP!!!!\n" );
|
|
*/
|
|
map_p=map;
|
|
|
|
while (n_texels) {
|
|
dN_receive ( &client, &receive_bytes, (char *) data, 1 );
|
|
|
|
receive_bytes-=4;
|
|
/* printf ("received %d bytes\n", receive_bytes ); */
|
|
|
|
if ((vr_action) data[0] != vr_set_texmap_texels_action) {
|
|
printf ("Unexpected action 0x%x during texmap texels\n",
|
|
data[0] );
|
|
}
|
|
|
|
/* replace texels from param_data[1] */
|
|
if (map_p) {
|
|
memcpy ( map_p, param_data, receive_bytes );
|
|
map_p+=receive_bytes;
|
|
}
|
|
n_texels-=receive_bytes;
|
|
/* printf ("%d texels to go\n", n_texels ); */
|
|
}
|
|
/*
|
|
printf ("gonna try and allocate an hsp texture of %d by %d\n",
|
|
u_size, v_size );
|
|
*/
|
|
cell=allocateHSPtexture( u_size, v_size );
|
|
|
|
if (cell && map) {
|
|
int pxpl5_address=64*64*cell->hwareOffs;
|
|
|
|
tm->hwareSize=cell->hwareSize;
|
|
tm->hwareOffs=cell->hwareOffs;
|
|
tm->bilinear=0;
|
|
|
|
if (mode == 1) {
|
|
tm->bilinear=1;
|
|
dN_pxpl5_texture8 ( (int *) map, pxpl5_address, u_size, 1 );
|
|
}
|
|
else if (mode == 2) {
|
|
dN_pxpl5_fx_texture24 ( (int *) map, pxpl5_address, u_size );
|
|
}
|
|
else {
|
|
dN_pxpl5_texture24 ( (int *) map, pxpl5_address, u_size );
|
|
}
|
|
free(map);
|
|
|
|
}
|
|
else if (map) {
|
|
printf ("ERROR : texcall malloc failed\n" );
|
|
free(map);
|
|
}
|
|
|
|
*param_data=0x1;
|
|
return 4;
|
|
}
|
|
/*}}} */
|
|
|
|
|
|
/*}}} */
|
|
|
|
/*{{{ int deal_with ( int *client, int me, int total )*/
|
|
void remote_velocirender ( int me, int total )
|
|
{
|
|
int ret=0, client=0;
|
|
void *param_data=&data[1];
|
|
vr_action action;
|
|
|
|
my_id=me;
|
|
|
|
while (1) {
|
|
dN_receive ( &client, &receive_bytes, (char *) data, 1 );
|
|
action = (vr_action) *data;
|
|
|
|
if (action == vr_init_action) {
|
|
ret = velocirender_init ( param_data );
|
|
init_pending=1;
|
|
}
|
|
else {
|
|
/*{{{ init if needed*/
|
|
if (init_pending) {
|
|
do_init ();
|
|
init_pending=0;
|
|
}
|
|
/*}}} */
|
|
|
|
switch (action) {
|
|
/* node manipulation */
|
|
case vr_create_action :
|
|
/*{{{ */
|
|
ret = velocirender_create ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_delete_action :
|
|
/*{{{ */
|
|
ret = velocirender_delete ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_flush_action :
|
|
/*{{{ */
|
|
ret = velocirender_flush ( param_data );
|
|
break;
|
|
|
|
/*}}} */
|
|
|
|
/* scene editing manipulation */
|
|
case vr_dcs_nest_action :
|
|
/*{{{ */
|
|
ret = velocirender_nest_dcs ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_dcs_link_action :
|
|
/*{{{ */
|
|
ret = velocirender_link_dcs ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_dcs_prune_action :
|
|
/*{{{ */
|
|
ret = velocirender_prune_dcs ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_list_add_action :
|
|
/*{{{ */
|
|
ret = velocirender_add_list_item ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_list_remove_action :
|
|
/*{{{ */
|
|
ret = velocirender_remove_list_item ( param_data );
|
|
break;
|
|
/*}}} */
|
|
|
|
/* geometry dumpage */
|
|
case vr_set_geom_verts_action :
|
|
/*{{{ */
|
|
ret = velocirender_set_geom_verts ( param_data );
|
|
break;
|
|
/*}}} */
|
|
|
|
case vr_set_texmap_texels_action :
|
|
/*{{{ */
|
|
ret = velocirender_set_texmap_texels ( param_data );
|
|
break;
|
|
/*}}} */
|
|
|
|
/* screen interrogation */
|
|
case vr_sect_pixel_action :
|
|
/*{{{ */
|
|
ret = velocirender_sectpixel ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_sect_vector_action :
|
|
/*{{{ */
|
|
ret = velocirender_sectvector ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_readpixels_action :
|
|
/*{{{ */
|
|
ret = velocirender_readpixels ( param_data );
|
|
break;
|
|
|
|
/*}}} */
|
|
|
|
/* general control stuff */
|
|
case vr_draw_scene_action :
|
|
/*{{{ */
|
|
ret = velocirender_draw_scene ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_morph_action :
|
|
/*{{{ */
|
|
ret = velocirender_morph_object ( param_data );
|
|
break;
|
|
/*}}} */
|
|
case vr_statistics_action :
|
|
/*{{{ */
|
|
ret = velocirender_statistics ( param_data );
|
|
break;
|
|
|
|
/*}}} */
|
|
|
|
/* what the duck? */
|
|
default :
|
|
printf ("unrecognised or illegal action 0x%x\n", (int) action );
|
|
protocol_error();
|
|
break;
|
|
}
|
|
}
|
|
if (ret != 0) {
|
|
reply ( ret, &client, data );
|
|
}
|
|
}
|
|
}
|
|
/*}}} */
|