diff options
author | Harvey Harrison <[email protected]> | 2013-09-14 23:41:45 -0700 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2013-09-14 23:41:45 -0700 |
commit | 6960b90c744143152f2a92de4b847add53112f21 (patch) | |
tree | 0eb07244b89291675b89a692851e1e4b6fed4a01 /src | |
parent | 2ec7a993f7b9220f8eac22922976f07f8b80aec9 (diff) |
j3dcore: move map of View to TransparentGeometry sorters into core
Help break one more dependency on the j3dutils code by pulling a simple map
into the core classes.
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src')
5 files changed, 100 insertions, 4 deletions
diff --git a/src/classes/share/javax/media/j3d/AutoOffScreenCanvas3D.java b/src/classes/share/javax/media/j3d/AutoOffScreenCanvas3D.java index 4bcfa45..0fc0a60 100644 --- a/src/classes/share/javax/media/j3d/AutoOffScreenCanvas3D.java +++ b/src/classes/share/javax/media/j3d/AutoOffScreenCanvas3D.java @@ -1,6 +1,5 @@ /* * Copyright 2013 Harvey Harrison - * 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 diff --git a/src/classes/share/javax/media/j3d/RenderBin.java b/src/classes/share/javax/media/j3d/RenderBin.java index f0a7b75..fe7cf2f 100644 --- a/src/classes/share/javax/media/j3d/RenderBin.java +++ b/src/classes/share/javax/media/j3d/RenderBin.java @@ -182,7 +182,7 @@ ArrayList<RenderAtom> positionDirtyList = new ArrayList<RenderAtom>(5); */ View view = null; - private Comparator transparencySortComparator = null; + private Comparator<TransparencySortGeom> transparencySortComparator = null; private ArrayList<TextureRetained> toBeAddedTextureResourceFreeList = new ArrayList<TextureRetained>(5); private ArrayList<Integer> displayListResourceFreeList = new ArrayList<Integer>(5); @@ -6449,7 +6449,7 @@ void addGeometryDlist(RenderAtomListInfo ra) { TransparentRenderingInfo depthSortAll(TransparentRenderingInfo startinfo) { - transparencySortComparator = com.sun.j3d.utils.scenegraph.transparency.TransparencySortController.getComparator(view); + transparencySortComparator = TransparencySortMap.getComparator(view); TransparentRenderingInfo tinfo, previnfo, nextinfo; double curZ; // System.err.println("&&&&&&&&&&&depthSortAll"); diff --git a/src/classes/share/javax/media/j3d/TransparencySortGeom.java b/src/classes/share/javax/media/j3d/TransparencySortGeom.java new file mode 100644 index 0000000..f07a947 --- /dev/null +++ b/src/classes/share/javax/media/j3d/TransparencySortGeom.java @@ -0,0 +1,49 @@ +/* + * Copyright 2013 Harvey Harrison + * + * 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). + */ +package javax.media.j3d; + +/** + * An interface that allows sorting the rendering order of transparent geometry. + * + * @since Java 3D 1.6 + */ +public interface TransparencySortGeom { + +/** + * Returns the Geometry for this object. + * @return geometry for this object + */ +public Geometry getGeometry(); + +/** + * Returns the distance squared of this object to the viewer. + * @return distancesquared to viewer + */ +public double getDistanceSquared(); + +/** + * Returns the LocalToVWorld transform for this object + * @param localToVW variable in which transform will be returned + */ +public void getLocalToVWorld(Transform3D localToVW); + +/** + * Returns the Shape3D being rendered using this geometry. + * @return the Shape3D being rendered using this geometry + */ +public Shape3D getShape3D(); + +} diff --git a/src/classes/share/javax/media/j3d/TransparencySortMap.java b/src/classes/share/javax/media/j3d/TransparencySortMap.java new file mode 100644 index 0000000..7f13d0a --- /dev/null +++ b/src/classes/share/javax/media/j3d/TransparencySortMap.java @@ -0,0 +1,48 @@ +/* + * Copyright 2013 Harvey Harrison + * + * 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). + */ +package javax.media.j3d; + +import java.util.Comparator; +import java.util.WeakHashMap; + +/** + * A class mapping Views to a TransparencySortGeom object. + */ +public class TransparencySortMap { + +private static final WeakHashMap<View, Comparator<TransparencySortGeom>> comparators = new WeakHashMap<View, Comparator<TransparencySortGeom>>(); + +// prevent an instance from being created. +private TransparencySortMap() {} + +/** + * Set the comparator for the specified view. + * @param view the view to which the comparator applies + * @param comparator the comparator to call + */ +public static void setComparator(View view, Comparator<TransparencySortGeom> comparator) { + comparators.put(view, comparator); +} + +/** + * Returns the comparator for the specified view + * @return the comparator for the specified view, or null if there is no + * comparator for the view or the view is unknown. + */ +public static Comparator<TransparencySortGeom> getComparator(View view) { + return comparators.get(view); +} +} diff --git a/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java b/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java index 0bddbb7..3901bc9 100644 --- a/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java +++ b/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java @@ -27,7 +27,7 @@ package javax.media.j3d; -class TransparentRenderingInfo extends Object implements com.sun.j3d.utils.scenegraph.transparency.TransparencySortGeom { +class TransparentRenderingInfo extends Object implements TransparencySortGeom { // For DepthSortedTransparency, rm is the rendermolecule // that this rInfo is part of // For non depth sorted transparency, rm is one of the rendermolecules |