计算机图形学课程设计html源码,计算机图形学 实验一:生成彩色立方体(含源代码)...

实验一

实验目的:生成彩色立方体

实验代码://ColorCube1.java

import java.applet.Applet; //可以插入html

import java.awt.BorderLayout; //窗口采用BorderLayout方式布局import com.sun.j3d.utils.applet.MainFrame; //application

import com.sun.j3d.utils.geometry.ColorCube;//调用生成ColorCube的Utility import com.sun.j3d.utils.geometry.Primitive;

import com.sun.j3d.utils.universe.*; //观测位置的设置

import javax.media.j3d.*; //核心类

import javax.vecmath.*; //矢量计算

import com.sun.j3d.utils.behaviors.mouse.*;

public class ColorCube1 extends Applet {

public BranchGroup createSceneGraph() {

BranchGroup objRoot=new BranchGroup();

//BranchGroup的一个对象objRoot(放置背景、灯光)BoundingSphere bounds=new BoundingSphere(new

Point3d(0.0,0.0,0.0),100.0);//有效范围

TransformGroup objTrans=new TransformGroup();

objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

objRoot.addChild(objTrans);

MouseRotate behavior = new MouseRotate();

behavior.setTransformGroup(objTrans);

objRoot.addChild(behavior);

behavior.setSchedulingBounds(bounds);

MouseZoom behavior2 = new MouseZoom();

behavior2.setTransformGroup(objTrans);

objRoot.addChild(behavior2);

behavior2.setSchedulingBounds(bounds);

MouseTranslate behavior3 = new MouseTranslate();

behavior3.setTransformGroup(objTrans);

objRoot.addChild(behavior3);

behavior3.setSchedulingBounds(bounds);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值