/* * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. * */ package javax.media.j3d; import java.nio.FloatBuffer; import java.util.ArrayList; import javax.vecmath.TexCoord2f; import javax.vecmath.TexCoord3f; /** * The GeometryStripArray object is an abstract class that is extended for * a set of GeometryArray strip primitives. These include LINE_STRIP, * TRIANGLE_STRIP, and TRIANGLE_FAN. */ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { // Array of per-strip vertex counts int stripVertexCounts[]; // Array of per-strip starting index int stripStartVertexIndices[]; // start of vertices for both by-copy // and by-ref int stripStartOffsetIndices[]; // Used in byRef non_interleaved // Following variables are only used in the compile mode // isCompiled = true int[] compileNumStrips; int[] compileStripCountOffset; /** * Set stripVertexCount data into local array */ void setStripVertexCounts(int stripVertexCounts[]) { boolean nullGeo = false; int i, num = stripVertexCounts.length, total = 0; for (i=0; i < num; i++) { total += stripVertexCounts[i]; if (this instanceof LineStripArrayRetained) { if (stripVertexCounts[i] < 2) { throw new IllegalArgumentException(J3dI18N.getString("LineStripArrayRetained1")); } } else if (this instanceof TriangleStripArrayRetained) { if (stripVertexCounts[i] < 3) { throw new IllegalArgumentException(J3dI18N.getString("TriangleStripArrayRetained1")); } } else if (this instanceof TriangleFanArrayRetained) { if (stripVertexCounts[i] < 3) { throw new IllegalArgumentException(J3dI18N.getString("TriangleFanArrayRetained1")); } } } if ((initialVertexIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray3")); } if ((initialCoordIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray7")); } if ((initialColorIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray4")); } if ((initialNormalIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray5")); } if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { if ((vertexFormat & (GeometryArray.BY_REFERENCE|vertexFormat &GeometryArray.INTERLEAVED)) == GeometryArray.BY_REFERENCE) { for (i = 0; i < texCoordSetCount; i++) { if ((initialTexCoordIndex[i] + total) > vertexCount) { throw new IllegalArgumentException( J3dI18N.getString("GeometryStripArray6")); } } } } if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { if ((vertexFormat & (GeometryArray.BY_REFERENCE|vertexFormat &GeometryArray.INTERLEAVED)) == GeometryArray.BY_REFERENCE) { for (i = 0; i < vertexAttrCount; i++) { if ((initialVertexAttrIndex[i] + total) > vertexCount) { throw new IllegalArgumentException( J3dI18N.getString("GeometryStripArray8")); } } } } boolean isLive = source!=null && source.isLive(); if(isLive){ geomLock.getLock(); } dirtyFlag |= STRIPCOUNT_CHANGED; validVertexCount = total; this.stripVertexCounts = new int[num]; stripStartVertexIndices = new int[num]; stripStartOffsetIndices = new int[num]; stripStartOffsetIndices[0] = 0; if ((vertexFormat & (GeometryArray.BY_REFERENCE|vertexFormat &GeometryArray.INTERLEAVED)) == GeometryArray.BY_REFERENCE) { stripStartVertexIndices[0] = initialCoordIndex; nullGeo = ((vertexType & GeometryArrayRetained.VERTEX_DEFINED) == 0); } else { stripStartVertexIndices[0] = initialVertexIndex; if ((vertexFormat & GeometryArray.INTERLEAVED) != 0) { if (( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { nullGeo = (interLeavedVertexData == null); } else { nullGeo = (interleavedFloatBufferImpl == null); } } } for (i=0; i