001: /*
002: * $RCSfile: LightSet.java,v $
003: *
004: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.5 $
028: * $Date: 2008/02/28 20:17:25 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import javax.vecmath.*;
035: import java.util.Vector;
036:
037: class LightSet extends Object {
038: /**
039: * The Lights that make up this set
040: */
041: LightRetained[] lights = null;
042:
043: // The number of lights in this lightset, may be less than lights.length
044: int nlights = 0;
045:
046: // A reference to the next LightSet
047: LightSet next = null;
048:
049: // A reference to the previous LightSet
050: LightSet prev = null;
051:
052: // A flag that indicates that lighting is on
053: boolean lightingOn = true;
054:
055: // A flag that indicates that this light set has changed.
056: boolean isDirty = true;
057:
058: /**
059: * Constructs a new LightSet
060: */
061: LightSet(RenderBin rb, RenderAtom ra, LightRetained[] lights,
062: int nlights, boolean lightOn) {
063: this .reset(rb, ra, lights, nlights, lightOn);
064: }
065:
066: void reset(RenderBin rb, RenderAtom ra, LightRetained[] lights,
067: int nlights, boolean lightOn) {
068: int i;
069:
070: this .isDirty = true;
071: this .lightingOn = lightOn;
072: if (this .lights == null || this .lights.length < nlights) {
073: this .lights = new LightRetained[nlights];
074: }
075:
076: for (i = 0; i < nlights; i++) {
077: this .lights[i] = lights[i];
078: }
079:
080: this .nlights = nlights;
081:
082: //lists = new RenderList(ro);
083: //lists.prims[ro.geometry.geoType-1] = ro;
084: }
085:
086: boolean equals(RenderBin rb, LightRetained[] lights, int nlights,
087: boolean lightOn) {
088: int i, j;
089: LightRetained light;
090:
091: if (this .nlights != nlights)
092: return (false);
093:
094: if (this .lightingOn != lightOn)
095: return (false);
096:
097: for (i = 0; i < nlights; i++) {
098: for (j = 0; j < this .nlights; j++) {
099: if (this .lights[j] == lights[i]) {
100: break;
101: }
102: }
103: if (j == this .nlights) {
104: return (false);
105: }
106: }
107: return (true);
108: }
109:
110: }
|