📄 rendermolecule.java
字号:
/* * $RCSfile: RenderMolecule.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.8 $ * $Date: 2007/04/12 17:34:06 $ * $State: Exp $ */package javax.media.j3d;import javax.vecmath.*;import java.util.*;/** * The RenderMolecule manages a collection of RenderAtoms. */class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponentUpdate { // different types of IndexedUnorderedSet that store RenderMolecule static final int REMOVE_RENDER_ATOM_IN_RM_LIST = 0; static final int RENDER_MOLECULE_LIST = 1; // total number of different IndexedUnorderedSet types static final int TOTAL_INDEXED_UNORDER_SET_TYPES = 2; /** * Values for the geometryType field */ static final int POINT = 0x01; static final int LINE = 0x02; static final int SURFACE = 0x04; static final int RASTER = 0x08; static final int COMPRESSED = 0x10; static int RM_COMPONENTS = (AppearanceRetained.POLYGON | AppearanceRetained.LINE | AppearanceRetained.POINT | AppearanceRetained.MATERIAL | AppearanceRetained.TRANSPARENCY| AppearanceRetained.COLOR); // XXXX: use definingMaterial etc. instead of these // when sole user is completely implement PolygonAttributesRetained polygonAttributes = null; LineAttributesRetained lineAttributes = null; PointAttributesRetained pointAttributes = null; MaterialRetained material = null; ColoringAttributesRetained coloringAttributes = null; TransparencyAttributesRetained transparency = null; // Use Object instead of AppearanceRetained class for // state caching optimation memory performance boolean normalPresent = true; // Equivalent bits static final int POINTATTRS_DIRTY = AppearanceRetained.POINT; static final int LINEATTRS_DIRTY = AppearanceRetained.LINE; static final int POLYGONATTRS_DIRTY = AppearanceRetained.POLYGON; static final int MATERIAL_DIRTY = AppearanceRetained.MATERIAL; static final int TRANSPARENCY_DIRTY = AppearanceRetained.TRANSPARENCY; static final int COLORINGATTRS_DIRTY = AppearanceRetained.COLOR; static final int ALL_DIRTY_BITS = POINTATTRS_DIRTY | LINEATTRS_DIRTY | POLYGONATTRS_DIRTY | MATERIAL_DIRTY | TRANSPARENCY_DIRTY | COLORINGATTRS_DIRTY; /** * bit mask of all attr fields that are equivalent across * renderMolecules */ int dirtyAttrsAcrossRms = ALL_DIRTY_BITS; // Mask set to true is any of the component have changed int soleUserCompDirty = 0; /** * The PolygonAttributes for this RenderMolecule */ PolygonAttributesRetained definingPolygonAttributes = null; /** * The LineAttributes for this RenderMolecule */ LineAttributesRetained definingLineAttributes = null; /** * The PointAttributes for this RenderMolecule */ PointAttributesRetained definingPointAttributes = null; /** * The TextureBin that this RenderMolecule resides */ TextureBin textureBin = null; /** * The localToVworld for this RenderMolecule */ Transform3D[] localToVworld = null; int[] localToVworldIndex = null; /** * The Material reference for this RenderMolecule */ MaterialRetained definingMaterial = null; /** * The ColoringAttribute reference for this RenderMolecule */ ColoringAttributesRetained definingColoringAttributes = null; /** * The Transparency reference for this RenderMolecule */ TransparencyAttributesRetained definingTransparency = null; /** * Transform3D - point to the right one based on bg or not */ Transform3D[] trans = null; /** * specify whether scale is nonuniform */ boolean isNonUniformScale = false; /** * number of renderAtoms to be rendered in this RenderMolecule */ int numRenderAtoms = 0; /** * number of render atoms, used during the renderBin update time */ int numEditingRenderAtoms = 0; RenderAtom addRAs = null; RenderAtom removeRAs = null; /** * The cached ColoringAttributes color value. It is * 1.0, 1.0, 1.0 if there is no ColoringAttributes. */ float red = 1.0f; float green = 1.0f; float blue = 1.0f; /** * Cached diffuse color value */ float dRed = 1.0f; float dGreen = 1.0f; float dBlue = 1.0f; /** * The cached TransparencyAttributes transparency value. It is * 0.0 if there is no TransparencyAttributes. */ float alpha = 0.0f; /** * The geometry type for this RenderMolecule */ int geometryType = -1; /** * A boolean indicating whether or not lighting should be on. */ boolean enableLighting = false; /** * A boolean indicating whether or not this molecule rendered Text3D */ int primaryMoleculeType = 0; static int COMPRESSED_MOLECULE = 0x1; static int TEXT3D_MOLECULE = 0x2; static int DLIST_MOLECULE = 0x4; static int RASTER_MOLECULE = 0x8; static int ORIENTEDSHAPE3D_MOLECULE = 0x10; static int SEPARATE_DLIST_PER_RINFO_MOLECULE = 0x20; /** * Cached values for polygonMode, line antialiasing, and point antialiasing */ int polygonMode = PolygonAttributes.POLYGON_FILL; boolean lineAA = false; boolean pointAA = false; /** * The vertex format for this RenderMolecule. Only looked * at for GeometryArray and CompressedGeometry objects. */ int vertexFormat = -1; /** * The texCoordSetMap length for this RenderMolecule. */ int texCoordSetMapLen = 0; /** * The primary renderMethod object for this RenderMolecule * this is either a Text3D, display list, or compressed geometry renderer. */ RenderMethod primaryRenderMethod = null; /** * The secondary renderMethod object for this RenderMolecule * this is used for geometry that is shared */ RenderMethod secondaryRenderMethod = null; /** * The RenderBino for this molecule */ RenderBin renderBin = null; /** * The references to the next and previous RenderMolecule in the * list. */ RenderMolecule next = null; RenderMolecule prev = null; /** * The list of RenderAtoms in this RenderMolecule that are not using * vertex arrays. */ RenderAtomListInfo primaryRenderAtomList = null; /** * The list of RenderAtoms in this RenderMolecule that are using * separte dlist . */ RenderAtomListInfo separateDlistRenderAtomList = null; /** * The list of RenderAtoms in this RenderMolecule that are using vertex * arrays. */ RenderAtomListInfo vertexArrayRenderAtomList = null; /** * This BoundingBox is used for View Frustum culling on the primary * list */ BoundingBox vwcBounds = null; /** * If this is end of the linked list for this xform, then * this field is non-null, if there is a map after this */ RenderMolecule nextMap = null; RenderMolecule prevMap = null; /** * If the any of the node component of the appearance in RM will be changed * frequently, then confine it to a separate bin */ boolean soleUser = false; Object appHandle = null; VertexArrayRenderMethod cachedVertexArrayRenderMethod = (VertexArrayRenderMethod) VirtualUniverse.mc.getVertexArrayRenderMethod(); // In D3D separate Quad/Triangle Geometry with others in RenderMolecule // Since we need to dynamically switch whether to use DisplayList // or not in render() as a group. boolean isQuadGeometryArray = false; boolean isTriGeometryArray = false; // display list id, valid id starts from 1 int displayListId = 0; Integer displayListIdObj = null; int onUpdateList = 0; static int NEW_RENDERATOMS_UPDATE = 0x1; static int BOUNDS_RECOMPUTE_UPDATE = 0x2; static int LOCALE_TRANSLATION = 0x4; static int UPDATE_BACKGROUND_TRANSFORM = 0x8; static int IN_DIRTY_RENDERMOLECULE_LIST = 0x10; static int LOCALE_CHANGED = 0x20; static int ON_UPDATE_CHECK_LIST = 0x40; // background geometry rendering boolean doInfinite; Transform3D[] infLocalToVworld; // Whether alpha is used in this renderMolecule boolean useAlpha = false; // Support for multiple locales Locale locale = null; // Transform when locale is different from the view's locale Transform3D[] localeLocalToVworld = null; // Vector used for locale translation Vector3d localeTranslation = null; boolean primaryChanged = false; boolean isOpaqueOrInOG = true; boolean inOrderedGroup = false; // closest switch parent SwitchRetained closestSwitchParent = null; // the child index from the closest switch parent int closestSwitchIndex = -1; RenderMolecule(GeometryAtom ga, PolygonAttributesRetained polygonAttributes, LineAttributesRetained lineAttributes, PointAttributesRetained pointAttributes, MaterialRetained material, ColoringAttributesRetained coloringAttributes, TransparencyAttributesRetained transparency, RenderingAttributesRetained renderAttrs, TextureUnitStateRetained[] texUnits, Transform3D[] transform, int[] transformIndex, RenderBin rb) { renderBin = rb; IndexedUnorderSet.init(this, TOTAL_INDEXED_UNORDER_SET_TYPES); reset(ga, polygonAttributes, lineAttributes, pointAttributes, material, coloringAttributes, transparency, renderAttrs, texUnits, transform, transformIndex); } void reset(GeometryAtom ga, PolygonAttributesRetained polygonAttributes, LineAttributesRetained lineAttributes, PointAttributesRetained pointAttributes, MaterialRetained material, ColoringAttributesRetained coloringAttributes, TransparencyAttributesRetained transparency, RenderingAttributesRetained renderAttrs, TextureUnitStateRetained[] texUnits, Transform3D[] transform, int[] transformIndex) { primaryMoleculeType = 0; numRenderAtoms = 0; numEditingRenderAtoms = 0; onUpdateList = 0; dirtyAttrsAcrossRms = ALL_DIRTY_BITS; primaryRenderMethod = null; isNonUniformScale = false; primaryChanged = false; this.material = material; this.polygonAttributes = polygonAttributes; this.lineAttributes = lineAttributes; this.pointAttributes = pointAttributes; this.coloringAttributes = coloringAttributes; this.transparency = transparency; closestSwitchParent = ga.source.closestSwitchParent; closestSwitchIndex = ga.source.closestSwitchIndex; int i1; // Find the first non-null geometey GeometryRetained geo = null; int k = 0; isOpaqueOrInOG = true; inOrderedGroup = false; while (geo == null && (k < ga.geometryArray.length)) { geo = ga.geometryArray[k]; k++; } // Issue 249 - check for sole user only if property is set soleUser = false; if (VirtualUniverse.mc.allowSoleUser) { if (ga.source.appearance != null) { soleUser = ((ga.source.appearance.changedFrequent & RM_COMPONENTS) != 0); } } // Set the appearance only for soleUser case if (soleUser) appHandle = ga.source.appearance; else appHandle = (Object)this; // If its of type GeometryArrayRetained if (ga.geoType <= GeometryRetained.GEO_TYPE_GEOMETRYARRAY || ga.geoType == GeometryRetained.GEO_TYPE_TEXT3D) { if (ga.source instanceof OrientedShape3DRetained) { primaryRenderMethod = VirtualUniverse.mc.getOrientedShape3DRenderMethod(); primaryMoleculeType = ORIENTEDSHAPE3D_MOLECULE; } else if (ga.geoType == GeometryRetained.GEO_TYPE_TEXT3D) { primaryRenderMethod = VirtualUniverse.mc.getText3DRenderMethod(); primaryMoleculeType = TEXT3D_MOLECULE; } else { // Make determination of dlist or not during addRenderAtom secondaryRenderMethod = cachedVertexArrayRenderMethod; } } else { if (ga.geoType == GeometryRetained.GEO_TYPE_COMPRESSED) { primaryRenderMethod = VirtualUniverse.mc.getCompressedGeometryRenderMethod(); primaryMoleculeType = COMPRESSED_MOLECULE; } else if (geo instanceof RasterRetained) { primaryRenderMethod =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -