All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sim.portrayal3d.simple.CubePortrayal3D Maven / Gradle / Ivy

Go to download

MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.

The newest version!
/*
  Copyright 2006 by Sean Luke and George Mason University
  Licensed under the Academic Free License version 3.0
  See the file "LICENSE" for more information
*/

package sim.portrayal3d.simple;

import sim.portrayal3d.*;
import javax.vecmath.*;
import sim.portrayal.*;
import javax.media.j3d.*;
import java.awt.*;

/**
 * Portrays objects as a cube of the specified color or appearance (flat opaque white by default)
 * which fills the region from (-0.5*scale,-0.5*scale,-0.5*scale) to (0.5*scale,0.5*scale,0.5*scale).
 * Objects portrayed by this portrayal are selectable.
 */
public class CubePortrayal3D extends SimplePortrayal3D
    {
    Appearance appearance;
    boolean generateTextureCoordinates;
    
    /** Constructs a CubePortrayal3D with a default (flat opaque white) appearance and a scale of 1.0. */
    public CubePortrayal3D()
        {
        this(1f);
        }
        
    /** Constructs a CubePortrayal3D with a default (flat opaque white) appearance and the given scale. */
    public CubePortrayal3D(double scale)
        {
        this(Color.white,scale);
        }
        
    /** Constructs a CubePortrayal3D with a flat opaque appearance of the given color and a scale of 1.0. */
    public CubePortrayal3D(Color color)
        {
        this(color,1f);
        }
        
    /** Constructs a CubePortrayal3D with a flat opaque appearance of the given color and the given scale. */
    public CubePortrayal3D(Color color, double scale)
        {
        this(appearanceForColor(color), false, scale);
        }
                
    /** Constructs a CubePortrayal3D with the given (opaque) image and a scale of 1.0. */
    public CubePortrayal3D(Image image)
        {
        this(image,1f);
        }

    /** Constructs a CubePortrayal3D with the given (opaque) image and scale. */
    public CubePortrayal3D(Image image, double scale)
        {
        this(appearanceForImage(image,true),true,scale);
        }

    /** Constructs a CubePortrayal3D with the given appearance and scale, plus whether or not to generate normals or texture coordinates.  Without texture coordiantes, a texture will not be displayed */
    public CubePortrayal3D(Appearance appearance, boolean generateTextureCoordinates, double scale)
        {
        this.generateTextureCoordinates = generateTextureCoordinates;
        this.appearance = appearance;  
        for(int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy