Java 类javax.vecmath.Color3f 实例源码

项目:JavaExamples    文件:ColoredBoxExample.java   
@Override
void buildScene(TransformGroup transformGroup) {
    Background background = new Background(new Color3f(.905f, .905f, 0.95f));
    background.setApplicationBounds(BOUNDS);
    transformGroup.addChild(background);

    Appearance appearance = new Appearance();
    ColoringAttributes ca = new ColoringAttributes();
    ca.setColor(1.0f, 0.0f, 1.0f);
    ca.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
    appearance.setColoringAttributes(ca);
    transformGroup.addChild(new Box(0.6f, 0.5f, 0.4f, appearance));

    Transform3D transform3D = new Transform3D();
    transform3D.setTranslation(new Vector3f(0.3f, 0.3f, 0.3f));
    transform3D.setScale(0.75);
    Transform3D t = new Transform3D();
    t.rotY(Math.PI / 4.0d);
    transform3D.mul(t);
    transformGroup.setTransform(transform3D);
}
项目:JavaAyo    文件:J3dTest.java   
public J3dTest(){  
  // 创建一个虚拟空间  
    SimpleUniverse universe = new SimpleUniverse();  
    // 创建一个用来包含对象的数据结构  
    BranchGroup group = new BranchGroup();  

    // 创建一个球并把它加入到group中  
    Sphere sphere = new Sphere(0.5f); // 小球的半径为0.5米  
    group.addChild(sphere);  

    Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);  
    // 设置光线的颜色  
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);  
    // 设置光线的作用范围  
    Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);  
    // 设置光线的方向  
    DirectionalLight light1= new DirectionalLight(light1Color, light1Direction);  
    // 指定颜色和方向,产生单向光源  
    light1.setInfluencingBounds(bounds);  
    // 把光线的作用范围加入光源中  
    group.addChild(light1);  
    // 将光源加入group组,安放观察点  
    universe.getViewingPlatform().setNominalViewingTransform();  
    // 把group加入到虚拟空间中  
    universe.addBranchGraph(group);  
}
项目:wig    文件:WigMod.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
    KeyBinding selectOption = new KeyBinding("key.wigctrl.selectoption", Keyboard.KEY_LMENU, "key.wigctrl.category");
    ClientRegistry.registerKeyBinding(selectOption);

    ToolPage terraform = new ToolPage(Keyboard.KEY_V, "wigpage.terraform.name", new Color3f(0.2f, 1.0f, 0.2f));
    Pages.add(terraform);

    terraform.addTool(new Tool("test", new ResourceLocation("wig:test"), null, null));

    MinecraftForge.EVENT_BUS.register(new BarSelectInputHandler());
    MinecraftForge.EVENT_BUS.register(new PageRenderHandler());
    MinecraftForge.EVENT_BUS.register(new SingleBarInputHandler());
    MinecraftForge.EVENT_BUS.register(new ToolNameRenderHandler());
    MinecraftForge.EVENT_BUS.register(new SingleToolInputHandler());

    proxy.initTexAtlas();
}
项目:project-bianca    文件:Points3DPanel.java   
private void lightScene()
/* One ambient light, 2 directional lights */
{
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);

    // Set up the ambient light
    AmbientLight ambientLightNode = new AmbientLight(white);
    ambientLightNode.setInfluencingBounds(bounds);
    sceneBG.addChild(ambientLightNode);

    // Set up the directional lights
    Vector3f light1Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    // left, down, backwards
    Vector3f light2Direction = new Vector3f(1.0f, -1.0f, 1.0f);
    // right, down, forwards

    DirectionalLight light1 = new DirectionalLight(white, light1Direction);
    light1.setInfluencingBounds(bounds);
    sceneBG.addChild(light1);

    DirectionalLight light2 = new DirectionalLight(white, light2Direction);
    light2.setInfluencingBounds(bounds);
    sceneBG.addChild(light2);
}
项目:project-bianca    文件:BlockWorldObject.java   
/** Set the object color */
@Override
public void setColor(Color3f color) {
    Material mat = appearance.getMaterial();
    Color3f ambient = new Color3f(color);
    ambient.scale(0.3f);
    mat.setAmbientColor(ambient);
    color.clampMax(0.8f);
    mat.setDiffuseColor(color);
    // No specular color
    Color3f specular = new Color3f(0, 0, 0);
    mat.setSpecularColor(specular);

    mat.setShininess(1f);

}
项目:project-bianca    文件:LampActuator.java   
void create3D(float size) {
    super.create3D(true);
    // lamp body
    onColor = new Color3f(0.1f, 1f, 1f);
    offColor = new Color3f(0.3f, 0.3f, 0.3f);
    blinkColor = new Color3f(1f, 0.3f, 0.3f);
    Appearance appear = new Appearance();
    material = new Material();
    material.setAmbientColor(offColor);
    material.setDiffuseColor(offColor);
    material.setCapability(Material.ALLOW_COMPONENT_WRITE);
    material.setSpecularColor(offColor);
    material.setColorTarget(Material.DIFFUSE);
    appear.setMaterial(material);
    Node node = new com.sun.j3d.utils.geometry.Cylinder(size, size, appear);
    node.setCollidable(false);
    node.setPickable(false);
    addChild(node);
}
项目:project-bianca    文件:Box.java   
/** Create the 3d object */
protected void create3D(EnvironmentDescription wd, Color3f color) {
    // create the box using a primitive
    super.create3D();
    Material mat = new Material();
    appearance.setMaterial(mat);

    int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
    flags |= Primitive.ENABLE_APPEARANCE_MODIFY;
    // com.sun.j3d.utils.geometry.Box box =new
    // com.sun.j3d.utils.geometry.Box(sx,sy,sz,flags,appearance,0);
    // bug in j3d api doc . must give half values.
    com.sun.j3d.utils.geometry.Box box = new com.sun.j3d.utils.geometry.Box(sx / 2, sy / 2, sz / 2, flags, appearance, 0);
    // Enable sensor detection
    box.setPickable(true);

    // define the boundsfFor collision detection
    BoundingBox bounds = new BoundingBox();
    bounds.setUpper(sx / 2, sy / 2, sz / 2);
    bounds.setLower(-sx / 2, -sy / 2, -sz / 2);
    setBounds(bounds);

    setColor(color);
    addChild(box);

}
项目:project-bianca    文件:BumpersDemo.java   
public BumpersDemo() {
    setWorldSize(12);

    boxColor = new Color3f(0.6f, 0.5f, .3f);

    add(new Box(new Vector3d(-5, 0, 0), new Vector3f(0.1f, 1, 10), this));
    add(new Box(new Vector3d(0, 0, -5), new Vector3f(10, 1, 0.1f), this));
    add(new Box(new Vector3d(5, 0, 0), new Vector3f(0.1f, 1, 10), this));
    add(new Box(new Vector3d(0, 0, 5), new Vector3f(10, 1, 0.1f), this));
    add(new Box(new Vector3d(2, 0, 2), new Vector3f(2, 1, 3), this));
    add(new Box(new Vector3d(-2, 0, -2), new Vector3f(3, 1, 2), this));

    add(new Robot(new Vector3d(4, 0, 4), "bump1"));
    add(new Robot(new Vector3d(4, 0, -4), "bump2"));
    add(new Robot(new Vector3d(-4, 0, 4), "bump3"));
    add(new Robot(new Vector3d(-4, 0, -4), "bump4"));

}
项目:project-bianca    文件:PickCherriesDemo.java   
public PickCherriesDemo() {
    showAxis(false);
    setWorldSize(12);
    boxColor = new Color3f(0.6f, 0.5f, .3f);
    // add the four walls
    add(new Box(new Vector3d(-5, 0, 0), new Vector3f(0.1f, 1, 10), this, new Color3f(.8f, 0.2f, 0.2f)));
    add(new Box(new Vector3d(0, 0, -5), new Vector3f(10, 1, 0.1f), this, new Color3f(0.2f, 0.8f, 0.2f)));
    add(new Box(new Vector3d(5, 0, 0), new Vector3f(0.1f, 1, 10), this, new Color3f(0f, 0.2f, 0.8f)));
    add(new Box(new Vector3d(0, 0, 5), new Vector3f(10, 1, 0.1f), this, new Color3f(0.2f, 0.2f, 0.8f)));

    // add the robot
    add(new Robot(new Vector3d(0, 0, 0), "R1"));

    // add cherries randomly .
    for (int n = 0; n < 30; n++) {
        double x = (Math.random() * 10 - 5);
        double z = (Math.random() * 10 - 5);
        add(new CherryAgent(new Vector3d(x, 0, z), "cherry", 0.15f));
    }
}
项目:NeuGen    文件:VRLDensityVisualization.java   
private void setLighting(TransformGroup objMove) {
    // Set up the ambient light
    Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(boundingSphere);
    objMove.addChild(ambientLightNode);

    // Set up the directional lights
    Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);

    //light1Direction.scale(scale * 10.0f);
    Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    //light2Direction.scale(scale * 10.0f);

    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(boundingSphere);
    objMove.addChild(light1);

    DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
    light2.setInfluencingBounds(boundingSphere);
    objMove.addChild(light2);
}
项目:NeuGen    文件:NeuGenDensityVisualization.java   
private void setLighting(TransformGroup objMove) {
    // Set up the ambient light
    Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(boundingSphere);
    objMove.addChild(ambientLightNode);

    // Set up the directional lights
    Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);

    //light1Direction.scale(scale * 10.0f);
    Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    //light2Direction.scale(scale * 10.0f);

    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(boundingSphere);
    objMove.addChild(light1);

    DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
    light2.setInfluencingBounds(boundingSphere);
    objMove.addChild(light2);
}
项目:NeuGen    文件:NeuGenVisualization.java   
private void setLightingRecon(TransformGroup objMove) {
    // Set up the ambient light
    Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    objMove.addChild(ambientLightNode);

    // Set up the directional lights
    Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);

    //light1Direction.scale(scale * 10.0f);
    Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    //light2Direction.scale(scale * 10.0f);

    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    objMove.addChild(light1);

    DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
    light2.setInfluencingBounds(bounds);
    objMove.addChild(light2);
}
项目:NeuGen    文件:NeuGenVisualization.java   
private void setLightingNet(TransformGroup objMove) {
    // Set up the ambient light
    Color3f ambientColor = Utils3D.lightBlue1;
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    objMove.addChild(ambientLightNode);
    // Set up the directional lights
    Color3f light1Color = Utils3D.brown;
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
    light1Direction.scale(scale * 10.0f);
    //Color3f light2Color = Utils3D.brown;
    //Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    //light2Direction.scale(scale * 10.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    objMove.addChild(light1);
    //DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
    //light2.setInfluencingBounds(bounds);
    //objMove.addChild(light2);

    //objMove.addChild(lgt1);
}
项目:NeuGen    文件:Triangle3dCreator.java   
/**
     * Creates a new instance of Triangle3dCreator color the color of the
     * triangle
     */
    public Triangle3dCreator(Color3f color) {
        this.triangleColor = color;
        this.triangleAppearance = new Appearance();

        // ca werden nicht benoetigt
        // ColoringAttributes ca = new ColoringAttributes();
        // ca.setColor(triangleColor);
        // this.triangleAppearance.setColoringAttributes(ca);

        TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.FASTEST, 0.5f);
        this.triangleAppearance.setTransparencyAttributes(ta);

//      Material material = new Material();
//      material.setAmbientColor(color);
//      material.setShininess(0.5f);
//      material.setLightingEnable(true);
//      this.triangleAppearance.setMaterial(material);

        this.triangleContainer = new Shape3D();
        this.triangleContainer.setAppearance(triangleAppearance);
        triangleContainer.removeGeometry(0);
    }
项目:NeuGen    文件:Triangle3dCreator.java   
/**
 * Creates a new instance of Triangle3dCreator color the color of the
 * triangle
 */
public Triangle3dCreator(Color3f color) {
    this.triangleColor = color;
    this.triangleAppearance = new Appearance();

    ColoringAttributes ca = new ColoringAttributes();
    ca.setColor(triangleColor);
    this.triangleAppearance.setColoringAttributes(ca);

    TransparencyAttributes ta = new TransparencyAttributes();
    ta.setTransparency(0.5f);
    this.triangleAppearance.setTransparencyAttributes(ta);

    this.triangleContainer = new Shape3D();
    triangleContainer.removeGeometry(0);
}
项目:whiskeyDEM    文件:myBackground.java   
/** Creates new myBackground */
public myBackground(BoundingSphere bounds)
{
  // Set up the background
  //Color3f bgColor = new Color3f(0.9f, 0.9f, 0.9f);
  Color3f bgColor = new Color3f(0.5f, 0.75f, 1f); //0.1f, 0.15f, 0.3f);

  /*
  String FileName = "clouds.gif";
  BufferedImage im = null;
try {
im = ImageIO.read(new File("./FlightObjects/Textures/"+FileName).toURL());
} catch (IOException e) {System.out.println(e);}//MalformedURLException mue) {mue.printStackTrace;}
  ImageComponent2D Imagee = new ImageComponent2D(ImageComponent2D.FORMAT_RGB, im);
  //setImage(Imagee);
  */

  setColor(bgColor);
  setApplicationBounds(bounds);
}
项目:whiskeyDEM    文件:myBackground.java   
/** Creates new myBackground */
public myBackground(BoundingSphere bounds)
{
  // Set up the background
  //Color3f bgColor = new Color3f(0.9f, 0.9f, 0.9f);
  Color3f bgColor = new Color3f(0.5f, 0.75f, 1f); //0.1f, 0.15f, 0.3f);

  /*
  String FileName = "clouds.gif";
  BufferedImage im = null;
try {
im = ImageIO.read(new File("./FlightObjects/Textures/"+FileName).toURL());
} catch (IOException e) {System.out.println(e);}//MalformedURLException mue) {mue.printStackTrace;}
  ImageComponent2D Imagee = new ImageComponent2D(ImageComponent2D.FORMAT_RGB, im);
  //setImage(Imagee);
  */

  setColor(bgColor);
  setApplicationBounds(bounds);
}
项目:ct-sim    文件:ParcoursLoader.java   
/**
 * Fuegt ein Licht ein
 * 
 * @param pointLightBounds
 * @param pointLightColor
 * @param x
 *            X-Koordinate
 * @param y
 *            Y-Koordinate
 * @param appearance
 *            Die Appearance
 */
private void createLight(BoundingSphere pointLightBounds, Color3f pointLightColor, int x, int y, Appearance appearance) {
    // Lichter bestehen aus dem echten Licht
    PointLight pointLight = new PointLight();
    pointLight.setColor(pointLightColor);
    pointLight.setPosition((x + 0.5f) * parcours.getBlockSizeInM(), (y + 0.5f) * parcours.getBlockSizeInM(), LIGHTZ);
    pointLight.setInfluencingBounds(pointLightBounds);
    pointLight.setAttenuation(1f, 3f, 0f);
    pointLight.setEnable(true);
    parcours.addLight(pointLight);

    // Und einer gelben Kugel, um es zu visualisieren
    Sphere lightSphere = new Sphere(0.07f);
    lightSphere.setAppearance(appearance);
    parcours.addLight(lightSphere, x + 0.5f, y + 0.5f, LIGHTZ);
}
项目:GpsPrune    文件:Java3DWindow.java   
/**
 * @return Material object for track points with the appropriate colour for the height
 */
private static Material getTrackpointMaterial(byte inHeightCode)
{
    // create default material
    Material mat = new Material(new Color3f(0.3f, 0.2f, 0.1f),
        new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.0f, 0.6f, 0.0f),
        new Color3f(1.0f, 0.6f, 0.6f), 70.0f);
    // change colour according to height code
    if (inHeightCode == 1) mat.setDiffuseColor(new Color3f(0.4f, 0.9f, 0.2f));
    else if (inHeightCode == 2) mat.setDiffuseColor(new Color3f(0.7f, 0.8f, 0.2f));
    else if (inHeightCode == 3) mat.setDiffuseColor(new Color3f(0.3f, 0.6f, 0.4f));
    else if (inHeightCode == 4) mat.setDiffuseColor(new Color3f(0.1f, 0.9f, 0.9f));
    else if (inHeightCode >= 5) mat.setDiffuseColor(new Color3f(1.0f, 1.0f, 1.0f));
    // return object
    return mat;
}
项目:ProGAL    文件:J3DScene.java   
private Appearance genAppearance(Color color){
    Appearance app = new Appearance(); 

    Material mat = new Material();
    Color3f ambient  = new Color3f(0.2f,0.2f,0.2f);
    Color3f emissive = new Color3f(0,0,0);
    Color3f diffuse  = new Color3f(color);
    Color3f specular = new Color3f(1,1,1);
    float shininess = 64;
    mat = new Material(ambient, emissive, diffuse, specular, shininess);
    app.setMaterial(mat);

    PolygonAttributes pa = new PolygonAttributes();
    app.setPolygonAttributes(pa);

    if(color.getAlpha()<255){
        TransparencyAttributes ta = new TransparencyAttributes();
        //          ta.setTransparencyMode(TransparencyAttributes.NICEST);
        ta.setTransparencyMode(TransparencyAttributes.FASTEST);
        ta.setTransparency(1-color.getAlpha()/255f);
        app.setTransparencyAttributes(ta);
    }
    return app;
}
项目:ProGAL    文件:J3DScene.java   
private void genLights(BranchGroup bg){

        Color3f lightColor = new Color3f(1f, 1f, 1f);

        Vector3f lightDirection = new Vector3f(0,-5,-5);
        DirectionalLight light  = new DirectionalLight(lightColor, lightDirection);
        light.setInfluencingBounds(bounds);
        bg.addChild(light);

        lightDirection = new Vector3f(0,-5,5);
        light  = new DirectionalLight(lightColor, lightDirection);
        light.setInfluencingBounds(bounds);
        bg.addChild(light);

        lightDirection = new Vector3f(0,5,0);
        light  = new DirectionalLight(lightColor, lightDirection);
        light.setInfluencingBounds(bounds);
        bg.addChild(light);

    }
项目:vzome-desktop    文件:Appearances.java   
public Appearances( Colors colors, boolean hasEmissiveColor )
{
    mColors = colors;
    mHasEmissiveColor = hasEmissiveColor;
    Color color = mColors .getColor( Colors .HIGHLIGHT );
    if ( ! hasEmissiveColor )
        color = mColors .getColor( Colors .HIGHLIGHT_MAC );
    float[] rgb = new float[3];
    mGlowColor = new Color3f( color .getRGBColorComponents( rgb ) );

       for (String name : mColors) {
           color = mColors .getColor( name );
           Appearance[][] set = makeAppearances( color );
           mAppearances .put( color, set );
       }
}
项目:vzome-desktop    文件:Appearances.java   
private Appearance makeAppearance( Material material, Color4f color, boolean transparent )
{
    Appearance appearance = new Appearance();
    appearance .setMaterial( material );
    appearance .setCapability( Appearance .ALLOW_MATERIAL_READ );
    appearance .setCapability( Appearance .ALLOW_MATERIAL_WRITE );
    material .setLightingEnable( true );
    Color3f justColor = new Color3f( color .x, color.y, color.z );
    appearance .setColoringAttributes( new ColoringAttributes( justColor, ColoringAttributes .SHADE_FLAT ) );
    if ( transparent || color.w < 1.0f ) {
        TransparencyAttributes ta = new TransparencyAttributes();
        ta .setTransparencyMode( TransparencyAttributes .BLENDED );
        float alpha = transparent? ( PREVIEW_TRANSPARENCY * color.w ) : color.w;
        ta .setTransparency( PREVIEW_TRANSPARENCY );
        appearance .setTransparencyAttributes( ta );
    }       
    return appearance;
}
项目:myrobotlab    文件:Points3DPanel.java   
private void lightScene()
/* One ambient light, 2 directional lights */
{
  Color3f white = new Color3f(1.0f, 1.0f, 1.0f);

  // Set up the ambient light
  AmbientLight ambientLightNode = new AmbientLight(white);
  ambientLightNode.setInfluencingBounds(bounds);
  sceneBG.addChild(ambientLightNode);

  // Set up the directional lights
  Vector3f light1Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
  // left, down, backwards
  Vector3f light2Direction = new Vector3f(1.0f, -1.0f, 1.0f);
  // right, down, forwards

  DirectionalLight light1 = new DirectionalLight(white, light1Direction);
  light1.setInfluencingBounds(bounds);
  sceneBG.addChild(light1);

  DirectionalLight light2 = new DirectionalLight(white, light2Direction);
  light2.setInfluencingBounds(bounds);
  sceneBG.addChild(light2);
}
项目:myrobotlab    文件:BlockWorldObject.java   
/** Set the object color */
@Override
public void setColor(Color3f color) {
  Material mat = appearance.getMaterial();
  Color3f ambient = new Color3f(color);
  ambient.scale(0.3f);
  mat.setAmbientColor(ambient);
  color.clampMax(0.8f);
  mat.setDiffuseColor(color);
  // No specular color
  Color3f specular = new Color3f(0, 0, 0);
  mat.setSpecularColor(specular);

  mat.setShininess(1f);

}
项目:myrobotlab    文件:LampActuator.java   
void create3D(float size) {
  super.create3D(true);
  // lamp body
  onColor = new Color3f(0.1f, 1f, 1f);
  offColor = new Color3f(0.3f, 0.3f, 0.3f);
  blinkColor = new Color3f(1f, 0.3f, 0.3f);
  Appearance appear = new Appearance();
  material = new Material();
  material.setAmbientColor(offColor);
  material.setDiffuseColor(offColor);
  material.setCapability(Material.ALLOW_COMPONENT_WRITE);
  material.setSpecularColor(offColor);
  material.setColorTarget(Material.DIFFUSE);
  appear.setMaterial(material);
  Node node = new com.sun.j3d.utils.geometry.Cylinder(size, size, appear);
  node.setCollidable(false);
  node.setPickable(false);
  addChild(node);
}
项目:myrobotlab    文件:Box.java   
/** Create the 3d object */
protected void create3D(EnvironmentDescription wd, Color3f color) {
  // create the box using a primitive
  super.create3D();
  Material mat = new Material();
  appearance.setMaterial(mat);

  int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
  flags |= Primitive.ENABLE_APPEARANCE_MODIFY;
  // com.sun.j3d.utils.geometry.Box box =new
  // com.sun.j3d.utils.geometry.Box(sx,sy,sz,flags,appearance,0);
  // bug in j3d api doc . must give half values.
  com.sun.j3d.utils.geometry.Box box = new com.sun.j3d.utils.geometry.Box(sx / 2, sy / 2, sz / 2, flags, appearance, 0);
  // Enable sensor detection
  box.setPickable(true);

  // define the boundsfFor collision detection
  BoundingBox bounds = new BoundingBox();
  bounds.setUpper(sx / 2, sy / 2, sz / 2);
  bounds.setLower(-sx / 2, -sy / 2, -sz / 2);
  setBounds(bounds);

  setColor(color);
  addChild(box);

}
项目:myrobotlab    文件:BumpersDemo.java   
public BumpersDemo() {
  setWorldSize(12);

  boxColor = new Color3f(0.6f, 0.5f, .3f);

  add(new Box(new Vector3d(-5, 0, 0), new Vector3f(0.1f, 1, 10), this));
  add(new Box(new Vector3d(0, 0, -5), new Vector3f(10, 1, 0.1f), this));
  add(new Box(new Vector3d(5, 0, 0), new Vector3f(0.1f, 1, 10), this));
  add(new Box(new Vector3d(0, 0, 5), new Vector3f(10, 1, 0.1f), this));
  add(new Box(new Vector3d(2, 0, 2), new Vector3f(2, 1, 3), this));
  add(new Box(new Vector3d(-2, 0, -2), new Vector3f(3, 1, 2), this));

  add(new Robot(new Vector3d(4, 0, 4), "bump1"));
  add(new Robot(new Vector3d(4, 0, -4), "bump2"));
  add(new Robot(new Vector3d(-4, 0, 4), "bump3"));
  add(new Robot(new Vector3d(-4, 0, -4), "bump4"));

}
项目:myrobotlab    文件:PickCherriesDemo.java   
public PickCherriesDemo() {
  showAxis(false);
  setWorldSize(12);
  boxColor = new Color3f(0.6f, 0.5f, .3f);
  // add the four walls
  add(new Box(new Vector3d(-5, 0, 0), new Vector3f(0.1f, 1, 10), this, new Color3f(.8f, 0.2f, 0.2f)));
  add(new Box(new Vector3d(0, 0, -5), new Vector3f(10, 1, 0.1f), this, new Color3f(0.2f, 0.8f, 0.2f)));
  add(new Box(new Vector3d(5, 0, 0), new Vector3f(0.1f, 1, 10), this, new Color3f(0f, 0.2f, 0.8f)));
  add(new Box(new Vector3d(0, 0, 5), new Vector3f(10, 1, 0.1f), this, new Color3f(0.2f, 0.2f, 0.8f)));

  // add the robot
  add(new Robot(new Vector3d(0, 0, 0), "R1"));

  // add cherries randomly .
  for (int n = 0; n < 30; n++) {
    double x = (Math.random() * 10 - 5);
    double z = (Math.random() * 10 - 5);
    add(new CherryAgent(new Vector3d(x, 0, z), "cherry", 0.15f));
  }
}
项目:javagame    文件:MainPanel.java   
/**
 * ������sceneBG�ɒlj�
 */
private void lightScene() {
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);

    // �‹����iAmbientLight�j
    // �ڂ���Ƃ������A���ꂪ�Ȃ��Ɛ^����
    AmbientLight ambientLight = new AmbientLight(white);
    ambientLight.setInfluencingBounds(bounds); // �����̋y�Ԕ͈͂�ݒ�
    sceneBG.addChild(ambientLight); // sceneBG�Ɍ�����lj�

    // ���s�����i�\�ʂ������ƌ���j
    Vector3f lightDirection = new Vector3f(-1.0f, -1.0f, -1.0f); // �����̌���
    DirectionalLight dirLight = new DirectionalLight(white, lightDirection);
    dirLight.setInfluencingBounds(bounds);
    sceneBG.addChild(dirLight);
}
项目:javagame    文件:Main.java   
private Box createBox() {
    // ��
    Appearance app = new Appearance();
    Material mat = new Material();
    mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f));
    mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
    app.setMaterial(mat);

    // �����ɂ���
    TransparencyAttributes transAttr = new TransparencyAttributes(
            TransparencyAttributes.BLENDED, 0.5f);
    app.setTransparencyAttributes(transAttr);

    Box box = new Box(0.5f, 0.5f, 0.5f, app);

    return box;
}
项目:javagame    文件:MainPanel.java   
/**
 * ������sceneBG�ɒlj�
 */
private void lightScene() {
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);

    // �‹����iAmbientLight�j
    // �ڂ���Ƃ������A���ꂪ�Ȃ��Ɛ^����
    AmbientLight ambientLight = new AmbientLight(white);
    ambientLight.setInfluencingBounds(bounds); // �����̋y�Ԕ͈͂�ݒ�
    sceneBG.addChild(ambientLight); // sceneBG�Ɍ�����lj�

    // ���s�����i�\�ʂ������ƌ���j
    Vector3f lightDirection = new Vector3f(-1.0f, -1.0f, -1.0f); // �����̌���
    DirectionalLight dirLight = new DirectionalLight(white, lightDirection);
    dirLight.setInfluencingBounds(bounds);
    sceneBG.addChild(dirLight);
}
项目:javagame    文件:Floor.java   
public Floor() {
    floorBG = new BranchGroup();

    Appearance app = new Appearance();

    // ��
    Material mat = new Material();
    mat.setAmbientColor(new Color3f(1.0f, 1.0f, 0.0f));  // ���F
    mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
    app.setMaterial(mat);

    // �����쐬
    Box floor = new Box(10.0f, 0.001f, 10.0f, app);

    floorBG.addChild(floor);
}
项目:javagame    文件:Ball.java   
public Ball(double x, double y, double z) {
    position = new Vector3d(x, y, z);
    velocity = new Vector3d(0, 0, 0);
    acceleration = new Vector3d(0, -0.01, 0);  // �����x�͈��

    // �ړ��”\
    this.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    this.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    app = new Appearance();
    Material mat = new Material();
    mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f));
    mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
    app.setMaterial(mat);

    TransparencyAttributes transAttr = new TransparencyAttributes(
            TransparencyAttributes.BLENDED, 0.2f);
    app.setTransparencyAttributes(transAttr);

    // �{�[����lj�
    this.addChild(new Sphere(radius, Sphere.GENERATE_NORMALS, 100, app));

    move();
}
项目:javagame    文件:MainPanel.java   
/**
 * ������sceneBG�ɒlj�
 */
private void lightScene() {
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);

    // �‹����iAmbientLight�j
    // �ڂ���Ƃ������A���ꂪ�Ȃ��Ɛ^����
    AmbientLight ambientLight = new AmbientLight(white);
    ambientLight.setInfluencingBounds(bounds); // �����̋y�Ԕ͈͂�ݒ�
    sceneBG.addChild(ambientLight); // sceneBG�Ɍ�����lj�

    // ���s�����i�\�ʂ������ƌ���j
    Vector3f lightDirection = new Vector3f(-1.0f, -1.0f, -1.0f); // �����̌���
    DirectionalLight dirLight = new DirectionalLight(white, lightDirection);
    dirLight.setInfluencingBounds(bounds);
    sceneBG.addChild(dirLight);
}
项目:billie    文件:UniverseBuilder.java   
private void initSceneGraph() {
    VirtualUniverse universe = new VirtualUniverse();
    locale = new Locale(universe);

    BranchGroup sceneRoot = new BranchGroup();

    Background background = new Background(new Color3f(0.8f, 0.9f, 1));
    background.setApplicationBounds(new BoundingSphere(new Point3d(), Double.MAX_VALUE));
    sceneRoot.addChild(background);

    sceneSwitch = new Switch();
    sceneSwitch.setCapability(Switch.ALLOW_CHILDREN_EXTEND);
    sceneSwitch.setCapability(Switch.ALLOW_CHILDREN_WRITE);
    sceneSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
    sceneSwitch.addChild(createLoaderSceneGraph());
    sceneSwitch.addChild(null);
    sceneRoot.addChild(sceneSwitch);

    locale.addBranchGraph(sceneRoot);
}
项目:billie    文件:UniverseBuilder.java   
public void addLights(BranchGroup group) {
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), Double.MAX_VALUE);

    AmbientLight ambientLight = new AmbientLight(new Color3f(0.5f, 0.5f, 0.5f));
    ambientLight.setInfluencingBounds(bounds);
    group.addChild(ambientLight);

    Color3f lightColor = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f light1Direction = new Vector3f(4.0f, -8.0f, -16.0f);
    DirectionalLight light1 = new DirectionalLight(true, lightColor, light1Direction);
    light1.setInfluencingBounds(bounds);
    group.addChild(light1);

    light1Direction.negate();
    DirectionalLight light2 = new DirectionalLight(true, lightColor, light1Direction);
    light2.setInfluencingBounds(bounds);
    group.addChild(light2);
}
项目:billie    文件:IfcSched_Colored4D.java   
Appearance getAppearance(float R, float G, float B, float alpha) {
    Color3f newColor = new Color3f(R, G, B);
    Color3f compareTo = new Color3f();
    for (Appearance appearance : appearances) {
        appearance.getMaterial().getDiffuseColor(compareTo);
        float transparency = appearance.getTransparencyAttributes() == null ? 0 : appearance.getTransparencyAttributes().getTransparency();
        if (compareTo.equals(newColor) && transparency == alpha)
            return appearance;
    }
    Material material = new Material(newColor, new Color3f(0f, 0f, 0f), newColor, newColor, 10f);
    material.setLightingEnable(true);
    Appearance newAppearance = new Appearance();
    newAppearance.setMaterial(material);
    PolygonAttributes pa = new PolygonAttributes();
    pa.setCullFace(PolygonAttributes.CULL_NONE);
    newAppearance.setPolygonAttributes(pa);
    if (alpha > 0)
        newAppearance.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST, alpha));
    appearances.add(newAppearance);
    return newAppearance;
}
项目:breakout    文件:DebugVector.java   
public DebugVector( Point3f location , Vector3f extent , Color3f color )
{
    ColoringAttributes ca = new ColoringAttributes( );
    ca.setCapability( ColoringAttributes.ALLOW_COLOR_WRITE );
    RenderingAttributes ra = new RenderingAttributes( );
    ra.setCapability( RenderingAttributes.ALLOW_VISIBLE_WRITE );
    TransparencyAttributes ta = new TransparencyAttributes( );
    ta.setTransparency( 0.3f );
    Appearance app = new Appearance( );
    app.setColoringAttributes( ca );
    app.setCapability( Appearance.ALLOW_COLORING_ATTRIBUTES_READ );
    app.setRenderingAttributes( ra );
    app.setCapability( Appearance.ALLOW_RENDERING_ATTRIBUTES_READ );
    shape.setAppearance( app );
    shape.setCapability( Shape3D.ALLOW_APPEARANCE_READ );
    shape.setCapability( Shape3D.ALLOW_GEOMETRY_WRITE );

    setVector( location , extent );
    setColor( color );

    addChild( shape );
}
项目:breakout    文件:Camera3D.java   
protected void createHeadlight( )
{
    final Color3f lightColor = new Color3f( 0.9f , 0.9f , 0.9f );
    final DirectionalLight light = new DirectionalLight( );
    light.setCapability( Light.ALLOW_STATE_WRITE );
    light.setColor( lightColor );

    final BoundingSphere worldBounds = new BoundingSphere( new Point3d( 0.0 , 0.0 , 0.0 ) , 100000.0 ); // Center, Extent
    light.setInfluencingBounds( worldBounds );

    m_headlight = light;
    final BranchGroup bg = new BranchGroup( );
    m_lightGroup = new TransformGroup( );
    m_lightGroup.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
    bg.addChild( m_lightGroup );
    m_lightGroup.addChild( m_headlight );
    m_transformGroup.addChild( bg );
}