src/shlit.c

00001 
00006 /*
00007  *  PROGRAM NAME:  sh
00008  *
00009  *  (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES
00010  *  CORPORATION 12/1/2001.  ALL RIGHTS RESERVED.
00011  *
00012  *  Please refer to the LICENSE file in the top directory
00013  *
00014  *      author: Mike Henderson mhender@watson.ibm.com
00015  */
00016 
00017 static char *id="@(#) $Id: shlit.c,v 1.2 2006/08/17 19:28:17 mhender Exp $";
00018 
00019 #include <shInternal.h>
00020 
00023 int sh_nlit=0;
00024 int sh_mlit=0;
00025 int *sh_rs=(int*)NULL;
00026 int *sh_gs=(int*)NULL;
00027 int *sh_bs=(int*)NULL;
00028 int *sh_type=(int*)NULL;
00029 double *sh_lit=(double*)NULL;
00030 
00044 void shlit(int *m,float *x,float *y,float *z,int *r,int *g,int *b)
00045  {
00046   float xt=0.;
00047   float yt=0.;
00048   float zt=0.;
00049 
00050 /*     This Routine Sets the parameters associated with light source m. */
00051 
00052 /*              x,y,z   (real) position.                                */
00053 /*              r,g,b   (integer 0-255) color.                          */
00054 /*              type    (integer 0-1) 0=point,1=direction.              */
00055 
00056   if((*m)>=sh_mlit)
00057    {
00058     if(sh_mlit==0)
00059      {
00060       sh_mlit=(*m)+10;
00061       sh_rs=(int*)malloc(sh_mlit*sizeof(int));
00062       sh_gs=(int*)malloc(sh_mlit*sizeof(int));
00063       sh_bs=(int*)malloc(sh_mlit*sizeof(int));
00064       sh_type=(int*)malloc(sh_mlit*sizeof(int));
00065       sh_lit=(double*)malloc(3*sh_mlit*sizeof(double));
00066      }else{
00067       sh_mlit=(*m)+10;
00068       sh_rs=(int*)realloc((void*)sh_rs,sh_mlit*sizeof(int));
00069       sh_gs=(int*)realloc((void*)sh_gs,sh_mlit*sizeof(int));
00070       sh_bs=(int*)realloc((void*)sh_bs,sh_mlit*sizeof(int));
00071       sh_type=(int*)realloc((void*)sh_type,sh_mlit*sizeof(int));
00072       sh_lit=(double*)realloc((void*)sh_lit,sh_mlit*sizeof(double));
00073      }
00074    }
00075   sh_rs[(*m)-1]=*r;
00076   sh_gs[(*m)-1]=*g;
00077   sh_bs[(*m)-1]=*b;
00078 
00079   shpers(x,y,z,&xt,&yt,&zt);
00080   sh_lit[0+3*((*m)-1)]=xt;
00081   sh_lit[1+3*((*m)-1)]=yt;
00082   sh_lit[2+3*((*m)-1)]=zt;
00083   sh_type[(*m)-1]=1;
00084 
00085   return;
00086  }

Generated on Thu Aug 17 15:29:43 2006 for sh by  doxygen 1.4.6