Remove current jAssimp port branch. Will be rewritten using SWIG, the previous attempt is unmaintainable.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@551 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2010-02-24 22:45:29 +00:00
parent 53100645a2
commit 11e666fb90
53 changed files with 0 additions and 8233 deletions

View File

@ -1 +0,0 @@
... it's under development, it doesn't work yet.

View File

@ -1,54 +0,0 @@
..................................................................................
README for jAssimp
..................................................................................
Last updated: May 2009
ABSTRACT
..................................................................................
jAssimp is a Java port of the full interface of the Open Asset Import Library.
It features almost everything and provides a Java interface that is quite
similar to the core C++ interface. However, some improvements on thread-safety
and type-safety were included. jAssimp doesn't provide any rendering
functionality. It loads 3d files and returns their data, but further processing
is left to the user. jAssimp has been developed and tested with JRE 1.6, but at
least JRE 1.5 should work fine as well.
Of course, using C++ components in Java applications is not really 'portable'.
However, you can achieve acceptable portability by building the native jAssimp
modules for all platforms you wish your application to run on. The Java Runtime
will always load the right module for the right platform.
CUSTOM BUILD
..................................................................................
In order to use jAssimp, you'll need to compile both the native Assimp library
and the Java bridge module (assimpjbridge) for all target platforms.
If you're using Visual Studio 2005 or 2008 (or any later version to be supported
in future releases), go to workspaces/vc8 (or vc9 or vc10, ..), open the solution
and compile both 'assimp' and 'assimpjbridge' as 'release-dll' (Win32 and/or x64).
Note that assimpjbridge doesn't work together with -noboost builds of the core Assimp
library, in other words you'll need boost for compiling. See the 'Installation
Page' of the C/C++ documentation for more information. it's not that difficult :-)
Makefile guys (either gcc or mingw) simply need to do a
... to be continued
...
NOTE: in order to compile assimpjbridge, 'JDK DIR' must point to your local copy of
the Java Development Kit.
TROUBLESHOOTING
..................................................................................
>> assimp.Importer keeps throwing assimp.NativeException.
The native library is probably not in the root directory of your application,
or it isn't compatible with your platform.

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jAssimp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,126 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* An animation consists of keyframe data for a number of bones. For each bone
* affected by the animation a separate series of data is given. There can be
* multiple animations in a single scene.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Animation {
/**
* Returns the name of the animation channel
*
* @return If the modeling package this data was exported from does support
* only a single animation channel, this name is usually
* <code>""</code>
*/
public final String getName() {
return name;
}
/**
* Returns the total duration of the animation, in ticks
*
* @return Total duration
*/
public final double getDuration() {
return mDuration;
}
/**
* Returns the ticks per second count.
*
* @return 0 if not specified in the imported file
*/
public final double getTicksPerSecond() {
return mTicksPerSecond;
}
/**
* Returns the number of bone animation channels
*
* @return This value is never 0
*/
public final int getNumNodeAnimChannels() {
assert (null != boneAnims);
return boneAnims.length;
}
/**
* Returns the list of all bone animation channels
*
* @return This value is never <code>null</code>
*/
public final NodeAnim[] getNodeAnimChannels() {
assert (null != boneAnims);
return boneAnims;
}
// --------------------------------------------------------------------------
// Private stuff
// --------------------------------------------------------------------------
/**
* The name of the animation.
*/
private String name = "";
/**
* Duration of the animation in ticks.
*/
private double mDuration = 0.0;
/**
* Ticks per second. 0 if not specified in the imported file
*/
private double mTicksPerSecond = 0.0;
/**
* Bone animation channels
*/
private NodeAnim[] boneAnims = null;
}

View File

@ -1,117 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* A bone belongs to a mesh stores a list of vertex weights. It represents a
* joint of the skeleton. The bone hierarchy is contained in the node graph.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Bone {
/**
* Represents a single vertex weight
*/
public class Weight {
public Weight() {
index = 0;
weight = 1.0f;
}
/**
* Index of the vertex in the corresponding <code>Mesh</code>
*/
public int index;
/**
* Weight of the vertex. All weights for a vertex sum up to 1.0
*/
public float weight;
}
/**
* Retrieves the name of the node
*
* @return Normally bones are never unnamed
*/
public final String getName() {
return name;
}
/**
* Returns a reference to the array of weights
*
* @return <code>Weight</code> array
*/
public final Weight[] getWeightsArray() {
assert (null != weights);
return weights;
}
/**
* Returns the number of bone weights.
*
* @return There should at least be one vertex weights (the validation step
* would complain otherwise)
*/
public final int getNumWeights() {
assert (null != weights);
return weights.length;
}
// --------------------------------------------------------------------------
// Private stuff
// --------------------------------------------------------------------------
/**
* Name of the bone
*/
private String name = "";
/**
* List of vertex weights for the bone
*/
private Weight[] weights = null;
}

View File

@ -1,191 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Describes a virtual camera in the scene.
*
* Cameras have a representation in the node graph and can be animated.
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public class Camera {
/**
* Get the screen aspect ratio of the camera
*
* This is the ration between the width and the height of the screen.
* Typical values are 4/3, 1/2 or 1/1. This value is 0 if the aspect ratio
* is not defined in the source file. 0 is also the default value.
*/
public final float GetAspect() {
return mAspect;
}
/**
* Get the distance of the far clipping plane from the camera.
*
* The far clipping plane must, of course, be farer away than the near
* clipping plane. The default value is 1000.f. The radio between the near
* and the far plane should not be too large (between 1000-10000 should be
* ok) to avoid floating-point inaccuracies which could lead to z-fighting.
*/
public final float GetFarClipPlane() {
return mClipPlaneFar;
}
/**
* Get the distance of the near clipping plane from the camera.
*
* The value may not be 0.f (for arithmetic reasons to prevent a division
* through zero). The default value is 0.1f.
*/
public final float GetNearClipPlane() {
return mClipPlaneNear;
}
/**
* Half horizontal field of view angle, in radians.
*
* The field of view angle is the angle between the center line of the
* screen and the left or right border. The default value is 1/4PI.
*/
public final float GetHorizontalFOV() {
return mHorizontalFOV;
}
/**
* Returns the 'LookAt' - vector of the camera coordinate system relative to
* the coordinate space defined by the corresponding node.
*
* This is the viewing direction of the user. The default value is 0|0|1.
* The vector may be normalized, but it needn't.
*
* @return component order: x,y,z
*/
public final float[] GetLookAt() {
return mLookAt;
}
/**
* Get the 'Up' - vector of the camera coordinate system relative to the
* coordinate space defined by the corresponding node.
*
* The 'right' vector of the camera coordinate system is the cross product
* of the up and lookAt vectors. The default value is 0|1|0. The vector may
* be normalized, but it needn't.
*
* @return component order: x,y,z
*/
public final float[] GetUp() {
return mUp;
}
/**
* Get the position of the camera relative to the coordinate space defined
* by the corresponding node.
*
* The default value is 0|0|0.
*
* @return component order: x,y,z
*/
public final float[] GetPosition() {
return mPosition;
}
/**
* Returns the name of the camera.
*
* There must be a node in the scene graph with the same name. This node
* specifies the position of the camera in the scene hierarchy and can be
* animated. The local transformation information of the camera is relative
* to the coordinate space defined by this node.
*/
public final String GetName() {
return mName;
}
// --------------------------------------------------------------------------
// Private stuff
// --------------------------------------------------------------------------
/**
* The name of the camera.
*/
private String mName;
/**
* Position of the camera
*/
private float[] mPosition;
/**
* 'Up' - vector of the camera coordinate system
*/
private float[] mUp;
/**
* 'LookAt' - vector of the camera coordinate system relative to
*/
private float[] mLookAt;
/**
* Half horizontal field of view angle, in radians.
*/
private float mHorizontalFOV;
/**
* Distance of the near clipping plane from the camera.
*/
private float mClipPlaneNear;
/**
* Distance of the far clipping plane from the camera.
*/
private float mClipPlaneFar;
/**
* Screen aspect ratio.
*/
private float mAspect;
};

View File

@ -1,175 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.ByteArrayInputStream;
/**
* Represents an embedded compressed texture typically stored in a format such
* as JPEG or PNG. See the documentation of <code>Texture</code> for more
* details on this class. Use <code>instanceof</code> to determine whether a
* particular <code>Texture</code> in the global texture array is actually
* compressed texture. Then downcast to <code>CompressedTexture</code>, extract
* the data and you're fine.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
* @see Texture
*/
public class CompressedTexture extends Texture {
/**
* Retrieves the format of the texture data. This is the most common file
* extension of the format. For example "jpg", "bmp", "tga", ...
*
* @return Extension string identifying the file format or alternatively
* <code>null</code> if Assimp has no further information on the
* format of the compressed data.
*/
public final String getFormat() {
return m_format;
}
/**
* Get a pointer to the data of the compressed texture
*
* @return Data buffer
*/
public final byte[] getData() {
return (byte[]) data;
}
/**
* Returns always 0 for compressed textures
*
* @return n/a
*/
@Override
public final int getHeight() {
return 0;
}
/**
* Returns always 0 for compressed textures
*
* @return n/a
*/
@Override
public final int getWidth() {
return 0;
}
/**
* Returns always <code>null</code> for compressed textures
*
* @return n/a
*/
@Override
public Color getPixel(int x, int y) {
return null;
}
/**
* Returns null for compressed textures
*
* @return n/a
*/
@Override
public final Color[] getColorArray() {
return null;
}
/**
* @return The return value is <code>true</code> of the file format can't be
* recognized.
* @see <code>Texture.hasAlphaChannel()</code>
*/
public boolean hasAlphaChannel() {
// try to determine it from the file format sequence
if (m_format.equals("bmp") || m_format.equals("dib"))
return false;
if (m_format.equals("tif") || m_format.equals("tiff"))
return false;
if (m_format.equals("jpg") || m_format.equals("jpeg"))
return false;
// TODO: add more
return true;
}
/**
* Convert the texture into a <code>java.awt.BufferedImage</code>
*
* @return A valid <code>java.awt.BufferedImage</code> object
* @throws IOException
* If the texture could not be uncompressed.
*/
public BufferedImage convertToImage() throws IOException {
BufferedImage img = null;
try {
// create an input stream and attach it to an image input stream
ImageInputStream stream = ImageIO
.createImageInputStream(new ByteArrayInputStream(
(byte[]) data));
// and use the stream to decode the file
img = ImageIO.read(stream);
} catch (IOException e) {
DefaultLogger.get().error("Failed to decode compressed texture");
throw e;
}
// return the created image to the caller
return img;
}
private String m_format = "";
}

View File

@ -1,513 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Defines all predefined configuration properties used by Assimp. The user can
* fine-tune these settings to optimize Assimp for a particular purpose. There
* are both global settings and settings referring to a post processing step or
* a particular import plugin.
*
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
* @see Importer#setProperty
*/
public class ConfigProperty {
private ConfigProperty() {
}
/**
* Enumerates components of the aiScene and aiMesh data structures that can
* be excluded from the import by using the
* <code>PostProcessing.RemoveComponent</code> step.
*
* See the documentation to <code>PostProcessing.RemoveComponent</code> for
* more details.
*
* @see PostProcessing#RemoveComponent
*/
public static final class Component {
/**
* Normal vectors
*/
public static final int NORMALS = 0x2;
/**
* Tangents and bitangents go always together ...
*/
public static final int TANGENTS_AND_BITANGENTS = 0x4;
/**
* ALL color sets Use aiComponent_COLORn(N) to specify the N'th set
*/
public static final int COLORS = 0x8;
/**
* ALL texture UV sets aiComponent_TEXCOORDn(N) to specify the N'th set
*/
public static final int TEXCOORDS = 0x10;
/**
* Removes all bone weights from all meshes. The scene graph nodes
* corresponding to the bones are NOT removed. use the
* #aiProcess_OptimizeGraph step to do this
*/
public static final int BONEWEIGHTS = 0x20;
/**
* Removes all node animations (aiScene::mAnimations). The scene graph
* nodes corresponding to the bones are NOT removed. use the
* #aiProcess_OptimizeGraph step to do this
*/
public static final int ANIMATIONS = 0x40;
/**
* Removes all embedded textures (aiScene::mTextures)
*/
public static final int TEXTURES = 0x80;
/**
* Removes all light sources (aiScene::mLights). The scenegraph nodes
* corresponding to the bones are NOT removed. use the
* #aiProcess_OptimizeGraph step to do this
*/
public static final int LIGHTS = 0x100;
/**
* Removes all light sources (aiScene::mCameras). The scenegraph nodes
* corresponding to the bones are NOT removed. use the
* #aiProcess_OptimizeGraph step to do this
*/
public static final int CAMERAS = 0x200;
/**
* Removes all meshes (aiScene::mMeshes).
*/
public static final int MESHES = 0x400;
/**
* Removes all materials. One default material will be generated, so
* aiScene::mNumMaterials will be 1.
*/
public static final int MATERIALS = 0x800;
// Remove a specific color channel 'n'
public static final int COLORSn(int n) {
return (1 << (n + 20));
}
// Remove a specific UV channel 'n'
public static final int TEXCOORDSn(int n) {
return (1 << (n + 25));
}
};
/**
* Dummy base for all predefined configuration keys.
*/
public static class Any<Type> {
public Any(String str) {
name = str;
}
String name;
}
/**
* Specifies the maximum angle that may be between two vertex tangents that
* their tangents and bitangents are smoothed.
*
* This applies to the CalcTangentSpace-Step. The angle is specified in
* degrees, so 180 is PI. The default value is 45 degrees. The maximum value
* is 175. Property type: float.
*/
public static final Any<Float> PP_CT_MAX_SMOOTHING_ANGLE = new Any<Float>(
"PP_CT_MAX_SMOOTHING_ANGLE");
/**
* Specifies the maximum angle that may be between two face normals at the
* same vertex position that their are smoothed together.
*
* Sometimes referred to as 'crease angle'. This applies to the
* GenSmoothNormals-Step. The angle is specified in degrees, so 180 is PI.
* The default value is 175 degrees (all vertex normals are smoothed). The
* maximum value is 175, too. Property type: float. Warning: setting this
* option may cause a severe loss of performance. The performance is
* unaffected if the #AI_CONFIG_FAVOUR_SPEED flag is set but the output
* quality may be reduced.
*/
public static final Any<Float> PP_GSN_MAX_SMOOTHING_ANGLE = new Any<Float>(
"PP_GSN_MAX_SMOOTHING_ANGLE");
/**
* Configures the #aiProcess_RemoveRedundantMaterials step to keep materials
* matching a name in a given list.
*
* This is a list of 1 to n strings, ' ' serves as delimiter character.
* Identifiers containing whitespaces must be enclosed in *single* quotation
* marks. For example:<tt>
* "keep-me and_me_to anotherMaterialToBeKept = new Any<Float>('name with whitespace= new Any<Float>('"</tt>
* . If a material matches on of these names, it will not be modified or
* removed by the postprocessing step nor will other materials be replaced
* by a reference to it. <br>
* This option might be useful if you are using some magic material names to
* pass additional semantics through the content pipeline. This ensures they
* won't be optimized away, but a general optimization is still performed
* for materials not contained in the list. Property type: String. Default
* value: n/a
*
* @note Linefeeds, tabs or carriage returns are treated as whitespace.
* Material names are case sensitive.
*/
public static final Any<Float> PP_RRM_EXCLUDE_LIST = new Any<Float>(
"PP_RRM_EXCLUDE_LIST");
/**
* Configures the #aiProcess_PretransformVertices step to keep the scene
* hierarchy. Meshes are moved to worldspace, but no optimization is
* performed (means: meshes are not joined. The total number of meshes won't
* change).
*
* This option could be of use for you if the scene hierarchy contains
* important additional information which you want to interpret. For
* rendering, you can still render all meshes in the scene without any
* transformations. Property type: integer (0: false; !0: true). Default
* value: false.
*/
public static final Any<Float> PP_PTV_KEEP_HIERARCHY = new Any<Float>(
"PP_PTV_KEEP_HIERARCHY");
/**
* Configures the #aiProcess_FindDegenerates step to remove degenerated
* primitives from the import - immediately.
*
* The default behaviour converts degenerated triangles to lines and
* degenerated lines to points. See the documentation to the
* #aiProcess_FindDegenerates step for a detailed example of the various
* ways to get rid of these lines and points if you don't want them.
* Property type: integer (0: false; !0: true). Default value: false.
*/
public static final Any<Float> PP_FD_REMOVE = new Any<Float>("PP_FD_REMOVE");
/**
* Configures the #aiProcess_OptimizeGraph step to preserve nodes matching a
* name in a given list.
*
* This is a list of 1 to n strings, ' ' serves as delimiter character.
* Identifiers containing whitespaces must be enclosed in *single* quotation
* marks. For example:<tt>
* "keep-me and_me_to anotherNodeToBeKept = new Any<Float>('name with whitespace= new Any<Float>('"</tt>
* . If a node matches on of these names, it will not be modified or removed
* by the postprocessing step.<br>
* This option might be useful if you are using some magic node names to
* pass additional semantics through the content pipeline. This ensures they
* won't be optimized away, but a general optimization is still performed
* for nodes not contained in the list. Property type: String. Default
* value: n/a
*
* @note Linefeeds, tabs or carriage returns are treated as whitespace. Node
* names are case sensitive.
*/
public static final Any<Float> PP_OG_EXCLUDE_LIST = new Any<Float>(
"PP_OG_EXCLUDE_LIST");
/**
* Set the maximum number of vertices in a mesh.
*
* This is used by the "SplitLargeMeshes" PostProcess-Step to determine
* whether a mesh must be split or not.
*
* @note The default value is AI_SLM_DEFAULT_MAX_VERTICES Property type:
* integer.
*/
public static final Any<Float> PP_SLM_TRIANGLE_LIMIT = new Any<Float>(
"PP_SLM_TRIANGLE_LIMIT");
/**
* Set the maximum number of triangles in a mesh.
*
* This is used by the "SplitLargeMeshes" PostProcess-Step to determine
* whether a mesh must be split or not.
*
* @note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES Property type:
* integer.
*/
public static final Any<Float> PP_SLM_VERTEX_LIMIT = new Any<Float>(
"PP_SLM_VERTEX_LIMIT");
/**
* Set the maximum number of bones affecting a single vertex
*
* This is used by the #aiProcess_LimitBoneWeights PostProcess-Step.
*
* @note The default value is AI_LBW_MAX_WEIGHTS Property type: integer.
*/
public static final Any<Float> PP_LBW_MAX_WEIGHTS = new Any<Float>(
"PP_LBW_MAX_WEIGHTS");
/**
* Set the size of the post-transform vertex cache to optimize the vertices
* for. This configures the #aiProcess_ImproveCacheLocality step.
*
* The size is given in vertices. Of course you can't know how the vertex
* format will exactly look like after the import returns, but you can still
* guess what your meshes will probably have.
*
* @note The default value is #PP_ICL_PTCACHE_SIZE. That results in slight
* performance improvements for most nVidia/AMD cards since 2002.
* Property type: integer.
*/
public static final Any<Float> PP_ICL_PTCACHE_SIZE = new Any<Float>(
"PP_ICL_PTCACHE_SIZE");
/**
* Input parameter to the #aiProcess_RemoveComponent step: Specifies the
* parts of the data structure to be removed.
*
* See the documentation to this step for further details. The property is
* expected to be an integer, a bitwise combination of the #aiComponent
* flags defined above in this header. The default value is 0. Important: if
* no valid mesh is remaining after the step has been executed (e.g you
* thought it was funny to specify ALL of the flags defined above) the
* import FAILS. Mainly because there is no data to work on anymore ...
*/
public static final Any<Float> PP_RVC_FLAGS = new Any<Float>("PP_RVC_FLAGS");
/**
* Input parameter to the #aiProcess_SortByPType step: Specifies which
* primitive types are removed by the step.
*
* This is a bitwise combination of the aiPrimitiveType flags. Specifying
* all of them is illegal, of course. A typical use would be to exclude all
* line and point meshes from the import. This is an integer property, its
* default value is 0.
*/
public static final Any<Float> PP_SBP_REMOVE = new Any<Float>(
"PP_SBP_REMOVE");
/**
* A hint to Assimp to favor speed against import quality.
*
* Enabling this option may result in faster loading, but it needn't. It
* represents just a hint to loaders and post-processing steps to use faster
* code paths, if possible. This property is expected to be an integer, != 0
* stands for true. The default value is 0.
*/
public static final Any<Float> FAVOUR_SPEED = new Any<Float>("FAVOUR_SPEED");
/**
* Set the vertex animation keyframe to be imported
*
* ASSIMP does not support vertex keyframes (only bone animation is
* supported). The library reads only one frame of models with vertex
* animations. By default this is the first frame. = new Any<Float>(note The
* default value is 0. This option applies to all importers. However, it is
* also possible to override the global setting for a specific loader. You
* can use the IMPORT_XXX_KEYFRAME options (where XXX is a placeholder for
* the file format for which you want to override the global setting).
* Property type: integer.
*/
public static final Any<Integer> IMPORT_GLOBAL_KEYFRAME = new Any<Integer>(
"IMPORT_GLOBAL_KEYFRAME");
public static final Any<Integer> IMPORT_MD3_KEYFRAME = new Any<Integer>(
"IMPORT_MD3_KEYFRAME");
public static final Any<Integer> IMPORT_MD2_KEYFRAME = new Any<Integer>(
"IMPORT_MD2_KEYFRAME");
public static final Any<Integer> IMPORT_MDL_KEYFRAME = new Any<Integer>(
"IMPORT_MDL_KEYFRAME");
public static final Any<Integer> IMPORT_MDC_KEYFRAME = new Any<Integer>(
"IMPORT_MDC_KEYFRAME");
public static final Any<Integer> IMPORT_SMD_KEYFRAME = new Any<Integer>(
"IMPORT_SMD_KEYFRAME");
public static final Any<Integer> IMPORT_UNREAL_KEYFRAME = new Any<Integer>(
"IMPORT_UNREAL_KEYFRAME");
/**
* Configures the AC loader to collect all surfaces which have the
* "Backface cull" flag set in separate meshes.
*
* Property type: integer (0: false; !0: true). Default value: true.
*/
public static final Any<Float> IMPORT_AC_SEPARATE_BFCULL = new Any<Float>(
"IMPORT_AC_SEPARATE_BFCULL");
/**
* Configures the UNREAL 3D loader to separate faces with different surface
* flags (e.g. two-sided vs. single-sided).
*
* Property type: integer (0: false; !0: true). Default value: true.
*/
public static final Any<Float> IMPORT_UNREAL_HANDLE_FLAGS = new Any<Float>(
"UNREAL_HANDLE_FLAGS");
/**
* Configures the terragen import plugin to compute uv's for terrains, if
* not given. Furthermore a default texture is assigned.
*
* UV coordinates for terrains are so simple to compute that you'll usually
* want to compute them on your own, if you need them. This option is
* intended for model viewers which want to offer an easy way to apply
* textures to terrains. Property type: integer (0: false; !0: true).
* Default value: false.
*/
public static final Any<Float> IMPORT_TER_MAKE_UVS = new Any<Float>(
"IMPORT_TER_MAKE_UVS");
/**
* Configures the ASE loader to always reconstruct normal vectors basing on
* the smoothing groups loaded from the file.
*
* Many ASE files have invalid normals (they're not orthonormal). Property
* type: integer (0: false; !0: true). Default value: true.
*/
public static final Any<Float> IMPORT_ASE_RECONSTRUCT_NORMALS = new Any<Float>(
"IMPORT_ASE_RECONSTRUCT_NORMALS");
/**
* Configures the M3D loader to process multi-part player models.
*
* These models usually consist of 3 files, lower.md3, upper.md3 and
* head.md3. If this property is set to true, Assimp will try to load and
* combine all three files if one of them is loaded. Property type: integer
* (0: false; !0: true). Default value: true.
*/
public static final Any<Float> IMPORT_MD3_HANDLE_MULTIPART = new Any<Float>(
"IMPORT_MD3_HANDLE_MULTIPART");
/**
* Tells the MD3 loader which skin files to load.
*
* When loading MD3 files, Assimp checks whether a file
* <md3_file_name>_<skin_name>.skin is existing. These files are used by
* Quake III to be able to assign different skins (e.g. red and blue team)
* to models. 'default', 'red', 'blue' are typical skin names. Property
* type: String. Default value: "default".
*/
public static final Any<Float> IMPORT_MD3_SKIN_NAME = new Any<Float>(
"IMPORT_MD3_SKIN_NAME");
/**
* Specify the Quake 3 shader file to be used for a particular MD3 file.
* This can also be a search path.
*
* By default Assimp's behaviour is as follows: If a MD3 file
* <tt><any_path>/models/<any_q3_subdir>/<model_name>/<file_name>.md3</tt>
* is loaded, the library tries to locate the corresponding shader file in
* <tt><any_path>/scripts/<model_name>.shader</tt>. This property overrides
* this behaviour. It can either specify a full path to the shader to be
* loaded or alternatively the path (relative or absolute) to the directory
* where the shaders for all MD3s to be loaded reside. Assimp attempts to
* open <tt><dir>/<model_name>.shader</tt> first,
* <tt><dir>/<file_name>.shader</tt> is the fallback file. Note that <dir>
* should have a terminal (back)slash. Property type: String. Default value:
* n/a.
*/
public static final Any<Float> IMPORT_MD3_SHADER_SRC = new Any<Float>(
"IMPORT_MD3_SHADER_SRC");
/**
* Configures the LWO loader to load just a single layer from the file.
*
* LWO files consist of layers which are completely separate from each
* other. Each layer has a zero-based index. If this property is set, only
* layers with that particular index are loaded.
*/
public static final Any<Integer> IMPORT_LWO_LAYER_INDEX = new Any<Integer>(
"IMPORT_LWO_ONE_LAYER_ONLY");
/**
* Configures the MD5 loader to not load the MD5ANIM file for a MD5MESH file
* automatically.
*
* The default strategy is to look for a file with the same name but the
* MD5ANIM extension in the same directory. If it is found, it is loaded and
* combined with the MD5MESH file. This configuration option can be used to
* disable this behaviour. This is a boolean property, != 0 is
* <code>true</code>.
*/
public static final Any<Float> IMPORT_MD5_NO_ANIM_AUTOLOAD = new Any<Float>(
"IMPORT_MD5_NO_ANIM_AUTOLOAD");
/**
* Defines the begin/end of the animation time range for the LWS loader.
*
* Assimp provides full conversion of LightWave's envelope system, including
* proper handling of LightWave's pre and post conditions. The loader
* computes linearly subsampled animation chanels with the frame rate given
* in the LWS file. This property defines the start time. Note: animation
* channels are only generated if a node has at least one envelope with more
* tan one key assigned. This property is given in frames, '0' is the first
* frame. By default the importer takes the animation start from the input
* LWS file ('FirstFrame' line)<br>
*
* @see IMPORT_LWS_ANIM_END - end of the imported time range
*/
public static final Any<Float> IMPORT_LWS_ANIM_START = new Any<Float>(
"IMPORT_LWS_ANIM_START");
public static final Any<Float> IMPORT_LWS_ANIM_END = new Any<Float>(
"IMPORT_LWS_ANIM_END");
/**
* Defines the output frame rate of the IRR loader.
*
* IRR animations are difficult to convert for Assimp and there will always
* be a loss of quality. This setting defines how many keys per second are
* returned by the converter.
*/
public static final Any<Integer> IMPORT_IRR_ANIM_FPS = new Any<Integer>(
"IMPORT_IRR_ANIM_FPS");
/**
* Sets the colormap (= palette) to be used to decode embedded textures in
* MDL (Quake or 3DGS) files.
*
* This must be a valid path to a file. The file is 768 (256*3) bytes large
* and contains RGB triplets for each of the 256 palette entries. The
* default value is 'colormap.lmp'. If the file is not found, a default
* palette (suitable for Quake 1) is used.
*/
public static final Any<String> IMPORT_MDL_COLORMAP = new Any<String>(
"IMPORT_MDL_COLORMAP");
};

View File

@ -1,406 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
import java.util.Vector;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
/**
* Default implementation of a logger. When writing to the log,
* jASSIMP uses the <code>Logger</code> instance returned by
* <code>DefaultLogger.get()</code>
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public class DefaultLogger implements Logger {
/**
* Helper class to combine a log stream with an error severity
*/
private static class LogStreamInfo {
public LogStream stream;
public int severity;
public LogStreamInfo(LogStream stream, int severity) {
this.stream = stream;
this.severity = severity;
}
}
/**
* NULL logger class. Does nothing ...
*/
private static class NullLogger implements Logger {
public void debug(String message) {
} // nothing to do here ...
public void error(String message) {
} // nothing to do here ...
public void warn(String message) {
} // nothing to do here ...
public void info(String message) {
} // nothing to do here ...
public void attachStream(LogStream stream, int severity) {
} // nothing to do here ...
public void detachStream(LogStream stream, int severity) {
} // nothing to do here ...
}
/**
* Implementation of LogStream that can be used to use a
* <code>java.io.OutputStream</code> object directly as log stream.
*/
public static class StreamWrapper implements LogStream {
private OutputStream stream;
/**
* Construction from an existing <code>java.io.OutputStream</code> object
*
* @param stream May not be null
*/
public StreamWrapper(OutputStream stream) {
assert(null != stream);
this.stream = stream;
}
public void write(String message) {
try {
stream.write(message.getBytes(), 0, message.length());
} catch (IOException e) {
// .... should't care
}
}
public OutputStream getStream() {
return stream;
}
}
/**
* Implementation of LogStream that can be used to use a
* <code>java.io.FileWriter</code> object directly as log stream.
*/
public static class FileStreamWrapper implements LogStream {
private FileWriter stream;
/**
* Construction from an existing <code>java.io.FileWriter</code> object
*
* @param stream May not be null
*/
public FileStreamWrapper(FileWriter stream) {
assert(null != stream);
this.stream = stream;
}
public void write(String message) {
try {
stream.write(message);
} catch (IOException e) {
// .... should't care
}
}
public FileWriter getStream() {
return stream;
}
}
/**
* Normal granularity of logging
*/
public static final int LOGSEVERITY_NORMAL = 0x0;
/**
* Debug info will be logged, too
*/
public static final int LOGSEVERITY_VERBOSE = 0x1;
/**
* Default logger. It does nothing and is used if the
* application hasn't allocated a default logger
*/
private static NullLogger s_nullLogger = new NullLogger();
/**
* The logger that is used by ASSIMP for logging
*/
private static Logger s_logger = s_nullLogger;
/**
* List of logstreams to output to
*/
private Vector<LogStreamInfo> m_avStreams;
/**
* One of the LOGSEVERITY_XXX constants.
*/
@SuppressWarnings("unused")
private int m_iLogSeverity = LOGSEVERITY_NORMAL;
private DefaultLogger() {
}
/**
* Create the default logger
*
* @param file Output log file. If != <code>null</code> this will
* automatically add a file log stream to the logger
* @param bErrOut If this is true an additional logstream which
* outputs all log messages via <code>System.err.println()</code>
* will be added to the logger.
*/
public static void create(String file, boolean bErrOut) throws IOException {
s_logger = new DefaultLogger();
if (null != file) {
FileWriter stream = new FileWriter(file);
s_logger.attachStream(new FileStreamWrapper(stream), 0);
}
if (bErrOut) {
s_logger.attachStream(new StreamWrapper(System.err), 0);
}
}
/**
* Create the default logger, no default log streams will be
* attached to it.
*/
public static void create() throws IOException {
create(null, false);
}
/**
* Supply your own implementation of <code>Logger</code> to the
* logging system. Use this if you want to override the default
* formatting behavior of <code>DefaultLogger</code>. You can
* access your logger as normal, via <code>get()</code>.
*
* @param logger
*/
public static void set(Logger logger) {
s_logger = logger;
}
/**
* Kill the logger ... a null logger will be used instead
*/
public static void kill() {
s_logger = s_nullLogger;
}
/**
* Get access to the Singleton instance of the logger. This will
* never be null. If no logger has been explicitly created via
* <code>create()</code> this is a <code>NULLLogger</code> instance.
* Use <code>isNullLogger()</code> to check whether the returned logger
* is a null logger.
*
* @return Never null ...
*/
public static Logger get() {
return s_logger;
}
/**
* Check whether the current logger is a null logger, which
* doesn't log anything. Use <code>create()</code> or <code>set()</code>
* to setup another logger.
*
* @return true if the curent logger is a null logger (true by default)
*/
public static boolean isNullLogger() {
return (s_logger instanceof NullLogger);
}
/**
* Write a debug message to the log
*
* @param message Message to be logged
*/
public void debug(String message) {
this.writeToStreams("Debug:" + message + "\n", ERRORSEVERITY_DEBUGGING);
}
/**
* Write an error message to the log
*
* @param message Message to be logged
*/
public void error(String message) {
this.writeToStreams("Debug:" + message + "\n", ERRORSEVERITY_ERR);
}
/**
* Write a warning message to the log
*
* @param message Message to be logged
*/
public void warn(String message) {
this.writeToStreams("Debug:" + message + "\n", ERRORSEVERITY_WARN);
}
/**
* Write an information message to the log
*
* @param message Message to be logged
*/
public void info(String message) {
this.writeToStreams("Debug:" + message + "\n", ERRORSEVERITY_INFO);
}
/**
* Attach a log stream to the logger
*
* @param stream Log stream instance
* @param severity Error severity. Bitwise combination of the
* ERRORSEVERITY_XXX constants. Specify 0 to attach the
* stream to all types of log messages.
*/
public void attachStream(LogStream stream, int severity) {
if (0 == severity) {
severity = ERRORSEVERITY_DEBUGGING | ERRORSEVERITY_WARN |
ERRORSEVERITY_ERR | ERRORSEVERITY_INFO;
}
for (LogStreamInfo info : this.m_avStreams) {
if (info.stream != stream) continue;
info.severity |= severity;
severity = 0xcdcdcdcd;
}
if (0xcdcdcdcd != severity)
this.m_avStreams.add(new LogStreamInfo(stream, severity));
}
/**
* Detach a log stream from the logger
*
* @param stream Log stream instance
* @param severity Error severities to detach the stream from.
* Bitwise combination of the ERRORSEVERITY_XXX constants.
* Specify 0 to detach the stream from all types of log messages.
*/
public void detachStream(LogStream stream, int severity) {
if (0 == severity) {
severity = ERRORSEVERITY_DEBUGGING | ERRORSEVERITY_WARN |
ERRORSEVERITY_ERR | ERRORSEVERITY_INFO;
}
for (LogStreamInfo info : this.m_avStreams) {
if (info.stream != stream) continue;
if (0 != (severity & ERRORSEVERITY_DEBUGGING)) {
info.severity &= (~ERRORSEVERITY_DEBUGGING);
}
if (0 != (severity & ERRORSEVERITY_ERR)) {
info.severity &= (~ERRORSEVERITY_ERR);
}
if (0 != (severity & ERRORSEVERITY_INFO)) {
info.severity &= (~ERRORSEVERITY_INFO);
}
if (0 != (severity & ERRORSEVERITY_WARN)) {
info.severity &= (~ERRORSEVERITY_WARN);
}
if (0 == info.severity) {
this.m_avStreams.remove(info);
}
break;
}
}
private void writeToStreams(String message, int severity) {
for (LogStreamInfo info : this.m_avStreams) {
if (0 == (info.severity & severity)) continue;
info.stream.write(message);
}
}
// Helpers to make access to the logging system easier for native code
public static void _NativeCallWriteError(String message) {
DefaultLogger.get().error(message);
}
public static void _NativeCallWriteWarn(String message) {
DefaultLogger.get().warn(message);
}
public static void _NativeCallWriteInfo(String message) {
DefaultLogger.get().info(message);
}
public static void _NativeCallWriteDebug(String message) {
DefaultLogger.get().debug(message);
}
}

View File

@ -1,106 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2009, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Represents a single face of a mesh. Faces a generally simple polygons and
* store n indices into the vertex streams of the mesh they belong to.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Face {
/**
* Different types of faces.
*
* Faces of different primitive types can occur in a single mesh. To get
* homogeneous meshes, try the <code>PostProcessing.SortByPType</code> flag.
*
* @see Mesh.mPrimitiveTypes
* @see PostProcessing#SortByPType
*/
public static class Type {
/**
* This is just a single vertex in the virtual world. #aiFace contains
* just one index for such a primitive.
*/
public static final int POINT = 0x1;
/**
* This is a line defined by start and end position. Surprise, Face
* defines two indices for a line.
*/
public static final int LINE = 0x2;
/**
* A triangle, probably the only kind of primitive you wish to handle. 3
* indices.
*/
public static final int TRIANGLE = 0x4;
/**
* A simple, non-intersecting polygon defined by n points (n > 3). Can
* be concave or convex. Use the <code>PostProcessing.Triangulate</code>
* flag to have all polygons triangulated.
*
* @see PostProcessing.Triangulate
*/
public static final int POLYGON = 0x8;
}
/**
* Get the indices of the face
*
* @return Array of n indices into the vertices of the father mesh. The
* return value is *never* <code>null</code>
*/
public int[] getIndices() {
assert(null != indices);
return indices;
}
/**
* Indices of the face
*/
private int[] indices;
}

View File

@ -1,13 +0,0 @@
package assimp;
/**
* Represents a s
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public interface IOStream {
}

View File

@ -1,71 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
import java.io.FileNotFoundException;
/**
*
*/
public interface IOSystem {
/**
* Called to check whether a file is existing
*
* @param file
* Filename
* @return true if the file is existing and accessible
*/
boolean Exists(String file);
/**
* Open a file and return an <code> IOStream </code> interface to access it.
*
* @param file
* File name of the file to be opened
* @return A valid IOStream interface
* @throws FileNotFoundException
* if the file can't be accessed
*/
IOStream Open(String file) throws FileNotFoundException;
}

View File

@ -1,562 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
import java.util.Vector;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.File;
/**
* Main class of jAssimp. Just a simple wrapper around the native Assimp API
* (Assimp::Importer).
*
* The java port exposes the full functionality of the library but differs in
* some documented details. In order to use Assimp from multiple threads, each
* thread should maintain its own <code>Importer</code> instance.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Importer {
/**
* Indicates that a requested property has not yet a defined value
*/
public static final int PROPERTY_WAS_NOT_EXISTING = 0xffffffff;
/**
* Current interface version. Increment this if a change on one side of the
* language bridge will also require to change the other.
*/
public static final int ABI_VERSION = 1;
/**
* Public constructor. Initializes the JNI bridge to the native Assimp
* library. The post processing flag list is set to zero and a default I/O
* handler is prepared for use.
*
* @throws NativeException
* Thrown if the required native jAssimp library could not be
* located and mapped into address space. If the c'tor succeeds
* with no exception, you can safely assume that jAssimp is
* fully available for use.
*/
public Importer() throws NativeException {
this(ABI_VERSION);
}
/**
* Get the I/O system (<code>IOSystem</code>) to be used for loading assets.
* If no custom implementation was provided via <code>setIoSystem()</code> a
* default implementation will be used. Use <code>isDefaultIoSystem()</code>
* to check this.
*
* @return Always a valid <code>IOSystem</code> object, never null.
*/
public final IOSystem getIoSystem() {
return ioSystem;
}
/**
* Checks whether a default IO system is currently being used to load
* assets. Using the default IO system has many performance benefits, but it
* is possible to provide a custom IO system (<code>setIoSystem()</code>).
* This allows applications to add support for archives like ZIP.
*
* @return true if a default <code>IOSystem</code> is active,
*/
public final boolean isDefaultIoSystem() {
return ioSystem instanceof DefaultIOSystem;
}
/**
* Load a model from a file using the current list of post processing steps
* and the current I/O handler. If no custom I/O handler was provided a
* default implementation is used. This implementation uses basic OS file
* handling and provides no support for direct reading from archives
* formats, such as ZIP or PAK.
*
* @param path
* Path to the file to be read
* @param flags
* List of post processing steps to be applied. Any values from
* the <code>PostProcessing</code> 'enum', or'ed together.
* @return <code>null</code> if the import failed, otherwise a valid
* <code>Scene</code> instance. The <code>Importer</code> keeps a
* reference to it, use <code>getScene()</code> to query it.
* @throws NativeException
* Thrown if an unknown error occurs somewhere in the magic JNI
* bridge module.
*/
public final Scene readFile(String path, long flags) throws NativeException {
this.scene = new Scene(this);
this.path = path;
// now load the scene and hope and pray for success
if (0xffffffff == this._NativeLoad(this.path, flags,
this.m_iNativeHandle)) {
this.scene = null;
this.path = null;
throw new NativeException("Failed to load the scene");
}
if (null == this.scene) {
throw new NativeException("Failed to transfer the scene data to VM");
}
return this.scene;
}
/**
* Get the current scene or <code>null</code> if none is loaded
*
* @return Current scene. The Importer keeps a permanent reference to it
* until it is replaced by a new scene. Nevertheless you may access
* if even after the Importer has been finalized.
*/
public final Scene getScene() {
return scene;
}
/**
* Get the source path of the current scene or <code>null</code> if none is
* in a loaded state.
*
* @return Game Over.
*/
public final String getScenePath() {
return path;
}
/**
* Implementation of <code>java.lang.Object.equals()</code>
*
* @param o
* Object to be compared with *this*
* @return true if *this* is equal to o
*/
public final boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
final Importer importer = (Importer) o;
// comparing native handles is unique
return m_iNativeHandle == importer.m_iNativeHandle;
}
/**
* Implementation of <code>java.lang.Object.finalize()</code> We override
* this to make sure that all native resources are deleted properly. This
* will free the native Assimp::Importer object and its associated aiScene
* instance. A NativeException is thrown if the destruction fails. This can
* mean that not all resources have been deallocated and memory leaks are
* remaining but it will not affect the stability of the VM (hopefully).
*/
@Override
protected void finalize() throws Throwable {
super.finalize();
// be sure that native resources are deallocated properly
if (0xffffffff == _NativeFreeContext(this.m_iNativeHandle)) {
throw new NativeException(
"Unable to destroy the native library context");
}
}
/**
* Implementation of <code>java.lang.Object.hashCode()</code>
* <p/>
* The native handle obtained from the JNI bridge is used as hash code. It
* is always unique.
*
* @return An unique value representing the object
*/
@Override
public int hashCode() {
return (int) (m_iNativeHandle >> 32) ^ (int) (m_iNativeHandle);
}
/**
* Set an integer property. All supported configuration properties are
* defined as constants in the <code>ConfigProperty</code> class
*
* @param prop
* Name of the configuration property
* @param val
* New value for the configuration property
*/
public final void setPropertyInt(final String prop, int val) {
this.properties.setProperty(prop, val);
this._NativeSetPropertyInt(prop, val, this.getContext());
}
/**
* Set a floating-point property. All supported import properties are
* defined as constants in the <code>ConfigProperty</code> class
*
* @param prop
* Name of the configuration property
* @param val
* New value for the configuration property
*/
public final void setPropertyFloat(final String prop, float val) {
this.propertiesFloat.setProperty(prop, val);
this._NativeSetPropertyFloat(prop, val, this.getContext());
}
/**
* Set a string property. All supported import properties are defined as
* constants in the <code>ConfigProperty</code> class
*
* @param prop
* Name of the configuration property
* @param val
* New value for the configuration property
*/
public final void setPropertyString(final String prop, String val) {
this.propertiesString.setProperty(prop, val);
this._NativeSetPropertyString(prop, val, this.getContext());
}
/**
* Gets an integer configuration property that has been set using
* <code>setPropertyInt</code>. All supported import properties are defined
* as constants in the <code>ConfigProperty</code> class
*
* @param prop
* Name of the configuration property
* @param error_return
* Default return value if the property isn't there
* @return Current value of the configuration property or error_return if
* the property has not yet been set
*/
public final int getPropertyInt(final String prop, int error_return) {
Integer i = this.properties.getProperty(prop);
return i != null ? i : error_return;
}
/**
* Gets a floating-point configuration property that has been set using
* <code>setPropertyFloat</code>. All supported import properties are
* defined as constants in the <code>ConfigProperty</code> class
*
* @see <code>getPropertyInt</code>
*/
public final float getPropertyFloat(final String prop, float error_return) {
Float i = this.propertiesFloat.getProperty(prop);
return i != null ? i : error_return;
}
/**
* Gets a string configuration property that has been set using
* <code>setPropertyString</code>. All supported import properties are
* defined as constants in the <code>ConfigProperty</code> class
*
* @see <code>getPropertyInt</code>
*/
public final String getPropertyString(final String prop, String error_return) {
String i = this.propertiesString.getProperty(prop);
return i != null ? i : error_return;
}
/**
* Gets an integer configuration property that has been set using
* <code>setPropertyInt</code>. All supported import properties are defined
* as constants in the <code>ConfigProperty</code> class
*
* @param prop
* Name of the configuration property
* @return Current of the property or <code>PROPERTY_WAS_NOT_EXISTING</code>
* if the property has not yet been set.
*/
public final int getPropertyInt(final String prop) {
return getPropertyInt(prop, PROPERTY_WAS_NOT_EXISTING);
}
/**
* Retrieves the native context of the class. This is normally the address
* of the native Importer object.
*
* @return Native context
*/
public final long getContext() {
return m_iNativeHandle;
}
/**
* Represents a property (key-value)
*/
private class Property<Type> {
String key;
Type value;
}
/**
* Represents a property list. This exposes Assimp's configuration interface
* from Java.
*/
private class PropertyList<Type> extends Vector<Property<Type>> {
/**
*
*/
private static final long serialVersionUID = -990406536792129089L;
public void setProperty(final String prop, final Type val) {
for (Property<Type> i : this) {
if (i.key.equals(prop)) {
i.value = val;
return;
}
}
Property<Type> propNew = new Property<Type>();
propNew.key = prop;
propNew.value = val;
this.add(propNew);
}
public Type getProperty(final String prop) {
for (Property<Type> i : this) {
if (i.key.equals(prop)) {
return i.value;
}
}
return null;
}
}
/**
* Default implementation of <code>IOStream</code>. <br>
* This might become a performance bottleneck: The application needs to map
* the data read via this interface into a C-style array. For every single
* read operation! Therefore it's a good optimization to use the default C
* IOStream handler if no custom java handler was specified. Assuming that
* the Java Runtime is using the fXXX-family of functions internally too,
* the result should be the same.
*/
private class DefaultIOStream implements IOStream {
@SuppressWarnings("unused")
private FileReader reader = null;
/**
* Construction from a given path
*
* @param file
* Path to the file to be opened
* @throws FileNotFoundException
* If the file isn't accessible at all
*/
public DefaultIOStream(final String file) throws FileNotFoundException {
reader = new FileReader(file);
}
}
/**
* Default implementation of <code>IOSystem</code>.
*
* Again, we're assuming that the Java runtime accesses the file system
* similar to our own native default implementation. This allows this piece
* of code to reside in Java.
*/
private class DefaultIOSystem implements IOSystem {
/**
* Called to check whether a file is existing
*
* @param file
* Filename
* @return true if the file is existing and accessible
*/
public boolean Exists(String file) {
File f = new File(file);
return f.exists();
}
/**
* Open a file and return an <code> IOStream </code> interface to access
* it.
*
* @param file
* File name of the file to be opened
* @return A valid IOStream interface
* @throws FileNotFoundException
* if the file can't be accessed
*/
public IOStream Open(String file) throws FileNotFoundException {
return new DefaultIOStream(file);
}
}
/**
* Unique number to identify the internal Assimp::Importer object which
* belongs to a Java Importer. This value is opaque and may not be changed
* from within Java.
*/
private long m_iNativeHandle = 0xffffffffffffffffl;
/**
* Loaded scene. It is - unlike in native Assimp - not bound to its father
* Importer.
*/
private Scene scene = null;
/**
* Path to the scene to be loaded
*/
private String path = null;
/**
* I/O system to be used for importing
*/
private IOSystem ioSystem = new DefaultIOSystem();
/**
* List of configuration properties for the three supported types integer,
* float and string.
*/
private PropertyList<Integer> properties = new PropertyList<Integer>();
private PropertyList<Float> propertiesFloat = new PropertyList<Float>();
private PropertyList<String> propertiesString = new PropertyList<String>();
/**
* Specifies whether the native jAssimp library is currently in a properly
* initialized and responding state.
*/
private static boolean bLibInitialized = false;
/**
* Expected names for native runtime libraries.
*/
private static final String JASSIMP_RUNTIME_NAME_X64 = "assimp-jbridge64";
private static final String JASSIMP_RUNTIME_NAME_X86 = "assimp-jbridge32";
/**
* Private constructor for internal use.
*
* @param Interface
* version. Increment this if a change has global effect.
* @throws NativeException
*/
private Importer(int iVersion) throws NativeException {
if (!bLibInitialized) {
/**
* Try to load the jAssimp library. First attempt to load the x64
* version, in case of failure the x86 version
*/
try {
System.loadLibrary(JASSIMP_RUNTIME_NAME_X64);
} catch (UnsatisfiedLinkError exc) {
try {
System.loadLibrary(JASSIMP_RUNTIME_NAME_X86);
} catch (UnsatisfiedLinkError exc2) {
throw new NativeException(
"Unable to load the jAssimp library");
}
}
bLibInitialized = true;
}
// Now create the native Importer class and setup our internal
// data structures outside the VM.
try {
if (0xffffffffffffffffl == (m_iNativeHandle = _NativeInitContext(iVersion))) {
throw new NativeException(
"Failed to initialize jAssimp: interface version not matching");
}
} catch (UnsatisfiedLinkError exc) {
throw new NativeException(
"Failed to initialize jAssimp: entry point not found");
}
}
// --------------------------------------------------------------------------
// JNI INTERNALS
// --------------------------------------------------------------------------
/**
* JNI interface call
*/
private native int _NativeInitContext(int version);
/**
* JNI interface call
*/
private native int _NativeFreeContext(long iContext);
/**
* JNI interface call
*/
private native int _NativeLoad(String path, long flags, long iContext);
/**
* JNI interface call
*/
private native int _NativeSetPropertyInt(String name, int prop,
long iContext);
/**
* JNI interface call
*/
private native int _NativeSetPropertyFloat(String name, float prop,
long iContext);
/**
* JNI interface call
*/
private native int _NativeSetPropertyString(String name, String prop,
long iContext);
}

View File

@ -1,280 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Describes a virtual light source in the scene
*
* Lights have a representation in the node graph and can be animated
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public class Light {
/**
* Enumerates all supported types of light sources
*/
public class Type {
// public static final int UNDEFINED = 0x0;
/**
* A directional light source has a well-defined direction but is
* infinitely far away. That's quite a good approximation for sun light.
* */
public static final int DIRECTIONAL = 0x1;
/**
* A point light source has a well-defined position in space but no
* direction - it emmits light in all directions. A normal bulb is a
* point light.
* */
public static final int POINT = 0x2;
/**
* A spot light source emmits light in a specific angle. It has a
* position and a direction it is pointing to. A good example for a spot
* light is a light spot in sport arenas.
* */
public static final int SPOT = 0x3;
};
/**
* Get the name of the light source.
*
* There must be a node in the scenegraph with the same name. This node
* specifies the position of the light in the scene hierarchy and can be
* animated.
*/
public final String GetName() {
return mName;
}
/**
* Get the type of the light source.
*
*/
public final Type GetType() {
return mType;
}
/**
* Get the position of the light source in space. Relative to the
* transformation of the node corresponding to the light.
*
* The position is undefined for directional lights.
*
* @return Component order: x,y,z
*/
public final float[] GetPosition() {
return mPosition;
}
/**
* Get the direction of the light source in space. Relative to the
* transformation of the node corresponding to the light.
*
* The direction is undefined for point lights. The vector may be
* normalized, but it needn't.
*
* @return Component order: x,y,z
*/
public final float[] GetDirection() {
return mDirection;
}
/**
* Get the constant light attenuation factor.
*
* The intensity of the light source at a given distance 'd' from the
* light's position is
*
* @code Atten = 1/( att0 + att1 * d + att2 * d*d)
* @endcode This member corresponds to the att0 variable in the equation.
*/
public final float GetAttenuationConstant() {
return mAttenuationConstant;
}
/**
* Get the linear light attenuation factor.
*
* The intensity of the light source at a given distance 'd' from the
* light's position is
*
* @code Atten = 1/( att0 + att1 * d + att2 * d*d)
* @endcode This member corresponds to the att1 variable in the equation.
*/
public final float GetAttenuationLinear() {
return mAttenuationLinear;
}
/**
* Get the quadratic light attenuation factor.
*
* The intensity of the light source at a given distance 'd' from the
* light's position is
*
* @code Atten = 1/( att0 + att1 * d + att2 * d*d)
* @endcode This member corresponds to the att2 variable in the equation.
*/
public final float GetAttenuationQuadratic() {
return mAttenuationQuadratic;
}
/**
* Get the diffuse color of the light source
*
*
*/
public final float[] GetColorDiffuse() {
return mColorDiffuse;
}
/**
* Get the specular color of the light source
*
* The specular light color is multiplied with the specular material color
* to obtain the final color that contributes to the specular shading term.
*/
public final float[] GetColorSpecular() {
return mColorSpecular;
}
/**
* Get the ambient color of the light source
*
* The ambient light color is multiplied with the ambient material color to
* obtain the final color that contributes to the ambient shading term. Most
* renderers will ignore this value it, is just a remaining of the
* fixed-function pipeline that is still supported by quite many file
* formats.
*/
public final float[] GetColorAmbient() {
return mColorAmbient;
}
/**
* Get the inner angle of a spot light's light cone.
*
* The spot light has maximum influence on objects inside this angle. The
* angle is given in radians. It is 2PI for point lights and undefined for
* directional lights.
*/
public final float GetAngleInnerCone() {
return mAngleInnerCone;
}
/**
* Get the outer angle of a spot light's light cone.
*
* The spot light does not affect objects outside this angle. The angle is
* given in radians. It is 2PI for point lights and undefined for
* directional lights. The outer angle must be greater than or equal to the
* inner angle. It is assumed that the application uses a smooth
* interpolation between the inner and the outer cone of the spot light.
*/
public final float GetAngleOuterCone() {
return mAngleOuterCone;
}
/**
* The name of the light source.
*/
private String mName;
/**
* The type of the light source.
*/
private Type mType;
/**
* Position of the light source in space.
*/
private float[] mPosition;
/**
* Direction of the light source in space.
*/
private float[] mDirection;
/**
* Constant light attenuation factor.
*/
private float mAttenuationConstant;
/**
* Linear light attenuation factor.
*/
private float mAttenuationLinear;
/**
* Quadratic light attenuation factor.
*/
private float mAttenuationQuadratic;
/**
* Diffuse color of the light source
*/
private float[] mColorDiffuse;
/**
* Specular color of the light source
*/
private float[] mColorSpecular;
/**
* Ambient color of the light source
*/
private float[] mColorAmbient;
/**
* Inner angle of a spot light's light cone.
*/
private float mAngleInnerCone;
/**
* Outer angle of a spot light's light cone.
*/
private float mAngleOuterCone;
};

View File

@ -1,62 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Output stream for the logger. Directly corresponding with the native
* LoggStream interface <br>
* For direct output to a <code>java.io.Stream</code> you can use the
* DefaultLogStream class.
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public interface LogStream {
/**
* Override this for your own output implementations
*
* @param message
* Message to be written to the log stream
*/
public void write(String message);
}

View File

@ -1,128 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Base logging interface. Directly corresponding with the native Logger
* interface
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public interface Logger {
/**
* Debug log message
*/
public static final int ERRORSEVERITY_DEBUGGING = 0x1;
/**
* Information log message
*/
public static final int ERRORSEVERITY_INFO = 0x2;
/**
* Warn log message
*/
public static final int ERRORSEVERITY_WARN = 0x4;
/**
* Error log message
*/
public static final int ERRORSEVERITY_ERR = 0x8;
/**
* Write a debug message to the log
*
* @param message
* Message to be logged
*/
public void debug(String message);
/**
* Write an error message to the log
*
* @param message
* Message to be logged
*/
public void error(String message);
/**
* Write a warn message to the log
*
* @param message
* Message to be logged
*/
public void warn(String message);
/**
* Write an info message to the log
*
* @param message
* Message to be logged
*/
public void info(String message);
/**
* Attach a logstream to the logger
*
* @param stream
* Log stream instance
* @param severity
* Error severity. Bitwise combination of the ERRORSEVERITY_XXX
* constants. Specify 0 to attach the stream to all types of log
* messages.
*/
public void attachStream(LogStream stream, int severity);
/**
* Detach a logstream from the logger
*
* @param stream
* Log stream instance
* @param severity
* Error severities to detach the stream from. Bitwise
* combination of the ERRORSEVERITY_XXX constants. Specify 0 to
* detach the stream from all types of log messages.
*/
public void detachStream(LogStream stream, int severity);
}

View File

@ -1,447 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* A material key represents a single material property, accessed through its
* key. Most material properties are predefined for simplicity.
*
* Material properties can be of several data types, including integers, floats
* strings and arrays of them.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public final class MatKey {
private MatKey() {}
/**
* Enumerates all supported texture layer blending operations.
*
* @see TEXOP()
*/
public static final class TextureOp {
/** T = T1 * T2 */
public static final int Multiply = 0x0;
/** T = T1 + T2 */
public static final int Add = 0x1;
/** T = T1 - T2 */
public static final int Subtract = 0x2;
/** T = T1 / T2 */
public static final int Divide = 0x3;
/** T = (T1 + T2) - (T1 * T2) */
public static final int SmoothAdd = 0x4;
/** T = T1 + (T2-0.5) */
public static final int SignedAdd = 0x5;
}
/**
* Enumerates all supported texture wrapping modes. They define how mapping
* coordinates outside the 0...1 range are handled.
*
* @see TEXWRAP_U()
* @see TEXWRAP_V()
*/
public static final class TextureWrapMode {
/**
* A texture coordinate u|v is translated to u%1|v%1
*/
public static final int Wrap = 0x0;
/**
* Texture coordinates outside [0...1] are clamped to the nearest valid
* value.
*/
public static final int Clamp = 0x1;
/**
* If the texture coordinates for a pixel are outside [0...1], the
* texture is not applied to that pixel.
*/
public static final int Decal = 0x3;
/**
* A texture coordinate u|v becomes u%1|v%1 if (u-(u%1))%2 is zero and
* 1-(u%1)|1-(v%1) otherwise
*/
public static final int Mirror = 0x2;
}
/**
* Enumerates all supported texture mapping modes. They define how the
* texture is applied to the surface.
*
* @see TEXMAP()
*/
public static final class TextureMapping {
/**
* Explicit mapping coordinates are given. The source mapping channel to
* be used is defined in the <code>UVSRC</code> material property.
*/
public static final int UV = 0x0;
/** Spherical mapping */
public static final int SPHERE = 0x1;
/** Cylindrical mapping */
public static final int CYLINDER = 0x2;
/** Cubic mapping */
public static final int BOX = 0x3;
/** Planar mapping */
public static final int PLANE = 0x4;
/** Undefined mapping. Have fun. */
public static final int OTHER = 0x5;
}
/**
* Enumerates all recognized purposes of texture maps. Textures are layered
* in stacks, one stack for each kind of texture map.
*/
public static final class TextureType {
/**
* Dummy value.
*
* Value for <code>Any.textureType</code> for properties not related to
* a specific texture layer.
*/
public static final int NONE = 0x0;
/**
* The texture is combined with the result of the diffuse lighting
* equation.
*/
public static final int DIFFUSE = 0x1;
/**
* The texture is combined with the result of the specular lighting
* equation.
*/
public static final int SPECULAR = 0x2;
/**
* The texture is combined with the result of the ambient lighting
* equation, if any.
*/
public static final int AMBIENT = 0x3;
/**
* The texture is added to the final result of the lighting calculation.
* It isn't influenced by incoming or ambient light.
*/
public static final int EMISSIVE = 0x4;
/**
* The texture is a height map.
*
* Usually higher grey-scale values map to higher elevations.
* Applications will typically want to convert height maps to tangent
* space normal maps.
*/
public static final int HEIGHT = 0x5;
/**
* The texture is a tangent space normal-map.
*
* There are many conventions, but usually you can expect the data to be
* given in the r,g channels of the texture where the b or a channel is
* probably containing the original height map.
*/
public static final int NORMALS = 0x6;
/**
* The texture defines the glossiness of the material.
*
* The glossiness is nothing else than the exponent of the specular
* (phong) lighting equation. Usually there is a conversion function
* defined to map the linear color values in the texture to a suitable
* exponent. Have fun.
*/
public static final int SHININESS = 0x7;
/**
* The texture defines per-pixel opacity.
*
* Usually 'white' means opaque and 'black' means 'transparency'. Or
* quite the opposite. Have fun.
*/
public static final int OPACITY = 0x8;
/**
* Displacement texture
*
* The exact purpose and format is application-dependent. Higher color
* values usually map to higher displacements.
*/
public static final int DISPLACEMENT = 0x9;
/**
* Lightmap texture (or Ambient Occlusion Map)
*
* Both 'lightmaps' in the classic sense and dedicated 'ambient
* occlusion maps' are covered by this material property. The texture
* contains a scaling value for the final color value of a pixel. It's
* intensity is not affected by incoming or ambient light.
*/
public static final int LIGHTMAP = 0xA;
/**
* Reflection texture
*
* Defines the color of a perfect mirror reflection at a particular
* pixel.
*/
public static final int REFLECTION = 0xB;
/**
* Unknown texture for your amusement.
*
* A texture reference that does not match any of the definitions above
* is considered to be 'unknown'. It is still imported, but is excluded
* from any further post processing.
*/
public static final int UNKNOWN = 0xC;
};
/**
* Defines some standard shading hints provided by Assimp. In order to match
* the intended visual appearance of a model as closely as possible,
* applications will need to apply the right shader to the model or at least
* find a similar one.
*
* The list of shaders comes from Blender, btw.
*/
public static final class ShadingMode {
/**
* Flat shading. Shading is done on per-face base, diffuse only. Also
* known as 'faceted shading'.
*/
public static final int Flat = 0x1;
/**
* Simple Gouraud Shader
*/
public static final int Gouraud = 0x2;
/**
* Phong Shader
*/
public static final int Phong = 0x3;
/**
* Phong-Blinn Shader
*/
public static final int Blinn = 0x4;
/**
* Toon Shader
*
* Also known as 'comic' shader.
*/
public static final int Toon = 0x5;
/**
* OrenNayar Shader
*
* Extension to standard Gouraud shading taking the roughness of the
* material into account
*/
public static final int OrenNayar = 0x6;
/**
* Minnaert Shader
*
* Extension to standard Gouraud shading taking the "darkness" of the
* material into account
*/
public static final int Minnaert = 0x7;
/**
* CookTorrance Shader.
*
* Special shader for metal surfaces.
*/
public static final int CookTorrance = 0x8;
/**
* No shading at all. Constant light influence of 1.0.
*/
public static final int NoShading = 0x9;
/**
* Fresnel Shader
*/
public static final int Fresnel = 0xa;
};
/**
* Some mixed texture flags. They are only present in a material if Assimp
* gets very, very detailed information about the characteristics of a
* texture from the source file. In order to display completely generic
* models properly, you'll need to query them.
*
* @see TEXFLAGS()
*/
public static final class TextureFlags {
/**
* The texture's color values have to be inverted (component wise 1-n)
*/
public static final int Invert = 0x1;
/**
* Explicit request to the application to process the alpha channel of
* the texture.
*
* Mutually exclusive with <code>IgnoreAlpha</code>. These flags are set
* if the library can say for sure that the alpha channel is used/is not
* used. If the model format does not define this, it is left to the
* application to decide whether the texture alpha channel - if any - is
* evaluated or not.
*/
public static final int UseAlpha = 0x2;
/**
* Explicit request to the application to ignore the alpha channel of
* the texture.
*
* Mutually exclusive with <code>UseAlpha</code>.
*/
public static final int IgnoreAlpha = 0x4;
}
/**
* Defines how the computed value for a particular pixel is combined with
* the previous value of the backbuffer at that position.
*
* @see #BLEND_FUNC()
*/
public static final class BlendFunc {
/** SourceColor*SourceAlpha + DestColor*(1-SourceAlpha) */
public static final int Default = 0x0;
/** SourceColor*1 + DestColor*1 */
public static final int Additive = 0x1;
}
/**
* Defines the name of the material.
*/
public static final Any<String> NAME = new Any<String>("?mat.name");
/**
* Defines whether the material must be rendered two-sided. This is a
* boolean property. n != 0 is <code>true</code>.
*/
public static final Any<Integer> TWOSIDED = new Any<Integer>(
"$mat.twosided");
/**
* Defines whether the material must be rendered in wireframe. This is a
* boolean property. n != 0 is <code>true</code>.
*/
public static final Any<Integer> WIREFRAME = new Any<Integer>(
"$mat.wireframe");
/**
* Defines the shading model to be used to compute the lighting for the
* material. This is one of the values defined in the
* <code>ShadingModel</code> 'enum'.
*/
public static final Any<Integer> SHADING_MODEL = new Any<Integer>(
"$mat.shadingm");
/**
* Defines the blend function to be used to combine the computed color value
* of a pixel with the previous value in the backbuffer. This is one of the
* values defined in the <code>BlendFunc</code> 'enum'.
*/
public static final Any<Integer> BLEND_FUNC = new Any<Integer>("$mat.blend");
/**
* Defines the basic opacity of the material in range 0..1 where 0 is fully
* transparent and 1 is fully opaque. The default value to be taken if this
* property is not defined is naturally <code>1.0f</code>.
*/
public static final Any<Float> OPACITY = new Any<Float>("$mat.opacity");
/**
* Defines the height scaling of bumpmaps/parallax maps on this material.
* The default value to be taken if this property is not defined is
* naturally <code>1.0f</code>.
*/
public static final Any<Float> BUMPHEIGHT = new Any<Float>(
"$mat.bumpscaling");
/**
* Defines the shininess of the material. This is simply the exponent of the
* phong and blinn-phong shading equations. If the property is not defined,
* no specular lighting must be computed for the material.
*/
public static final Any<Float> SHININESS = new Any<Float>("$mat.shininess");
/**
* Dummy base for all predefined material keys.
*/
public static class Any<Type> {
public Any(String str) {
this(str, 0, 0);
}
public Any(String str, int tType, int tIndex) {
name = str;
textureType = tType;
textureIndex = tIndex;
}
String name;
int textureType, textureIndex;
}
}

View File

@ -1,186 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Class to wrap materials. Materials are represented in ASSIMP as a list of
* key/value pairs, the key being a <code>String</code> and the value being a
* binary buffer. The class provides several get methods to access material
* properties easily.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Material {
/**
* Internal representation of a material property
*/
private class Property {
String key;
Object value;
}
/**
* List of all properties for this material
*/
private Property[] properties;
/**
* Special exception class which is thrown if a material property could not
* be found.
*/
@SuppressWarnings("serial")
public class PropertyNotFoundException extends Exception {
public final String property_key;
/**
* Constructs a new exception
*
* @param message
* Error message
* @param property_key
* Name of the property that wasn't found
*/
public PropertyNotFoundException(String message, String property_key) {
super(message);
this.property_key = property_key;
}
}
/**
* Get the value for a specific key from the material.
*
* @param key
* Raw name of the property to be queried
* @return null if the property wasn't there or hasn't the desired output
* type. The returned <code>Object</code> can be casted to the
* expected data type for the property. Primitive types are
* represented by their boxed variants.
*/
public Object getProperty(String key) throws PropertyNotFoundException {
for (Property prop : properties) {
if (prop.key.equals(key)) {
return prop.value;
}
}
throw new PropertyNotFoundException(
"Unable to find material property: ", key);
}
/**
* Get the floating-point value for a specific key from the material.
*
* @param key
* One of the constant key values defined in <code>MatKey</code>
* @return the value of the property
* @throws PropertyNotFoundException
* If the property isn't set.
*/
public Float getProperty(MatKey.Any<Float> key)
throws PropertyNotFoundException {
return (Float) getProperty(key.name);
}
/**
* Get the integer value for a specific key from the material.
*
* @param key
* One of the constant key values defined in <code>MatKey</code>
* @return the value of the property
* @throws PropertyNotFoundException
* If the property isn't set.
*/
public Integer getProperty(MatKey.Any<Integer> key)
throws PropertyNotFoundException {
return (Integer) getProperty(key.name);
}
/**
* Get the floating-point-array value for a specific key from the material.
*
* @param key
* One of the constant key values defined in <code>MatKey</code>
* @return the value of the property
* @throws PropertyNotFoundException
* If the property isn't set.
*/
public float[] getProperty(MatKey.Any<float[]> key)
throws PropertyNotFoundException {
return (float[]) getProperty(key.name);
}
/**
* Get the integer-array value for a specific key from the material.
*
* @param key
* One of the constant key values defined in <code>MatKey</code>
* @return the value of the property
* @throws PropertyNotFoundException
* If the property isn't set.
*/
public int[] getProperty(MatKey.Any<int[]> key)
throws PropertyNotFoundException {
return (int[]) getProperty(key.name);
}
/**
* Get the string value for a specific key from the material.
*
* @param key
* One of the constant key values defined in <code>MatKey</code>
* @return the value of the property
* @throws PropertyNotFoundException
* If the property isn't set.
*/
public String getProperty(MatKey.Any<String> key)
throws PropertyNotFoundException {
return (String) getProperty(key.name);
}
}

View File

@ -1,149 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Represents a 3x3 row major matrix
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public class Matrix3x3 {
/**
* Default constructor. Initializes the matrix with its identity
*/
public Matrix3x3() {
coeff[0] = coeff[4] = coeff[8] = 1.0f;
}
/**
* Copy constructor
* @param other Matrix to be copied
*/
public Matrix3x3 ( Matrix3x3 other) {
System.arraycopy(other.coeff, 0, this.coeff, 0, 9);
}
/**
* Construction from nine given coefficents
* @param a1
* @param a2
* @param a3
* @param b1
* @param b2
* @param b3
* @param c1
* @param c2
* @param c3
*/
public Matrix3x3 (float a1, float a2, float a3,
float b1, float b2, float b3,
float c1, float c2, float c3) {
coeff[0] = a1;
coeff[1] = a2;
coeff[2] = a3;
coeff[3] = b1;
coeff[4] = b2;
coeff[5] = b3;
coeff[6] = c1;
coeff[7] = c2;
coeff[8] = c3;
}
/**
* Copy constructor (construction from a 4x4 matrix)
* @param other Matrix to be copied
*/
public Matrix3x3 ( Matrix4x4 other) {
coeff[0] = other.coeff[0];
coeff[1] = other.coeff[1];
coeff[2] = other.coeff[2];
coeff[3] = other.coeff[4];
coeff[4] = other.coeff[5];
coeff[5] = other.coeff[6];
coeff[6] = other.coeff[8];
coeff[7] = other.coeff[9];
coeff[8] = other.coeff[10];
}
/**
* The coefficients of the matrix
*/
public float[] coeff = new float[9];
/**
* Returns a field in the matrix
* @param row Row index
* @param column Column index
* @return The corresponding field value
*/
public final float get(int row, int column) {
assert(row <= 2 && column <= 2);
return coeff[row*3+column];
}
/**
* Multiplies *this* matrix with another matrix
* @param m Matrix to multiply with
* @return Output matrix
*/
public final Matrix3x3 Mul(Matrix3x3 m) {
return new Matrix3x3(
m.coeff[0] * coeff[0] + m.coeff[3] * coeff[1] + m.coeff[6] * coeff[2],
m.coeff[1] * coeff[0] + m.coeff[4] * coeff[1] + m.coeff[7] * coeff[2],
m.coeff[2] * coeff[0] + m.coeff[5] * coeff[1] + m.coeff[8] * coeff[2],
m.coeff[0] * coeff[3] + m.coeff[3] * coeff[4] + m.coeff[6] * coeff[5],
m.coeff[1] * coeff[3] + m.coeff[4] * coeff[4] + m.coeff[7] * coeff[5],
m.coeff[2] * coeff[3] + m.coeff[5] * coeff[4] + m.coeff[8] * coeff[5],
m.coeff[0] * coeff[6] + m.coeff[3] * coeff[7] + m.coeff[6] * coeff[8],
m.coeff[1] * coeff[6] + m.coeff[4] * coeff[7] + m.coeff[7] * coeff[8],
m.coeff[2] * coeff[6] + m.coeff[5] * coeff[7] + m.coeff[8] * coeff[8]);
}
}

