001: /*
002: * $RCSfile: Text3DRenderMethod.java,v $
003: *
004: * Copyright 1999-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.7 $
028: * $Date: 2008/02/28 20:17:31 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * The RenderMethod interface is used to create various ways to render
036: * different geometries.
037: */
038:
039: class Text3DRenderMethod implements RenderMethod {
040:
041: /**
042: * The actual rendering code for this RenderMethod
043: */
044: public boolean render(RenderMolecule rm, Canvas3D cv,
045: RenderAtomListInfo ra, int dirtyBits) {
046:
047: boolean isNonUniformScale;
048: Transform3D trans = null;
049:
050: GeometryArrayRetained geo = (GeometryArrayRetained) ra
051: .geometry();
052: geo
053: .setVertexFormat(
054: (rm.useAlpha && ((geo.vertexFormat & GeometryArray.COLOR) != 0)),
055: rm.textureBin.attributeBin.ignoreVertexColors,
056: cv.ctx);
057:
058: if (rm.doInfinite) {
059: cv.updateState(dirtyBits);
060: while (ra != null) {
061: trans = ra.infLocalToVworld;
062: isNonUniformScale = !trans.isCongruent();
063: cv.setModelViewMatrix(cv.ctx, cv.vworldToEc.mat, trans);
064:
065: ra.geometry().execute(cv, ra.renderAtom,
066: isNonUniformScale,
067: (rm.useAlpha && ra.geometry().noAlpha),
068: rm.alpha, cv.screen.screen,
069: rm.textureBin.attributeBin.ignoreVertexColors);
070: ra = ra.next;
071: }
072: return true;
073: }
074:
075: boolean isVisible = false; // True if any of the RAs is visible.
076: while (ra != null) {
077: if (cv.ra == ra.renderAtom) {
078: if (cv.raIsVisible) {
079: cv.updateState(dirtyBits);
080: trans = ra.localToVworld;
081: isNonUniformScale = !trans.isCongruent();
082:
083: cv.setModelViewMatrix(cv.ctx, cv.vworldToEc.mat,
084: trans);
085: ra
086: .geometry()
087: .execute(
088: cv,
089: ra.renderAtom,
090: isNonUniformScale,
091: (rm.useAlpha && ra.geometry().noAlpha),
092: rm.alpha,
093: cv.screen.screen,
094: rm.textureBin.attributeBin.ignoreVertexColors);
095: isVisible = true;
096: }
097: } else {
098: if (!VirtualUniverse.mc.viewFrustumCulling
099: || ra.renderAtom.localeVwcBounds
100: .intersect(cv.viewFrustum)) {
101: cv.updateState(dirtyBits);
102: cv.raIsVisible = true;
103: trans = ra.localToVworld;
104: isNonUniformScale = !trans.isCongruent();
105:
106: cv.setModelViewMatrix(cv.ctx, cv.vworldToEc.mat,
107: trans);
108: ra
109: .geometry()
110: .execute(
111: cv,
112: ra.renderAtom,
113: isNonUniformScale,
114: (rm.useAlpha && ra.geometry().noAlpha),
115: rm.alpha,
116: cv.screen.screen,
117: rm.textureBin.attributeBin.ignoreVertexColors);
118: isVisible = true;
119: } else {
120: cv.raIsVisible = false;
121: }
122: cv.ra = ra.renderAtom;
123: }
124:
125: ra = ra.next;
126:
127: }
128:
129: geo
130: .disableGlobalAlpha(
131: cv.ctx,
132: (rm.useAlpha && ((geo.vertexFormat & GeometryArray.COLOR) != 0)),
133: rm.textureBin.attributeBin.ignoreVertexColors);
134:
135: return isVisible;
136: }
137: }
|