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

📄 defaultdominanthand.java

📁 Java 3D Desktop Environment旨在使用Java 3D来创建一个3D桌面环境。功能包括:分布式的应用程序
💻 JAVA
字号:
package org.j3de.ui.impl;

import java.util.List;

import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;

import javax.media.j3d.Appearance;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.BoundingSphere;   
import javax.media.j3d.Geometry; 
import javax.media.j3d.PointLight;
import javax.media.j3d.Shape3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.Transform3D;

import javax.vecmath.Color3f;
import javax.vecmath.Point3d; 
import javax.vecmath.Point3f; 
import javax.vecmath.Vector3f;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import org.j3de.exception.ExceptionHandler;    
import org.j3de.ui.Skin;
import org.j3de.ui.Skinable;
import org.j3de.ui.SkinException;
import org.j3de.ui.UIElement;
import org.j3de.ui.UILocalElement;  
import org.j3de.ui.UIDominantHand;
import org.j3de.ui.skin.SkinAppearanceDominantHand;
import org.j3de.ui.skin.SkinBoundsDominantHand; 
import org.j3de.ui.skin.SkinGeometryDominantHand;  
import org.j3de.util.ConfigHelper;      
import org.j3de.util.EntryFactory;      
import org.j3de.util.StringParser;

public class DefaultDominantHand implements UILocalElement, Skinable {
  private PointLight     light;  
  private Shape3D        sh;
  private TransformGroup tg;  
  private Transform3D    t3d;
  
  private UIDominantHand uiRemoteElement;  
  
  public DefaultDominantHand() {   
    light = new PointLight();  
    light.setInfluencingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0), 100)); 
    
    sh = new Shape3D();
    
    tg = new TransformGroup();
    tg.addChild(sh);
    tg.addChild(light);                  
    tg.setCapability(TransformGroup.ALLOW_BOUNDS_READ);
 
    // the Hand should not be pickable, else it could pick itself, which would not be particulary
    // usefull
    tg.setPickable(true);
    
    t3d = new Transform3D();   
        
    uiRemoteElement = new RemoteDominantHand();
  }
  
  public javax.media.j3d.Node getNode() { 
    return tg;
  }             
  
  public UIElement getRemoteElement() {
    return uiRemoteElement;
  }             
  
    
  public void setSkin(Skin skin) throws SkinException {       
    // set color of emitted light;
    light.setColor(skin.getColorByName("dominantHandColor"));
    
    // set appearance of the hand-shape
    sh.setAppearance(skin.getAppearance(SkinAppearanceDominantHand.class));     
    
    // get the size, the geometry should have
    javax.media.j3d.Bounds bounds = skin.getBounds(SkinBoundsDominantHand.class);     
    
    // set the geometry
    Geometry geometry = skin.getGeometry(SkinGeometryDominantHand.class).getGeometry(bounds); 
    sh.setGeometry(geometry);  
    
    // try to scale geometry to the right size
    try {
      t3d.setScale(BoundsScale.getScale(sh.getBounds(), bounds));
      tg.setTransform(t3d);
    } catch (UnknownBoundsException e) {
      ExceptionHandler.handleException(e);
    }  
    
    ConfigHelper helper = new ConfigHelper(skin.getXMLFragment("dominanthand_light"));   
    
    Vector3f attenuation = StringParser.parseVector3f(helper.getPropertyValue("attenuation"));
    
  }   
                 
  public void addBoundsChangeListener(ChangeListener listener) {
  }

  public void removeBoundsChangeListener(ChangeListener listener) {
  }
 
  /** Dummy implementation, EnvironmentLights should not be accessed from a remote location. */
  private class RemoteDominantHand implements UIDominantHand { 
      
  }
  
}

⌨️ 快捷键说明

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