View File

@ -1,184 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Represents a 4x4 matrix.
*
* There's no explicit convention for 'majorness'; objects of Matrix4x4 can be
* either row-major or column-major.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
* @see Node#getTransformColumnMajor()
* @see Node#getTransformRowMajor()()
*/
public class Matrix4x4 {
/**
* Default constructor. Initializes the matrix with its identity
*/
public Matrix4x4() {
coeff[0] = coeff[5] = coeff[10] = coeff[15] = 1.0f;
}
/**
* Copy constructor
*
* @param other
* Matrix to be copied
*/
public Matrix4x4(Matrix4x4 other) {
System.arraycopy(other.coeff, 0, this.coeff, 0, 16);
}
/**
* Construction from 16 given coefficients
*
* @param a1
* @param a2
* @param a3
* @param a4
* @param b1
* @param b2
* @param b3
* @param b4
* @param c1
* @param c2
* @param c3
* @param c4
* @param d1
* @param d2
* @param d3
* @param d4
*/
public Matrix4x4(float a1, float a2, float a3, float a4, float b1,
float b2, float b3, float b4, float c1, float c2, float c3,
float c4, float d1, float d2, float d3, float d4) {
coeff[0] = a1;
coeff[1] = a2;
coeff[2] = a3;
coeff[3] = a4;
coeff[4] = b1;
coeff[5] = b2;
coeff[6] = b3;
coeff[7] = b4;
coeff[8] = c1;
coeff[9] = c2;
coeff[10] = c3;
coeff[11] = c4;
coeff[12] = d1;
coeff[13] = d2;
coeff[14] = d3;
coeff[15] = d4;
}
/**
* Copy constructor (construction from a 4x4 matrix)
*
* @param other
* Matrix to be copied
*/
public Matrix4x4(Matrix3x3 other) {
coeff[0] = other.coeff[0];
coeff[1] = other.coeff[1];
coeff[2] = other.coeff[2];
coeff[4] = other.coeff[3];
coeff[5] = other.coeff[4];
coeff[6] = other.coeff[5];
coeff[8] = other.coeff[6];
coeff[9] = other.coeff[7];
coeff[10] = other.coeff[8];
coeff[15] = 1.0f;
}
/**
* The coefficients of the matrix
*/
public float[] coeff = new float[16];
/**
* Returns a field in the matrix
*
* @param row
* Row index
* @param column
* Column index
* @return The corresponding field value
*/
public final float get(int row, int column) {
assert (row <= 3 && column <= 3);
return coeff[row * 4 + column];
}
/**
* Computes the transpose of *this* matrix.
*/
public final Matrix4x4 transpose() {
float fTemp = coeff[1 * 4 + 0];
coeff[1 * 4 + 0] = coeff[0 * 4 + 1];
coeff[0 * 4 + 1] = fTemp;
fTemp = coeff[2 * 4 + 0];
coeff[2 * 4 + 0] = coeff[0 * 4 + 2];
coeff[0 * 4 + 2] = fTemp;
fTemp = coeff[2 * 4 + 1];
coeff[2 * 4 + 1] = coeff[1 * 4 + 2];
coeff[1 * 4 + 2] = fTemp;
fTemp = coeff[3 * 4 + 0];
coeff[3 * 4 + 0] = coeff[0 * 4 + 3];
coeff[0 * 4 + 3] = fTemp;
fTemp = coeff[3 * 4 + 1];
coeff[3 * 4 + 1] = coeff[1 * 4 + 3];
coeff[1 * 4 + 3] = fTemp;
fTemp = coeff[3 * 4 + 2];
coeff[3 * 4 + 2] = coeff[2 * 4 + 3];
coeff[2 * 4 + 3] = fTemp;
return this;
}
}

View File

@ -1,633 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
import java.awt.*;
/**
* A mesh represents a part of the whole scene geometry. It references exactly
* one material and can this be drawn in a single draw call.
* <p/>
* It usually consists of a number of vertices and a series of primitives/faces
* referencing the vertices. In addition there might be a series of bones, each
* of them addressing a number of vertices with a certain weight. Vertex data is
* presented in channels with each channel containing a single per-vertex
* information such as a set of texture coordinates or a normal vector.
* <p/>
* Note that not all mesh data channels must be there. E.g. most models don't
* contain vertex colors so this data channel is mostly not filled.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Mesh {
/**
* Defines the maximum number of UV(W) channels that are available for a
* mesh. If a loader finds more channels in a file, it skips them
*/
public static final int MAX_NUMBER_OF_TEXTURECOORDS = 0x4;
/**
* Defines the maximum number of vertex color channels that are available
* for a mesh. If a loader finds more channels in a file, it skips them.
*/
public static final int MAX_NUMBER_OF_COLOR_SETS = 0x4;
/**
* Check whether there are vertex positions in the model
* <code>getPosition()</code> asserts this.
*
* @return true if vertex positions are available. Currently this is
* guaranteed to be <code>true</code>.
*
*/
public final boolean hasPositions() {
return null != m_vVertices;
}
/**
* Check whether there are normal vectors in the model
* <code>getNormal()</code> asserts this.
*
* @return true if vertex normals are available.
*/
public final boolean hasNormals() {
return null != m_vNormals;
}
/**
* Check whether there are bones in the model. If the answer is
* <code>true</code>, use <code>getBone()</code> to query them.
*
* @return true if vertex normals are available.
*/
public final boolean hasBones() {
return null != m_vBones;
}
/**
* Check whether there are tangents/bitangents in the model If the answer is
* <code>true</code>, use <code>getTangent()</code> and
* <code>getBitangent()</code> to query them.
*
* @return true if vertex tangents and bitangents are available.
*/
public final boolean hasTangentsAndBitangents() {
return null != m_vBitangents && null != m_vTangents;
}
/**
* Check whether a given UV set is existing the model <code>getUV()</code>
* will assert this.
*
* @param n
* UV coordinate set index
* @return true the uv coordinate set is available.
*/
public final boolean hasUVCoords(int n) {
return n < m_avUVs.length && null != m_avUVs[n];
}
/**
* Check whether a given vertex color set is existing the model
* <code>getColor()</code> will assert this.
*
* @param n
* Vertex color set index
* @return true the vertex color set is available.
*/
public final boolean hasVertexColors(int n) {
return n < m_avColors.length && null != m_avColors[n];
}
/**
* Get the number of vertices in the model
*
* @return Number of vertices in the model. This could be 0 in some extreme
* cases although loaders should filter such cases out
*/
public final int getNumVertices() {
return m_vVertices.length;
}
/**
* Get the number of faces in the model
*
* @return Number of faces in the model. This could be 0 in some extreme
* cases although loaders should filter such cases out
*/
public final int getNumFaces() {
return m_vFaces.length;
}
/**
* Get the number of bones in the model
*
* @return Number of bones in the model.
*/
public final int getNumBones() {
return m_vBones.length;
}
/**
* Get the material index of the mesh
*
* @return Zero-based index into the global material array
*/
public final int getMaterialIndex() {
return m_iMaterialIndex;
}
/**
* Get a bitwise combination of all types of primitives which are present in
* the mesh.
*
* @see Face.Type
*/
public final int getPrimitiveTypes() {
return m_iPrimitiveTypes;
}
/**
* Get a single vertex position in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3 Receives the vertex
* position components in x,y,z order
*/
public final void getPosition(int iIndex, float[] afOut) {
assert (hasPositions() && afOut.length >= 3 && iIndex < this
.getNumVertices());
iIndex *= 3;
afOut[0] = this.m_vVertices[iIndex];
afOut[1] = this.m_vVertices[iIndex + 1];
afOut[2] = this.m_vVertices[iIndex + 2];
}
/**
* Get a single vertex position in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3
* @param iOutBase
* Start index in the output array Receives the vertex position
* components in x,y,z order
*/
public final void getPosition(int iIndex, float[] afOut, int iOutBase) {
assert (hasPositions() && iOutBase + 3 <= afOut.length && iIndex < getNumVertices());
iIndex *= 3;
afOut[iOutBase] = m_vVertices[iIndex];
afOut[iOutBase + 1] = m_vVertices[iIndex + 1];
afOut[iOutBase + 2] = m_vVertices[iIndex + 2];
}
/**
* Provides direct access to the vertex position array of the mesh This is
* the recommended way of accessing the data.
*
* @return Array of floats, size is numverts * 3. Component ordering is xyz.
*/
public final float[] getPositionArray() {
return m_vVertices;
}
/**
* Get a vertex normal in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3 Receives the vertex
* normal components in x,y,z order
*/
public final void getNormal(int iIndex, float[] afOut) {
assert (hasNormals() && afOut.length >= 3 && iIndex < getNumVertices());
iIndex *= 3;
afOut[0] = m_vTangents[iIndex];
afOut[1] = m_vTangents[iIndex + 1];
afOut[2] = m_vTangents[iIndex + 2];
}
/**
* Get a vertex normal in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3
* @param iOutBase
* Start index in the output array Receives the vertex normal
* components in x,y,z order
*/
public final void getNormal(int iIndex, float[] afOut, int iOutBase) {
assert (hasNormals() && iOutBase + 3 <= afOut.length && iIndex < getNumVertices());
iIndex *= 3;
afOut[iOutBase] = m_vNormals[iIndex];
afOut[iOutBase + 1] = m_vNormals[iIndex + 1];
afOut[iOutBase + 2] = m_vNormals[iIndex + 2];
}
/**
* Provides direct access to the vertex normal array of the mesh This is the
* recommended way of accessing the data.
*
* @return Array of floats, size is numverts * 3. Component order is xyz.
*/
public final float[] getNormalArray() {
return this.m_vNormals;
}
/**
* Get a vertex tangent in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3 Receives the vertex
* tangent components in x,y,z order
*/
public final void getTangent(int iIndex, float[] afOut) {
assert (hasTangentsAndBitangents() && afOut.length >= 3 && iIndex < getNumVertices());
iIndex *= 3;
afOut[0] = m_vTangents[iIndex];
afOut[1] = m_vTangents[iIndex + 1];
afOut[2] = m_vTangents[iIndex + 2];
}
/**
* Get a vertex tangent in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3
* @param iOutBase
* Start index in the output array Receives the vertex tangent
* components in x,y,z order
*/
public final void getTangent(int iIndex, float[] afOut, int iOutBase) {
assert (hasTangentsAndBitangents() && iOutBase + 3 <= afOut.length && iIndex < getNumVertices());
iIndex *= 3;
afOut[iOutBase] = m_vTangents[iIndex];
afOut[iOutBase + 1] = m_vTangents[iIndex + 1];
afOut[iOutBase + 2] = m_vTangents[iIndex + 2];
}
/**
* Provides direct access to the vertex tangent array of the mesh This is
* the recommended way of accessing the data.
*
* @return Array of floats, size is numverts * 3. Component order is xyz.
*/
public final float[] getTangentArray() {
return m_vTangents;
}
/**
* Get a vertex bitangent in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3 Receives the vertex
* bitangent components in x,y,z order
*/
public final void getBitangent(int iIndex, float[] afOut) {
assert (hasTangentsAndBitangents() && afOut.length >= 3
&& 3 >= afOut.length && iIndex < getNumVertices());
iIndex *= 3;
afOut[0] = m_vBitangents[iIndex];
afOut[1] = m_vBitangents[iIndex + 1];
afOut[2] = m_vBitangents[iIndex + 2];
}
/**
* Get a vertex bitangent in the mesh
*
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 3
* @param iOutBase
* Start index in the output array Receives the vertex bitangent
* components in x,y,z order
*/
public final void getBitangent(int iIndex, float[] afOut, int iOutBase) {
assert (hasTangentsAndBitangents() && iOutBase + 3 <= afOut.length && iIndex < getNumVertices());
iIndex *= 3;
afOut[iOutBase] = m_vBitangents[iIndex];
afOut[iOutBase + 1] = m_vBitangents[iIndex + 1];
afOut[iOutBase + 2] = m_vBitangents[iIndex + 2];
}
/**
* Provides direct access to the vertex bitangent array of the mesh This is
* the recommended way of accessing the data.
*
* @return Array of floats, size is numverts * 3. Vector components are
* given in xyz order.
*/
public final float[] getBitangentArray() {
assert (hasTangentsAndBitangents());
return m_vBitangents;
}
/**
* Get a vertex texture coordinate in the mesh
*
* @param channel
* Texture coordinate channel
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be equal to the value
* <code>getNumUVComponents</code> returns for
* <code>channel</code> Receives the vertex texture coordinate.
* Vector components are given in uvw order.
*/
public final void getTexCoord(int channel, int iIndex, float[] afOut) {
assert (hasUVCoords(channel) && afOut.length >= 4 && 4 >= afOut.length && iIndex < getNumVertices());
iIndex *= m_aiNumUVComponents[channel];
for (int i = 0; i < m_aiNumUVComponents[channel]; ++i) {
afOut[i] = m_avUVs[channel][iIndex + i];
}
}
/**
* Get a vertex texture coordinate in the mesh
*
* @param channel
* Texture coordinate channel
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be equal to the value
* <code>getNumUVComponents</code> returns for
* <code>channel</code> Receives the vertex texture coordinate,
* components are in u,v,w order
* @param iOutBase
* Start index in the output array
*/
public final void getTexCoord(int channel, int iIndex, float[] afOut,
int iOutBase) {
assert (hasUVCoords(channel) && afOut.length >= 4
&& iOutBase + 4 <= afOut.length && iIndex < getNumVertices());
iIndex *= m_aiNumUVComponents[channel];
for (int i = 0; i < m_aiNumUVComponents[channel]; ++i) {
afOut[i + iOutBase] = m_avUVs[channel][iIndex + i];
}
}
/**
* Provides direct access to a texture coordinate channel of the mesh This
* is the recommended way of accessing the data.
*
* @return Array of floats, size is numverts * <code>getNumUVComponents
* (channel)</code>. Component ordering is uvw.
*/
public final float[] getTexCoordArray(int channel) {
assert (channel < MAX_NUMBER_OF_TEXTURECOORDS);
return m_avUVs[channel];
}
/**
* Get a vertex color in the mesh
*
* @param channel
* Vertex color channel
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 4 Receives the vertex
* color components in r,g,b,a order
*/
public final void getVertexColor(int channel, int iIndex, float[] afOut) {
assert (this.hasVertexColors(channel) && afOut.length >= 4 && iIndex < this
.getNumVertices());
iIndex *= 4; // RGBA order
afOut[0] = m_avColors[channel][iIndex];
afOut[1] = m_avColors[channel][iIndex + 1];
afOut[2] = m_avColors[channel][iIndex + 2];
afOut[3] = m_avColors[channel][iIndex + 3];
}
/**
* Get a vertex color as <code>java.awt.Color</code> in the mesh
*
* @param channel
* Vertex color channel
* @param iIndex
* Zero-based index of the vertex
* @return Vertex color value packed as <code>java.awt.Color</code>
*/
public final Color getVertexColor(int channel, int iIndex) {
float[] afColor = new float[4];
getVertexColor(channel, iIndex, afColor);
return new Color(afColor[0], afColor[1], afColor[2], afColor[3]);
}
/**
* Get a vertex color in the mesh
*
* @param channel
* Vertex color channel
* @param iIndex
* Zero-based index of the vertex
* @param afOut
* Output array, size must at least be 4 Receives the vertex
* color components in r,g,b,a order
* @param iOutBase
* Start index in the output array
*/
public final void getVertexColor(int channel, int iIndex, float[] afOut,
int iOutBase) {
assert (hasVertexColors(channel) && afOut.length >= 4
&& iOutBase + 4 <= afOut.length && iIndex < getNumVertices());
iIndex *= 4; // RGBA order
afOut[iOutBase] = m_avColors[channel][iIndex];
afOut[iOutBase + 1] = m_avColors[channel][iIndex + 1];
afOut[iOutBase + 2] = m_avColors[channel][iIndex + 2];
afOut[iOutBase + 3] = m_avColors[channel][iIndex + 3];
}
/**
* Provides direct access to the vertex bitangent array of the mesh This is
* the recommended way of accessing the data.
*
* @return Array of floats, size is numverts * 3. Component ordering is xyz.
*/
public final float[] getVertexColorArray(int channel) {
assert (channel < MAX_NUMBER_OF_COLOR_SETS);
return m_avColors[channel];
}
/**
* Get a single face of the mesh
*
* @param iIndex
* Index of the face. Must be smaller than the value returned by
* <code>getNumFaces()</code>
*/
public final Face getFace(int iIndex) {
return this.m_vFaces[iIndex];
}
/**
* Provides direct access to the face array of the mesh This is the
* recommended way of accessing the data.
*
* @return Array of ints, size is numfaces * 3. Each face consists of three
* indices (higher level polygons are automatically triangulated by
* the library)
*/
public final Face[] getFaceArray() {
return this.m_vFaces;
}
/**
* Provides access to the array of all bones influencing this mesh.
*
* @return Bone array
*/
public final Bone[] getBonesArray() {
assert (null != this.m_vBones);
return this.m_vBones;
}
/**
* Get a bone influencing the mesh
*
* @param i
* Index of the bone
* @return Bone
*/
public final Bone getBone(int i) {
assert (null != this.m_vBones && i < this.m_vBones.length);
return this.m_vBones[i];
}
// --------------------------------------------------------------------------
// PRIVATE STUFF
// --------------------------------------------------------------------------
/**
* Contains normal vectors in a continuous float array, xyz order. Can't be
* <code>null</code>
*/
private float[] m_vVertices = null;
/**
* Contains normal vectors in a continuous float array, xyz order. Can be
* <code>null</code>
*/
private float[] m_vNormals = null;
/**
* Contains tangent vectors in a continuous float array, xyz order. Can be
* <code>null</code>
*/
private float[] m_vTangents = null;
/**
* Contains bitangent vectors in a continuous float array, xyz order. Can be
* <code>null</code>
*/
private float[] m_vBitangents = null;
/**
* Contains UV coordinate channels in a continuous float array, uvw order.
* Unused channels are set to <code>null</code>.
*/
private float[][] m_avUVs = new float[MAX_NUMBER_OF_TEXTURECOORDS][];
/**
* Defines the number of relevant vector components for each UV channel.
* Typically the value is 2 or 3.
*/
private int[] m_aiNumUVComponents = new int[MAX_NUMBER_OF_TEXTURECOORDS];
/**
* Contains vertex color channels in a continuous float array, rgba order.
* Unused channels are set to <code>null</code>.
*/
private float[][] m_avColors = new float[MAX_NUMBER_OF_COLOR_SETS][];
/**
* The list of all faces for the mesh.
*/
private Face[] m_vFaces = null;
/**
* Bones influencing the mesh
*/
private Bone[] m_vBones = null;
/**
* Material index of the mesh. This is simply an index into the global
* material array.
*/
private int m_iMaterialIndex = 0;
/**
* Bitwise combination of the kinds of primitives present in the mesh. The
* constant values are enumerated in <code>Face.Type</code>
*/
private int m_iPrimitiveTypes = 0;
}

View File

@ -1,62 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Exception class used by jAssimp. It is thrown whenever an unknown error
* occurs in the JNI bridge between the native Assimp library and the Java VM.
*/
public class NativeException extends Exception {
/**
*
*/
private static final long serialVersionUID = -8882941564623281784L;
public NativeException() {
super("Unknown error");
}
public NativeException(String sz) {
super(sz);
}
}

View File

@ -1,242 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
import java.io.IOException;
import java.io.PrintStream;
/**
* A node in the imported scene hierarchy.
*
* Each node has name, a single parent node (except for the root node), a
* transformation relative to its parent and possibly several child nodes.
* Simple file formats don't support hierarchical structures, for these formats
* the imported scene does consist of only a single root node with no childs.
* Multiple meshes can be assigned to a single node.
*
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Node {
/**
* Constructs a new node and initializes it
*
* @param parentNode
* Parent node or null for root nodes
*/
public Node(Node parentNode) {
this.parent = parentNode;
}
/**
* Returns the number of meshes of this node
*
* @return Number of meshes
*/
public final int getNumMeshes() {
return meshIndices.length;
}
/**
* Get a list of all meshes of this node
*
* @return Array containing indices into the Scene's mesh list. If there are
* no meshes, the array is <code>null</code>
*/
public final int[] getMeshes() {
return meshIndices;
}
/**
* Get the local transformation matrix of the node in row-major order:
* <code>
* a1 a2 a3 a4 (the translational part of the matrix is stored
* b1 b2 b3 b4 in (a4|b4|c4))
* c1 c2 c3 c4
* d1 d2 d3 d4
* </code>
*
* @return Row-major transformation matrix
*/
public final Matrix4x4 getTransformRowMajor() {
return nodeTransform;
}
/**
* Get the local transformation matrix of the node in column-major order:
* <code>
* a1 b1 c1 d1 (the translational part of the matrix is stored
* a2 b2 c2 d2 in (a4|b4|c4))
* a3 b3 c3 d3
* a4 b4 c4 d4
* </code>
*
* @return Column-major transformation matrix
*/
public final Matrix4x4 getTransformColumnMajor() {
Matrix4x4 m = new Matrix4x4(nodeTransform);
return m.transpose();
}
/**
* Get the name of the node. The name might be empty (length of zero) but
* all nodes which need to be accessed afterwards by bones or anims are
* usually named.
*
* @return Node name
*/
public final String getName() {
return name;
}
/**
* Get the list of all child nodes of *this* node
*
* @return List of children. May be empty.
*/
public final Node[] getChildren() {
return children;
}
/**
* Get the number of child nodes of *this* node
*
* @return May be 0
*/
public final int getNumChildren() {
return children.length;
}
/**
* Get the parent node of the node
*
* @return Parent node
*/
public final Node getParent() {
return parent;
}
/**
* Searches this node and recursively all sub nodes for a node with a
* specific name
*
* @param _name
* Name of the node to search for
* @return Either a reference to the node or <code>null</code> if no node
* with this name was found.
*/
public final Node findNode(String _name) {
if (_name.equals(name))
return this;
for (Node node : children) {
Node out;
if (null != (out = node.findNode(_name)))
return out;
}
return null;
}
/**
* Print all nodes recursively. This is a debugging utility.
* @param stream
* Output stream
* @param suffix
* Suffix to all output
* @throws IOException
* yes ... sometimes ... :-)
*/
public void printNodes(PrintStream stream, String suffix)
throws IOException {
String suffNew = suffix + "\t";
stream.println(suffix + getName());
// print all mesh indices
if (0 != getNumMeshes()) {
stream.println(suffNew + "Meshes: ");
for (int i : getMeshes()) {
stream.println(i + " ");
}
stream.println("");
}
// print all children
if (0 != getNumChildren()) {
for (Node n : getChildren()) {
n.printNodes(stream, suffNew);
}
}
}
/**
* List of all meshes of this node. The array contains indices into the
* Scene's mesh list
*/
private int[] meshIndices = null;
/**
* Local transformation matrix of the node Stored in row-major order.
*/
private Matrix4x4 nodeTransform = null;
/**
* Name of the node The name might be empty (length of zero) but all nodes
* which need to be accessed afterwards by bones or anims are usually named.
*/
private String name = "";
/**
* List of all child nodes May be empty
*/
private Node[] children = null;
/**
* Parent node or null if we're the root node of the scene
*/
private Node parent = null;
}

View File

@ -1,155 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* A bone animation channel defines the animation keyframes for a single bone in
* the mesh hierarchy.
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public class NodeAnim {
/**
* Describes a keyframe
*/
public class KeyFrame<Type> {
/**
* Time line position of *this* keyframe, in "ticks"
*/
public double time;
/**
* Current value of the property being animated
*/
public Type value;
}
/**
* Returns the name of the bone affected by this animation channel
*
* @return Bone name
*/
public final String getName() {
return mName;
}
/**
* Returns the number of rotation keyframes
*
* @return This can be 0.
*/
public final int getNumQuatKeys() {
return null == mQuatKeys ? 0 : mQuatKeys.length;
}
/**
* Returns the number of position keyframes
*
* @return This can be 0.
*/
public final int getNumPosKeys() {
return null == mPosKeys ? 0 : mPosKeys.length;
}
/**
* Returns the number of scaling keyframes
*
* @return This can be 0.
*/
public final int getNumScalingKeys() {
return null == mScalingKeys ? 0 : mScalingKeys.length;
}
/**
* Get a reference to the list of all rotation keyframes
*
* @return Could be <code>null</code> if there are no rotation keys
*/
public final KeyFrame<Quaternion>[] getQuatKeys() {
return mQuatKeys;
}
/**
* Get a reference to the list of all position keyframes
*
* @return Could be <code>null</code> if there are no position keys
*/
public final KeyFrame<float[]>[] getPosKeys() {
return mPosKeys;
}
/**
* Get a reference to the list of all scaling keyframes
*
* @return Could be <code>null</code> if there are no scaling keys
*/
public final KeyFrame<float[]>[] getScalingKeys() {
return mScalingKeys;
}
// --------------------------------------------------------------------------
// Private stuff
// --------------------------------------------------------------------------
/**
* Rotation keyframes
*/
private KeyFrame<Quaternion>[] mQuatKeys = null;
/**
* Position keyframes. Component order is x,y,z
*/
private KeyFrame<float[]>[] mPosKeys = null;
/**
* scaling keyframes. Component order is x,y,z
*/
private KeyFrame<float[]>[] mScalingKeys = null;
/**
* Name of the bone affected by this animation channel
*/
private String mName;
}

View File

@ -1,552 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Lists all provided post processing steps.
*
* Post processing steps are various algorithms to improve the output scene.
* They compute additional data, help identify invalid data and optimize the 3d
* scene for a particular purpose. Post processing is one of the key concept of
* Assimp. If the various flags seem confusing to you, simply try one of the
* presets and check out whether the results fit to your requirements.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
*/
public class PostProcessing {
/**
* Declares some handy post processing presets.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
*/
public static class Preset {
/**
* Simple post processing preset targeting fast loading for use in real
* time apps.
*
* Applications would want to use this preset to load models on end-user
* PCs, maybe even for direct use in game. That's not absolutely what
* Assimp was designed for but who cares ..?
*
* If you're using DirectX, don't forget to combine this value with the
* #aiProcess_ConvertToLeftHanded step. If you don't support UV
* transformations in your application apply the
* #aiProcess_TransformUVCoords step, too.
*
* @note Please take the time to read the doc for the single flags
* included by this preset. Some of them offer further
* configurable properties and some of them might not be of use
* for you.
*/
public static final long TargetRealtime_Fast = CalcTangentSpace
| GenNormals | JoinIdenticalVertices | Triangulate
| GenUVCoords | SortByPType | 0;
/**
* Default post processing configuration targeting real time rendering
*
* Unlike TargetRealtime_Fast this predefined configuration performs
* some extra optimizations to improve rendering speed and to minimize
* memory usage. It could be a good choice for a level editor
* environment where import speed is not so important.
*
* If you're using DirectX, don't forget to combine this value with the
* #aiProcess_ConvertToLeftHanded step. If you don't support UV
* transformations in your application apply the
* #aiProcess_TransformUVCoords step, too.
*
* @note Please take the time to read the doc for the single flags
* included by this preset. Some of them offer further
* configurable properties and some of them might not be of use
* for you.
*/
public static final long TargetRealtime_Quality = CalcTangentSpace
| GenSmoothNormals | JoinIdenticalVertices
| ImproveCacheLocality | LimitBoneWeights
| RemoveRedundantMaterials | SplitLargeMeshes | Triangulate
| GenUVCoords | SortByPType | FindDegenerates | FindInvalidData
| 0;
/**
* Default post processing configuration targeting real time rendering.
*
* This preset enables almost every optimization step to achieve
* perfectly optimized data. It's your choice for level editor
* environments where import speed doesn't care.
*
* If you're using DirectX, don't forget to combine this value with the
* ConvertToLeftHanded step. If you don't support UV transformations in
* your application, apply the TransformUVCoords step too.
*
* @note Please take the time to read the doc for the single flags
* included by this preset. Some of them offer further
* configurable properties and some of them might not be of use
* for you.
*/
public static final long TargetRealtime_MaxQuality = TargetRealtime_Quality
| FindInstances | ValidateDataStructure | OptimizeMeshes | 0;
}
/**
* Calculates the tangents and bitangents (aka 'binormals') for the imported
* meshes.
*
* Does nothing if a mesh does not have normals. You might want this post
* processing step to be executed if you plan to use tangent space
* calculations such as normal mapping applied to the meshes. There's a
* separate setting, <tt>#AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE</tt>, which
* allows you to specify a maximum smoothing angle for the algorithm.
* However, usually you'll want to let the default value. Thanks.
*/
public static final long CalcTangentSpace = 0x1;
/**
* Identifies and joins identical vertex data sets within all imported
* meshes.
*
* After this step is run each mesh does contain only unique vertices
* anymore, so a vertex is possibly used by multiple faces. You usually want
* to use this post processing step. If your application deals with indexed
* geometry, this step is compulsory or you'll just waste rendering time.
* <b>If this flag is not specified</b>, no vertices are referenced by more
* than one face and <b>no index buffer is required</b> for rendering.
*/
public static final int JoinIdenticalVertices = 0x2;
/**
* Converts all the imported data to a left-handed coordinate space.
*
* By default the data is returned in a right-handed coordinate space which
* for example OpenGL prefers. In this space, +X points to the right, +Z
* points towards the viewer and and +Y points upwards. In the DirectX
* coordinate space +X points to the right, +Y points upwards and +Z points
* away from the viewer.
*
* You'll probably want to consider this flag if you use Direct3D for
* rendering. The #aiProcess_ConvertToLeftHanded flag supersedes this
* setting and boundles all conversions typically required for D3D-based
* applications.
*/
public static final long MakeLeftHanded = 0x4;
/**
* Triangulates all faces.
*
* Originally the imported mesh data might contain faces with more than 3
* indices. For rendering you'll usually want all faces to be triangles.
* This post processing step splits up all higher faces to triangles. Lines
* and points are *not* modified!. If you want 'triangles only' with no
* other kinds of primitives, try the following:
* <ul>
* <li>Specify both #aiProcess_Triangulate and #aiProcess_SortByPType</li>
* </li>Processing Assimp's output, ignore all point and line meshes</li>
* </ul>
*/
public static final long Triangulate = 0x8;
/**
* Removes some parts of the data structure (animations, materials, light
* sources, cameras, textures, specific vertex components, ..).
*
* The components to be removed are specified in a separate configuration
* option, <tt>#AI_CONFIG_PP_RVC_FLAGS</tt>. This is quite useful if you
* don't need all parts of the output structure. Calling this step to remove
* unneeded stuff from the pipeline as early as possible results in better
* performance and a perfectly optimized output data structure. This step is
* also useful if you want to force Assimp to recompute normals or tangents.
* The corresponding steps don't recompute them if they're already there
* (loaded from the source asset). By using this step you can make sure they
* are NOT there :-)
*
* Consider the following case: a 3d model has been exported from a CAD
* application, it has per-face vertex colors. Vertex positions can't be
* shared, thus the #aiProcess_JoinIdenticalVertices step fails to optimize
* the data. Just because these nasty, little vertex colors. Most apps don't
* even process them so it's all for nothing. By using this step unneeded
* components are excluded as early as possible thus opening more room for
* internal optimizations.
*/
public static final long RemoveComponent = 0x10;
/**
* Generates per-face normals for all meshes in the scene.
*
* This step is skipped if normals are already present in the source file.
* Model importers try to load them from the source file and many file
* formats provide support for them. Face normals are shared between all
* points of a single face. Thus a single point can have multiple normals
* forcing the library to duplicate vertices in some cases.
* #aiProcess_JoinIdenticalVertices is *senseless* then because there's
* nothing to be joined.
*
* This flag may not be specified together with #aiProcess_GenSmoothNormals.
*/
public static final long GenNormals = 0x20;
/**
* Generates smooth per-vertex normals for all meshes in the scene.
*
* This step is skipped if normals are already present in the source file.
* Model importers try to load them from the source file and many file
* formats provide support for them.
*
* There the, <tt>#AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE</tt> configuration
* property which allows you to specify an angle maximum for the normal
* smoothing algorithm. Normals exceeding this limit are not smoothed,
* resulting in a a visually 'hard' seam between two faces. Using a decent
* angle here (e.g. 80°) results in very good visual appearance. Again, this
* doesn't apply if the source format provides proper normals.
*
* This flag may not be specified together with #aiProcess_GenNormals.
*/
public static final long GenSmoothNormals = 0x40;
/**
* Splits large unbeatable meshes into smaller sub meshes
*
* This is quite useful for real time rendering where the number of
* triangles which can be maximally processed in a single draw-call is
* usually limited by the video hardware. The maximum vertex buffer is
* usually limited too. Both requirements can be met with this step: you may
* specify both a triangle and vertex limit for a single mesh.
*
* The split limits can (and should!) be set through the
* <tt>#AI_CONFIG_PP_SLM_VERTEX_LIMIT</tt> and
* <tt>#AI_CONFIG_PP_SLM_TRIANGLE_LIMIT</tt> settings. The default values
* are <tt>#AI_SLM_DEFAULT_MAX_VERTICES</tt> and
* <tt>#AI_SLM_DEFAULT_MAX_TRIANGLES</tt>.
*
* Note that splitting is generally a time-consuming task, but not if
* there's nothing to split. The use of this step is recommended for most
* users.
*/
public static final long SplitLargeMeshes = 0x80;
/**
* Removes the node graph and transforms all vertices by the absolute
* transformations of their host nodes. The output scene does still contain
* nodes but there is only a root node with children, each one referencing
* exactly only one mesh, each mesh referencing exactly one material. For
* rendering you can simply draw all meshes in order, you don't need to pay
* attention to local transformations and the node hierarchy. Animations are
* removed during this step. This step is intended for applications without
* a scene graph-like system.
*/
public static final long PreTransformVertices = 0x100;
/**
* Limits the number of bones simultaneously affecting a single vertex to a
* maximum value.
*
* If any vertex is affected by more than that number of bones, the least
* important vertex weights are removed and the remaining vertex weights are
* renormalized so that the weights still sum up to 1. The default bone
* weight limit is 4 (defined as <tt>#AI_LMW_MAX_WEIGHTS</tt> in
* aiConfig.h), but you can use the <tt>#AI_CONFIG_PP_LBW_MAX_WEIGHTS</tt>
* setting to supply your own limit to the post processing step.
*
* If you intend to perform the skinning in hardware, this post processing
* step might be of interest for you.
*/
public static final long LimitBoneWeights = 0x200;
/**
* Validates the imported scene data structure .This makes sure that all
* indices are valid, all animations and bones are linked correctly, all
* material references are correct .. etc.
*
* It is recommended to capture Assimp's log output if you use this flag, so
* you can easily find ot what's actually wrong if a file fails the
* validation. The validation is quite rude and will usually find *all*
* inconsistencies in the data structure ... plugin developers are
* recommended to use it to debug their loaders. There are two types of
* validation failures:
* <ul>
* <li>Error: There's something wrong with the imported data. Further post
* processing is not possible and the data is not usable at all. The import
* fails. <code>Importer::getErrorString()</code> retrieves the error
* string.</li>
* <li>Warning: There are some minor issues with the imported scene but
* further post processing and use of the data structure is still safe.
* Details about the issue are written to the log file and the
* <tt>Importer.SCENE_FLAGS_VALIDATION_WARNING</tt> scene flag is set</li>
* </ul>
*
* This post-processing step is not time-consuming at all. It's use is not
* compulsory but recommended.
*/
public static final long ValidateDataStructure = 0x400;
/**
* Reorders triangles for better vertex cache locality.
*
* The step tries to improve the ACMR (average post-transform vertex cache
* miss ratio) for all meshes. The implementation runs in O(n) and is
* roughly based on the 'tipsify' algorithm.
*
* If you intend to render huge models in hardware, this step might be of
* interest for you. The <tt>#AI_CONFIG_PP_ICL_PTCACHE_SIZE</tt>
* configuration is provided to fine-tune the cache optimization for a
* particular target cache size. The default value is mostly fine.
*
* @see http://www.cs.princeton.edu/gfx/pubs/Sander_2007_%3ETR/tipsy.pdf
*/
public static final long ImproveCacheLocality = 0x800;
/**
* Searches for redundant/unreferenced materials and removes them.
*
* This is especially useful in combination with the
* <code>PretransformVertices</code> and <code>OptimizeMeshes</code> flags.
* Both join small meshes with equal characteristics, but they can't do
* their work if two meshes have different materials. Because several
* material settings are always lost during Assimp's import filters, (and
* because many exporters don't check for redundant materials), huge models
* often have materials which are are defined several times with exactly the
* same settings ..
*
* Several material settings not contributing to the final appearance of a
* surface are ignored in all comparisons ... the material name is one of
* them. So, if you're passing additional information through the content
* pipeline (probably using using *magic* material names), don't specify
* this flag. Alternatively take a look at the
* <tt>#AI_CONFIG_PP_RRM_EXCLUDE_LIST</tt> setting.
*/
public static final long RemoveRedundantMaterials = 0x1000;
/**
* This step tries to determine which meshes have normal vectors that are
* facing inwards. The algorithm is simple but effective: the bounding box
* of all vertices + their normals is compared against the volume of the
* bounding box of all vertices without their normals. This works well for
* most objects, problems might occur with planar surfaces. However, the
* step tries to filter such cases. The step inverts all in-facing normals.
* Generally it is recommended to enable this step, although the result is
* not always correct.
*/
public static final long FixInfacingNormals = 0x2000;
/**
* This step splits meshes with more than one primitive type in homogeneous
* sub meshes.
*
* The step is executed directly after the triangulation step. After the
* step returns just *one* bit remains set in aiMesh::mPrimitiveTypes. This
* is especially useful for real-time rendering where point and line
* primitives are often ignored, or rendered separately. You can use the
* <tt>#AI_CONFIG_PP_SBP_REMOVE</tt> option to specify which primitive types
* you need. This can be used to easily exclude the rarely wanted lines and
* points from the import.
*/
public static final long SortByPType = 0x8000;
/**
* This step searches all meshes for degenerated primitives and converts
* them to proper lines or points.
*
* A face is 'degenerated' if one or more of its points are identical. To
* have the degenerated stuff not only detected and collapsed but also
* removed, try one of the following procedures: <br>
* <b>1.</b> (if you support lines&points for rendering but don't want the
* degenerates)</br>
* <ul>
* <li>Specify the #aiProcess_FindDegenerates flag.</li>
* <li>Set the <tt>AI_CONFIG_PP_FD_REMOVE</tt> option to 1. This will cause
* the step to remove degenerated triangles from the import as soon as
* they're detected. They won't pass any further pipeline steps.</li>
* </ul>
* <br>
* <b>2.</b>(if you don't support lines&points at all ...)</br>
* <ul>
* <li>Specify the #aiProcess_FindDegenerates flag.</li>
* <li>Specify the #aiProcess_SortByPType flag. This moves line and point
* primitives to separate meshes.</li>
* <li>Set the <tt>AI_CONFIG_PP_SBP_REMOVE</tt> option to
*
* <code>aiPrimitiveType_POINTS | aiPrimitiveType_LINES</code> to enforce
* SortByPType to reject point and line meshes from the scene.</li>
* </ul>
*
* Degenerated polygons are not necessarily evil and that's why they're not
* removed by default. There are several file formats which don't support
* lines or points. Some exporters bypass the format specification and write
* them as degenerated triangle instead. Assimp can't guess for you, so you
* have to decide. YOU!
*/
public static final long FindDegenerates = 0x10000;
/**
* This step searches all meshes for incorrect data such as all-zero normal
* vectors or invalid UV coordinates and removes them.
*
* This is especially useful for stuff like normals or tangents. Some
* exporters tend to write very strange stuff into their output files. This
* flag increases the chance that this is detected and repaired
* automatically.
*/
public static final long FindInvalidData = 0x20000;
/**
* This step converts non-UV mappings (such as spherical or cylindrical
* mapping) to proper texture coordinate channels.
*
* Most applications will support UV mapping only so you will probably want
* to specify this step in every case. Note that Assimp is not always able
* to match the original mapping implementation of the 3d application which
* produced a model perfectly. It's always better to let max,maja,blender or
* whatever you're using compute the UV channels.
*
* @note If this step is not requested, you'll need to process the
* <tt>#AI_MATKEY_MAPPING<7tt> material property in order to display
* all files properly.
*/
public static final long GenUVCoords = 0x40000;
/**
* This step applies per-texture UV transformations and bakes them to
* stand-alone texture coordinate channels.
*
* UV transformations are specified per-texture - see the
* <tt>#AI_MATKEY_UVTRANSFORM</tt> material key for more information. This
* step processes all textures with transformed input UV coordinates and
* generates new (pre-transformed) UV channel which replace the old channel.
* Most applications won't support UV transformations, so you will probably
* always want to request this step.
*
* @note UV transformations are usually implemented in real time
* applications by transforming texture coordinates at vertex shader
* stage with a 3x3 (homogeneous) transformation matrix.
*/
public static final long TransformUVCoords = 0x80000;
/**
* This step searches for duplicate meshes and replaces duplicates with
* references to the first mesh.
*
* This step takes a while, don't use it if you have no time for it. It's
* main purpose is to provide a workaround for the limitation that many
* export file formats don't support instanced meshes, so exporters need to
* duplicate meshes. This step removes the duplicates again. Please note
* that Assimp does currently not support per-node material assignment to
* meshes, which means that identical meshes with different materials are
* currently *not* joined, although this is planned for future versions.
*/
public static final long FindInstances = 0x100000;
/**
* A post processing step to reduce the number of meshes in the scene.
*
* This is a very effective optimization and is recommended to be used
* together with <code>OptimizeGraph</code>, if possible. It is fully
* compatible with both <code>SplitLargeMeshes</code> and
* <code>SortByPType</code>.
*/
public static final long OptimizeMeshes = 0x200000;
/**
* A post processing step to optimize the scene hierarchy.
*
* Nodes with no animations, bones, lights or cameras assigned are collapsed
* and joined.
*
* Node names can be lost during this step. If you use special 'tag nodes'
* to pass additional information through your content pipeline, use the
* <tt>#AI_CONFIG_PP_OG_EXCLUDE_LIST<7tt> setting to specify a list of node
* names you want to be kept. Nodes matching one of the names in this list won't
* be touched or modified.
*
* Use this flag with caution. Most simple files will be collapsed to a
* single node, complex hierarchies are usually completely lost. That's not
* the right choice for editor environments, but probably a very effective
* optimization if you just want to get the model data, convert it to your
* own format and render it as fast as possible.
*
* This flag is designed to be used with #aiProcess_OptimizeMeshes for best
* results.
*
* 'Crappy' scenes with thousands of extremely small meshes packed in
* deeply nested nodes exist for almost all file formats.
* <code>OptimizeMeshes</code> in combination with
* <code>OptimizeGraph</code> usually fixes them all and makes them
* beatable.
*/
public static final long OptimizeGraph = 0x400000;
/**
* This step flips all UV coordinates along the y-axis and adjusts material
* settings and bitangents accordingly. <br>
* <b>Output UV coordinate system:</b> <code>
* 0y|0y ---------- 1x|0y
* | |
* | |
* | |
* 0x|1y ---------- 1x|1y
* </code>
*
* You'll probably want to consider this flag if you use Direct3D for
* rendering. The #aiProcess_ConvertToLeftHanded flag supersedes this
* setting and includes all conversions typically required for D3D-based
* applications.
*/
public static final long FlipUVs = 0x800000;
/**
* This step adjusts the output face winding order to be clockwise.
*
* The default face winding order is counter-clockwise. <br>
* <b>Output face order:</b>
*
* <code> x2
*
* x0 x1
* </code>
*
* You'll probably want to consider this flag if you use Direct3D for
* rendering. The #aiProcess_ConvertToLeftHanded flag supersedes this
* setting and includes all conversions typically required for D3D-based
* applications.
*/
public static final long FlipWindingOrder = 0x1000000;
}

View File

@ -1,147 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Represents a rotation quaternion
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public class Quaternion {
public float x, y, z, w;
/**
* Construction from euler angles
*
* @param fPitch
* Rotation around the x axis
* @param fYaw
* Rotation around the y axis
* @param fRoll
* Rotation around the z axis
*/
public Quaternion(float fPitch, float fYaw, float fRoll) {
float fSinPitch = (float) Math.sin(fPitch * 0.5F);
float fCosPitch = (float) Math.cos(fPitch * 0.5F);
float fSinYaw = (float) Math.sin(fYaw * 0.5F);
float fCosYaw = (float) Math.cos(fYaw * 0.5F);
float fSinRoll = (float) Math.sin(fRoll * 0.5F);
float fCosRoll = (float) Math.cos(fRoll * 0.5F);
float fCosPitchCosYaw = (fCosPitch * fCosYaw);
float fSinPitchSinYaw = (fSinPitch * fSinYaw);
x = fSinRoll * fCosPitchCosYaw - fCosRoll * fSinPitchSinYaw;
y = fCosRoll * fSinPitch * fCosYaw + fSinRoll * fCosPitch * fSinYaw;
z = fCosRoll * fCosPitch * fSinYaw - fSinRoll * fSinPitch * fCosYaw;
w = fCosRoll * fCosPitchCosYaw + fSinRoll * fSinPitchSinYaw;
}
/**
* Construction from an existing rotation matrix
*
* @param pRotMatrix
* Matrix to be converted to a quaternion
*/
public Quaternion(Matrix3x3 pRotMatrix) {
float t = 1 + pRotMatrix.coeff[0] + pRotMatrix.coeff[4]
+ pRotMatrix.coeff[8];
// large enough
if (t > 0.00001f) {
float s = (float) Math.sqrt(t) * 2.0f;
x = (pRotMatrix.coeff[8] - pRotMatrix.coeff[7]) / s;
y = (pRotMatrix.coeff[6] - pRotMatrix.coeff[2]) / s;
z = (pRotMatrix.coeff[1] - pRotMatrix.coeff[3]) / s;
w = 0.25f * s;
} // else we have to check several cases
else if (pRotMatrix.coeff[0] > pRotMatrix.coeff[4]
&& pRotMatrix.coeff[0] > pRotMatrix.coeff[8]) {
// Column 0:
float s = (float) Math.sqrt(1.0f + pRotMatrix.coeff[0]
- pRotMatrix.coeff[4] - pRotMatrix.coeff[8]) * 2.0f;
x = -0.25f * s;
y = (pRotMatrix.coeff[1] + pRotMatrix.coeff[3]) / s;
z = (pRotMatrix.coeff[6] + pRotMatrix.coeff[2]) / s;
w = (pRotMatrix.coeff[7] - pRotMatrix.coeff[5]) / s;
} else if (pRotMatrix.coeff[4] > pRotMatrix.coeff[8]) {
// Column 1:
float s = (float) Math.sqrt(1.0f + pRotMatrix.coeff[4]
- pRotMatrix.coeff[0] - pRotMatrix.coeff[8]) * 2.0f;
x = (pRotMatrix.coeff[1] + pRotMatrix.coeff[3]) / s;
y = -0.25f * s;
z = (pRotMatrix.coeff[5] + pRotMatrix.coeff[7]) / s;
w = (pRotMatrix.coeff[2] - pRotMatrix.coeff[6]) / s;
} else {
// Column 2:
float s = (float) Math.sqrt(1.0f + pRotMatrix.coeff[8]
- pRotMatrix.coeff[0] - pRotMatrix.coeff[4]) * 2.0f;
x = (pRotMatrix.coeff[6] + pRotMatrix.coeff[2]) / s;
y = (pRotMatrix.coeff[5] + pRotMatrix.coeff[7]) / s;
z = -0.25f * s;
w = (pRotMatrix.coeff[3] - pRotMatrix.coeff[1]) / s;
}
}
/**
* Convert the quaternion to a rotation matrix
*
* @return 3x3 rotation matrix
*/
public Matrix3x3 getMatrix() {
Matrix3x3 resMatrix = new Matrix3x3();
resMatrix.coeff[0] = 1.0f - 2.0f * (y * y + z * z);
resMatrix.coeff[1] = 2.0f * (x * y + z * w);
resMatrix.coeff[2] = 2.0f * (x * z - y * w);
resMatrix.coeff[3] = 2.0f * (x * y - z * w);
resMatrix.coeff[4] = 1.0f - 2.0f * (x * x + z * z);
resMatrix.coeff[5] = 2.0f * (y * z + x * w);
resMatrix.coeff[6] = 2.0f * (x * z + y * w);
resMatrix.coeff[7] = 2.0f * (y * z - x * w);
resMatrix.coeff[8] = 1.0f - 2.0f * (x * x + y * y);
return resMatrix;
}
}

