|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Window | +--java.awt.Frame | +--md3.md3view.MD3View
Java MD3 Model Viewer - A Java based Quake 3 model viewer. Copyright (C) 1999 Erwin 'KLR8' Vervaet This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Java MD3 Model Viewer application: A windowed application that uses OpenGL to display a Quake 3 MD3 model file on the screen.
This class is really a singleton: the sole top level frame of the application.
It uses Jausoft's GL4Java package. GL4Java maps the OpenGL API to Java and implements window handle functions (native and java), while using the Java Native Interface (JNI) of Java 1.1.X. The JNI library uses the native OpenGL library of the operating system.
All code of the MD3 Viewer was heavilly based on the PC MD3View 1.51 C/C++ source code, written by Matthew 'pagan' Baranowski & Sander 'FireStorm' van Rossen. They did gread work reverse engineering the MD3 file format and building a OpenGL viewer for it. This code is basically a conversion of their C/C++ program to Java. However, the code was completely reengineered to make it more object oriented.
You can find the original MD3View at the following location: Mental Vortex.
Jausoft's GL4Java can be found on the following site: Jausoft Home-Page.
Thanx also to Koen Hendrikx and Kris Cardinaels for help in getting the code to work!
Field Summary | |
protected MD3GLCanvas |
md3canvas
The OpenGL canvas to render on. |
Fields inherited from class java.awt.Frame |
CROSSHAIR_CURSOR,
DEFAULT_CURSOR,
E_RESIZE_CURSOR,
HAND_CURSOR,
ICONIFIED,
MOVE_CURSOR,
N_RESIZE_CURSOR,
NE_RESIZE_CURSOR,
NORMAL,
NW_RESIZE_CURSOR,
S_RESIZE_CURSOR,
SE_RESIZE_CURSOR,
SW_RESIZE_CURSOR,
TEXT_CURSOR,
W_RESIZE_CURSOR,
WAIT_CURSOR |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Method Summary | |
void |
applySkin(java.lang.String name,
java.io.InputStream in)
Apply a skin to the model currently displayed by the viewer. |
void |
applyTexture(java.lang.String name,
java.lang.String loadFilename,
java.io.InputStream in)
Apply a texture to the model currently displayed by the viewer. |
MD3Model |
attachModel(MD3Model to,
int tag,
java.lang.String childName,
java.io.InputStream childIn)
Attach a child model, read from the given input stream, to a parent model at the specified tag position of the parent model. |
void |
closeModel()
Close the model currently displayed by the viewer. |
void |
detachModel(MD3Model model)
Detach the given model from the model structure currently displayed by the viewer. |
protected java.io.InputStream |
getInputStreamForPath(java.lang.String filename)
Try to get an input stream for the specified path. |
static MD3View |
instance()
Factory method that creates an MD3 Model Viewer Frame. |
static void |
main(java.lang.String[] args)
Starts the MD3 Viewer application. |
void |
openModel(java.lang.String name,
java.io.InputStream in)
Loads an MD3 model from the given input stream and displays it in the viewer window. |
protected java.lang.String |
searchForPath(java.lang.String relativePath,
boolean allDataSources)
Clients can use this method to resolve a relative path to an absolute path in the context of the data sources (current open directory, open pak file) of the application. |
protected void |
showExceptionDialog(java.lang.String msg)
Pops up a message dialog with a specified Error message. |
protected java.lang.String |
showOpenDialog(java.lang.String fileMask)
Show the Open dialogbox and return the name of the selected file, once the dialog is dismissed. |
protected java.lang.String |
showSaveDialog(java.lang.String defaultFile)
Show the Save dialogbox and return the name of the selected file, once the dialog is dismissed. |
protected void |
showSplashScreen()
Display the splash screen of the application. |
protected void |
showTextViewer(java.lang.String name,
java.io.InputStream textIn)
Pop up the text file viewer to display a textfile with the given name, that's read from the given input stream. |
void |
shutdown()
Shutdown the MD3 Model Viewer application. |
protected void |
updateCurrentDataSource(java.lang.String name)
If the specified name starts with a "pak://" identifier, the data source will become PAK_FILE, otherwise it will become FILE_SYSTEM. |
void |
viewTexture(java.lang.String name,
java.lang.String loadFilename,
java.io.InputStream in)
Loads an texture from the given input stream and displays it in the viewer window. |
Methods inherited from class java.awt.Frame |
addNotify,
finalize,
getCursorType,
getFrames,
getIconImage,
getMenuBar,
getState,
getTitle,
isResizable,
paramString,
remove,
removeNotify,
setCursor,
setIconImage,
setMenuBar,
setResizable,
setState,
setTitle |
Methods inherited from class java.awt.Window |
addWindowListener,
applyResourceBundle,
applyResourceBundle,
dispose,
getFocusOwner,
getInputContext,
getLocale,
getOwnedWindows,
getOwner,
getToolkit,
getWarningString,
hide,
isShowing,
pack,
postEvent,
processEvent,
processWindowEvent,
removeWindowListener,
setCursor,
show,
toBack,
toFront |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getInsets,
getLayout,
getMaximumSize,
getMinimumSize,
getPreferredSize,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paint,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
remove,
remove,
removeAll,
removeContainerListener,
setFont,
setLayout,
update,
validate,
validateTree |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputMethodRequests,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getParent,
getPeer,
getSize,
getSize,
getTreeLock,
getWidth,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isFocusTraversable,
isLightweight,
isOpaque,
isValid,
isVisible,
keyDown,
keyUp,
list,
list,
list,
location,
lostFocus,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
prepareImage,
prepareImage,
printAll,
processComponentEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
size,
toString,
transferFocus |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected MD3GLCanvas md3canvas
The OpenGL canvas to render on.
Method Detail |
protected void updateCurrentDataSource(java.lang.String name)
If the specified name starts with a "pak://" identifier, the data source will become PAK_FILE, otherwise it will become FILE_SYSTEM.
protected java.lang.String showOpenDialog(java.lang.String fileMask)
Show the Open dialogbox and return the name of the selected file, once the dialog is dismissed.
fileMask
- The file selection mask to use (e.g. "*.md3").protected java.lang.String showSaveDialog(java.lang.String defaultFile)
Show the Save dialogbox and return the name of the selected file, once the dialog is dismissed.
defaultFile
- The default name of the file to save to.protected void showExceptionDialog(java.lang.String msg)
Pops up a message dialog with a specified Error message.
msg
- The error message that should be shown.protected void showSplashScreen()
Display the splash screen of the application.
protected void showTextViewer(java.lang.String name, java.io.InputStream textIn) throws java.io.IOException
Pop up the text file viewer to display a textfile with the given name, that's read from the given input stream.
protected java.lang.String searchForPath(java.lang.String relativePath, boolean allDataSources) throws java.io.FileNotFoundException
Clients can use this method to resolve a relative path to an absolute path in the context of the data sources (current open directory, open pak file) of the application.
If the file is found in a pak file, the resulting path will be prefixed with a "pak://" identifier.
If the relative path is actually absolute and denotes an existing file, it is returned as is.
relativePath
- Complete path of file, or relative to (a part of) the base
open path of the application or relative to (a part of) the
base pak file open path.allDataSources
- If true, all available data sources will be checked untill
a match is found. If false, only the current data source
is be checked.protected java.io.InputStream getInputStreamForPath(java.lang.String filename) throws java.io.IOException
Try to get an input stream for the specified path. The given filename should be absolute (use searchForPath()). If the filename starts with a "pak://" identifier, the file is taken to be in a pak file, otherwise is will be interpreted as a normal filename.
filename
- File to look for.public static MD3View instance()
Factory method that creates an MD3 Model Viewer Frame. It sets up the menu's and the OpenGL Canvas that is used to display the model. By default the window will be 640x480 pixels in size.
MD3View is a singleton class, so this will allways return the same instance!
public void shutdown()
Shutdown the MD3 Model Viewer application. This will do the necessary cleanup operations and exit the JVM.
public void openModel(java.lang.String name, java.io.InputStream in) throws java.io.IOException
Loads an MD3 model from the given input stream and displays it in the viewer window.
name
- Name of file from which model is supposedly loaded.in
- Stream from which to read data.public void closeModel()
Close the model currently displayed by the viewer.
public MD3Model attachModel(MD3Model to, int tag, java.lang.String childName, java.io.InputStream childIn) throws java.io.IOException
Attach a child model, read from the given input stream, to a parent model at the specified tag position of the parent model. Returns the attached child.
to
- Parent model to connect child to.tag
- Tag position of parent to connect child to.childName
- Name of file from which model is supposedly loaded.childIn
- Stream from which to read child model data.public void detachModel(MD3Model model)
Detach the given model from the model structure currently displayed by the viewer.
public void applySkin(java.lang.String name, java.io.InputStream in) throws java.io.IOException
Apply a skin to the model currently displayed by the viewer.
name
- Name of skin file from which data is supposedly loaded.in
- Stream from which to read data.public void applyTexture(java.lang.String name, java.lang.String loadFilename, java.io.InputStream in) throws java.io.IOException
Apply a texture to the model currently displayed by the viewer.
name
- Name of texture as specified in .skin or .md3 file.loadFilename
- Name of file from which texture is supposedly loaded.in
- Stream from which to read data.public void viewTexture(java.lang.String name, java.lang.String loadFilename, java.io.InputStream in) throws java.io.IOException
Loads an texture from the given input stream and displays it in the viewer window.
name
- Name of texture as specified in .skin or .md3 file.loadFilename
- Name of file from which texture is supposedly loaded.in
- Stream from which to read data.public static void main(java.lang.String[] args)
Starts the MD3 Viewer application. This creates an MD3View Frame and makes it visible.
The first command line argument, if present, will be intepreted as the name of an .md3 file that should be opened.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |