资源简介
这是一个印度的大学教授写的,学jogl 的可以看看,很不错。这是java 与 opengl 结合的小例子,有导入模型的。和声音,如果不错你就顶

代码片段和文件信息
// ModelLoaderGL.java
// Andrew Davison November 2006 ad@fivedots.coe.psu.ac.th
/* A Jframe contains a JPanel which holds a GLCanvas. The GLCanvas
displays a loaded OBJ model which may be rotating. The model
is scaled and centered at the origin. The scaling is controlled
by the maxSize value which specifies the maximum size of the
model‘s largest dimension.
The listener for the canvas is ModelLoaderGLListener and the updates
to the canvas‘ display are triggered by FPSAnimator using
fixed-rate scheduling.
The code uses the JSR-231 1.0.0 release build of JOGL
14th September 2006.
Usage:
runGL modelGL [max-size] [-nr]
The OBJ name is assumed to be for a file in the “models/“
subdirectory and the “.OBJ“ extension is added automatically.
If a “max-size“ value is not specified then MAX_SIZE is used.
“-nr“ means “no rotation“ so the default action is to rotate the
model.
*/
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.media.opengl.GLCanvas;
import javax.swing.Jframe;
import javax.swing.JPanel;
import com.sun.opengl.util.FPSAnimator;
public class ModelLoaderGL extends Jframe
{
private static int DEFAULT_FPS = 80;
private static final int PWIDTH = 512; // initial size of panel
private static final int PHEIGHT = 512;
private static final float MAX_SIZE = 4.0f; // for a model‘s dimension
private ModelLoaderGLListener listener;
private FPSAnimator animator;
public ModelLoaderGL(String nm float maxSize boolean doRotate)
{
super(“ModelLoaderGL“);
System.out.println(“Max model size: “ + maxSize);
System.out.println(“Rotating: “ + doRotate);
Container c = getContentPane();
c.setLayout( new BorderLayout() );
JPanel p = makeRenderPanel(nm maxSize doRotate);
c.add(p BorderLayout.CENTER);
addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent e)
/* The animator must be stopped in a different thread from
the AWT event queue to make sure that it completes before
exit is called. */
{ new Thread( new Runnable() {
public void run() {
animator.stop();
System.exit(0);
}
}).start();
} // end of windowClosing()
});
pack();
setVisible(true);
animator.start();
} // end of ModelLoaderGL()
/**Construct a GLCanvas in a JPanel and add a
listener and animator. */
private JPanel makeRenderPanel(String nm float maxSize boolean doRotate)
{
JPanel renderPane = new JPanel();
renderPane.setLayout( new BorderLayout() );
renderPane.setOpaque(false);
renderPane.setPreferredSize( new Dimension(PWIDTH PHEIGHT));
//添加JOGL特性
GLCanvas canvas = new GLCanvas();
File filename=new File(“../src/models/“+nm);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2007-05-30 11:17 jogl2\
文件 644 2007-05-30 13:44 jogl2\.classpath
文件 381 2007-05-30 11:17 jogl2\.project
目录 0 2007-06-14 14:13 jogl2\bin\
文件 848 2007-06-14 14:17 jogl2\bin\ModelLoaderGL$1$1.class
文件 881 2007-06-14 14:17 jogl2\bin\ModelLoaderGL$1.class
文件 3371 2007-06-14 14:17 jogl2\bin\ModelLoaderGL.class
文件 3439 2007-06-14 14:13 jogl2\bin\ModelLoaderGLListener.class
目录 0 2007-06-14 14:13 jogl2\bin\models\
文件 246 2007-05-30 11:18 jogl2\bin\models\barbell.mtl
文件 14326 2007-05-30 11:18 jogl2\bin\models\barbell.obj
文件 307864 2007-06-14 13:57 jogl2\bin\models\beisishou2.md2
文件 355326 2007-06-14 13:57 jogl2\bin\models\beisishou2.png
文件 126 2007-05-30 11:18 jogl2\bin\models\colorCube.mtl
文件 431 2007-05-30 11:18 jogl2\bin\models\colorCube.obj
文件 35 2007-05-30 11:08 jogl2\bin\models\couch.mtl
文件 80177 2007-05-30 11:08 jogl2\bin\models\couch.obj
文件 2781 2007-05-30 11:08 jogl2\bin\models\formula.mtl
文件 709155 2007-05-30 11:08 jogl2\bin\models\formula.obj
文件 205 2007-05-30 11:18 jogl2\bin\models\heli.mtl
文件 75149 2007-05-30 11:18 jogl2\bin\models\heli.obj
文件 2321 2007-05-30 11:08 jogl2\bin\models\me
文件 69 2007-05-30 11:18 jogl2\bin\models\pawn.mtl
文件 22717 2007-05-30 11:18 jogl2\bin\models\pawn.obj
文件 27313 2007-05-30 11:08 jogl2\bin\models\penguin.gif
文件 179 2007-05-30 11:08 jogl2\bin\models\penguin.mtl
文件 14325 2007-05-30 11:08 jogl2\bin\models\penguin.obj
文件 465 2007-05-30 11:08 jogl2\bin\models\rose+vase.mtl
文件 368428 2007-05-30 11:08 jogl2\bin\models\rose+vase.obj
目录 0 2007-06-14 14:13 jogl2\bin\OBJLoader\
文件 2478 2007-06-14 14:13 jogl2\bin\OBJLoader\FaceMaterials.class
............此处省略46个文件信息
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
评论
共有 条评论