View File

@ -1,176 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
/**
* Represents the asset data that has been loaded. A scene consists of
* multiple meshes, animations, materials and embedded textures.
* And it defines the scene graph of the asset (the hierarchy of all
* meshes, bones, ...).
* <p/>
* An instance of this class is returned by <code>Importer.readFile()</code>.
*
* @author Alexander Gessler (aramis_acg@users.sourceforge.net)
* @version 1.0
*/
public class Scene {
private Mesh[] m_vMeshes = null;
private Texture[] m_vTextures = null;
private Material[] m_vMaterials = null;
private Animation[] m_vAnimations = null;
private Node m_rootNode = null;
private Importer imp = null;
private int flags = 0;
@SuppressWarnings("unused")
private Scene() {
}
protected Scene(Importer imp) {
this.imp = imp;
}
public final Importer getImporter() {
return this.imp;
}
/**
* Get the scene flags. This can be any combination of the FLAG_XXX constants.
* @return Scene flags.
*/
public final int getFlags() {
return flags;
}
/**
* Get the mesh list of the scene.
*
* @return mesh list
*/
public final Mesh[] getMeshes() {
return m_vMeshes;
}
/**
* Get the number of meshes in the scene
* @return this value can be 0 if the <code>ANIMATION_SKELETON_ONLY</code>
* flag is set.
*/
public final int getNumMeshes() {
return m_vMeshes.length;
}
/**
* Get a mesh from the scene
* @param i Index of the mesh
* @return scene.mesh[i]
*/
public final Mesh getMesh(int i) {
assert(i < m_vMeshes.length);
return m_vMeshes[i];
}
/**
* Get the texture list
*
* @return Texture list
*/
public final Texture[] getTextures() {
return m_vTextures;
}
/**
* Get the number of embedded textures in the scene
* @return the number of embedded textures in the scene, usually 0.
*/
public int getNumTextures() {
return m_vTextures.length;
}
/**
* Get an embedded texture from the scene
* @param i Index of the textures.
* @return scene.texture[i]
*/
public final Texture getTexture(int i) {
assert(i < m_vTextures.length);
return m_vTextures[i];
}
/**
* Get the material list for the scene
*
* @return Material list
*/
public final Material[] getMaterials() {
return m_vMaterials;
}
/**
* Get the number of animations in the scene
* @return this value could be 0, most models have no animations
*/
public int getNumAnimations() {
return m_vAnimations.length;
}
/**
* Get the animation list for the scene
*
* @return Animation list
*/
public final Animation[] getAnimations() {
return m_vAnimations;
}
/**
* Get the root node of the scene graph
*
* @return Root node
*/
public final Node getRootNode() {
return m_rootNode;
}
}

View File

@ -1,195 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
/**
* Represents an embedded texture. Sometimes textures are not referenced with a
* path, instead they are directly embedded into the model file. Example file
* formats doing this include MDL3, MDL5 and MDL7 (3D GameStudio). Embedded
* textures are converted to an array of color values (RGBA).
* <p/>
* Compressed textures (textures that are stored in a format like png or jpg)
* are represented by the <code><CompressedTexture/code> class.
*
* @author Aramis (Alexander Gessler)
* @version 1.0
*/
public class Texture {
protected int width = 0;
protected int height = 0;
protected int needAlpha = 0xffffffff;
protected Object data = null;
/**
* Retrieve the height of the texture image
*
* @return Height, in pixels
*/
public int getHeight() {
return height;
}
/**
* Retrieve the width of the texture image
*
* @return Width, in pixels
*/
public int getWidth() {
return width;
}
/**
* Returns whether the texture uses its alpha channel
*
* @return <code>true</code> if at least one pixel has an alpha value below
* 0xFF.
*/
public boolean hasAlphaChannel() {
// already computed?
if (0xffffffff == needAlpha && null != data) {
Color[] clr = getColorArray();
for (Color c : clr) {
if (c.getAlpha() < 255) {
needAlpha = 1;
return true;
}
}
needAlpha = 0;
return false;
}
return 0x1 == needAlpha;
}
/**
* Get the color at a given position of the texture
*
* @param x
* X coordinate, zero based
* @param y
* Y coordinate, zero based
* @return Color at this position
*/
public Color getPixel(int x, int y) {
assert (x < width && y < height);
return ((Color[]) data)[y * width + x];
}
/**
* Get a pointer to the color buffer of the texture
*
* @return Array of <code>java.awt.Color</code>, size: width * height
*/
public Color[] getColorArray() {
return (Color[]) data;
}
/**
* Convert the texture into a <code>java.awt.BufferedImage</code>
*
* @return Valid <code>java.awt.BufferedImage</code> object containing a
* copy of the texture image. The texture is a ARGB texture if an
* alpha channel is really required, otherwise RGB is used as pixel
* format.
* @throws IOException
* If the conversion fails.
*/
public BufferedImage convertToImage() throws IOException {
BufferedImage buf = new BufferedImage(width, height,
hasAlphaChannel() ? BufferedImage.TYPE_INT_ARGB
: BufferedImage.TYPE_INT_RGB);
int[] aiColorBuffer = new int[width * height];
Color[] clr = getColorArray();
for (int i = 0; i < width * height; ++i) {
aiColorBuffer[i] = clr[i].getRGB();
}
buf.setRGB(0, 0, width, height, aiColorBuffer, 0, width * 4);
return buf;
}
/**
* Saves a texture as TGA file. This is a debugging helper.
*
* @param texture
* Texture to be exported
* @param path
* Output path. Output file format is always TGA, regardless of
* the file extension.
*/
public static void SaveTextureToTGA(Texture texture, String path)
throws IOException {
BufferedImage bImg = texture.convertToImage();
Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix("tga");
if (!(writers.hasNext())) {
final String err = "No writer for TGA file format available";
DefaultLogger.get().error(err);
throw new IOException(err);
}
ImageWriter w = (ImageWriter) (writers.next());
File fo = new File(path);
ImageOutputStream ios = ImageIO.createImageOutputStream(fo);
w.setOutput(ios);
w.write(bImg);
}
}

View File

@ -1,376 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
package assimp.test;
import assimp.*;
import java.io.FileWriter;
import java.io.IOException;
/**
* Example class to demonstrate how to use jAssimp to load an asset from a file.
* The Main() method expects two parameters, the first being the path to the
* file to be opened, the second being the output path. The class writes a text
* file with the asset data inside.
*/
public class DumpToFile {
/**
* Count all nodes recursively
*
* @param node
* Current node
* @return Number of nodes
*/
public static int CountNodes(Node node) {
int ret = 1;
if (0 != node.getNumChildren()) {
for (Node n : node.getChildren()) {
ret += CountNodes(n);
}
}
return ret;
}
/**
* Entry point of the application
*
* @param arguments
* The first argument is the name of the mesh to be opened, the
* second is the name of the primary output file.
* @throws IOException
*/
public static void main(String[] arguments) throws IOException {
/*
* Use output.txt as default output file if none was specified.
*/
if (1 == arguments.length) {
String s = arguments[0];
arguments = new String[2];
arguments[0] = s;
arguments[1] = "output.txt";
} else if (2 != arguments.length) {
System.exit(-5);
}
if (!arguments[1].endsWith(".txt")) {
System.out.println("The output file extension must be .txt");
System.exit(-10);
return;
}
FileWriter stream;
try {
stream = new FileWriter(arguments[1]);
} catch (IOException e) {
e.printStackTrace();
System.out.println("Unable to open output file for writing");
System.exit(-15);
return;
}
/*
* Try to create an instance of class assimp.Importer. The constructor
* throws an assimp.NativeException exception if the native jAssimp
* library is not available.It must be placed in the jar/class directory
* of the application
*/
Importer imp;
try {
imp = new Importer();
} catch (NativeException nativeException) {
nativeException.printStackTrace();
System.out.println("NativeException caught [#1]: "
+ nativeException.getMessage());
return;
}
/*
* Load the asset into memory. Again, a NativeException exception could
* be thrown if an unexpected errors occurs in the native interface. If
* assimp is just unable to load the asset null is the return value and
* no exception is thrown
*/
Scene scene;
try {
scene = imp.readFile(arguments[0],
PostProcessing.Preset.TargetRealtime_MaxQuality);
} catch (NativeException nativeException) {
nativeException.printStackTrace();
System.out.println("NativeException caught [#2] :"
+ nativeException.getMessage());
return;
}
if (null == scene) {
System.out.println("Unable to load asset: " + arguments[0]);
return;
}
/*
* Now iterate through all meshes that have been loaded
*/
if (0 != scene.getNumMeshes()) {
for (Mesh mesh : scene.getMeshes()) {
stream.write("Mesh\n");
stream.write("\tNum Vertices: " + mesh.getNumVertices() + "\n");
stream.write("\tNum Faces: " + mesh.getNumFaces() + "\n");
stream.write("\tNum Bones: " + mesh.getNumBones() + "\n\n");
/*
* Output all vertices. First get direct access to jAssimp's
* buffers
*/
float[] positions = mesh.getPositionArray();
float[] normals = mesh.getNormalArray();
float[] tangents = mesh.getTangentArray();
float[] bitangents = mesh.getBitangentArray();
float[][] uvs = new float[Mesh.MAX_NUMBER_OF_TEXTURECOORDS][];
for (int i = 0; i < Mesh.MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
if (mesh.hasUVCoords((i)))
uvs[i] = mesh.getTexCoordArray(i);
else
break;
}
float[][] vcs = new float[Mesh.MAX_NUMBER_OF_COLOR_SETS][];
for (int i = 0; i < Mesh.MAX_NUMBER_OF_COLOR_SETS; ++i) {
if (mesh.hasVertexColors((i)))
uvs[i] = mesh.getVertexColorArray(i);
else
break;
}
for (int i = 0; i < mesh.getNumVertices(); ++i) {
// format:
// "Vertex pos(x|y|z) nor(x|y|z) tan(x|y|) bit(x|y|z)"
// great that this IDE is automatically able to replace +
// with append ... ;-)
if (mesh.hasPositions()) {
stream.write(new StringBuilder().append(
"\tVertex: pos(").append(positions[i * 3])
.append("|").append(positions[i * 3 + 1])
.append("|").append(positions[i * 3 + 2])
.append(")").toString());
}
if (mesh.hasNormals()) {
stream.write(new StringBuilder().append("\tnor(")
.append(normals[i * 3]).append("|").append(
normals[i * 3 + 1]).append("|").append(
normals[i * 3 + 2]).append(")")
.toString());
}
if (mesh.hasTangentsAndBitangents()) {
stream.write(new StringBuilder().append("\ttan(")
.append(tangents[i * 3]).append("|").append(
tangents[i * 3 + 1]).append("|")
.append(tangents[i * 3 + 2]).append(")")
.toString());
stream.write(new StringBuilder().append("\tbit(")
.append(bitangents[i * 3]).append("|").append(
bitangents[i * 3 + 1]).append("|")
.append(bitangents[i * 3 + 2]).append(")")
.toString());
}
for (int a = 0; i < Mesh.MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
if (!mesh.hasUVCoords((a)))
break;
stream.write(new StringBuilder().append("\tuv").append(
a).append("(").append(uvs[a][i * 3])
.append("|").append(uvs[a][i * 3 + 1]).append(
"|").append(uvs[a][i * 3 + 2]).append(
")").toString());
}
for (int a = 0; i < Mesh.MAX_NUMBER_OF_COLOR_SETS; ++a) {
if (!mesh.hasVertexColors((a)))
break;
stream.write(new StringBuilder().append("\tcol")
.append(a).append("(").append(vcs[a][i * 4])
.append("|").append(vcs[a][i * 4 + 1]).append(
"|").append(vcs[a][i * 4 + 2]).append(
"|").append(vcs[a][i * 4 + 3]).append(
")").toString());
}
stream.write("\n");
}
stream.write("\n");
/*
* Now write a list of all faces in this model
*/
Face[] faces = mesh.getFaceArray();
for (int i = 0; i < mesh.getNumFaces(); ++i) {
stream.write(new StringBuilder().append("\tFace (").append(
faces[i * 3]).append("|").append(faces[i * 3 + 1])
.append("|").append(faces[i * 3 + 2]).append(")\n")
.toString());
}
stream.write("\n");
/*
* Now write a list of all bones of this model
*/
if (mesh.hasBones()) {
Bone[] bones = mesh.getBonesArray();
for (Bone bone : bones) {
stream.write("\tBone " + bone.getName() + "\n");
Bone.Weight[] weights = bone.getWeightsArray();
for (Bone.Weight weight : weights) {
stream.write("\t\tWeight (" + weight.index + "|"
+ weight.weight + ")\n");
}
}
}
stream.write("\n");
}
}
/*
* Now iterate through all animations that have been loaded
*/
if (0 != scene.getNumAnimations()) {
for (Animation anim : scene.getAnimations()) {
stream.write("Animation\n" + "\tName: " + anim.getName() + "\n"
+ "\tDuration: " + anim.getDuration() + "\n"
+ "\tTicks/s: " + anim.getTicksPerSecond() + "\n"
+ "\tNum BoneAnim channels: "
+ anim.getNumNodeAnimChannels() + "\n\n");
/*
* Write all bone animation channels
*/
if (0 != anim.getNumNodeAnimChannels()) {
for (NodeAnim boneAnim : anim.getNodeAnimChannels()) {
stream.write("\tBoneAnim\n" + "\tName: "
+ boneAnim.getName() + "\n"
+ "\tNum QuatKeys: "
+ boneAnim.getNumQuatKeys() + "\n");
/*
* Write all rotation keys
*/
for (NodeAnim.KeyFrame<Quaternion> key : boneAnim
.getQuatKeys()) {
stream.write("\t\tQuatKey: \n" + "\t\t\tTicks: "
+ key.time + "\n" + "\t\t\tValue: ("
+ key.value.x + "|" + key.value.y + "|"
+ key.value.z + "|" + key.value.w + ")\n");
}
stream.write("\tNum SclKeys: "
+ boneAnim.getNumScalingKeys() + "\n");
/*
* Write all scaling keys
*/
for (NodeAnim.KeyFrame<float[]> key : boneAnim
.getScalingKeys()) {
stream.write("\t\tSclKey: \n" + "\t\t\tTicks: "
+ key.time + "\n" + "\t\t\tValue: ("
+ key.value[0] + "|" + key.value[1] + "|"
+ key.value[2] + ")\n");
}
stream.write("\tNum PosKeys: "
+ boneAnim.getNumPosKeys() + "\n");
/*
* Write all position keys
*/
for (NodeAnim.KeyFrame<float[]> key : boneAnim
.getPosKeys()) {
stream.write("\t\tPosKey: \n" + "\t\t\tTicks: "
+ key.time + "\n" + "\t\t\tValue: ("
+ key.value[0] + "|" + key.value[1] + "|"
+ key.value[2] + ")\n");
}
stream.write("\n");
}
}
}
}
/*
* Now print all nodes -> recursively
*/
stream.write("Nodegraph\n" + "\tNodes: "
+ CountNodes(scene.getRootNode()) + "\n\n");
// scene.getRootNode().printNodes( stream, "\t");
stream.write("\n");
/*
* Now print all textures .. hm ... export them to proper TGA files
*/
if (0 != scene.getNumTextures()) {
int i = 0;
for (Texture texture : scene.getTextures()) {
String path = arguments[1].substring(0,
arguments[1].length() - 4)
+ "_tex" + i++ + ".tga";
stream.write("Emb. Texture\n" + "\tExportPath: " + path
+ "\n\n");
Texture.SaveTextureToTGA(texture, path);
}
}
/*
* Now print all materials
*/
// ...
// close the stream again
stream.close();
}
}

View File

@ -1,2 +0,0 @@
javah -classpath ".\..\java\bin" -d "." "assimp.Importer"

View File

@ -1,67 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class assimp_Importer */
#ifndef _Included_assimp_Importer
#define _Included_assimp_Importer
#ifdef __cplusplus
extern "C" {
#endif
#undef assimp_Importer_PROPERTY_WAS_NOT_EXISTING
#define assimp_Importer_PROPERTY_WAS_NOT_EXISTING -1L
#undef assimp_Importer_ABI_VERSION
#define assimp_Importer_ABI_VERSION 1
/*
* Class: assimp_Importer
* Method: _NativeInitContext
* Signature: (I)I
*/
JNIEXPORT jlong JNICALL Java_assimp_Importer__1NativeInitContext
(JNIEnv *, jobject, jint);
/*
* Class: assimp_Importer
* Method: _NativeFreeContext
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeFreeContext
(JNIEnv *, jobject, jlong);
/*
* Class: assimp_Importer
* Method: _NativeLoad
* Signature: (Ljava/lang/String;JJ)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeLoad
(JNIEnv *, jobject, jstring, jlong, jlong);
/*
* Class: assimp_Importer
* Method: _NativeSetPropertyInt
* Signature: (Ljava/lang/String;IJ)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeSetPropertyInt
(JNIEnv *, jobject, jstring, jint, jlong);
/*
* Class: assimp_Importer
* Method: _NativeSetPropertyFloat
* Signature: (Ljava/lang/String;FJ)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeSetPropertyFloat
(JNIEnv *, jobject, jstring, jfloat, jlong);
/*
* Class: assimp_Importer
* Method: _NativeSetPropertyString
* Signature: (Ljava/lang/String;Ljava/lang/String;J)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeSetPropertyString
(JNIEnv *, jobject, jstring, jstring, jlong);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,41 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Animation::Initialize()
{
AIJ_LOAD_CLASS();
AIJ_LOAD_FIELD(name);
AIJ_LOAD_FIELD(mDuration);
AIJ_LOAD_FIELD(mTicksPerSecond);
AIJ_LOAD_FIELD(nodeAnims);
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Animation::Fill(jobject obj,const aiAnimation* pcSrc)
{
jobjectArray ja;
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
pc->SetObjectField(obj,name,JNU_NewStringNative(pc,pcSrc->mName.data));
pc->SetDoubleField(obj,mDuration,pcSrc->mDuration);
pc->SetDoubleField(obj,mTicksPerSecond,pcSrc->mTicksPerSecond);
// copy node animations
if (pcSrc->mNumChannels) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mChannels,pcSrc->mNumChannels,
AIJ_GET_HANDLE(assimp.NodeAnim),ja);
pc->SetObjectField(obj,nodeAnims,ja);
}
}

View File

@ -1,66 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Bone::Initialize()
{
AIJ_LOAD_CLASS();
AIJ_LOAD_FIELD(name);
AIJ_LOAD_FIELD(weights);
Weight.Initialize();
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Bone::Fill(jobject obj,const aiBone* pcSrc)
{
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
// copy bone weights
if (pcSrc->mNumWeights) {
jobjectArray jarr = pc->NewObjectArray(pcSrc->mNumWeights,Weight.Class,0);
for (unsigned int i = 0; i < pcSrc->mNumWeights;++i) {
jobject jobj = pc->NewObject(Weight.Class,Weight.DefaultCtor);
Weight.Fill(jobj,&pcSrc->mWeights[i]);
pc->SetObjectArrayElement(jarr,i,jobj);
}
pc->SetObjectField(obj,weights,jarr);
}
pc->SetObjectField(obj,name,JNU_NewStringNative(pc,pcSrc->mName.data));
jobject matrix = pc->NewObject(AIJ_GET_CLASS_HANDLE(assimp.Matrix4x4),AIJ_GET_DEFAULT_CTOR_HANDLE(assimp.Matrix4x4));
AIJ_GET_HANDLE(assimp.Matrix4x4).Fill(matrix,&pcSrc->mOffsetMatrix);
pc->SetObjectField(obj,name,matrix);
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Bone::_Weight::Initialize()
{
AIJ_LOAD_CLASS();
AIJ_LOAD_FIELD(index);
AIJ_LOAD_FIELD(weight);
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Bone::_Weight::Fill(jobject obj,const aiVertexWeight* pcSrc)
{
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
pc->SetIntField(obj,index,(jint)pcSrc->mVertexId);
pc->SetFloatField(obj,weight,(jfloat)pcSrc->mWeight);
}

View File

@ -1,56 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_NodeAnim::Initialize()
{
AIJ_LOAD_CLASS();
AIJ_LOAD_FIELD(mName);
AIJ_LOAD_FIELD(mPosKeys);
AIJ_LOAD_FIELD(mScalingKeys);
AIJ_LOAD_FIELD(mQuatKeys);
VectorKey.Initialize();
QuatKey.Initialize();
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_NodeAnim::Fill(jobject obj,const aiNodeAnim* pcSrc)
{
jobjectArray ja;
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
pc->SetObjectField(obj,mName,JNU_NewStringNative(pc,pcSrc->mNodeName.data));
// copy position keys
if (pcSrc->mNumPositionKeys) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mPositionKeys,pcSrc->mNumPositionKeys,
AIJ_GET_HANDLE(assimp.NodeAnim.VectorKey),ja);
pc->SetObjectField(obj,mPosKeys,ja);
}
// copy scaling keys
if (pcSrc->mNumScalingKeys) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mScalingKeys,pcSrc->mNumScalingKeys,
AIJ_GET_HANDLE(assimp.NodeAnim.VectorKey),ja);
pc->SetObjectField(obj,mScalingKeys,ja);
}
// copy rotation keys
if (pcSrc->mNumRotationKeys) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mRotationKeys,pcSrc->mNumRotationKeys,
AIJ_GET_HANDLE(assimp.NodeAnim.QuatKey),ja);
pc->SetObjectField(obj,mQuatKeys,ja);
}
}

View File

@ -1,14 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;

View File

@ -1,186 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
bool JNIEnvironment::AttachToCurrentThread (JNIEnv* pcEnv)
{
ai_assert(NULL != pcEnv);
// now initialize the thread-local storage
if (!ptr.get()) {
// attach to the current thread
JavaVM* vm;
pcEnv->GetJavaVM(&vm);
vm->AttachCurrentThread((void **) &pcEnv, NULL);
ptr.reset(new JNIThreadData(pcEnv));
}
// increase the reference counter
else ptr->m_iNumRef++;
// attach the logger
((JNILogDispatcher*)DefaultLogger::get())->OnAttachToCurrentThread(ptr.get());
// get handles to all methods/fields/classes
Initialize();
return true;
}
// ------------------------------------------------------------------------------------------------
bool JNIEnvironment::DetachFromCurrentThread ()
{
ai_assert(NULL != pcEnv);
// detach the logger
((JNILogDispatcher*)DefaultLogger::get())->OnDetachFromCurrentThread(ptr.get());
// decrease the reference counter
if (NULL != ptr.get()) {
ptr->m_iNumRef--;
if (0 == ptr->m_iNumRef) {
JavaVM* vm;
ptr->m_pcEnv->GetJavaVM(&vm);
vm->DetachCurrentThread();
}
}
return true;
}
// ------------------------------------------------------------------------------------------------
JNIThreadData* JNIEnvironment::GetThread()
{
ai_assert(NULL != ptr.get());
return ptr.get();
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_java::_lang::_String::Initialize()
{
JNIEnv* pcEnv = JNIEnvironment::Get()->GetThread()->m_pcEnv;
// first initialize some members
if( !(Class = pcEnv->FindClass("java.lang.String"))) {
JNIEnvironment::Get()->ThrowNativeError("Can't get handle of class java.lang.String");
}
if( !(getBytes = pcEnv->GetMethodID(Class,"getBytes","()[byte"))) {
JNIEnvironment::Get()->ThrowNativeError("Can't get handle of class java.lang.String");
}
if( !(constructor_ByteArray = pcEnv->GetStaticMethodID(Class,"<init>","([byte)V"))) {
JNIEnvironment::Get()->ThrowNativeError("Can't get handle of class java.lang.String");
}
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_java::_lang::_Array::Initialize()
{
JNIEnv* pcEnv = JNIEnvironment::Get()->GetThread()->m_pcEnv;
if( !(FloatArray_Class = pcEnv->FindClass("[F")))
JNIEnvironment::Get()->ThrowNativeError("Unable to get handle of class float[]");
if( !(IntArray_Class = pcEnv->FindClass("[I")))
JNIEnvironment::Get()->ThrowNativeError("Unable to get handle of class int[]");
}
// ------------------------------------------------------------------------------------------------
jstring JNU_NewStringNative(JNIEnv *env, const char *str)
{
jstring result;
jbyteArray bytes = 0;
int len;
if (env->EnsureLocalCapacity( 2) < 0) {
return NULL; /* out of memory error */
}
len = (int)::strlen(str);
bytes = env->NewByteArray(len);
if (bytes != NULL) {
env->SetByteArrayRegion(bytes, 0, len,
(jbyte *)str);
result = (jstring)env->NewObject(AIJ_GET_HANDLE(java.lang.String.Class),
AIJ_GET_HANDLE(java.lang.String.constructor_ByteArray), bytes);
env->DeleteLocalRef(bytes);
return result;
} /* else fall through */
return NULL;
}
// ------------------------------------------------------------------------------------------------
char *JNU_GetStringNativeChars(JNIEnv *env, jstring jstr)
{
jbyteArray bytes = 0;
jthrowable exc;
char *result = 0;
if (env->EnsureLocalCapacity(2) < 0) {
return 0; /* out of memory error */
}
bytes = (jbyteArray)env->CallObjectMethod(jstr,AIJ_GET_HANDLE(java.lang.String.getBytes));
exc = env->ExceptionOccurred();
if (!exc) {
jint len = env->GetArrayLength(bytes);
result = (char *)malloc(len + 1);
if (result == 0)
{
env->DeleteLocalRef(bytes);
return 0;
}
env->GetByteArrayRegion(bytes, 0, len,
(jbyte *)result);
result[len] = 0; /* NULL-terminate */
}
else {
env->DeleteLocalRef(exc);
}
env->DeleteLocalRef(bytes);
return result;
}
// ------------------------------------------------------------------------------------------------
void JNU_CopyDataToArray(JNIEnv* pc, jarray jfl, void* data, unsigned int size)
{
void* pf;
jboolean iscopy = false;
// lock the array and get direct access to its buffer
if(!(pf = pc->GetPrimitiveArrayCritical(jfl,&iscopy))) {
JNIEnvironment::Get()->ThrowNativeError("Unable to lock array");
}
// copy the data to the array
memcpy(pf,data,size);
// release our reference to the array
pc->ReleasePrimitiveArrayCritical(jfl,pf,0);
}
// ------------------------------------------------------------------------------------------------
void JNU_CopyObjectArrayToVM(JNIEnv* pc, const void** in, unsigned int num,
JNIEnvironment::_Base& type, jobjectArray& out)
{
jobjectArray jarr = pc->NewObjectArray(num,type.Class,0);
for (unsigned int i = 0; i < num;++i) {
jobject jobj = pc->NewObject(type.Class,type.DefaultCtor);
type.Fill(jobj,in[i]);
pc->SetObjectArrayElement(jarr,i,jobj);
}
out = jarr;
}

View File

@ -1,506 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#ifndef INCLUDED_JBRIDGE_ENVIRONMENT_H
#define INCLUDED_JBRIDGE_ENVIRONMENT_H
namespace Assimp {
namespace jbridge {
// -----------------------------------------------------------------------------------------
// Nasty macros. One day I'll probably switch to a generic and beautiful solution, but
// this day is still far, far away
// -----------------------------------------------------------------------------------------
#define _AI_CONCAT(a,b) a ## b
#define AI_CONCAT(a,b) _AI_CONCAT(a,b)
#define AIJ_GET_JNIENV() JNIEnvironment::Get()->GetThread()->m_pcEnv
#define AIJ_BEGIN_CLASS(name) \
struct AI_CONCAT(_,name) : public _Base { \
void Initialize(); \
#define AIJ_END_CLASS(name) \
} name ;
#define AIJ_SET_FIELD_TYPE(field,type) \
const char* AI_CONCAT(QueryFieldString_,field) () { \
return type; \
} \
jfieldID field;
#define AIJ_SET_CLASS_TYPE(ctype,jtype) \
const char* QueryClassString() { \
return jtype; \
} \
void Fill(jobject obj,const ctype* pcSrc); \
\
inline void Fill(jobject obj,const void* pcSrc) { \
Fill(obj,(const ctype*)pcSrc); \
}
#define AIJ_LOAD_CLASS() \
JNIEnv* pc = AIJ_GET_JNIENV(); \
\
if(!(Class = pc->FindClass(QueryClassString()))) { \
JNIEnvironment::Get()->ThrowNativeError(std::string("Failed to load class ") + \
QueryClassString()); \
} \
DefaultCtor = pc->GetMethodID(Class,"<init>","");
#define AIJ_LOAD_FIELD(name) { \
const char* t = AI_CONCAT(QueryFieldString_,name)(); \
name = pc->GetFieldID(Class,# name,t); \
if (!name) \
JNIEnvironment::Get()->ThrowNativeError(std::string("Failed to load ") + \
QueryClassString() + "#" + t); \
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
#define AIJ_GET_HANDLE(h) (JNIEnvironment::Get()->h)
#define AIJ_GET_DEFAULT_CTOR_HANDLE(h) (JNIEnvironment::Get()->h.DefaultCtor)
#define AIJ_GET_CLASS_HANDLE(h) (JNIEnvironment::Get()->h.Class)
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
/**
* @brief Manages a list of JNI data structures private to a thread.
*/
struct JNIThreadData
{
//! Default constructor
JNIThreadData()
: m_pcEnv(NULL), m_iNumRef(1) {}
//! Construction from an existing JNIEnv
JNIThreadData(JNIEnv* env) : m_pcEnv(env), m_iNumRef(1) {}
//! JNI environment, is attached to the thread
JNIEnv* m_pcEnv;
//! Number of Importer instances that have been created by this thread
unsigned int m_iNumRef;
};
// -----------------------------------------------------------------------------------------
/** @brief Helper class to manage the JNI environment for multithreaded calls.
*
* It's not so simple. Java users have to create multiple instances of assimp.Importer
* to access Assimp from multiple threads, but we need to synchronize everything to a
* single Java logging implementation.
*/
class JNIEnvironment
{
private:
JNIEnvironment()
: m_iRefCnt(1) {}
public:
/** Attach a new thread to the environment */
static JNIEnvironment* Create() {
if (NULL == s_pcEnv) {
s_pcEnv = new JNIEnvironment();
}
else s_pcEnv->AddRef();
return s_pcEnv;
}
/** Static getter */
static JNIEnvironment* Get() {
ai_assert(NULL != s_pcEnv);
return s_pcEnv;
}
/** Add a reference to the environment */
unsigned int AddRef() {
return ++m_iRefCnt;
}
/** Remove a reference from the environment */
unsigned int Release() {
const unsigned int iNew = --m_iRefCnt;
if (0 == iNew) {
delete this;
}
return iNew;
}
/** Attach a JNIEnv to the current thread */
bool AttachToCurrentThread (JNIEnv* pcEnv);
/** Detach from the current thread */
bool DetachFromCurrentThread ();
/** Get the thread local data of the current thread */
JNIThreadData* GetThread();
/** Throw an NativeException exception with the specified error message
* The error message itself is optional. */
void ThrowNativeError(const std::string& msg = std::string("Unknown error"));
public:
// ------------------------------------------------------------------------------------
// Reflects the part of the Java class library which we need for our dealings
//
struct _java
{
void Initialize() {
lang.Initialize();
}
struct _lang
{
void Initialize() {
String.Initialize();
}
struct _String
{
void Initialize();
//! Handle to the java.lang.String class
static jclass Class;
//! Handle to the java.lang.String.getBytes() class
static jmethodID getBytes;
//! Handle to the java.lang.String.String(byte[]) c'tor
static jmethodID constructor_ByteArray;
} String;
struct _Array {
void Initialize();
jclass FloatArray_Class;
jclass IntArray_Class;
} Array;
} lang;
} java;
struct _Base {
virtual void Fill(jobject obj,const void* pcSrc) {}
//! Handle to class
jclass Class;
//! Handle to default c'tor
jmethodID DefaultCtor;
};
// ------------------------------------------------------------------------------------
// Reflects the classes of the assimp package.
//
struct _assimp
{
//! Initializes the package assimp for use with our bridge module
inline void Initialize() {
// The NativeException class must be initialized first as it
// is used by all other class initializion routines
NativeException.Initialize();
Importer.Initialize();
// now initialize all other classes, the order doesn't care.
Face.Initialize();
Scene.Initialize();
Importer.Initialize();
Mesh.Initialize();
Bone.Initialize();
Animation.Initialize();
NodeAnim.Initialize();
Texture.Initialize();
CompressedTexture.Initialize();
Matrix3x3.Initialize();
Matrix4x4.Initialize();
Quaternion.Initialize();
Node.Initialize();
Material.Initialize();
Camera.Initialize();
Light.Initialize();
};
//! Represents the JNI interface to class assimp.NativeException
AIJ_BEGIN_CLASS(NativeException)
AIJ_END_CLASS(NativeException)
//! Represents the JNI interface to class assimp.Importer
AIJ_BEGIN_CLASS(Importer)
AIJ_SET_CLASS_TYPE(Assimp::Importer,"assimp.Importer");
AIJ_SET_FIELD_TYPE(scene,"Lassimp.Scene");
AIJ_END_CLASS(Importer)
//! Represents the JNI interface to class assimp.Scene
AIJ_BEGIN_CLASS(Scene)
AIJ_SET_CLASS_TYPE(aiScene,"assimp.Scene");
AIJ_SET_FIELD_TYPE(m_vTextures,"[Lassimp.Texture");
AIJ_SET_FIELD_TYPE(m_vCameras,"[Lassimp.Camera");
AIJ_SET_FIELD_TYPE(m_vLights,"[Lassimp.Light");
AIJ_SET_FIELD_TYPE(m_vMeshes,"[Lassimp.Mesh");
AIJ_SET_FIELD_TYPE(m_vMaterials,"[Lassimp.Material");
AIJ_SET_FIELD_TYPE(m_vAnimations,"[Lassimp.Animation");
AIJ_SET_FIELD_TYPE(m_rootNode,"[Lassimp.Node");
AIJ_SET_FIELD_TYPE(flags,"I");
AIJ_END_CLASS(Scene)
//! Represents the JNI interface to class assimp.Mesh
AIJ_BEGIN_CLASS(Mesh)
AIJ_SET_CLASS_TYPE(aiMesh,"assimp.Mesh");
AIJ_SET_FIELD_TYPE(m_iPrimitiveTypes,"I");
AIJ_SET_FIELD_TYPE(m_vVertices,"[[F");
AIJ_SET_FIELD_TYPE(m_vTangents,"[[F");
AIJ_SET_FIELD_TYPE(m_vBitangents,"[[F");
AIJ_SET_FIELD_TYPE(m_vNormals,"[[F");
AIJ_SET_FIELD_TYPE(m_avUVs,"[[F");
AIJ_SET_FIELD_TYPE(m_vFaces,"[[F");
AIJ_SET_FIELD_TYPE(m_avColors,"[[F");
AIJ_SET_FIELD_TYPE(m_aiNumUVComponents,"[I");
AIJ_SET_FIELD_TYPE(m_vBones,"[Lassimp.Bone");
AIJ_SET_FIELD_TYPE(m_iMaterialIndex,"I");
AIJ_END_CLASS(Mesh)
//! Represents the JNI interface to class assimp.Face
AIJ_BEGIN_CLASS(Face)
AIJ_SET_CLASS_TYPE(aiFace,"assimp.Face");
AIJ_SET_FIELD_TYPE(indices,"LI");
AIJ_END_CLASS(Face)
//! Represents the JNI interface to class assimp.Bone
AIJ_BEGIN_CLASS(Bone)
AIJ_SET_CLASS_TYPE(aiBone,"assimp.Bone");
AIJ_SET_FIELD_TYPE(name,"Ljava.lang.String");
AIJ_SET_FIELD_TYPE(weights,"[Lassimp.Bone.Weight");
//! Represents the JNI interface to class assimp.Bone.Weight
AIJ_BEGIN_CLASS(Weight)
AIJ_SET_CLASS_TYPE(aiVertexWeight,"assimp.Bone.Weight");
AIJ_SET_FIELD_TYPE(index,"I");
AIJ_SET_FIELD_TYPE(weight,"F");
AIJ_END_CLASS(Weight)
AIJ_END_CLASS(Bone)
//! Represents the JNI interface to class assimp.Animation
AIJ_BEGIN_CLASS(Animation)
AIJ_SET_CLASS_TYPE(aiAnimation,"assimp.Animation");
AIJ_SET_FIELD_TYPE(name,"Ljava.lang.String");
AIJ_SET_FIELD_TYPE(mDuration,"D");
AIJ_SET_FIELD_TYPE(mTicksPerSecond,"D");
AIJ_SET_FIELD_TYPE(nodeAnims,"[Lassimp.NodeAnim");
AIJ_END_CLASS(Animation)
//! Represents the JNI interface to class assimp.NodeAnim
AIJ_BEGIN_CLASS(NodeAnim)
AIJ_SET_CLASS_TYPE(aiNodeAnim,"assimp.NodeAnim");
//! Represents the JNI interface to class assimp.BoneAnim.KeyFrame<float[]>
AIJ_BEGIN_CLASS(VectorKey)
AIJ_SET_CLASS_TYPE(aiVectorKey,"Lassimp.NodeAnim.KeyFrame<[F>");
AIJ_SET_FIELD_TYPE(time,"D");
AIJ_SET_FIELD_TYPE(value,"[F");
AIJ_END_CLASS(VectorKey)
//! Represents the JNI interface to class assimp.BoneAnim.KeyFrame<assimp.Quaternion>
AIJ_BEGIN_CLASS(QuatKey)
AIJ_SET_CLASS_TYPE(aiQuatKey,"Lassimp.NodeAnim.KeyFrame<Lassimp.Quaternion>");
AIJ_SET_FIELD_TYPE(time,"D");
AIJ_SET_FIELD_TYPE(value,"Lassimp.Quaternion");
AIJ_END_CLASS(QuatKey)
AIJ_SET_FIELD_TYPE(mName,"Ljava.lang.String");
AIJ_SET_FIELD_TYPE(mQuatKeys,"[Lassimp.NodeAnim.KeyFrame<Lassimp.Quaternion>");
AIJ_SET_FIELD_TYPE(mPosKeys, "[Lassimp.NodeAnim.KeyFrame<[F>");
AIJ_SET_FIELD_TYPE(mScalingKeys,"[Lassimp.NodeAnim.KeyFrame<[F>");
AIJ_END_CLASS(NodeAnim)
//! Represents the JNI interface to class assimp.Texture
AIJ_BEGIN_CLASS(Texture)
AIJ_SET_CLASS_TYPE(aiTexture,"assimp.Texture");
AIJ_SET_FIELD_TYPE(width,"I");
AIJ_SET_FIELD_TYPE(height,"I");
AIJ_SET_FIELD_TYPE(data,"[b");
AIJ_END_CLASS(Texture)
//! Represents the JNI interface to class assimp.CompressedTexture
AIJ_BEGIN_CLASS(CompressedTexture)
AIJ_SET_CLASS_TYPE(aiTexture,"assimp.CompressedTexture");
AIJ_SET_FIELD_TYPE(m_format,"Ljava.lang.String");
AIJ_END_CLASS(CompressedTexture)
//! Represents the JNI interface to class assimp.Material
AIJ_BEGIN_CLASS(Material)
AIJ_SET_CLASS_TYPE(aiMaterial,"assimp.Material");
//! Represents the JNI interface to class assimp.Material.Property
AIJ_BEGIN_CLASS(Property)
AIJ_SET_CLASS_TYPE(aiMaterialProperty,"assimp.Material.Property");
AIJ_SET_FIELD_TYPE(key,"L.java.lang.String");
AIJ_SET_FIELD_TYPE(value,"Ljava.lang.Object");
AIJ_END_CLASS(Property)
AIJ_SET_FIELD_TYPE(properties,"[Lassimp.Material.Property");
AIJ_END_CLASS(Material)
//! Represents the JNI interface to class assimp.Matrix4x4
AIJ_BEGIN_CLASS(Matrix4x4)
AIJ_SET_CLASS_TYPE(aiMatrix4x4,"assimp.Matrix4x4");
AIJ_SET_FIELD_TYPE(coeff,"[F");
AIJ_END_CLASS(Matrix4x4)
//! Represents the JNI interface to class assimp.Matrix3x3
AIJ_BEGIN_CLASS(Matrix3x3)
AIJ_SET_CLASS_TYPE(aiMatrix3x3,"assimp.Matrix3x3");
AIJ_SET_FIELD_TYPE(coeff,"[F");
AIJ_END_CLASS(Matrix3x3)
//! Represents the JNI interface to class assimp.Quaternion
AIJ_BEGIN_CLASS(Quaternion)
AIJ_SET_CLASS_TYPE(aiQuaternion,"assimp.Quaternion");
AIJ_SET_FIELD_TYPE(x,"F");
AIJ_SET_FIELD_TYPE(y,"F");
AIJ_SET_FIELD_TYPE(z,"F");
AIJ_SET_FIELD_TYPE(w,"F");
AIJ_END_CLASS(Quaternion)
//! Represents the JNI interface to class assimp.Node
AIJ_BEGIN_CLASS(Node)
AIJ_SET_CLASS_TYPE(aiNode,"assimp.Node");
AIJ_SET_FIELD_TYPE(meshIndices,"[I");
AIJ_SET_FIELD_TYPE(name,"Ljava.lang.String");
AIJ_SET_FIELD_TYPE(children,"[Lassimp.Node");
AIJ_SET_FIELD_TYPE(nodeTransform,"Lassimp.Matrix4x4");
AIJ_SET_FIELD_TYPE(parent,"Lassimp.Node");
AIJ_END_CLASS(Node)
//! Represents the JNI interface to class assimp.Camera
AIJ_BEGIN_CLASS(Camera)
AIJ_SET_CLASS_TYPE(aiCamera,"assimp.Camera");
AIJ_SET_FIELD_TYPE(mName,"Ljava.lang.String");
AIJ_SET_FIELD_TYPE(mPosition,"[F");
AIJ_SET_FIELD_TYPE(mUp,"[F");
AIJ_SET_FIELD_TYPE(mLookAt,"[F");
AIJ_SET_FIELD_TYPE(mHorizontalFOV,"F");
AIJ_SET_FIELD_TYPE(mClipPlaneNear,"F");
AIJ_SET_FIELD_TYPE(mClipPlaneFar,"F");
AIJ_SET_FIELD_TYPE(mAspect,"F");
AIJ_END_CLASS(Camera)
//! Represents the JNI interface to class assimp.Light
AIJ_BEGIN_CLASS(Light)
AIJ_SET_CLASS_TYPE(aiLight,"assimp.Light");
AIJ_SET_FIELD_TYPE(mName,"[I");
AIJ_SET_FIELD_TYPE(mType,"I");
AIJ_SET_FIELD_TYPE(mPosition,"[F");
AIJ_SET_FIELD_TYPE(mDirection,"[F");
AIJ_SET_FIELD_TYPE(mAttenuationConstant,"F");
AIJ_SET_FIELD_TYPE(mAttenuationLinear,"F");
AIJ_SET_FIELD_TYPE(mAttenuationQuadratic,"F");
AIJ_SET_FIELD_TYPE(mColorDiffuse,"[F");
AIJ_SET_FIELD_TYPE(mColorSpecular,"[F");
AIJ_SET_FIELD_TYPE(mColorAmbient,"[F");
AIJ_SET_FIELD_TYPE(mAngleInnerCone,"F");
AIJ_SET_FIELD_TYPE(mAngleOuterCone,"F");
AIJ_END_CLASS(Light)
} assimp;
//! Master initialization of all stuff we need
void Initialize()
{
assimp.Initialize();
java.Initialize();
}
private:
//! Singleton instance
static JNIEnvironment* s_pcEnv;
//! TLS data
boost::thread_specific_ptr<JNIThreadData> ptr;
//! Reference counter of the whole class
unsigned int m_iRefCnt;
};
// ---------------------------------------------------------------------------
/** @brief Helper function to copy data to a Java array
*
* @param pc JNI env handle
* @param jfl Java array
* @param data Input data
* @param size Size of data to be copied, in bytes
*/
void JNU_CopyDataToArray(JNIEnv* pc, jarray jfl, void* data, unsigned int size);
// ---------------------------------------------------------------------------
/** @brief Helper function to create a java.lang.String from a native char*.
*
* This function has been taken from
* http://java.sun.com/docs/books/jni/html/other.html#26021
*/
jstring JNU_NewStringNative(JNIEnv *env, const char *str);
// ---------------------------------------------------------------------------
/** @brief Helper function to create a char* from a managed jstring
*
* This function has been taken from
* http://java.sun.com/docs/books/jni/html/other.html#26021
*/
char* JNU_GetStringNativeChars(JNIEnv *env, jstring jstr);
// ---------------------------------------------------------------------------
/** @brief Helper function to copy a whole object array to the VM
*
* @param pc JNI env handle
* @param in Input object array
* @param num Size of input array
* @param type Type of input
* @param out Output object
*/
// ---------------------------------------------------------------------------
void JNU_CopyObjectArrayToVM(JNIEnv* pc, const void** in, unsigned int num,
JNIEnvironment::_Base& type, jobjectArray& out);
}} // end namespaces
using namespace Assimp;
using namespace Assimp::jbridge;
#include "jbridge_Logger.h"
#endif //! AI_JNIENVIRONMENT_H_INCLUDED

View File

@ -1,14 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;

View File

@ -1,14 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;

View File

@ -1,283 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// include the header files generated by javah
#include "assimp_Importer.h"
#include <list>
// used as error return code
#define AI_JNI_ERROR_RETURN 0xffffffff
////////////////////////////////////////////////////////////////////////////////////
/* typedef for a jassimp context, used to identify the Importer object which
* belongs to a particular java Importer.
*/
////////////////////////////////////////////////////////////////////////////////////
typedef uint64_t JASSIMP_CONTEXT;
#ifdef JASSIMP_DEBUG_CHECKS
typedef std::list< JASSIMP_CONTEXT > ImporterContextList;
static ImporterContextList g_listActiveContexts;
// ------------------------------------------------------------------------------------------------
/* DEBUG: Check the validity of a particular context.
*/
bool jValidateContext (JASSIMP_CONTEXT context)
{
ImporterContextList::const_iterator t = std::find( g_listActiveContexts.begin(),g_listActiveContexts.end(),context);
if (t != g_listActiveContexts.end() {
return true;
}
DefaultLogger::get()->error("[jnibridge] Invalid context");
return false;
}
// ------------------------------------------------------------------------------------------------
/* DEBUG: Check the validity of a particular scene
*/
bool jValidateScene (const aiScene* scene)
{
if (!scene) {
DefaultLogger::get()->error("[jnibridge] There's not asset");
return false;
}
return true;
}
#endif // ! ASSIMP_DEBUG
// ------------------------------------------------------------------------------------------------
/* Get the #Assimp::Importer for a particular JASSIMP_CONTEXT
*/
Assimp::Importer* jGetValidImporterScenePair (JASSIMP_CONTEXT jvmcontext)
{
#ifdef JASSIMP_DEBUG_CHECKS
if (!jValidateContext((JASSIMP_CONTEXT)jvmcontext)) {
return NULL;
}
#endif // ! ASSIMP_DEBUG
// get the importer instance from the context
Assimp::Importer* pcImp = (Assimp::Importer*)jvmcontext;
#ifdef DEBUG
if (!jValidateScene(pcImp->GetScene())) {
return NULL;
}
#endif // ! ASSIMP_DEBUG
return pcImp;
}
// ------------------------------------------------------------------------------------------------
/*
* Class: assimp_Importer
* Method: _NativeInitContext
* Signature: ()I
*/
JNIEXPORT jlong JNICALL Java_assimp_Importer__1NativeInitContext
(JNIEnv * jvmenv, jobject jvmthis, jint version) {
// 2^64-1 indicates error
JASSIMP_CONTEXT context = 0xffffffffffffffffL;
if (version != assimp_Importer_ABI_VERSION) {
return context;
}
// create a new Importer instance
Assimp::Importer* pcImp = new Assimp::Importer();
context = (JASSIMP_CONTEXT)(uintptr_t)pcImp;
#ifdef JASSIMP_DEBUG_CHECKS
g_listActiveContexts.push_back(context);
#endif // ! ASSIMP_DEBUG
// need to setup the logger ... or did we already initialize it?
JNILogDispatcher* pcLogger;
if (DefaultLogger::isNullLogger()) {
pcLogger = new JNILogDispatcher();
DefaultLogger::set (pcLogger);
}
else {
JNILogDispatcher* pcLogger = ( JNILogDispatcher* )DefaultLogger::get();
pcLogger->AddRef();
}
// setup the JNI environment
if(!JNIEnvironment::Get()->AttachToCurrentThread(jvmenv)) {
return 0xffffffffffffffffL;
}
// return our native context handle to the caller
return context;
}
// ------------------------------------------------------------------------------------------------
/*
* Class: assimp_Importer
* Method: _NativeFreeContext
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeFreeContext
(JNIEnv * jvmenv, jobject jvmthis, jlong jvmcontext)
{
#ifdef JASSIMP_DEBUG_CHECKS
if (!jValidateContext((JASSIMP_CONTEXT)jvmcontext)) {
return AI_JNI_ERROR_RETURN;
}
#endif // ! ASSIMP_DEBUG
// delete the underlying Importer instance
Assimp::Importer* pcImp = (Assimp::Importer*)jvmcontext;
delete pcImp;
#ifdef JASSIMP_DEBUG_CHECKS
g_listActiveContexts.remove(jvmcontext);
#endif // ! ASSIMP_DEBUG
JNIEnvironment::Get()->DetachFromCurrentThread();
return 0;
}
// ------------------------------------------------------------------------------------------------
/*
* Class: assimp_Importer
* Method: _NativeLoad
* Signature: (Ljava/lang/String;II)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeLoad
(JNIEnv *jvmenv, jobject jvmthis, jstring jvmpath, jint jvmflags, jlong jvmcontext)
{
jint iRet = 0;
#ifdef JASSIMP_DEBUG_CHECKS
if (!jValidateContext((JASSIMP_CONTEXT)jvmcontext)) {
return AI_JNI_ERROR_RETURN;
}
#endif // ! ASSIMP_DEBUG
// get the path from the jstring
const char* szPath = JNU_GetStringNativeChars(jvmenv,jvmpath);
if (!szPath) {
DefaultLogger::get()->error("[jnibridge] Unable to get path string from the java vm");
return AI_JNI_ERROR_RETURN;
}
// get the importer instance from the context
Assimp::Importer* pcImp = (Assimp::Importer*)jvmcontext;
const aiScene* pcOut;
// and load the file. The aiScene object itself remains accessible via Importer.GetScene().
if(!(pcOut = pcImp->ReadFile(std::string(szPath),(unsigned int)jvmflags))) {
DefaultLogger::get()->error("[jnibridge] Unable to load asset");
free((void*)szPath);
return AI_JNI_ERROR_RETURN;
}
free((void*)szPath);
// allocate a new assimp.Scene object to be returned by the importer
jobject jScene;
if(!(jScene = jvmenv->AllocObject(AIJ_GET_HANDLE(assimp.Importer.Class)))) {
DefaultLogger::get()->error("[jnibridge] Unable to allocate output scene");
return AI_JNI_ERROR_RETURN;
}
// fill the assimp.Scene instance with our data ...
JNIEnvironment::Get()->assimp.Scene.Fill(jScene,pcOut);
// ... and store it in the Importer instance
jvmenv->SetObjectField(jvmthis,AIJ_GET_HANDLE(assimp.Importer.scene),jScene);
// .. and finally we don't need th scene anymore
pcImp->FreeScene();
return iRet;
}
// ------------------------------------------------------------------------------------------------
/*
* Class: assimp_Importer
* Method: _NativeSetPropertyInt
* Signature: (Ljava/lang/String;IJ)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeSetPropertyInt
(JNIEnv * jvmenv, jobject _this, jstring name, jint value, jlong jvmcontext)
{
#ifdef JASSIMP_DEBUG_CHECKS
if (!jValidateContext((JASSIMP_CONTEXT)jvmcontext)) {
return AI_JNI_ERROR_RETURN;
}
#endif // ! ASSIMP_DEBUG
Assimp::Importer* pcImp = (Assimp::Importer*)jvmcontext;
const char* sz = JNU_GetStringNativeChars(jvmenv,name);
// set the property
pcImp->SetPropertyInteger(sz,(int)value,NULL);
free((void*)sz);
return 0;
}
// ------------------------------------------------------------------------------------------------
/*
* Class: assimp_Importer
* Method: _NativeSetPropertyFloat
* Signature: (Ljava/lang/String;FJ)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeSetPropertyFloat
(JNIEnv * jvmenv, jobject _this, jstring name, jfloat value, jlong jvmcontext)
{
#ifdef JASSIMP_DEBUG_CHECKS
if (!jValidateContext((JASSIMP_CONTEXT)jvmcontext)) {
return AI_JNI_ERROR_RETURN;
}
#endif // ! ASSIMP_DEBUG
Assimp::Importer* pcImp = (Assimp::Importer*)jvmcontext;
const char* sz = JNU_GetStringNativeChars(jvmenv,name);
// set the property
pcImp->SetPropertyFloat(sz,(float)value,NULL);
free((void*)sz);
return 0;
}
// ------------------------------------------------------------------------------------------------
/*
* Class: assimp_Importer
* Method: _NativeSetPropertyString
* Signature: (Ljava/lang/String;Ljava/lang/String;J)I
*/
JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeSetPropertyString
(JNIEnv * jvmenv, jobject _this, jstring name, jstring value, jlong jvmcontext)
{
#ifdef JASSIMP_DEBUG_CHECKS
if (!jValidateContext((JASSIMP_CONTEXT)jvmcontext)) {
return AI_JNI_ERROR_RETURN;
}
#endif // ! ASSIMP_DEBUG
Assimp::Importer* pcImp = (Assimp::Importer*)jvmcontext;
const char* sz = JNU_GetStringNativeChars(jvmenv,name);
const char* sc = JNU_GetStringNativeChars(jvmenv,value);
// set the property
pcImp->SetPropertyString(sz,sc,NULL);
free((void*)sz);
free((void*)sc);
return 0;
}

View File

@ -1,14 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;

View File

@ -1,102 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
bool JNILogDispatcher::OnAttachToCurrentThread(JNIThreadData* pcData)
{
ai_assert(NULL != pcData);
//this->AddRef(); - done at another location
// There is much error handling code in this function. We do it to be absolutely sure that the
// interface is of the same version on both sides.
JNIEnv* jvmenv = AIJ_GET_JNIENV();
// get a handle to the assimp.DefaultLogger class
if (!m_pcClass) {
if( NULL == (m_pcClass = jvmenv->FindClass("assimp.DefaultLogger"))) {
return false;
}
}
// get handles to the logging functions
if (!m_pcMethodError) {
if( !(m_pcMethodError = jvmenv->GetStaticMethodID(m_pcClass,"_NativeCallWriteError","(Ljava/lang/String;)V"))) {
return false;
}
}
if (!m_pcMethodWarn) {
if( !(m_pcMethodWarn = jvmenv->GetStaticMethodID(m_pcClass,"_NativeCallWriteWarn","(Ljava/lang/String;)V"))) {
return false;
}
}
if (!m_pcMethodInfo) {
if( !(m_pcMethodInfo = jvmenv->GetStaticMethodID(m_pcClass,"_NativeCallWriteInfo","(Ljava/lang/String;)V"))) {
return false;
}
}
if (!m_pcMethodDebug) {
if( !(m_pcMethodDebug = jvmenv->GetStaticMethodID(m_pcClass,"_NativeCallWriteDebug","(Ljava/lang/String;)V"))) {
return false;
}
}
return true;
}
// ------------------------------------------------------------------------------------------------
bool JNILogDispatcher::OnDetachFromCurrentThread(JNIThreadData* pcData)
{
Release();
return true;
}
// ------------------------------------------------------------------------------------------------
void JNILogDispatcher::debug(const std::string &message)
{
JNIEnv* jvmenv = AIJ_GET_JNIENV();
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
jvmenv->CallStaticVoidMethod(m_pcClass,m_pcMethodDebug,jstr);
jvmenv->DeleteLocalRef(jstr);
}
// ------------------------------------------------------------------------------------------------
void JNILogDispatcher::info(const std::string &message)
{
JNIEnv* jvmenv = AIJ_GET_JNIENV();
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
jvmenv->CallStaticVoidMethod(m_pcClass,m_pcMethodInfo,jstr);
jvmenv->DeleteLocalRef(jstr);
}
// ------------------------------------------------------------------------------------------------
void JNILogDispatcher::warn(const std::string &message)
{
JNIEnv* jvmenv = AIJ_GET_JNIENV();
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
jvmenv->CallStaticVoidMethod(m_pcClass,m_pcMethodWarn,jstr);
jvmenv->DeleteLocalRef(jstr);
}
// ------------------------------------------------------------------------------------------------
void JNILogDispatcher::error(const std::string &message)
{
JNIEnv* jvmenv = AIJ_GET_JNIENV();
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
jvmenv->CallStaticVoidMethod(m_pcClass,m_pcMethodError,jstr);
jvmenv->DeleteLocalRef(jstr);
}

View File

@ -1,114 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
/** @file jbridge_Logger.h
* Declaration of a log dispatching service to send all log messages to Java
*/
#ifndef INCLUDED_JBRIDGE_LOGGER_H
#define INCLUDED_JBRIDGE_LOGGER_H
#include <DefaultLogger.h>
namespace Assimp {
namespace jbridge {
// ---------------------------------------------------------------------------
class IOStream;
struct LogStreamInfo;
// ---------------------------------------------------------------------------
/** @class JNILogDispatcher
* @brief Logging system implementation that is used to send all
* log messages generated by native code to the Java logging system.
*/
class JNILogDispatcher : public Logger
{
friend class JNIEnvironment;
public:
//! Default constructor
JNILogDispatcher()
: m_iRefCnt(1) {}
/** @brief Logs a debug message */
void OnDebug(const char* msg);
/** @brief Logs an info message */
void OnInfo(const char* msg);
/** @brief Logs a warning message */
void OnWarn(const char* msg);
/** @brief Logs an error message */
void OnError(const char* msg);
/** @brief Log severity setter */
void setLogSeverity(LogSeverity log_severity) {}
/** @brief Detach a still attached stream from logger */
bool attachStream(LogStream *pStream, unsigned int severity) {
return false;
}
/** @brief Detach a still attached stream from logger */
bool detatchStream(LogStream *pStream, unsigned int severity) {
return false;
}
//! COM-style reference counting mechanism
unsigned int AddRef()
{
return ++m_iRefCnt;
}
//! COM-style reference counting mechanism
unsigned int Release()
{
const unsigned int n = --m_iRefCnt;
if (n == 0)
{
delete this;
// don't forget to reset the logger to the default implementation
DefaultLogger::set(NULL);
}
return n;
}
private:
//! Called by JNIEnvironment
bool OnAttachToCurrentThread(JNIThreadData* pcData);
bool OnDetachFromCurrentThread(JNIThreadData* pcData);
private:
//! Handle to assimp.DefaultLogger class
jclass m_pcClass;
//! Handle to the static assimp.DefaultLogger._NativeCallWriteError() method
jmethodID m_pcMethodError;
//! Handle to the static assimp.DefaultLogger._NativeCallWriteInfo() method
jmethodID m_pcMethodInfo;
//! Handle to the static assimp.DefaultLogger._NativeCallWriteDebug() method
jmethodID m_pcMethodDebug;
//! Handle to the static assimp.DefaultLogger._NativeCallWriteWarn() method
jmethodID m_pcMethodWarn;
//! Reference counter of the logger
unsigned int m_iRefCnt;
};
}}
#endif // !! INCLUDED_JBRIDGE_LOGGER_H

View File

@ -1,14 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;

View File

@ -1,129 +0,0 @@
/** @file Implementation of the JNI API for jAssimp */
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Mesh::Initialize()
{
AIJ_LOAD_CLASS();
AIJ_LOAD_FIELD(m_iPrimitiveTypes);
AIJ_LOAD_FIELD(m_vVertices);
AIJ_LOAD_FIELD(m_vBitangents);
AIJ_LOAD_FIELD(m_vTangents);
AIJ_LOAD_FIELD(m_vNormals);
AIJ_LOAD_FIELD(m_avUVs);
AIJ_LOAD_FIELD(m_vFaces);
AIJ_LOAD_FIELD(m_avColors);
AIJ_LOAD_FIELD(m_aiNumUVComponents);
AIJ_LOAD_FIELD(m_vBones);
AIJ_LOAD_FIELD(m_iMaterialIndex);
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Mesh::Fill(jobject obj,const aiMesh* pcSrc)
{
jobjectArray ja;
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
pc->SetIntField(obj,m_iMaterialIndex,pcSrc->mMaterialIndex);
const unsigned int vsize = pcSrc->mNumVertices*12, nsize = pcSrc->mNumVertices*3;
// copy vertex positions
if (pcSrc->HasPositions()) {
jfloatArray jfl = pc->NewFloatArray(nsize);
JNU_CopyDataToArray(pc,jfl,pcSrc->mVertices,vsize);
pc->SetObjectField(obj,m_vVertices,jfl);
}
// copy vertex normals
if (pcSrc->HasNormals()) {
jfloatArray jfl = pc->NewFloatArray(nsize);
JNU_CopyDataToArray(pc,jfl,pcSrc->mNormals,vsize);
pc->SetObjectField(obj,m_vNormals,jfl);
}
// copy tangents and bitangents
if (pcSrc->HasTangentsAndBitangents()) {
jfloatArray jfl = pc->NewFloatArray(nsize);
JNU_CopyDataToArray(pc,jfl,pcSrc->mTangents,vsize);
pc->SetObjectField(obj,m_vTangents,jfl);
jfl = pc->NewFloatArray(nsize);
JNU_CopyDataToArray(pc,jfl,pcSrc->mBitangents,vsize);
pc->SetObjectField(obj,m_vBitangents,jfl);
}
// copy texture coordinates
if (pcSrc->HasTextureCoords(0)) {
jobjectArray jobjarr = pc->NewObjectArray(AI_MAX_NUMBER_OF_TEXTURECOORDS,
AIJ_GET_HANDLE(java.lang.Array.FloatArray_Class),0);
unsigned int channel = 0;
while (pcSrc->HasTextureCoords(channel)) {
jfloatArray jfl = pc->NewFloatArray(nsize);
JNU_CopyDataToArray(pc,jfl,pcSrc->mTextureCoords[channel],vsize);
pc->SetObjectArrayElement(jobjarr,channel,jfl);
++channel;
}
// set the corresponding field in the java object
pc->SetObjectField(obj,m_avUVs,jobjarr);
jobjarr = (jobjectArray) pc->NewIntArray(AI_MAX_NUMBER_OF_TEXTURECOORDS);
pc->SetIntArrayRegion((jintArray)jobjarr,0,channel,(const jint*)&pcSrc->mNumUVComponents);
pc->SetObjectField(obj,m_aiNumUVComponents,jobjarr);
}
// copy vertex colors
if (pcSrc->HasVertexColors(0)) {
jobjectArray jobjarr = pc->NewObjectArray(AI_MAX_NUMBER_OF_COLOR_SETS,
AIJ_GET_HANDLE(java.lang.Array.FloatArray_Class),0);
unsigned int channel = 0;
while (pcSrc->HasVertexColors(channel)) {
jfloatArray jfl = pc->NewFloatArray(pcSrc->mNumVertices*4);
JNU_CopyDataToArray(pc,jfl,pcSrc->mColors[channel],pcSrc->mNumVertices*16);
pc->SetObjectArrayElement(jobjarr,channel,jfl);
++channel;
}
// set the corresponding field in the java object
pc->SetObjectField(obj,m_avColors,jobjarr);
}
// copy faces
if (pcSrc->mNumFaces) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mFaces,pcSrc->mNumFaces,
AIJ_GET_HANDLE(assimp.Face),ja);
pc->SetObjectField(obj,m_vFaces,ja);
}
// copy bones
if (pcSrc->mNumBones) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mBones,pcSrc->mNumBones,
AIJ_GET_HANDLE(assimp.Bone),ja);
pc->SetObjectField(obj,m_vBones,ja);
}
}

View File

@ -1,36 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_NativeException::Initialize()
{
// get a handle to the JNI context for this thread
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
// and load a handle to the class
if(!(Class = pc->FindClass("assimp.NativeException"))) {
pc->ThrowNew(pc->FindClass("java.lang.Exception"),"Unable to load class assimp.NativeException"); // :-)
}
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::ThrowNativeError(const std::string& msg)
{
// get a handle to the JNI context for this thread ...
JNIEnv* pc = GetThread()->m_pcEnv;
// and throw a new assimp.NativeException
pc->ThrowNew(assimp.NativeException.Class,msg.c_str());
}

View File

@ -1,14 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;

View File

@ -1,88 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Scene::Initialize()
{
AIJ_LOAD_CLASS();
AIJ_LOAD_FIELD(m_rootNode);
AIJ_LOAD_FIELD(m_vAnimations);
AIJ_LOAD_FIELD(m_vMaterials);
AIJ_LOAD_FIELD(m_vMeshes);
AIJ_LOAD_FIELD(m_vTextures);
AIJ_LOAD_FIELD(m_vLights);
AIJ_LOAD_FIELD(m_vCameras);
AIJ_LOAD_FIELD(flags);
}
// ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_Scene::Fill(jobject obj,const aiScene* pcSrc)
{
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
jobjectArray ja;
// copy meshes
if (pcSrc->mNumMeshes) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mMeshes,pcSrc->mNumMeshes,
AIJ_GET_HANDLE(assimp.Mesh),ja);
pc->SetObjectField(obj,m_vMeshes,ja);
}
// copy textures
if (pcSrc->mNumTextures) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mTextures,pcSrc->mNumTextures,
AIJ_GET_HANDLE(assimp.Texture),ja);
pc->SetObjectField(obj,m_vTextures,ja);
}
// copy materials
if (pcSrc->mNumMeshes) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mMaterials,pcSrc->mNumMaterials,
AIJ_GET_HANDLE(assimp.Material),ja);
pc->SetObjectField(obj,m_vMaterials,ja);
}
// copy animations
if (pcSrc->mNumAnimations) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mAnimations,pcSrc->mNumAnimations,
AIJ_GET_HANDLE(assimp.Animation),ja);
pc->SetObjectField(obj,m_vAnimations,ja);
}
// copy lights
if (pcSrc->mNumLights) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mLights,pcSrc->mNumLights,
AIJ_GET_HANDLE(assimp.Light),ja);
pc->SetObjectField(obj,m_vLights,ja);
}
// copy cameras
if (pcSrc->mNumCameras) {
JNU_CopyObjectArrayToVM(pc,(const void**)pcSrc->mCameras,pcSrc->mNumCameras,
AIJ_GET_HANDLE(assimp.Camera),ja);
pc->SetObjectField(obj,m_vCameras,ja);
}
// copy scene flags
pc->SetIntField(obj,flags,(jint)pcSrc->mFlags);
// copy the root node
jobject root = pc->NewObject(AIJ_GET_CLASS_HANDLE(assimp.Node),
AIJ_GET_DEFAULT_CTOR_HANDLE(assimp.Node));
AIJ_GET_HANDLE(assimp.Node).Fill(root,pcSrc->mRootNode);
pc->SetObjectField(obj,m_rootNode,root);
}

View File

@ -1,14 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
using namespace Assimp;

View File

@ -1,15 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#include "jbridge_pch.h"
// PCH unit

View File

@ -1,31 +0,0 @@
/* --------------------------------------------------------------------------------
*
* Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net)
* Assimp2Java bridge
*
* Copyright (c) 2006-2009, ASSIMP Development Team
* All rights reserved. See the LICENSE file for more information.
*
* --------------------------------------------------------------------------------
*/
#ifdef DEBUG
# define JASSIMP_DEBUG_CHECKS
#endif
// Assimp's public headers don't include it anymore, but we need it for uint64_t
#include "Compiler/pstdint.h"
#include <boost/thread/thread.hpp>
#include <boost/thread/tss.hpp>
#include <vector>
#include <jni.h>
#include <aiScene.h>
#include "assimp.hpp"
#include "jbridge_Environment.h"
#include "jbridge_Logger.h"

View File

@ -1,81 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "..\..\..\..\mkutil\revision.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Deutsch (Deutschland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
#ifdef _WIN32
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,SVNRevision, 0
PRODUCTVERSION 1,0,SVNRevision,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x7L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040704b0"
BEGIN
VALUE "Comments", "Licensed under a 3-clause BSD license"
VALUE "CompanyName", "ASSIMP Development Team"
VALUE "FileDescription", "Assimp2Java Bridge Module"
VALUE "FileVersion", 1,0,SVNRevision,0
VALUE "InternalName", "assimp "
VALUE "LegalCopyright", "Copyright (C) 2006-2009"
VALUE "OriginalFilename", "assimpNN.dll"
VALUE "ProductName", "Assimp2Java Bridge Module"
VALUE "ProductVersion", 1,0,SVNRevision,0
,0
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x407, 1200
END
END
#endif // Deutsch (Deutschland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED