seanrowens/oObjLoader

语言: Java

git: https://github.com/seanrowens/oObjLoader

用于解析和加载Lightwave / Wavefront .obj(对象)文件的Java库。还测试要在OpenGL / LWJGL中显示的代码。
A java library to parse and load Lightwave/Wavefront .obj (object) files. Also test code to display in OpenGL/LWJGL.
README.md (中文)

创建将编译的netbeans项目(使用Netbeans 7.01.1) 并运行此代码;

0)此步骤只需执行一次。

a)下载最新的LWJGL(我使用LWJGL 2.7.1测试了这段代码) 来自LWJGL网站;

HTTP://另外就够了.org/download.PHP

b)将LWJGL下载档案提取到目录中。它的    将您的目录命名为lwjgl可能是个好主意    加上你下载的lwjgl的版本号。对于我们    例如,我们将选择作为我们的目录;

/users/Sean/另外就够了-2.7.1

c)将LWJGL添加到Netbeans中的库中,以便稍后添加    他们到你的项目。这些说明几乎被偷走了;

HTTP://另外就够了.org/wiki/index.PHP?title=setting_up_l WJ GL_with_NetBeans

但为了以防万一,我会在这里附上说明。

  i) Open up NetBeans.

  ii) Go to Tools|Libraries in the main menu.

  iii) Click on the New Library button.

  iv) Type in LWJGL or LWJGL-X.X to distinguish it from
  earlier/later versions or any other name that you want for the
  Library Name.

  v) Always make sure that the correct Library is selected; you
  don't want to accidentally modify another Library. Now select
  the Classpath tab for your newly created Library and then click
  the Add JAR/Folder... button.

  vi) Go to the folder where you extracted lwjgl-X.X.zip and then
  go into the jar folder. The only JARs that you really need are
  lwjgl.jar, lwjgl_util.jar, and jinput.jar. You can select
  multiple files by holding down the Ctrl key while you click so
  that you can do this in just one step.

如果您愿意,该网页上列出了一些可选步骤    还要安装LWJGL源代码和java文档。

1)下载并解压缩java源码,进入某个目录,其中 将被称为“mydir”。当你在mydir上运行“ls -l”时,你 应该看到类似的东西;

共16    -rw-r - r-- 1 sean staff 2613 Jan 8 21:31 README_NETBEANS.TXT    -rw-r - r-- 1 sean staff 1786 Jan 8 21:04 README.TXT    drwxr-xr-x 3 sean staff 102 Jan 8 21:03 com

2)在netbeans中,创建一个新项目;

a)使用菜单选项File-> New project - 这将打开一个New Project    对话框

b)在Categories中单击Java,然后在Projects中单击“Java”    “使用现有源项目”,然后单击“下一步”

c)给项目命名 - 我将使用“oObjLoader”,单击“下一步”

d)单击“源包”旁边的“添加文件夹”按钮    文件夹“字段并浏览到”mydir“

e)单击“完成”按钮

3)使用以下命令打开新项目的“项目属性”对话框 文件菜单或右键单击项目端的项目 酒吧。

  a) click on "Run" in the "Categories" list on the left of the
  dialogue

  b) In the VM Options field, enter

    -Djava.library.path=/Users/sean/lwjgl-2.7.1/lwjgl-2.7.1/native/macosx

where "/Users/sean/lwjgl-2.7.1" is replaced by your extracted
LWJGL directory, and macosx has the appropriate directory for
your OS

  c) In the Main Class field enter;

     com.owens.oobjloader.lwjgl.Test

  d) in Arguments, add the full path of an .obj file you want to
  load and display.  Optionally, add a "default" texture image
  file by adding "-defaulttexture somefile.jpg" - I've noticed
  that a lot of the time, .obj files either don't specify a
  texture or the texture file get's left out.  If your .obj file
  doesn't specify a texture, it won't be loaded and displayed
  unless you specify an default texture.

  e) In the Categories list on the left, click on "Libaries"

  f) Click the "Add Library" button on the right, and the "Add
  Library" dialogue will come up

  g) Select LWJGL-2.7.1 from the list of "Available Libraries" on
  the left, then click the "Add Library button", the "Add Library"
  dialogue should close.

  h) You should now be back at the "Project Properties" dialogue,
  click the "OK" button and it should close

而且你已经完成了!现在使用菜单选项Run-> Run Main Project,和 如果oObjLoader是你当前的主项目,它应该编译 oObjLoader并运行lwgjl.Test程序。如果您指定了.obj 文件和项目属性中的纹理 - >运行对话框,如 在上面的说明的第4d部分讨论,它应该很快加载 并从.obj文件中显示您的模型。 (注意LARGE型号 可能需要一段时间才能加载,因此可能只是看到一个充满黑色的窗口 一会儿。另请注意,如果默认纹理最终成为 使用过,你的模型很可能看起来很奇怪的纹理。)

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

To create a netbeans project (using Netbeans 7.01.1) that will compile
and run this code;

0) This step need only be done once.

a) Download the latest LWJGL (I tested this code using LWJGL 2.7.1)
from the LWJGL website;

http://lwjgl.org/download.php

b) extract the LWJGL download archive into a directory. It's
probably a good idea to name your directory something like lwjgl
plus the version number of lwjgl that you downloaded. For our
example, we will choose as our directory;

/Users/sean/lwjgl-2.7.1

c) add LWJGL to the libraries in Netbeans, so you can later add
them to your project. These instructions are pretty much stolen from;

http://lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_NetBeans

but just in case, I'll include the instructions here.

  i) Open up NetBeans.

  ii) Go to Tools|Libraries in the main menu.

  iii) Click on the New Library button.

  iv) Type in LWJGL or LWJGL-X.X to distinguish it from
  earlier/later versions or any other name that you want for the
  Library Name.

  v) Always make sure that the correct Library is selected; you
  don't want to accidentally modify another Library. Now select
  the Classpath tab for your newly created Library and then click
  the Add JAR/Folder... button.

  vi) Go to the folder where you extracted lwjgl-X.X.zip and then
  go into the jar folder. The only JARs that you really need are
  lwjgl.jar, lwjgl_util.jar, and jinput.jar. You can select
  multiple files by holding down the Ctrl key while you click so
  that you can do this in just one step.

There are some optional steps listed on that web page if you wish
to also install LWJGL sources and java docs.

1) download and extract the java source, into some directory, which
will be referred to as "mydir". When you run "ls -l" on mydir, you
should see something like;

total 16
-rw-r--r-- 1 sean staff 2613 Jan 8 21:31 README_NETBEANS.TXT
-rw-r--r-- 1 sean staff 1786 Jan 8 21:04 README.TXT
drwxr-xr-x 3 sean staff 102 Jan 8 21:03 com

2) In netbeans, create a new project;

a) Use the menu option File->New project - this opens a New Project
dialogue box

b) In Categories click on Java, then in Projects click on "Java
Project with existing sources", then click Next

c) Give the project a name - I'll use "oObjLoader", click Next

d) Click on the "Add Folder" button next to the "Source Package
Folders" field and browse to "mydir"

e) click "Finish" button

3) Open the Project Properties dialogue on your new project, using the
File menu or by right clicking on the project in the Projects side
bar.

  a) click on "Run" in the "Categories" list on the left of the
  dialogue

  b) In the VM Options field, enter

    -Djava.library.path=/Users/sean/lwjgl-2.7.1/lwjgl-2.7.1/native/macosx

where "/Users/sean/lwjgl-2.7.1" is replaced by your extracted
LWJGL directory, and macosx has the appropriate directory for
your OS

  c) In the Main Class field enter;

     com.owens.oobjloader.lwjgl.Test

  d) in Arguments, add the full path of an .obj file you want to
  load and display.  Optionally, add a "default" texture image
  file by adding "-defaulttexture somefile.jpg" - I've noticed
  that a lot of the time, .obj files either don't specify a
  texture or the texture file get's left out.  If your .obj file
  doesn't specify a texture, it won't be loaded and displayed
  unless you specify an default texture.

  e) In the Categories list on the left, click on "Libaries"

  f) Click the "Add Library" button on the right, and the "Add
  Library" dialogue will come up

  g) Select LWJGL-2.7.1 from the list of "Available Libraries" on
  the left, then click the "Add Library button", the "Add Library"
  dialogue should close.

  h) You should now be back at the "Project Properties" dialogue,
  click the "OK" button and it should close

And you're done! Now use the menu option Run->Run Main Project, and
if oObjLoader is your current main project, it should compile
oObjLoader and run the lwgjl.Test program. If you specified an .obj
file and a texture in the Project Propertries->Run dialogue, as
discussed in part 4d of the instructions above, it should shortly load
and display your model from the .obj file. (Note that LARGE models
may take a while to load, so may simply see a window filled with black
for a moment. Note also that if the default texture ends up being
used, your model may well look reall weird texture-wise.)