⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewingplatform.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: ViewingPlatform.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistribution of source code must retain the above copyright *   notice, this list of conditions and the following disclaimer. * * - Redistribution in binary form must reproduce the above copyright *   notice, this list of conditions and the following disclaimer in *   the documentation and/or other materials provided with the *   distribution. * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * This software is provided "AS IS," without a warranty of any * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed, licensed or * intended for use in the design, construction, operation or * maintenance of any nuclear facility. * * $Revision: 1.4 $ * $Date: 2007/02/09 17:20:45 $ * $State: Exp $ */package com.sun.j3d.utils.universe;import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector;import java.awt.Component;import javax.media.j3d.*;import javax.vecmath.*;import com.sun.j3d.utils.behaviors.vp.*;import com.sun.j3d.internal.J3dUtilsI18N;/** * This class is used to set up the "view" side of a Java 3D scene graph. * The ViewingPlatform object contains a MultiTransformGroup node to allow * for a series of transforms to be linked together.  To this structure * the ViewPlatform is added as well as any geometry to associate with this * view platform. * * @see ViewPlatform */public class ViewingPlatform extends BranchGroup {    /**     * Cached ViewPlatform associated with this ViewingPlatform object.     */    protected ViewPlatform        viewPlatform;    /**     * MultiTransformGroup that holds all TransformGroups between     * the BranchGroup and the View object.     */    protected MultiTransformGroup mtg;    /**     * Used to keep track of added geometry.  When geometry     * is added to the view platform, an addChild to this BranchGroup     * is performed.     */    protected BranchGroup         platformGeometryRoot;    /**     * Used to keep track of added geometry.  When geometry     * is added for an avatar, an addChild to this BranchGroup     * is performed.     */    protected BranchGroup         avatarRoot;    /**     * Cached PlatformGeometry object.     */    protected PlatformGeometry    platformGeometry = null;    /**     * Table of the Viewer objects.     */    protected Hashtable		viewerList;    /**     * Used to keep track of behaviors.     *     * @since Java 3D 1.2.1     */    protected BranchGroup behaviors;    /**      * The universe to which this viewing platform is attached     *     * @since Java 3D 1.3     */    protected SimpleUniverse universe;        /**     * Creates a default ViewingPlatform object.  This consists of a     * MultiTransfromGroup node with one transform and a ViewPlatform     * object. The ViewPlatform is positioned at (0.0, 0.0, 0.0).     */    public ViewingPlatform() {        // Call main constructor with default values.        this(1);    }    /**     * Creates the ViewingPlatform object.  This consists of a     * MultiTransfromGroup node with the specified number of transforms     * (all initialized to the identity transform).     * and a ViewPlatform object.     *     * @param numTransforms The number of transforms the MultiTransformGroup     *  node should contain.  If this number is less than 1, 1 is assumed.     */    public ViewingPlatform(int numTransforms) {        viewerList = new Hashtable();        // Set default capabilities for this node.        setCapability(Group.ALLOW_CHILDREN_WRITE);        setCapability(Group.ALLOW_CHILDREN_EXTEND);        setCapability(BranchGroup.ALLOW_DETACH);        // Create MultiTransformGroup node.        if (numTransforms < 1)            numTransforms = 1;        mtg = new MultiTransformGroup(numTransforms);        // Get first transform and add it to the scene graph.        TransformGroup tg = mtg.getTransformGroup(0);        addChild(tg);        // Create ViewPlatform and add it to the last transform in the        // MultiTransformGroup node.        tg = mtg.getTransformGroup(numTransforms - 1);        viewPlatform = new ViewPlatform();        viewPlatform.setCapability(ViewPlatform.ALLOW_POLICY_READ);        viewPlatform.setCapability(ViewPlatform.ALLOW_POLICY_WRITE);        tg.addChild(viewPlatform);        // Set capabilities to allow for changes when live.        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);        // Initialize the avatarRoot BranchGroup node and add it to the        // last transform in the MultiTransformGroup node.        avatarRoot = new BranchGroup();        avatarRoot.setCapability(Group.ALLOW_CHILDREN_READ);        avatarRoot.setCapability(Group.ALLOW_CHILDREN_WRITE);        avatarRoot.setCapability(Group.ALLOW_CHILDREN_EXTEND);        tg.addChild(avatarRoot);        // Initialize the platformGeometry BranchGroup node and add it to the        // last transform in the MultiTransformGroup node.        platformGeometryRoot = new BranchGroup();        platformGeometryRoot.setCapability(Group.ALLOW_CHILDREN_READ);        platformGeometryRoot.setCapability(Group.ALLOW_CHILDREN_WRITE);        platformGeometryRoot.setCapability(Group.ALLOW_CHILDREN_EXTEND);        tg.addChild(platformGeometryRoot);    }    /**     * Sets the ViewPlatform node for this ViewingPlatform object.     *     * @param vp The ViewPlatform node to associate with this ViewingPlatform     *  object.     */    public void setViewPlatform(ViewPlatform vp) {	TransformGroup tg = getViewPlatformTransform();	tg.removeChild(viewPlatform);	tg.addChild(vp);        viewPlatform = vp;        // Assign this to all Viewers.        Enumeration e = viewerList.keys();        while (e.hasMoreElements())            ((Viewer)e.nextElement()).setViewingPlatform(this);    }    /**     * Returns the ViewPlatform node for this ViewingPlatform object.     *     * @return The ViewPlatform node associated with this ViewingPlatform     *  object.     */    public ViewPlatform getViewPlatform() {        return viewPlatform;    }    /**     * Assigns the geometry to associate with the ViewingPlatform.     * PlatformGeometry is used to hold any geometry to be associated     * with the ViewingPlatform.  If the ViewingPlatform is to be the     * inside of a car, for instance, than the PlatformGeometry could be     * the dashboard of the car.     *      * @param pg The geometry to be associated with this ViewingPlatform.     *  Passing in null has the effect of deleting any geometry associated     *  with this ViewingPlatform.     */    public void setPlatformGeometry(PlatformGeometry pg) {        // Just return if trying to set the same PlatformGeometry object.        if (platformGeometry == pg)            return;        // If the PlatformGeometry is null, will be removing any geometry        // already present.        if (pg == null) {            if (platformGeometryRoot.numChildren() != 0)                platformGeometryRoot.removeChild(0);        }        else {            // See if there is an old PlatformGeometry to replace.            if (platformGeometryRoot.numChildren() != 0)                platformGeometryRoot.setChild(pg, 0);            else {                platformGeometryRoot.addChild(pg);            }        }        platformGeometry = pg;    }    /**      * Returns the PlatformGeometry associated with this ViewingPlatform      *      * @return The PlatformGeometry associated with this ViewingPlatform      */    public PlatformGeometry getPlatformGeometry() {	return platformGeometry;    }    /**     * Returns the MultitransformGroup object for this     * ViewingPlatform object.     *     * @return The MultitransformGroup object.     */    public MultiTransformGroup getMultiTransformGroup() {        return mtg;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -