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

📄 linevector.java

📁 Java 3D Game SDK.老外做的.
💻 JAVA
字号:
/*
 * LineVector.java
 *
 * Created on 6. Oktober 2002, 09:46
 */

package org.java3dgamesdk.graphics.util;

import javax.media.j3d.*;
import javax.vecmath.*;

import org.java3dgamesdk.graphics.*;

/**
 * Class provides drawing a simple line.
 *
 * @author  Norbert Nopper
 */
public class LineVector extends Model3D {
    
    /**
     * Class variable for the red color.
     */
    final public static Color3f RED = new Color3f(1.0f, 0.0f, 0.0f);
    
    /**
     * Class variable for the green color.
     */
    final public static Color3f GREEN = new Color3f(0.0f, 1.0f, 0.0f);

    /**
     * Class variable for the blue color.
     */
    final public static Color3f BLUE = new Color3f(0.0f, 0.0f, 1.0f);
    
    /**
     * The line itself.
     */
    private LineArray   line;
    
    /**
     * Default appearance.
     */
    private Appearance  appearance;
    
    /**
     * Creates a vector starting from (0,0,0) to the given point. 
     *
     * @param direction the vector where the line is pointing
     * @param color     the color of the line
     */
    public LineVector(Point3d direction, Color3f color) {
        // create the line array ...
        line = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3 );
        // ... set the coordinates ...
        line.setCoordinate(0, new Point3d(0.0, 0.0, 0.0));
        line.setCoordinate(1, direction);
        // ... and the color
        line.setColor(0, color);
        line.setColor(1, color);

        // create the default appearance
        appearance = new Appearance();
    }

    /**
     * Nothing needs to be updated.
     *
     * @param time the passed time in milliseconds
     */
    protected void updateModel(long time) {
        // do nothing
    }
    
    /**
     * Render the line.
     *
     * @param gc3D the graphics contect 3D to render on
     */    
    protected void drawModel(GraphicsContext3D gc3D) {        
        gc3D.setAppearance(appearance);
        
        gc3D.draw(line);        
    }
    
}

⌨️ 快捷键说明

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