Deleting unused jAssimp stuff.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@429 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
fe58fa6603
commit
c029c5e142
|
@ -1,134 +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.
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Animation {
|
||||
|
||||
/**
|
||||
* 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 BoneAnim[] boneAnims = null;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of the animation channel
|
||||
*
|
||||
* @return If the modelling 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 getNumBoneAnimChannels() {
|
||||
assert(null != boneAnims);
|
||||
return boneAnims.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all bone animation channels
|
||||
* @return This value is never <code>null</code>
|
||||
*/
|
||||
public final BoneAnim[] getBoneAnimChannels() {
|
||||
assert(null != boneAnims);
|
||||
return boneAnims;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a specific bone animation channel
|
||||
* @param i Index of the animation channel. Must be between
|
||||
* 0 and the value returned by <code>getNumBoneAnimChannels</code>
|
||||
* @return This value is never <code>null</code>
|
||||
*/
|
||||
public final BoneAnim getBoneAnimChannel(int i) {
|
||||
assert(null != boneAnims && i < boneAnims.length);
|
||||
return boneAnims[i];
|
||||
}
|
||||
}
|
|
@ -1,133 +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 Aramis (Alexander Gessler)
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the bone
|
||||
*/
|
||||
private String name = "";
|
||||
|
||||
|
||||
/**
|
||||
* List of vertex weights for the bone
|
||||
*/
|
||||
private Weight[] weights = null;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the name of the node
|
||||
* @return Normally bones are never unnamed
|
||||
*/
|
||||
public final String getName() {
|
||||
return this.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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns one specific vertex weights
|
||||
* @param weight Index of the vertex weights. Must be between
|
||||
* 0 and <code>getNumWeights()-1</code>
|
||||
* @return Vertex weight
|
||||
*/
|
||||
public final Weight getWeight(int weight) {
|
||||
assert(null != weights && weight < this.weights.length);
|
||||
return this.weights[weight];
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
* 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 BoneAnim {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,182 +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
|
||||
{
|
||||
/** 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;
|
||||
|
||||
|
||||
/** 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 scenegraph with the same name.
|
||||
* This node specifies the position of the camera in the scene
|
||||
* hierarchy and can be animated.
|
||||
*/
|
||||
public final String GetName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
};
|
|
@ -1,125 +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;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Enumerates components of the <code>Scene</code> and <code>Mesh</code>
|
||||
* classes that can be excluded from the import with the RemoveComponent step.
|
||||
*
|
||||
* See the documentation for the postprocessing step for more details.
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Component
|
||||
{
|
||||
/** Normal vectors are removed from all meshes
|
||||
*/
|
||||
public static final int NORMALS = 0x2;
|
||||
|
||||
/** Tangents an bitangents are removed from all meshes
|
||||
*
|
||||
* Tangents and bitangents below together in every case.
|
||||
*/
|
||||
public static final int TANGENTS_AND_BITANGENTS = 0x4;
|
||||
|
||||
/** All vertex color sets are removed
|
||||
*
|
||||
* Use <code>COLORn(N)</code> to specifiy the N'th set
|
||||
*/
|
||||
public static final int COLORS = 0x8;
|
||||
|
||||
/** All texture UV sets are removed
|
||||
*
|
||||
* Use <code>TEXCOORDn(N)</code> to specifiy the N'th set
|
||||
*/
|
||||
public static final int TEXCOORDS = 0x10;
|
||||
|
||||
/** Removes all bone weights from all meshes.
|
||||
*
|
||||
* The scenegraph nodes corresponding to the
|
||||
* bones are removed
|
||||
*/
|
||||
public static final int BONEWEIGHTS = 0x20;
|
||||
|
||||
/** Removes all bone animations
|
||||
*/
|
||||
public static final int ANIMATIONS = 0x40;
|
||||
|
||||
/** Removes all embedded textures
|
||||
*/
|
||||
public static final int TEXTURES = 0x80;
|
||||
|
||||
/** Removes all light sources
|
||||
*
|
||||
* The scenegraph nodes corresponding to the
|
||||
* light sources are removed.
|
||||
*/
|
||||
public static final int LIGHTS = 0x100;
|
||||
|
||||
/** Removes all light sources
|
||||
*
|
||||
* The scenegraph nodes corresponding to the
|
||||
* cameras are removed.
|
||||
*/
|
||||
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.
|
||||
* This makes no real sense without the <code>TEXTURES</code> flag.
|
||||
* */
|
||||
public static final int MATERIALS = 0x800;
|
||||
|
||||
|
||||
public static final int COLORSn(int n)
|
||||
{
|
||||
return (1 << (n + 20));
|
||||
}
|
||||
|
||||
public static final int TEXCOORDSn(int n)
|
||||
{
|
||||
return (1 << (n + 25));
|
||||
}
|
||||
};
|
|
@ -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;
|
||||
|
||||
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 that is stored in a format
|
||||
* like 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 list
|
||||
* returned by <code>Scene.getTextures()</code> is a compressed texture.
|
||||
* <p/>
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CompressedTexture extends Texture {
|
||||
|
||||
private String m_format = "";
|
||||
|
||||
/**
|
||||
* Retrieves the format of the texture data. This is
|
||||
* the most common file extension of the format (without a
|
||||
* dot at the beginning). Examples include dds, png, jpg ...
|
||||
*
|
||||
* @return Extension string or null if the format of the texture
|
||||
* data is not known to ASSIMP.
|
||||
*/
|
||||
public final String getFormat() {
|
||||
return m_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to the data of the compressed texture
|
||||
*
|
||||
* @return Data poiner
|
||||
*/
|
||||
public final byte[] getData() {
|
||||
return (byte[]) data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the data of the compressed texture
|
||||
*
|
||||
* @return Data poiner
|
||||
*/
|
||||
public final int getLength() {
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 for compressed textures
|
||||
*
|
||||
* @return n/a
|
||||
*/
|
||||
@Override
|
||||
public final int getHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 for compressed textures
|
||||
*
|
||||
* @return n/a
|
||||
*/
|
||||
@Override
|
||||
public final int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null 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 <code>java.awt.BufferedImage</code> object containing
|
||||
* a copy of the texture image. The return value is <code>null</code>
|
||||
* if the file format is not known.
|
||||
*/
|
||||
public BufferedImage convertToImage() {
|
||||
|
||||
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("Unable to decode compressed embedded texture +" +
|
||||
"(Format hint: " + m_format + ")" );
|
||||
|
||||
}
|
||||
// return the created image to the caller
|
||||
return img;
|
||||
}
|
||||
}
|
|
@ -1,204 +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 configuration properties.
|
||||
* <p/>
|
||||
* Static helper class, can't be instanced. It defines configuration
|
||||
* property keys to be used with <code> Importer.setPropertyInt</code>
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ConfigProperty {
|
||||
|
||||
private ConfigProperty() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default value for the <code>CONFIG_PP_SLM_TRIANGLE_LIMIT</code>
|
||||
* configuration property.
|
||||
*/
|
||||
public static final int DEFAULT_SLM_MAX_TRIANGLES = 1000000;
|
||||
|
||||
|
||||
/**
|
||||
* Default value for the <code>CONFIG_PP_SLM_VERTEX_LIMIT</code>
|
||||
* configuration property.
|
||||
*/
|
||||
public static final int DEFAULT_SLM_MAX_VERTICES = 1000000;
|
||||
|
||||
|
||||
/**
|
||||
* Default value for the <code>CONFIG_PP_LBW_MAX_WEIGHTS</code>
|
||||
* configuration property.
|
||||
*/
|
||||
public static final int DEFAULT_LBW_MAX_WEIGHTS = 4;
|
||||
|
||||
|
||||
/**
|
||||
* Set the maximum number of vertices in a mesh.
|
||||
* <p/>
|
||||
* This is used by the "SplitLargeMeshes" PostProcess-Step to determine
|
||||
* whether a mesh must be splitted or not.
|
||||
* note: The default value is <code>DEFAULT_SLM_MAX_TRIANGLES</code>.
|
||||
* The type of the property is int.
|
||||
*/
|
||||
public static final String CONFIG_PP_SLM_TRIANGLE_LIMIT
|
||||
= "pp.slm.triangle_limit";
|
||||
|
||||
|
||||
/**
|
||||
* Set the maximum number of triangles in a mesh.
|
||||
* <p/>
|
||||
* This is used by the "SplitLargeMeshes" PostProcess-Step to determine
|
||||
* whether a mesh must be splitted or not.
|
||||
* note: The default value is <code>DEFAULT_SLM_MAX_VERTICES</code>.
|
||||
* The type of the property is int.
|
||||
*/
|
||||
public static final String CONFIG_PP_SLM_VERTEX_LIMIT
|
||||
= "pp.slm.vertex_limit";
|
||||
|
||||
|
||||
/**
|
||||
* Set the maximum number of bones affecting a single vertex
|
||||
* <p/>
|
||||
* This is used by the aiProcess_LimitBoneWeights PostProcess-Step.
|
||||
* note :The default value is <code>DEFAULT_LBW_MAX_WEIGHTS</code>.
|
||||
* The type of the property is int.
|
||||
*/
|
||||
public static final String CONFIG_PP_LBW_MAX_WEIGHTS
|
||||
= "pp.lbw.weights_limit";
|
||||
|
||||
|
||||
/**
|
||||
* Set the vertex animation keyframe to be imported
|
||||
* <p/>
|
||||
* 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.
|
||||
* \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
|
||||
* <code>CONFIG_IMPORT_XXX_KEYFRAME</code> options (where XXX is a
|
||||
* placeholder for the file format for which you want to override the
|
||||
* global setting).
|
||||
* The type of the property is int.
|
||||
*/
|
||||
public static final String CONFIG_IMPORT_GLOBAL_KEYFRAME
|
||||
= "imp.global.kf";
|
||||
|
||||
public static final String CONFIG_IMPORT_MD3_KEYFRAME = "imp.md3.kf";
|
||||
public static final String CONFIG_IMPORT_MD2_KEYFRAME = "imp.md2.kf";
|
||||
public static final String CONFIG_IMPORT_MDL_KEYFRAME = "imp.mdl.kf";
|
||||
public static final String CONFIG_IMPORT_MDC_KEYFRAME = "imp.mdc.kf";
|
||||
public static final String CONFIG_IMPORT_MDR_KEYFRAME = "imp.mdr.kf";
|
||||
public static final String CONFIG_IMPORT_SMD_KEYFRAME = "imp.smd.kf";
|
||||
|
||||
|
||||
/**
|
||||
* Causes the 3DS loader to ignore pivot points in the file
|
||||
* <p/>
|
||||
* There are some faulty 3DS files on the internet which look
|
||||
* only correctly with pivot points disabled. By default,
|
||||
* this option is disabled.
|
||||
* note: This is a boolean property stored as an integer, 0 is false
|
||||
*/
|
||||
public static final String CONFIG_IMPORT_3DS_IGNORE_PIVOT
|
||||
= "imp.3ds.nopivot";
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the maximum angle that may be between two vertex tangents
|
||||
* that their tangents and bitangents are smoothed.
|
||||
* <p/>
|
||||
* 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 180.f
|
||||
* The type of the property is float.
|
||||
*/
|
||||
public static final String AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE
|
||||
= "pp.ct.max_smoothing";
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the maximum angle that may be between two face normals
|
||||
* at the same vertex position that their are smoothed.
|
||||
* <p/>
|
||||
* This applies to the GenSmoothNormals-Step. The angle is specified
|
||||
* in degrees * 1000, so 180.f is PI. The default value is
|
||||
* 180 degrees (all vertex normals are smoothed). The maximum value is 180.f
|
||||
* The type of the property is float.
|
||||
*/
|
||||
public static final String AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE
|
||||
= "pp.gsn.max_smoothing";
|
||||
|
||||
|
||||
/** 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
|
||||
* flags defined in the <code>Component</code> class. 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 String AI_CONFIG_PP_RVC_FLAGS
|
||||
= "pp.rvc.flags";
|
||||
|
||||
|
||||
/** Causes assimp to favour 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 String AI_CONFIG_FAVOUR_SPEED
|
||||
= "imp.speed_flag";
|
||||
};
|
|
@ -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 logstream 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 granlality of logging
|
||||
*/
|
||||
public static final int LOGSEVERITY_NORMAL = 0x0;
|
||||
|
||||
/**
|
||||
* Debug infos 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.
|
||||
*/
|
||||
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 behaviour 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 warn message to the log
|
||||
*
|
||||
* @param message Message to be logged
|
||||
*/
|
||||
public void warn(String message) {
|
||||
this.writeToStreams("Debug:" + message + "\n", ERRORSEVERITY_WARN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an info message to the log
|
||||
*
|
||||
* @param message Message to be logged
|
||||
*/
|
||||
public void info(String message) {
|
||||
this.writeToStreams("Debug:" + message + "\n", ERRORSEVERITY_INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
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 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) {
|
||||
|
||||
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 the 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package assimp;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Alex
|
||||
* Date: 15.06.2008
|
||||
* Time: 19:51:45
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface IOStream {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,72 +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;
|
||||
|
||||
}
|
|
@ -1,631 +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. The class is a simple wrapper for the native
|
||||
* Assimp::Importer and aiScene classes.
|
||||
* If multiple threads are used to load assets, each thread should manage its
|
||||
* own instance of this class to avoid threading issues. The class requires
|
||||
* the native jAssimp library to work. It must be named "jassimpNN.EXT", where
|
||||
* NN is the platform's default int size, e.g. 32 for the x86 architecture.
|
||||
* EXT is the default extension for program libraries on the system, .DLL for
|
||||
* Windows, .SO for Linux derivates.
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Importer {
|
||||
|
||||
|
||||
/**
|
||||
* Represents a property (key-value)
|
||||
*/
|
||||
private class Property<Type> {
|
||||
String key;
|
||||
Type value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a property list
|
||||
*/
|
||||
private class PropertyList<Type> extends Vector<Property<Type>> {
|
||||
|
||||
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 by this interface into a C-style
|
||||
* array. For every single read operation! Therefore it is 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. The problem is: we can't be sure we'll be able to open
|
||||
* the file for reading from both Java and native code. Therefore we
|
||||
* need to close our Java <code>FileReader</code> handle before
|
||||
* control is given to native code.
|
||||
*/
|
||||
private class DefaultIOStream implements IOStream {
|
||||
|
||||
private FileReader reader = null;
|
||||
|
||||
/**
|
||||
* Construction with 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>.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List of all postprocess steps to apply to the model
|
||||
* Empty by default.
|
||||
*/
|
||||
private Vector<PostProcessStep> m_vPPSteps = new Vector<PostProcessStep>();
|
||||
|
||||
/**
|
||||
* Unique number representing the address of the internal
|
||||
* Assimp::Importer object. For 64 bit platforms it is something else ..
|
||||
* at least it is guaranted to be unique ;-)
|
||||
*/
|
||||
private long m_iNativeHandle = 0xffffffffffffffffl;
|
||||
|
||||
/**
|
||||
* Loaded scene. It can't be used after the Importer class instance
|
||||
* has been finalized!
|
||||
*/
|
||||
private Scene scene = null;
|
||||
|
||||
/**
|
||||
* Path to the scene loaded
|
||||
*/
|
||||
private String path = null;
|
||||
|
||||
/**
|
||||
* I/O system to be used
|
||||
*/
|
||||
private IOSystem ioSystem = new DefaultIOSystem();
|
||||
|
||||
/**
|
||||
* List of config properties for all supported types: int, 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 loaded state.
|
||||
*/
|
||||
private static boolean bLibInitialized = false;
|
||||
|
||||
|
||||
private static final String JASSIMP_RUNTIME_NAME_X64 = "jAssimp64";
|
||||
private static final String JASSIMP_RUNTIME_NAME_X86 = "jAssimp32";
|
||||
|
||||
public static final int PROPERTY_WAS_NOT_EXISTING = 0xffffffff;
|
||||
|
||||
/**
|
||||
* Public constructor. Initialises the JNI bridge to the native
|
||||
* ASSIMP library. A native Assimp::Importer object is constructed and
|
||||
* initialized. The flag list is set to zero, a default I/O handler
|
||||
* is initialized.
|
||||
*
|
||||
* @param iVersion Version of the JNI interface to be used.
|
||||
* @throws NativeException Thrown if the jassimp library could not be loaded
|
||||
* or if the entry point to the module wasn't found. if this exception
|
||||
* is not thrown you can assume that jAssimp is fully available.
|
||||
*/
|
||||
public Importer(int iVersion) throws NativeException {
|
||||
|
||||
if (!bLibInitialized) {
|
||||
|
||||
/** try to load the jassimp library. First try 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 == (this.m_iNativeHandle = _NativeInitContext(iVersion))) {
|
||||
throw new NativeException(
|
||||
"Unable to initialize the native library context." +
|
||||
"The initialization routine has failed");
|
||||
}
|
||||
}
|
||||
catch (UnsatisfiedLinkError exc) {
|
||||
throw new NativeException(
|
||||
"Unable to initialize the native library context." +
|
||||
"The initialization routine has not been found");
|
||||
}
|
||||
}
|
||||
|
||||
public Importer() throws NativeException {
|
||||
this(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a postprocess step to the list of steps to be executed on
|
||||
* the model. Postprocess steps are applied to the model after it
|
||||
* has been loaded. They are implemented in C/C++, this is only a wrapper.
|
||||
*
|
||||
* @param p_Step Postprocess step to be added
|
||||
* @return true if the step has been added successfully
|
||||
* @see PostProcessStep
|
||||
*/
|
||||
public final boolean addPostProcessStep(PostProcessStep p_Step) {
|
||||
|
||||
if (isPostProcessStepActive(p_Step)) return false;
|
||||
this.m_vPPSteps.add(p_Step);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether a given postprocess step is existing in the list
|
||||
* of all steps to be executed on the model. Postprocess steps are
|
||||
* applied to the model after it has been loaded. They are implemented
|
||||
* in C/C++, this is only a wrapper.
|
||||
*
|
||||
* @param p_Step Postprocess step to be queried
|
||||
* @return true if the step is active
|
||||
* @see PostProcessStep
|
||||
*/
|
||||
public final boolean isPostProcessStepActive(PostProcessStep p_Step) {
|
||||
|
||||
for (PostProcessStep step : m_vPPSteps) {
|
||||
if (step.equals(p_Step)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a postprocess step from the list of steps to be executed
|
||||
* on the model. Postprocess steps are applied to the model after it
|
||||
* has been loaded. They are implemented in C/C++, this is only a wrapper.
|
||||
*
|
||||
* @param p_Step Postprocess step to be removed
|
||||
* @return true if the step has been removed successfully, false if
|
||||
* it was not existing
|
||||
* @see PostProcessStep
|
||||
*/
|
||||
public final boolean removePostProcessStep(PostProcessStep p_Step) {
|
||||
|
||||
return this.m_vPPSteps.remove(p_Step);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load a model from a file using the current list of postprocess steps
|
||||
* and the current I/O handler. If no custom I/O handler was provided,
|
||||
* a default implementation is used. This implementation uses fopen()/
|
||||
* fread()/fwrite()/fclose()/ftell()/fseek() and provides no support
|
||||
* for archives like ZIP or PAK.
|
||||
*
|
||||
* @param path Path to the file to be read
|
||||
* @return null if the import failed, otherwise a valid Scene instance
|
||||
* @throws NativeException This exception is thrown when an unknown error
|
||||
* occurs in the JNI bridge module.
|
||||
*/
|
||||
public final Scene readFile(String path) throws NativeException {
|
||||
this.scene = new Scene(this);
|
||||
this.path = path;
|
||||
|
||||
// we need to build a path that is valid for the current OS
|
||||
char sep = System.getProperty("file.separator").charAt(0);
|
||||
if (sep != '\\') this.path = this.path.replace('\\', sep);
|
||||
if (sep != '/') this.path = this.path.replace('/', sep);
|
||||
|
||||
// need to build a list of postprocess step as bitflag combination
|
||||
// Of course, this could have been implemented directly. However,
|
||||
// I've used the PostProcessStep enumeration to make debugging easier.
|
||||
int flags = 0x8; // always apply the triangulation step
|
||||
|
||||
for (PostProcessStep step : m_vPPSteps) {
|
||||
if (step.equals(PostProcessStep.CalcTangentSpace)) flags |= 0x1;
|
||||
else if (step.equals(PostProcessStep.JoinIdenticalVertices)) flags |= 0x2;
|
||||
else if (step.equals(PostProcessStep.ConvertToLeftHanded)) flags |= 0x4;
|
||||
else if (step.equals(PostProcessStep.KillNormals)) flags |= 0x10;
|
||||
else if (step.equals(PostProcessStep.GenFaceNormals)) flags |= 0x20;
|
||||
else if (step.equals(PostProcessStep.GenSmoothNormals)) flags |= 0x40;
|
||||
else if (step.equals(PostProcessStep.SplitLargeMeshes)) flags |= 0x80;
|
||||
else if (step.equals(PostProcessStep.PreTransformVertices)) flags |= 0x100;
|
||||
else if (step.equals(PostProcessStep.LimitBoneWeights)) flags |= 0x200;
|
||||
else if (step.equals(PostProcessStep.ValidateDataStructure)) flags |= 0x400;
|
||||
else if (step.equals(PostProcessStep.ImproveVertexLocality)) flags |= 0x800;
|
||||
else if (step.equals(PostProcessStep.RemoveRedundantMaterials)) flags |= 0x1000;
|
||||
else if (step.equals(PostProcessStep.FixInfacingNormals)) flags |= 0x2000;
|
||||
else if (step.equals(PostProcessStep.OptimizeGraph)) flags |= 0x4000;
|
||||
}
|
||||
|
||||
// now load the mesh
|
||||
if (0xffffffff == this._NativeLoad(this.path, flags, this.m_iNativeHandle)) {
|
||||
this.scene = null;
|
||||
this.path = null;
|
||||
throw new NativeException("Failed to load the mesh");
|
||||
}
|
||||
if (null == this.scene) {
|
||||
throw new NativeException("Failed to copy the data to Java");
|
||||
}
|
||||
return this.scene;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current scene or <code>null</code> if none is loaded
|
||||
* @return Hello Amanda, I want to play a game ...
|
||||
*/
|
||||
public final Scene getScene() {
|
||||
return scene;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the source path of the current scene or <code>null</code> if none is loaded
|
||||
* @return Game Over.
|
||||
*/
|
||||
public final String getScenePath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of <code>java.lang.Object.equals()</code>
|
||||
*
|
||||
* @param o Object to be compred 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;
|
||||
|
||||
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 failed. This means that not all resources have
|
||||
* been deallocated and memory leaks are remaining.
|
||||
*/
|
||||
@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 assumed to be unique, in fact it is normally the address of
|
||||
* the native Assimp::Importer object.
|
||||
*
|
||||
* @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 config properties are
|
||||
* defined as constants in the <code>ConfigProperty</code> class
|
||||
*
|
||||
* @param prop Name of the config property
|
||||
* @param val New value for the config 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 config properties are
|
||||
* defined as constants in the <code>ConfigProperty</code> class
|
||||
*
|
||||
* @param prop Name of the config property
|
||||
* @param val New value for the config 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 config properties are
|
||||
* defined as constants in the <code>ConfigProperty</code> class
|
||||
*
|
||||
* @param prop Name of the config property
|
||||
* @param val New value for the config property
|
||||
*/
|
||||
public final void setPropertyString(final String prop, String val) {
|
||||
|
||||
this.propertiesString.setProperty(prop, val);
|
||||
this._NativeSetPropertyString(prop, val, this.getContext());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets an integer config property that has been set using
|
||||
* <code>setPropertyInt</code>. All supported config properties are
|
||||
* defined as constants in the <code>ConfigProperty</code> class
|
||||
*
|
||||
* @param prop Name of the config property
|
||||
* @param error_return Default return value if the property isn't there
|
||||
* @return Current value of the config 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 config property that has been set using
|
||||
* <code>setPropertyFloat</code>. All supported config 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 config property that has been set using
|
||||
* <code>setPropertyString</code>. All supported config 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 config property that has been set using
|
||||
* <code>setPropertyInt</code>. All supported config properties are
|
||||
* defined as constants in the <code>ConfigProperty</code> class
|
||||
*
|
||||
* @param prop Name of the config 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;
|
||||
}
|
||||
|
||||
|
||||
// *********************************************************************************
|
||||
// JNI INTERNALS
|
||||
// *********************************************************************************
|
||||
|
||||
/**
|
||||
* JNI bridge call. For internal use only
|
||||
* The method initializes the ASSIMP-JNI bridge for use. No native
|
||||
* function call to assimp will be successful unless this function has
|
||||
* been called. If the function is found by the Java VM (and no <code>
|
||||
* UnsatisfiedLinkError</code> is thrown), jAssimp assumes that all other
|
||||
* library functions are available, too. If they are not, an <code>
|
||||
* UnsatisfiedLinkError</code> will be thrown during model loading.
|
||||
*
|
||||
* @param version Version of the JNI bridge requested
|
||||
* @return Unique handle for the class or 0xffffffff if an error occured
|
||||
*/
|
||||
private native int _NativeInitContext(int version);
|
||||
|
||||
/**
|
||||
* JNI bridge call. For internal use only
|
||||
* The method destroys the ASSIMP-JNI bridge. No native function call
|
||||
* to assimp will be successful after this method has been called.
|
||||
*
|
||||
* @return 0xffffffff if an error occured
|
||||
*/
|
||||
private native int _NativeFreeContext(long iContext);
|
||||
|
||||
/**
|
||||
* JNI bridge call. For internal use only
|
||||
* The method loads the model into memory, but does not map it into the VM
|
||||
*
|
||||
* @param path Path (valid separators for the OS) to the model to be loaded
|
||||
* @param flags List of postprocess steps to be executed
|
||||
* @return 0xffffffff if an error occured
|
||||
*/
|
||||
private native int _NativeLoad(String path, int flags, long iContext);
|
||||
|
||||
/**
|
||||
* JNI bridge call. For internal use only
|
||||
* The method sets a property
|
||||
*
|
||||
* @param name Name of the property
|
||||
* @param prop New value for the property
|
||||
* @return 0xffffffff if an error occured
|
||||
*/
|
||||
private native int _NativeSetPropertyInt(String name,
|
||||
int prop, long iContext);
|
||||
|
||||
// float-version
|
||||
private native int _NativeSetPropertyFloat(String name,
|
||||
float prop, long iContext);
|
||||
|
||||
// String-version
|
||||
private native int _NativeSetPropertyString(String name,
|
||||
String prop, long iContext);
|
||||
}
|
|
@ -1,276 +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 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;
|
||||
};
|
||||
|
||||
|
||||
/** 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;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 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
|
||||
*
|
||||
* The diffuse light color is multiplied with the diffuse
|
||||
* material color to obtain the final color that contributes
|
||||
* to the diffuse shading term.
|
||||
*/
|
||||
public final float[] 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;
|
||||
}
|
||||
};
|
|
@ -1,63 +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);
|
||||
}
|
|
@ -1,122 +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);
|
||||
}
|
|
@ -1,610 +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 Aramis (Alexander Gessler)
|
||||
* @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.
|
||||
*/
|
||||
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 a property with a specific name as generic <code>Object</code>
|
||||
*
|
||||
* @param key MATKEY_XXX key constant
|
||||
* @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 a material property as float array
|
||||
*
|
||||
* @param key MATKEY_XXX key constant
|
||||
* @throws PropertyNotFoundException - if the property can't be found
|
||||
* or if it has the wrong data type.
|
||||
*/
|
||||
public float[] getPropertyAsFloatArray(String key) throws PropertyNotFoundException {
|
||||
|
||||
Object obj = getProperty(key);
|
||||
if (obj instanceof float[]) {
|
||||
return (float[]) obj;
|
||||
}
|
||||
String msg = "The data type requested (float[]) doesn't match the " +
|
||||
"real data type of the material property";
|
||||
DefaultLogger.get().error(msg);
|
||||
throw new PropertyNotFoundException(msg, key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a floating-point material property
|
||||
*
|
||||
* @param key MATKEY_XXX key constant
|
||||
* @return The value of the property.
|
||||
* @throws PropertyNotFoundException - if the property can't be found
|
||||
* or if it has the wrong data type.
|
||||
*/
|
||||
public float getPropertyAsFloat(String key) throws PropertyNotFoundException {
|
||||
|
||||
Object obj = getProperty(key);
|
||||
if (obj instanceof Float) {
|
||||
return (Float) obj;
|
||||
}
|
||||
String msg = "The data type requested (Float) doesn't match the " +
|
||||
"real data type of the material property";
|
||||
DefaultLogger.get().error(msg);
|
||||
throw new PropertyNotFoundException(msg, key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an integer material property
|
||||
*
|
||||
* @param key MATKEY_XXX key constant
|
||||
* @return The value of the property.
|
||||
* @throws PropertyNotFoundException - if the property can't be found
|
||||
* or if it has the wrong data type.
|
||||
*/
|
||||
public int getPropertyAsInt(String key) throws PropertyNotFoundException {
|
||||
|
||||
Object obj = getProperty(key);
|
||||
if (obj instanceof Integer) {
|
||||
return (Integer) obj;
|
||||
}
|
||||
String msg = "The data type requested (Integer) doesn't match the " +
|
||||
"real data type of the material property";
|
||||
DefaultLogger.get().error(msg);
|
||||
throw new PropertyNotFoundException(msg, key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a material property string
|
||||
*
|
||||
* @param key MATKEY_XXX key constant
|
||||
* @return The value of the property.
|
||||
* @throws PropertyNotFoundException - if the property can't be found
|
||||
* or if it has the wrong data type.
|
||||
*/
|
||||
public String getPropertyAsString(String key) throws PropertyNotFoundException {
|
||||
|
||||
Object obj = getProperty(key);
|
||||
if (obj instanceof String) {
|
||||
return (String) obj;
|
||||
}
|
||||
String msg = "The data type requested (java.lang.String) doesn't match the " +
|
||||
"real data type of the material property";
|
||||
DefaultLogger.get().error(msg);
|
||||
throw new PropertyNotFoundException(msg, key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Material key: defines the name of the material
|
||||
* The type of this material property is <code>String</code>
|
||||
*/
|
||||
public static final String MATKEY_NAME = "$mat.name";
|
||||
|
||||
/**
|
||||
* Material key: defines the diffuse base color of the material
|
||||
* The type of this material property is <code>float[]</code>.
|
||||
* The array has 4 or 3 components in RGB(A) order.
|
||||
*/
|
||||
public static final String MATKEY_COLOR_DIFFUSE = "$clr.diffuse";
|
||||
|
||||
/**
|
||||
* Material key: defines the specular base color of the material
|
||||
* The type of this material property is <code>float[]</code>.
|
||||
* The array has 4 or 3 components in RGB(A) order.
|
||||
*/
|
||||
public static final String MATKEY_COLOR_SPECULAR = "$clr.specular";
|
||||
|
||||
/**
|
||||
* Material key: defines the ambient base color of the material
|
||||
* The type of this material property is <code>float[]</code>.
|
||||
* The array has 4 or 3 components in RGB(A) order.
|
||||
*/
|
||||
public static final String MATKEY_COLOR_AMBIENT = "$clr.ambient";
|
||||
|
||||
/**
|
||||
* Material key: defines the emissive base color of the material
|
||||
* The type of this material property is <code>float[]</code>.
|
||||
* The array has 4 or 3 components in RGB(A) order.
|
||||
*/
|
||||
public static final String MATKEY_COLOR_EMISSIVE = "$clr.emissive";
|
||||
|
||||
/**
|
||||
* Specifies the blend operation to be used to combine the Nth
|
||||
* diffuse texture with the (N-1)th diffuse texture (or the diffuse
|
||||
* base color for the first diffuse texture)
|
||||
* <br>
|
||||
* <b>Type:</b> int (TextureOp)<br>
|
||||
* <b>Default value:</b> 0<br>
|
||||
* <b>Requires:</b> MATKEY_TEXTURE_DIFFUSE(N)<br>
|
||||
*
|
||||
* @param N Index of the texture
|
||||
*/
|
||||
public static String MATKEY_TEXOP_DIFFUSE(int N) {
|
||||
return "$tex.op.diffuse[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXOP_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXOP_SPECULAR(int N) {
|
||||
return "$tex.op.specular[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXOP_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXOP_AMBIENT(int N) {
|
||||
return "$tex.op.ambient[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXOP_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXOP_EMISSIVE(int N) {
|
||||
return "$tex.op.emissive[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXOP_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXOP_NORMALS(int N) {
|
||||
return "$tex.op.normals[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXOP_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXOP_HEIGHT(int N) {
|
||||
return "$tex.op.height[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXOP_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXOP_SHININESS(int N) {
|
||||
return "$tex.op.shininess[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXOP_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXOP_OPACITY(int N) {
|
||||
return "$tex.op.opacity[" + N + "]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the blend factor to be multiplied with the value of
|
||||
* the n'th texture layer before it is combined with the previous
|
||||
* layer using a specific blend operation.
|
||||
* <p/>
|
||||
* <br>
|
||||
* <b>Type:</b> float<br>
|
||||
* <b>Default value:</b> 1.0f<br>
|
||||
* <b>Requires:</b> MATKEY_TEXTURE_DIFFUSE(N)<br>
|
||||
*
|
||||
* @param N Index of the texture
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_DIFFUSE(int N) {
|
||||
return "$tex.blend.diffuse[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXBLEND_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_SPECULAR(int N) {
|
||||
return "$tex.blend.specular[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXBLEND_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_AMBIENT(int N) {
|
||||
return "$tex.blend.ambient[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXBLEND_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_EMISSIVE(int N) {
|
||||
return "$tex.blend.emissive[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXBLEND_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_SHININESS(int N) {
|
||||
return "$tex.blend.shininess[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXBLEND_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_OPACITY(int N) {
|
||||
return "$tex.blend.opacity[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXBLEND_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_HEIGHT(int N) {
|
||||
return "$tex.blend.height[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_TEXBLEND_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_TEXBLEND_NORMALS(int N) {
|
||||
return "$tex.blend.normals[" + N + "]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the index of the UV channel to be used for a texture
|
||||
* <br>
|
||||
* <b>Type:</b>int<br>
|
||||
* <b>Default value:</b>0<br>
|
||||
* <b>Requires:</b> MATKEY_TEXTURE_DIFFUSE(N)<br>
|
||||
*
|
||||
* @param N Index of the texture
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_DIFFUSE(int N) {
|
||||
return "$tex.uvw.diffuse[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_UVWSRC_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_SPECULAR(int N) {
|
||||
return "$tex.uvw.specular[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_UVWSRC_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_AMBIENT(int N) {
|
||||
return "$tex.uvw.ambient[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_UVWSRC_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_EMISSIVE(int N) {
|
||||
return "$tex.uvw.emissive[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_UVWSRC_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_SHININESS(int N) {
|
||||
return "$tex.uvw.shininess[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_UVWSRC_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_OPACITY(int N) {
|
||||
return "$tex.uvw.opacity[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_UVWSRC_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_HEIGHT(int N) {
|
||||
return "$tex.uvw.height[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_UVWSRC_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_UVWSRC_NORMALS(int N) {
|
||||
return "$tex.uvw.normals[" + N + "]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the texture mapping mode in the v (y) direction.
|
||||
* <br>
|
||||
* <b>Type:</b>int<br>
|
||||
* <b>Default value:</b>TextureMapMode.Wrap<br>
|
||||
* <b>Requires:</b> MATKEY_TEXTURE_DIFFUSE(N)<br>
|
||||
*
|
||||
* @param N Index of the texture
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_DIFFUSE(int N) {
|
||||
return "$tex.mapmodeu.diffuse[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_U_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_SPECULAR(int N) {
|
||||
return "$tex.mapmodeu.specular[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_U_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_AMBIENT(int N) {
|
||||
return "$tex.mapmodeu.ambient[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_U_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_EMISSIVE(int N) {
|
||||
return "$tex.mapmodeu.emissive[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_U_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_SHININESS(int N) {
|
||||
return "$tex.mapmodeu.shininess[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_U_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_OPACITY(int N) {
|
||||
return "$tex.mapmodeu.opacity[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_U_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_HEIGHT(int N) {
|
||||
return "$tex.mapmodeu.height[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_U_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_U_NORMALS(int N) {
|
||||
return "$tex.mapmodeu.normals[" + N + "]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the texture mapping mode in the v (y) direction.
|
||||
* <br>
|
||||
* <b>Type:</b>int<br>
|
||||
* <b>Default value:</b>TextureMapMode.Wrap<br>
|
||||
* <b>Requires:</b> MATKEY_TEXTURE_DIFFUSE(N)<br>
|
||||
*
|
||||
* @param N Index of the texture
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_DIFFUSE(int N) {
|
||||
return "$tex.mapmodev.diffuse[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_SPECULAR(int N) {
|
||||
return "$tex.mapmodev.specular[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_AMBIENT(int N) {
|
||||
return "$tex.mapmodev.ambient[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_EMISSIVE(int N) {
|
||||
return "$tex.mapmodev.emissive[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_SHININESS(int N) {
|
||||
return "$tex.mapmodev.shininess[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_OPACITY(int N) {
|
||||
return "$tex.mapmodev.opacity[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_HEIGHT(int N) {
|
||||
return "$tex.mapmodev.height[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_V_NORMALS(int N) {
|
||||
return "$tex.mapmodev.normals[" + N + "]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the texture mapping mode in the w (z) direction.
|
||||
* <br>
|
||||
* <b>Type:</b>int<br>
|
||||
* <b>Default value:</b>TextureMapMode.Wrap<br>
|
||||
* <b>Requires:</b> MATKEY_TEXTURE_DIFFUSE(N)<br>
|
||||
*
|
||||
* @param N Index of the texture
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_DIFFUSE(int N) {
|
||||
return "$tex.mapmodew.diffuse[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_SPECULAR(int N) {
|
||||
return "$tex.mapmodew.specular[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_AMBIENT(int N) {
|
||||
return "$tex.mapmodew.ambient[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_EMISSIVE(int N) {
|
||||
return "$tex.mapmodew.emissive[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_SHININESS(int N) {
|
||||
return "$tex.mapmodew.shininess[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_OPACITY(int N) {
|
||||
return "$tex.mapmodew.opacity[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_HEIGHT(int N) {
|
||||
return "$tex.mapmodew.height[" + N + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <code>MATKEY_MAPPINGMODE_V_DIFFUSE</code>
|
||||
*/
|
||||
public static String MATKEY_MAPPINGMODE_W_NORMALS(int N) {
|
||||
return "$tex.mapmodew.normals[" + N + "]";
|
||||
}
|
||||
}
|
|
@ -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]);
|
||||
}
|
||||
}
|
|
@ -1,179 +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 row major matrix
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
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 coefficents
|
||||
* @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 the matrix. *this* matrix
|
||||
* will be modified!
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,622 +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 geometry or model with a single material.
|
||||
* <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 coords 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 often not filled.
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @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, some
|
||||
* will be skipped
|
||||
*/
|
||||
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,
|
||||
* some will be skipped
|
||||
*/
|
||||
public static final int MAX_NUMBER_OF_COLOR_SETS = 0x4;
|
||||
|
||||
|
||||
/**
|
||||
* Contains the vertices loaded from the model
|
||||
*/
|
||||
private float[] m_vVertices = null;
|
||||
|
||||
/**
|
||||
* Contains the normal vectors loaded from the model or
|
||||
* computed by postprocess steps. Needn't be existing
|
||||
*/
|
||||
private float[] m_vNormals = null;
|
||||
|
||||
/**
|
||||
* Contains the tangent vectors computed by Assimp
|
||||
* Needn't be existing
|
||||
*/
|
||||
private float[] m_vTangents = null;
|
||||
|
||||
/**
|
||||
* Contains the bitangent vectors computed by Assimp
|
||||
* Needn't be existing
|
||||
*/
|
||||
private float[] m_vBitangents = null;
|
||||
|
||||
/**
|
||||
* Contains the texture coordinate sets that have been loaded
|
||||
* Needn't be existing
|
||||
*/
|
||||
private float[][] m_avUVs = new float[MAX_NUMBER_OF_TEXTURECOORDS][];
|
||||
|
||||
/**
|
||||
* Specifies how many texture coordinate components are valid
|
||||
* in an UV channel. Normally this will be 2, but 3d texture
|
||||
* coordinates for cubic or volumetric mapping are also supported.
|
||||
*/
|
||||
private int[] m_aiNumUVComponents = new int[MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
|
||||
/**
|
||||
* Contains the vertex color sets that have been loaded
|
||||
* Needn't be existing
|
||||
*/
|
||||
private float[][] m_avColors = new float[MAX_NUMBER_OF_COLOR_SETS][];
|
||||
|
||||
/**
|
||||
* Contains a list of all faces of the mesh. each face consists of
|
||||
* three indices into the vertex buffer.
|
||||
*/
|
||||
private int[] m_vFaces = null;
|
||||
|
||||
|
||||
/**
|
||||
* Bones which are influencing the mesh
|
||||
*/
|
||||
private Bone[] m_vBones = null;
|
||||
|
||||
/**
|
||||
* Material index of the mesh
|
||||
*/
|
||||
private int m_iMaterialIndex = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Check whether there are vertex positions in the model
|
||||
* <code>getPosition()</code> will assert this.
|
||||
*
|
||||
* @return true if vertex positions are available. This is
|
||||
* guaranteed to be always true, except for scenes which contain only
|
||||
* animation skeletons.
|
||||
*/
|
||||
public final boolean hasPositions() {
|
||||
return null != this.m_vVertices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether there are normal vectors in the model
|
||||
* <code>getNormal()</code> will assert this.
|
||||
*
|
||||
* @return true if vertex normals are available.
|
||||
*/
|
||||
public final boolean hasNormals() {
|
||||
return null != this.m_vNormals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether there are bones in the model
|
||||
* <code>getBone()</code> will assert this.
|
||||
*
|
||||
* @return true if vertex normals are available.
|
||||
*/
|
||||
public final boolean hasBones() {
|
||||
return null != this.m_vBones;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether there are tangents/bitangents in the model
|
||||
* <code>getTangent()</code> and <code>GetBitangent()</code> will assert this.
|
||||
*
|
||||
* @return true if vertex tangents and bitangents are available.
|
||||
*/
|
||||
public final boolean hasTangentsAndBitangents() {
|
||||
return null != this.m_vBitangents && null != this.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 < this.m_avUVs.length && null != this.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 < this.m_avColors.length && null != this.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 material index
|
||||
*/
|
||||
public final int getMaterialIndex() {
|
||||
return m_iMaterialIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a 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 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 < this.getNumVertices());
|
||||
|
||||
iIndex *= 3;
|
||||
afOut[iOutBase] = this.m_vVertices[iIndex];
|
||||
afOut[iOutBase + 1] = this.m_vVertices[iIndex + 1];
|
||||
afOut[iOutBase + 2] = this.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 this.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 < this.getNumVertices());
|
||||
|
||||
iIndex *= 3;
|
||||
afOut[0] = this.m_vTangents[iIndex];
|
||||
afOut[1] = this.m_vTangents[iIndex + 1];
|
||||
afOut[2] = this.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 < this.getNumVertices());
|
||||
|
||||
iIndex *= 3;
|
||||
afOut[iOutBase] = this.m_vNormals[iIndex];
|
||||
afOut[iOutBase + 1] = this.m_vNormals[iIndex + 1];
|
||||
afOut[iOutBase + 2] = this.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 ordering
|
||||
* 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 < this.getNumVertices());
|
||||
|
||||
iIndex *= 3;
|
||||
afOut[0] = this.m_vTangents[iIndex];
|
||||
afOut[1] = this.m_vTangents[iIndex + 1];
|
||||
afOut[2] = this.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 < this.getNumVertices());
|
||||
|
||||
iIndex *= 3;
|
||||
afOut[iOutBase] = this.m_vTangents[iIndex];
|
||||
afOut[iOutBase + 1] = this.m_vTangents[iIndex + 1];
|
||||
afOut[iOutBase + 2] = this.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 ordering
|
||||
* is xyz.
|
||||
*/
|
||||
public final float[] getTangentArray() {
|
||||
return this.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 < this.getNumVertices());
|
||||
|
||||
iIndex *= 3;
|
||||
afOut[0] = this.m_vBitangents[iIndex];
|
||||
afOut[1] = this.m_vBitangents[iIndex + 1];
|
||||
afOut[2] = this.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 < this.getNumVertices());
|
||||
|
||||
iIndex *= 3;
|
||||
afOut[iOutBase] = this.m_vBitangents[iIndex];
|
||||
afOut[iOutBase + 1] = this.m_vBitangents[iIndex + 1];
|
||||
afOut[iOutBase + 2] = this.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. Component ordering
|
||||
* is xyz.
|
||||
*/
|
||||
public final float[] getBitangentArray() {
|
||||
assert(this.hasTangentsAndBitangents());
|
||||
return this.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, components are in u,v,w order
|
||||
*/
|
||||
public final void getTexCoord(int channel, int iIndex, float[] afOut) {
|
||||
assert(this.hasUVCoords(channel) && afOut.length >= 4 &&
|
||||
4 >= afOut.length && iIndex < this.getNumVertices());
|
||||
|
||||
iIndex *= this.m_aiNumUVComponents[channel];
|
||||
for (int i = 0; i < this.m_aiNumUVComponents[channel]; ++i) {
|
||||
afOut[i] = this.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(this.hasUVCoords(channel) && afOut.length >= 4 &&
|
||||
iOutBase + 4 <= afOut.length && iIndex < this.getNumVertices());
|
||||
|
||||
iIndex *= this.m_aiNumUVComponents[channel];
|
||||
for (int i = 0; i < this.m_aiNumUVComponents[channel]; ++i) {
|
||||
afOut[i + iOutBase] = this.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 this.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] = this.m_avColors[channel][iIndex];
|
||||
afOut[1] = this.m_avColors[channel][iIndex + 1];
|
||||
afOut[2] = this.m_avColors[channel][iIndex + 2];
|
||||
afOut[3] = this.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];
|
||||
this.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(this.hasVertexColors(channel) && afOut.length >= 4 &&
|
||||
iOutBase + 4 <= afOut.length && iIndex < this.getNumVertices());
|
||||
|
||||
iIndex *= 4; // RGBA order
|
||||
afOut[iOutBase] = this.m_avColors[channel][iIndex];
|
||||
afOut[iOutBase + 1] = this.m_avColors[channel][iIndex + 1];
|
||||
afOut[iOutBase + 2] = this.m_avColors[channel][iIndex + 2];
|
||||
afOut[iOutBase + 3] = this.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 this.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>
|
||||
* @param aiOut Output array, size must at least be 3
|
||||
*/
|
||||
public final void getFace(int iIndex, int[] aiOut) {
|
||||
assert(aiOut.length >= 3);
|
||||
iIndex *= 3;
|
||||
aiOut[0] = this.m_vFaces[iIndex];
|
||||
aiOut[1] = this.m_vFaces[iIndex + 1];
|
||||
aiOut[2] = this.m_vFaces[iIndex + 2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single face of the mesh
|
||||
*
|
||||
* @param iIndex Index of the face. Must be smaller than the value
|
||||
* returned by <code>getNumFaces()</code>
|
||||
* @param aiOut Output array, size must at least be 3
|
||||
* @param iOutBase Start index in the output array
|
||||
*/
|
||||
public final void getFace(int iIndex, int[] aiOut, int iOutBase) {
|
||||
assert(aiOut.length >= 3);
|
||||
iIndex *= 3;
|
||||
aiOut[0] = this.m_vFaces[iIndex];
|
||||
aiOut[iOutBase + 1] = this.m_vFaces[iIndex + 1];
|
||||
aiOut[iOutBase + 2] = this.m_vFaces[iIndex + 2];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 int[] 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];
|
||||
}
|
||||
}
|
|
@ -1,57 +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 {
|
||||
|
||||
public NativeException() {
|
||||
super("Unknown error");
|
||||
}
|
||||
|
||||
public NativeException(String sz) {
|
||||
super(sz);
|
||||
}
|
||||
}
|
|
@ -1,217 +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;
|
||||
|
||||
|
||||
/**
|
||||
* A node in the imported hierarchy.
|
||||
* <p/>
|
||||
* Each node has name, a 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.
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Node {
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
|
||||
private native int _NativeInitMembers(long context, int nodeIndex);
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -1,252 +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;
|
||||
|
||||
/**
|
||||
* Enumeration class that defines postprocess steps that can be executed on a model
|
||||
* after it has been loaded. All PPSteps are implemented in C++, so their performance
|
||||
* is awesome :-) (*duck*)
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PostProcessStep {
|
||||
|
||||
/**
|
||||
* Default vertex split limit for the SplitLargeMeshes process
|
||||
*/
|
||||
public static final int DEFAULT_VERTEX_SPLIT_LIMIT = 1000000;
|
||||
|
||||
/**
|
||||
* Default triangle split limit for the SplitLargeMeshes process
|
||||
*/
|
||||
public static final int DEFAULT_TRIANGLE_SPLIT_LIMIT = 1000000;
|
||||
|
||||
/**
|
||||
* Default bone weight limit for the LimitBoneWeight process
|
||||
*/
|
||||
public static final int DEFAULT_BONE_WEIGHT_LIMIT = 4;
|
||||
|
||||
|
||||
private static int s_iVertexSplitLimit = DEFAULT_VERTEX_SPLIT_LIMIT;
|
||||
private static int s_iTriangleSplitLimit = DEFAULT_TRIANGLE_SPLIT_LIMIT;
|
||||
private static int s_iBoneWeightLimit = DEFAULT_BONE_WEIGHT_LIMIT;
|
||||
|
||||
/**
|
||||
* 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 propably always want to use this post processing step.
|
||||
*/
|
||||
public static final PostProcessStep JoinIdenticalVertices =
|
||||
new PostProcessStep("JoinIdenticalVertices");
|
||||
|
||||
|
||||
/**
|
||||
* Splits large meshes into submeshes
|
||||
* This is quite useful for realtime rendering where the number of
|
||||
* vertices is usually limited by the video driver.
|
||||
* <p/>
|
||||
* The split limits can be set through SetVertexSplitLimit() and
|
||||
* SetTriangleSplitLimit(). The default values are
|
||||
* <code>DEFAULT_VERTEX_SPLIT_LIMIT</code> and
|
||||
* <code>DEFAULT_TRIANGLE_SPLIT_LIMIT</code>
|
||||
*/
|
||||
public static final PostProcessStep SplitLargeMeshes =
|
||||
new PostProcessStep("SplitLargeMeshes");
|
||||
|
||||
|
||||
/**
|
||||
* Omits all normals found in the file. This can be used together
|
||||
* with either the <code>GenSmoothNormals</code> or the
|
||||
* <code>GenFaceNormal</code> step to force the recomputation of the
|
||||
* normals. If none of the two flags is specified, the output mesh
|
||||
* won't have normals
|
||||
*/
|
||||
public static final PostProcessStep KillNormals =
|
||||
new PostProcessStep("KillNormals");
|
||||
|
||||
|
||||
/**
|
||||
* Generates smooth normals for all vertices in the mesh. This is
|
||||
* ignored if normals are already existing. This step may not be used
|
||||
* together with <code>GenFaceNormals</code>
|
||||
*/
|
||||
public static final PostProcessStep GenSmoothNormals =
|
||||
new PostProcessStep("GenSmoothNormals");
|
||||
|
||||
|
||||
/**
|
||||
* Generates normals for all faces of all meshes. The normals are
|
||||
* shared between the three vertices of a face. This is ignored
|
||||
* if normals are already existing. This step may not be used together
|
||||
* with <code>GenSmoothNormals</code>
|
||||
*/
|
||||
public static final PostProcessStep GenFaceNormals =
|
||||
new PostProcessStep("GenFaceNormals");
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the tangents and bitangents 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.
|
||||
*/
|
||||
public static final PostProcessStep CalcTangentSpace =
|
||||
new PostProcessStep("CalcTangentSpace");
|
||||
|
||||
|
||||
/**
|
||||
* Converts all the imported data to a left-handed coordinate space
|
||||
* such as the DirectX coordinate system. 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, +Y points towards
|
||||
* the viewer and and +Z points upwards. In the DirectX coordinate space
|
||||
* +X points to the right, +Y points upwards and +Z points away from
|
||||
* the viewer.
|
||||
*/
|
||||
public static final PostProcessStep ConvertToLeftHanded =
|
||||
new PostProcessStep("ConvertToLeftHanded ");
|
||||
|
||||
|
||||
/**
|
||||
* Removes the node graph and pretransforms all vertices with the local
|
||||
* transformation matrices of their nodes. The output scene does still
|
||||
* contain nodes, however, there is only a root node with childs, each
|
||||
* one referencing only one mesh, each mesh referencing one material.
|
||||
* For rendering, you can simply render all meshes in order, you don't
|
||||
* need to pay attention to local transformations and the node hierarchy.
|
||||
* Animations are removed during this step.
|
||||
*/
|
||||
public static final PostProcessStep PreTransformVertices =
|
||||
new PostProcessStep("PreTransformVertices");
|
||||
|
||||
/**
|
||||
* 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 (DEFAULT_BONE_WEIGHT_LIMIT).
|
||||
* However, you can use setBoneWeightLimit() to supply your own limit.
|
||||
* If you intend to perform the skinning in hardware, this post processing step
|
||||
* might be of interest for you.
|
||||
*/
|
||||
public static final PostProcessStep LimitBoneWeights =
|
||||
new PostProcessStep("LimitBoneWeights");
|
||||
|
||||
/**
|
||||
* Validates the aiScene data structure before it is returned.
|
||||
* This makes sure that all indices are valid, all animations and
|
||||
* bones are linked correctly, all material are correct and so on ...
|
||||
* This is primarily intended for our internal debugging stuff,
|
||||
* however, it could be of interest for applications like editors
|
||||
* where stability is more important than loading performance.
|
||||
*/
|
||||
public static final PostProcessStep ValidateDataStructure =
|
||||
new PostProcessStep("ValidateDataStructure");
|
||||
|
||||
|
||||
/**
|
||||
* Reorders triangles for vertex cache locality and thus better performance.
|
||||
* The step tries to improve the ACMR (average post-transform vertex cache
|
||||
* miss ratio) for all meshes. The step runs in O(n) and is roughly
|
||||
* basing on the algorithm described in this paper:
|
||||
* <url>http://www.cs.princeton.edu/gfx/pubs/Sander_2007_%3ETR/tipsy.pdf</url>
|
||||
*/
|
||||
public static final PostProcessStep ImproveVertexLocality =
|
||||
new PostProcessStep("ImproveVertexLocality");
|
||||
|
||||
|
||||
/**
|
||||
* Searches for redundant materials and removes them.
|
||||
* <p/>
|
||||
* This is especially useful in combination with the PretransformVertices
|
||||
* and OptimizeGraph steps. Both steps join small meshes, but they
|
||||
* can't do that if two meshes have different materials.
|
||||
*/
|
||||
public static final PostProcessStep RemoveRedundantMaterials =
|
||||
new PostProcessStep("RemoveRedundantMaterials");
|
||||
|
||||
/**
|
||||
* 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 infacing normals. Generally it is recommended
|
||||
* to enable this step, although the result is not always correct.
|
||||
*/
|
||||
public static final PostProcessStep FixInfacingNormals =
|
||||
new PostProcessStep("FixInfacingNormals");
|
||||
|
||||
/**
|
||||
* This step performs some optimizations on the node graph.
|
||||
* <p/>
|
||||
* It is incompatible to the PreTransformVertices-Step. Some configuration
|
||||
* options exist, see aiConfig.h for more details.
|
||||
* Generally, two actions are available:<br>
|
||||
* 1. Remove animation nodes and data from the scene. This allows other
|
||||
* steps for further optimizations.<br>
|
||||
* 2. Combine very small meshes to larger ones. Only if the meshes
|
||||
* are used by the same node or by nodes on the same hierarchy (with
|
||||
* equal local transformations). Unlike PreTransformVertices, the
|
||||
* OptimizeGraph-step doesn't transform vertices from one space
|
||||
* another.<br>
|
||||
* 3. Remove hierarchy levels<br>
|
||||
* <p/>
|
||||
* It is recommended to have this step run with the default configuration.
|
||||
*/
|
||||
public static final PostProcessStep OptimizeGraph =
|
||||
new PostProcessStep("OptimizeGraph");
|
||||
|
||||
private final String myName; // for debug only
|
||||
|
||||
private PostProcessStep(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myName;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,185 +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 scenegraph of the asset (the hierarchy of all
|
||||
* meshes, ...).
|
||||
* <p/>
|
||||
* An instance of this class is returned by Importer.readFile().
|
||||
*
|
||||
* @author Aramis (Alexander Gessler)
|
||||
* @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;
|
||||
|
||||
private Scene() {
|
||||
}
|
||||
|
||||
protected Scene(Importer imp) {
|
||||
this.imp = imp;
|
||||
}
|
||||
|
||||
public final Importer getImporter() {
|
||||
return this.imp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies that no full model but only an animation skeleton has been
|
||||
* imported. There are no materials in this case. There are no
|
||||
* textures in this case. But there is a node graph, animation channels
|
||||
* and propably meshes with bones.
|
||||
*/
|
||||
public static final int FLAG_ANIM_SKELETON_ONLY = 0x1;
|
||||
|
||||
|
||||
/**
|
||||
* Get the scene flags. This can be any combination of the
|
||||
* FLAG_XXX constants defined int this scope
|
||||
* @return Scene flags.
|
||||
*/
|
||||
public final int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mesh list
|
||||
*
|
||||
* @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 textures in the scene
|
||||
* @return this value is often 0 since most texture's arent' embedded
|
||||
*/
|
||||
public int getNumTextures() {
|
||||
return m_vTextures.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an embedded texture from the scene
|
||||
* @param i Index of the mesh
|
||||
* @return scene.texture[i]
|
||||
*/
|
||||
public final Texture getTexture(int i) {
|
||||
assert(i < m_vTextures.length);
|
||||
return m_vTextures[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material list
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @return Animation list
|
||||
*/
|
||||
public final Animation[] getAnimations() {
|
||||
return m_vAnimations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root node of the scenegraph
|
||||
*
|
||||
* @return Root node
|
||||
*/
|
||||
public final Node getRootNode() {
|
||||
return m_rootNode;
|
||||
}
|
||||
}
|
|
@ -1,118 +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 shading models supported by the library
|
||||
*
|
||||
* NOTE: The list of shading modes has been taken from Blender3D.
|
||||
* See Blender3D documentation for more information. The API does
|
||||
* not distinguish between "specular" and "diffuse" shaders (thus the
|
||||
* specular term for diffuse shading models like Oren-Nayar remains
|
||||
* undefined)
|
||||
*/
|
||||
public class ShadingMode {
|
||||
|
||||
private ShadingMode() {}
|
||||
|
||||
/**
|
||||
* Flat shading. Shading is done on per-face base,
|
||||
* diffuse only.
|
||||
*/
|
||||
public static final int Flat = 0x1;
|
||||
|
||||
/**
|
||||
* Diffuse gouraud shading. Shading on per-vertex base
|
||||
*/
|
||||
public static final int Gouraud = 0x2;
|
||||
|
||||
/**
|
||||
* Diffuse/Specular Phong-Shading
|
||||
* <p/>
|
||||
* Shading is applied on per-pixel base. This is the
|
||||
* slowest algorithm, but generates the best results.
|
||||
*/
|
||||
public static final int Phong = 0x3;
|
||||
|
||||
/**
|
||||
* Diffuse/Specular Phong-Blinn-Shading
|
||||
* <p/>
|
||||
* Shading is applied on per-pixel base. This is a little
|
||||
* bit faster than phong and in some cases even
|
||||
* more realistic
|
||||
*/
|
||||
public static final int Blinn = 0x4;
|
||||
|
||||
/**
|
||||
* Toon-Shading per pixel
|
||||
* <p/>
|
||||
* Shading is applied on per-pixel base. The output looks
|
||||
* like a comic. Often combined with edge detection.
|
||||
*/
|
||||
public static final int Toon = 0x5;
|
||||
|
||||
/**
|
||||
* OrenNayar-Shading per pixel
|
||||
* <p/>
|
||||
* Extension to standard lambertian shading, taking the
|
||||
* roughness of the material into account
|
||||
*/
|
||||
public static final int OrenNayar = 0x6;
|
||||
|
||||
/**
|
||||
* Minnaert-Shading per pixel
|
||||
* <p/>
|
||||
* Extension to standard lambertian shading, taking the
|
||||
* "darkness" of the material into account
|
||||
*/
|
||||
public static final int Minnaert = 0x7;
|
||||
|
||||
/**
|
||||
* CookTorrance-Shading per pixel
|
||||
*/
|
||||
public static final int CookTorrance = 0x8;
|
||||
|
||||
/**
|
||||
* No shading at all
|
||||
*/
|
||||
public static final int NoShading = 0x9;
|
||||
}
|
|
@ -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;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* 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 <code>java.awt.BufferedImage</code> object containing
|
||||
* a copy of the texture image. The texture is a ARGB texture if
|
||||
* an alpha channel is required, otehrwise RGB is used as format.
|
||||
*/
|
||||
public BufferedImage convertToImage() {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,66 +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 how texture coordinates ! ElemOf [0 ... 1] are handled.
|
||||
*
|
||||
* This corresponds to the native <code>aiTextureMapMode</code> enum.
|
||||
*
|
||||
* @author Alexander Gessler (Aramis)
|
||||
*/
|
||||
public class TextureMapMode {
|
||||
|
||||
/** A texture coordinate u|v is translated to u%1|v%1
|
||||
*/
|
||||
public static final int Wrap = 0x0;
|
||||
|
||||
/** Texture coordinates outside the area formed by 1|1 and 0|0
|
||||
* are clamped to the nearest valid value on an axis
|
||||
*/
|
||||
public static final int Clamp = 0x1;
|
||||
|
||||
/** 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;
|
||||
}
|
|
@ -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;
|
||||
|
||||
public class TextureOp {
|
||||
|
||||
private TextureOp() {}
|
||||
|
||||
/** T = T1 * T2
|
||||
*/
|
||||
public static int Add = 0x0;
|
||||
|
||||
/** T = T1 * T2
|
||||
*/
|
||||
public static int Multiply = 0x1;
|
||||
|
||||
/** T = T1 - T2
|
||||
*/
|
||||
public static int Subtract = 0x2;
|
||||
|
||||
/** T = T1 / T2
|
||||
*/
|
||||
public static int Divide = 0x3;
|
||||
|
||||
/** T = (T1 + T2) - (T1 * T2)
|
||||
*/
|
||||
public static int SmoothAdd = 0x4;
|
||||
|
||||
/** T = T1 + (T2-0.5)
|
||||
*/
|
||||
public static int SignedAdd = 0x5;
|
||||
}
|
|
@ -1,435 +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 javax.imageio.ImageWriter;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print all nodes recursively
|
||||
*
|
||||
* @param node Current node
|
||||
* @param stream Output stream
|
||||
* @param suffix Suffix to all output
|
||||
* @throws IOException yes ... sometimes ... :-)
|
||||
*/
|
||||
public static void PrintNodes(Node node, FileWriter stream, String suffix) throws IOException {
|
||||
String suffNew = suffix + "\t";
|
||||
stream.write(suffix + node.getName() + "\n");
|
||||
|
||||
// print all meshes
|
||||
if (0 != node.getNumMeshes()) {
|
||||
stream.write(suffNew + "Meshes: ");
|
||||
|
||||
for (int i : node.getMeshes()) {
|
||||
|
||||
stream.write(i + " ");
|
||||
}
|
||||
stream.write("\n");
|
||||
}
|
||||
|
||||
// print all children
|
||||
if (0 != node.getNumChildren()) {
|
||||
for (Node n : node.getChildren()) {
|
||||
|
||||
PrintNodes(n, stream, suffNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves an embedded texture image as TrueVision Targa file
|
||||
*
|
||||
* @param texture Texture to be exported
|
||||
* @param path Output path
|
||||
*/
|
||||
public static void SaveTextureToTGA(Texture texture, String path) {
|
||||
BufferedImage bImg = texture.convertToImage();
|
||||
|
||||
Iterator writers = ImageIO.getImageWritersBySuffix("tga");
|
||||
if (!(writers.hasNext())) {
|
||||
System.out.println("No writer for TGA file format available");
|
||||
return;
|
||||
}
|
||||
ImageWriter w = (ImageWriter) (writers.next());
|
||||
if (w == null) {
|
||||
System.out.println("No writer for TGA file format available");
|
||||
return;
|
||||
}
|
||||
File fo = new File(path);
|
||||
|
||||
try {
|
||||
|
||||
ImageOutputStream ios = ImageIO.createImageOutputStream(fo);
|
||||
w.setOutput(ios);
|
||||
w.write(bImg);
|
||||
|
||||
}
|
||||
catch (IOException ex) {
|
||||
System.out.println("Failed to write " + path);
|
||||
return;
|
||||
}
|
||||
System.out.println(path + " has been written");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Entry point of the application
|
||||
*
|
||||
* @param arguments The first argument is the name of the
|
||||
* mesh to be opened, the second is te 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
|
||||
* However, at least one parameter is expected
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
int iLen;
|
||||
if ((iLen = arguments[1].length()) < 4 ||
|
||||
arguments[1].charAt(iLen - 1) != 't' ||
|
||||
arguments[1].charAt(iLen - 2) != 'x' ||
|
||||
arguments[1].charAt(iLen - 3) != 't' ||
|
||||
arguments[1].charAt(iLen - 4) != '.') {
|
||||
System.out.println("The output path must have .txt as file extension");
|
||||
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");
|
||||
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 exception [#1]: " + nativeException.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now setup the correct postprocess steps. Triangulation is
|
||||
* automatically performed, DX conversion is not necessary,
|
||||
* However, a few steps are normally useful. Especially
|
||||
* JoinVertices since it will dramantically reduce the size
|
||||
* of the output file
|
||||
*/
|
||||
imp.addPostProcessStep(PostProcessStep.CalcTangentSpace);
|
||||
imp.addPostProcessStep(PostProcessStep.GenSmoothNormals);
|
||||
imp.addPostProcessStep(PostProcessStep.JoinIdenticalVertices);
|
||||
imp.addPostProcessStep(PostProcessStep.FixInfacingNormals);
|
||||
|
||||
/* 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]);
|
||||
} catch (NativeException nativeException) {
|
||||
nativeException.printStackTrace();
|
||||
System.out.println("NativeException exception [#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
|
||||
*/
|
||||
int[] 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.getNumBoneAnimChannels() + "\n\n");
|
||||
|
||||
/*
|
||||
* Write all bone animation channels
|
||||
*/
|
||||
if (0 != anim.getNumBoneAnimChannels()) {
|
||||
for (BoneAnim boneAnim : anim.getBoneAnimChannels()) {
|
||||
|
||||
stream.write("\tBoneAnim\n" +
|
||||
"\tName: " + boneAnim.getName() + "\n" +
|
||||
"\tNum QuatKeys: " + boneAnim.getNumQuatKeys() + "\n");
|
||||
|
||||
/* Write all rotation keys
|
||||
*/
|
||||
for (BoneAnim.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 (BoneAnim.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 (BoneAnim.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");
|
||||
PrintNodes(scene.getRootNode(), stream, "\t");
|
||||
stream.write("\n");
|
||||
|
||||
/* Now print all textures .. ehm ... 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");
|
||||
|
||||
SaveTextureToTGA(texture, path);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now print all materials
|
||||
*/
|
||||
|
||||
// close the stream again
|
||||
stream.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue