summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/PEX5/ddpex/mi/level2/miLight.c
blob: 2b4af44738cdd5d04a14c44ec86115fb961bbdad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
/* $XConsortium: miLight.c,v 5.4 94/04/17 20:37:07 hersh Exp $ */
/*

Copyright (c) 1989, 1990, 1991  X Consortium

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.


Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. 
All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Sun Microsystems
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.

SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

*/

#include "miLUT.h"
#include "misc.h"
#include "miscstruct.h"
#include "PEXErr.h"
#include "miRender.h"
#include "miLight.h"
 
extern ddpex3rtn	InquireLUTEntryAddress();
ddpex3rtn ComputeWCEyePosition();

/*++
 |
 |  Apply_Lighting(pRend, pddc, input_vert, output_fct)
 |
 |	Create a facet list for the fill area defined by the
 |	specified vertex list.
 |
 |      NOTE: This routine does not use back-facing lighting parameters.
 |	      Furthermore, it assumes that the input lights are
 |	      specified in rgb.
 |
 --*/
ddpex3rtn
miApply_Lighting(pRend, pddc, point, mat_color, normal, out_color)
    ddRendererPtr	pRend;		/* renderer handle */
    miDDContext		*pddc;
    ddCoord4D		*point;
    ddRgbFloatColour	*mat_color;
    ddVector3D		*normal;
    ddRgbFloatColour	*out_color;
{
/* calls */
    double		pow();

/* uses */
    listofObj		*light_sources = pddc->Dynamic->pPCAttr->lightState;
    ddUSHORT		*index = (ddUSHORT *)light_sources->pList;
    miLightEntry	*pLUT;
    ddLightEntry	*lightentry; 
    ddUSHORT		status;
    ddFLOAT		n_dot_l, v_dot_r, d_dot_l;
    ddFLOAT		distance;
    ddFLOAT		atten;
    ddVector3D		view_vec, refl_vec, light_vec;
    int			j;


    /* some quick bounds checking */
    if (light_sources->numObj <= 0) {
      *out_color = *mat_color;
      return(Success);
    }

    out_color->red = out_color->green = out_color->blue = 0.0;

    for (j = 0; j < light_sources->numObj; j++) {
      /* Fetch light source data from LUT */
      if ((InquireLUTEntryAddress (PEXLightLUT,
				   pRend->lut[PEXLightLUT], *index,
				   &status, (ddPointer *)(&pLUT)))
	   == PEXLookupTableError)
	return (PEXLookupTableError);

	lightentry = &pLUT->entry;

      /* 
       * Insure that light color is same model as the current
       * rendering model.
       */
      if (lightentry->lightColour.colourType) {}

      /* The shading equations are different for each light type */
      switch(lightentry->lightType) {

	case PEXLightAmbient:
	  /*
	  * An ambient light simply adds a constant background
	  * color term to all the facets in a scene.
	  */
	  out_color->red += 
			pddc->Static.attrs->reflAttr.ambient * 
			(lightentry->lightColour.colour.rgbFloat.red *
			 mat_color->red);
	  out_color->green +=
			pddc->Static.attrs->reflAttr.ambient *
			(lightentry->lightColour.colour.rgbFloat.green*
			 mat_color->green);
	  out_color->blue += 
			pddc->Static.attrs->reflAttr.ambient *
			(lightentry->lightColour.colour.rgbFloat.blue *
			 mat_color->blue);
	  break;

	case PEXLightWcsVector:
	  /*
	   * A directional light source is located at an 
	   * infinite distance from the object along
	   * the specified direction.
	   */
	  n_dot_l = 0.0;

	  /* compute reflect view vector */
	  DOT_PRODUCT(&lightentry->direction, normal, n_dot_l);
	  /* negate because light vector should point towards light */
	  n_dot_l = -n_dot_l;
	  if (n_dot_l <= 0.0) break; 

	  switch(pddc->Static.attrs->reflModel) {
	    /* 
	     * Note that the total light source contribution
	     * is the sum of the specular, diffuse and ambient
	     * contributions.
	     */
	    case PEXReflectionSpecular:

		CALCULATE_REFLECTION_VECTOR(&refl_vec, -n_dot_l,
					    normal,
					    &lightentry->direction);
    		refl_vec.x *= -1.0;		
    		refl_vec.y *= -1.0;		
    		refl_vec.z *= -1.0;		
		NORMALIZE_VECTOR (&refl_vec, v_dot_r);

		/*
		 * Insure eye point is correct for view vector
		 * calculation. As eye_point is computed from
		 * the inverse view matrix, this matrix must
		 * be valid for eye point to be correct.
		 */
		if (pddc->Static.misc.flags & INVVIEWXFRMFLAG)
		  ComputeWCEyePosition(pRend, pddc);

		if (NEAR_ZERO(pddc->Static.misc.eye_pt.w)) {
		  /* 
		   * if the homogeneous component of the eye
		   * position is near zero after the inverse
		   * transform from NPC space, it indicates that
		   * the view transform is an orthographic, as oppposed
		   * to perspective transformation and that the eye
		   * point thus represents a vector rather than a point
		   */
		  view_vec.x = pddc->Static.misc.eye_pt.x;
		  view_vec.y = pddc->Static.misc.eye_pt.y;
		  view_vec.z = pddc->Static.misc.eye_pt.z;
		} else {
		  /*
		   * Compute the view vector.
		   */
		  CALCULATE_DIRECTION_VECTOR(&pddc->Static.misc.eye_pt,
					     point,
					     &view_vec);
		  NORMALIZE_VECTOR (&view_vec, v_dot_r);
		}

		DOT_PRODUCT(&refl_vec, &view_vec, v_dot_r);
		if (v_dot_r > 0.0)
		 {
		  v_dot_r = pow(v_dot_r, 
			     pddc->Static.attrs->reflAttr.specularConc);
		  out_color->red += 
		    v_dot_r *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.red * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.red);
		  out_color->green += 
		    v_dot_r *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.green * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.green);
		  out_color->blue += 
		    v_dot_r *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.blue * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.blue);
		 }

	    case PEXReflectionDiffuse:

		out_color->red += n_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.red * 
			 mat_color->red);
		out_color->green += n_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.green * 
			 mat_color->green);
		out_color->blue += n_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.blue * 
			 mat_color->blue);

	    case PEXReflectionAmbient:
		/* No ambient contribution except from ambient lights */

	   break;
	  }
	  break;

	case PEXLightWcsPoint:
	  /*
	   * A point light source is a radiating point source
	   * located at the specified position.
	   */
	  n_dot_l = 0.0;
	  /* 
	   * Note that the total light source contribution
	   * is the sum if the specular, diffuse and ambient
	   * contributions.
	   */

	  CALCULATE_DIRECTION_VECTOR(&lightentry->point,
				     point,
				     &light_vec);
	  NORMALIZE_VECTOR (&light_vec, distance);

	  /* compute reflect view vector */
	  DOT_PRODUCT(&light_vec, normal, n_dot_l);
	  if (n_dot_l <= 0.0) break; 

	  /* Compute light attenuation */
	  atten = 1.0/(lightentry->attenuation1 + 
			   (lightentry->attenuation2 * distance));

	  switch(pddc->Static.attrs->reflModel) {

	      case PEXReflectionSpecular:

		CALCULATE_REFLECTION_VECTOR(&refl_vec, n_dot_l,
					    normal,
					    &light_vec);
		NORMALIZE_VECTOR (&refl_vec, v_dot_r);

		/*
		 * Insure eye point is correct for view vector
		 * calculation. As eye_point is computed from
		 * the inverse view matrix, this matrix must
		 * be valid for eye point to be correct.
		 */
		if (pddc->Static.misc.flags & INVVIEWXFRMFLAG)
		  ComputeWCEyePosition(pRend, pddc);

		if (NEAR_ZERO(pddc->Static.misc.eye_pt.w)) {
		  /* 
		   * if the homogeneous component of the eye
		   * position is near zero after the inverse
		   * transform from NPC space, it indicates that
		   * the view transform is an orthographic, as oppposed
		   * to perspective transformation and that the eye
		   * point thus represents a vector rather than a point
		   */
		  view_vec.x = pddc->Static.misc.eye_pt.x;
		  view_vec.y = pddc->Static.misc.eye_pt.y;
		  view_vec.z = pddc->Static.misc.eye_pt.z;
		} else {
		  /*
		   * Compute the view vector.
		   */
		  CALCULATE_DIRECTION_VECTOR(&pddc->Static.misc.eye_pt,
					     point,
					     &view_vec);
		  NORMALIZE_VECTOR (&view_vec, v_dot_r);
		}

		DOT_PRODUCT(&refl_vec, &view_vec, v_dot_r);
		if (v_dot_r > 0.0)
		 {
		  v_dot_r = pow(v_dot_r, 
			     pddc->Static.attrs->reflAttr.specularConc);
		  out_color->red += 
		    atten * v_dot_r *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.red * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.red);
		  out_color->green += 
		    atten * v_dot_r *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.green * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.green);
		  out_color->blue += 
		    atten * v_dot_r *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.blue * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.blue);
		 }

	      case PEXReflectionDiffuse:

		out_color->red += atten * n_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.red * 
			 mat_color->red);
		out_color->green += atten * n_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.green * 
			 mat_color->green);
		out_color->blue += atten * n_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.blue * 
			 mat_color->blue);

	      case PEXReflectionAmbient:
		/* No ambient contribution except from ambient lights */
		break;
	  }
	  break;

	case PEXLightWcsSpot:
	  /*
	   * A spot light source is a radiating point source
	   * output whose output is limited by a cone of specified
	   * direction and angle.
	   */
	  n_dot_l = 0.0;
	  /* 
	   * Note that the total light source contribution
	   * is the sum if the specular, diffuse and ambient
	   * contributions.
	   */

	  CALCULATE_DIRECTION_VECTOR(&lightentry->point,
				     point,
				     &light_vec);
	  NORMALIZE_VECTOR (&light_vec, distance);

	  /* Check that object is within spot angle. */
	  DOT_PRODUCT(&lightentry->direction, &light_vec, d_dot_l);
	  /* Negate because light vec should point other way for this test */
	  d_dot_l = -d_dot_l;
	  if (d_dot_l <= pLUT->cosSpreadAngle) break;
	  d_dot_l = pow(d_dot_l, lightentry->concentration);

	  /* compute reflect view vector */
	  DOT_PRODUCT(&light_vec, normal, n_dot_l);
	  if (n_dot_l <= 0.0) break; 

	  /* Compute light attenuation */
	  atten = 1.0/(lightentry->attenuation1 + 
			(lightentry->attenuation2 * distance));

	  switch(pddc->Static.attrs->reflModel) {

	      case PEXReflectionSpecular:

		CALCULATE_REFLECTION_VECTOR(&refl_vec, n_dot_l,
					    normal,
					    &light_vec);
		NORMALIZE_VECTOR (&refl_vec, v_dot_r);

		/*
		 * Insure eye point is correct for view vector
		 * calculation. As eye_point is computed from
		 * the inverse view matrix, this matrix must
		 * be valid for eye point to be correct.
		 */
		if (pddc->Static.misc.flags & INVVIEWXFRMFLAG)
		  ComputeWCEyePosition(pRend, pddc);

		if (NEAR_ZERO(pddc->Static.misc.eye_pt.w)) {
		  /* 
		   * if the homogeneous component of the eye
		   * position is near zero after the inverse
		   * transform from NPC space, it indicates that
		   * the view transform is an orthographic, as oppposed
		   * to perspective transformation and that the eye
		   * point thus represents a vector rather than a point
		   */
		  view_vec.x = pddc->Static.misc.eye_pt.x;
		  view_vec.y = pddc->Static.misc.eye_pt.y;
		  view_vec.z = pddc->Static.misc.eye_pt.z;
		} else {
		  /*
		   * Compute the view vector.
		   */
		  CALCULATE_DIRECTION_VECTOR(&pddc->Static.misc.eye_pt,
					     point,
					     &view_vec);
		  NORMALIZE_VECTOR (&view_vec, v_dot_r);
		}

		DOT_PRODUCT(&refl_vec, &view_vec, v_dot_r);
		if (v_dot_r > 0.0)
		 {
		  v_dot_r = pow(v_dot_r, 
			     pddc->Static.attrs->reflAttr.specularConc);
		  out_color->red += 
		    atten * v_dot_r * d_dot_l *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.red * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.red);
		  out_color->green += 
		    atten * v_dot_r * d_dot_l *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.green * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.green);
		  out_color->blue += 
		    atten * v_dot_r * d_dot_l *
		    pddc->Static.attrs->reflAttr.specular *
		    (lightentry->lightColour.colour.rgbFloat.blue * 
		     pddc->Static.attrs->reflAttr.specularColour.colour.rgbFloat.blue);
		 }

	      case PEXReflectionDiffuse:

		out_color->red += atten * n_dot_l * d_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.red * 
			 mat_color->red);
		out_color->green += atten * n_dot_l * d_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.green * 
			 mat_color->green);
		out_color->blue += atten * n_dot_l * d_dot_l *
			pddc->Static.attrs->reflAttr.diffuse *
			(lightentry->lightColour.colour.rgbFloat.blue * 
			 mat_color->blue);

	      case PEXReflectionAmbient:
		/* No ambient contribution except from ambient lights */
		break;
	  }
      }
    index++; /* skip to next light source index in list */

    }

    return(Success);
}

/*++
 |
 |  ComputeWCEyePosition(pRend, pddc)
 |
 |	Compute a WC eye position from the inverse view transform.
 |
 --*/
ddpex3rtn ComputeWCEyePosition(pRend, pddc)
	ddRendererPtr	pRend;		/* renderer handle */
	miDDContext	*pddc;
{
	extern void	miMatCopy();

	/* First, update inverse view matrix */
	miViewEntry	*pLUT;
	ddUSHORT	status;
	ddCoord4D	NPCEye;
	ddFLOAT		mag;

	/* Get the view table entry at current view index first */
	if ((InquireLUTEntryAddress (PEXViewLUT, pRend->lut[PEXViewLUT],
				     pddc->Dynamic->pPCAttr->viewIndex,
				     &status, (ddPointer *)&pLUT))
	    == PEXLookupTableError)
	  return (PEXLookupTableError);


	/* Compute the composite [VOM] next */
/*
	ddViewEntry	*viewbundle;
	viewbundle = &pLUT->entry;
	miMatMult (pddc->Static.misc.inv_view_xform,
		   viewbundle->orientation,
		   viewbundle->mapping );
*/

	if (!pLUT->inv_flag)
	{
		/* compute the inverse */
		miMatCopy(pLUT->vom, pddc->Static.misc.inv_view_xform);
		miMatInverse(pddc->Static.misc.inv_view_xform);
		miMatCopy(pddc->Static.misc.inv_view_xform, pLUT->vom_inv);
		pLUT->inv_flag = MI_TRUE;
	}
	else
		miMatCopy(pLUT->vom_inv, pddc->Static.misc.inv_view_xform);

	/* Clear ddc status flag */
	pddc->Static.misc.flags &= ~INVVIEWXFRMFLAG;
	
	/* 
	 * Multiply NPC eye point by inverse view matrix 
	 * NPC eye point is defined as (0.0, 0.0, 1.0, 0.0) in NPC space
	 */
	NPCEye.x = 0.0;
	NPCEye.y = 0.0;
	NPCEye.z = 1.0;
	NPCEye.w = 0.0;
	miTransformPoint(&NPCEye, pddc->Static.misc.inv_view_xform,
			 &pddc->Static.misc.eye_pt);

	/* normalize the result if a eye pint is a vector in WC */
	if (NEAR_ZERO(pddc->Static.misc.eye_pt.w)) {
	  NORMALIZE_VECTOR (&(pddc->Static.misc.eye_pt), mag);
	}
}


/*++
 |
 |  Compute_CC_Dcue(pRend, pddc)
 |
 |      Compute a CC version of the current depth cue bundle entry
 |
 --*/
ddpex3rtn Compute_CC_Dcue(pRend, pddc)
        ddRendererPtr   pRend;          /* renderer handle */
        miDDContext     *pddc;
{
	ddpex3rtn	miConvertColor();

        ddUSHORT        status;
        miDepthCueEntry	*dcue_entry;
	ddFLOAT		*matrix, cc_frontplane, cc_backplane; 

	/* Check valid flag */
	if (!(pddc->Static.misc.flags & CC_DCUEVERSION)) return(Success);

        /* Get current depth cueing information */
        if ((InquireLUTEntryAddress (PEXDepthCueLUT, pRend->lut[PEXDepthCueLUT],
             pddc->Dynamic->pPCAttr->depthCueIndex,
             &status, (ddPointer *)&dcue_entry)) == PEXLookupTableError)
          return (PEXLookupTableError);

	/* Compute cc versions of front and back planes
	   We assume that the transformation matrix from npc to cc is
	   diagonal, and only tranform the "z" portion */

	matrix = (ddFLOAT *)(pddc->Dynamic->npc_to_cc_xform);

	/* skip to Z translate and scale terms */
	matrix += 10;

	cc_frontplane = (*matrix * dcue_entry->entry.frontPlane) + *(matrix + 1); 
	cc_backplane = (*matrix * dcue_entry->entry.backPlane) + *(matrix + 1); 
 
	/* copy over relevant info */
	pddc->Static.misc.cc_dcue_entry.mode = dcue_entry->entry.mode;
	pddc->Static.misc.cc_dcue_entry.frontScaling = 
		dcue_entry->entry.frontScaling;
	pddc->Static.misc.cc_dcue_entry.backScaling = 
		dcue_entry->entry.backScaling;

        pddc->Static.misc.cc_dcue_entry.frontPlane = cc_frontplane;
        pddc->Static.misc.cc_dcue_entry.backPlane = cc_backplane;

	/* Convert depth cue color to proper rendering model during copy */
	miConvertColor(pRend,
		       &dcue_entry->entry.depthCueColour,
		       pddc->Dynamic->pPCAttr->rdrColourModel,
		       &pddc->Static.misc.cc_dcue_entry.depthCueColour);

	/* validate flag */
	pddc->Static.misc.flags &= ~CC_DCUEVERSION;
 
}