MakeVerbose moved to subdirectory
pp step c'tors are protected now viewer changes JNI additions - JNI BUILD CURRENTLY NOT WORKING git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@43 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
36d120f886
commit
70f155e515
|
@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file Implementation of the 3ds importer class */
|
/** @file Implementation of the 3ds importer class */
|
||||||
#include "3DSLoader.h"
|
#include "3DSLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
|
|
||||||
#include "../include/IOStream.h"
|
#include "../include/IOStream.h"
|
||||||
#include "../include/IOSystem.h"
|
#include "../include/IOSystem.h"
|
||||||
|
|
|
@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file Implementation of the 3ds importer class */
|
/** @file Implementation of the 3ds importer class */
|
||||||
#include "3DSLoader.h"
|
#include "3DSLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
|
|
||||||
#include "../include/IOStream.h"
|
#include "../include/IOStream.h"
|
||||||
#include "../include/IOSystem.h"
|
#include "../include/IOSystem.h"
|
||||||
|
|
|
@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "ASELoader.h"
|
#include "ASELoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
|
|
||||||
#include "../include/IOStream.h"
|
#include "../include/IOStream.h"
|
||||||
|
|
|
@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of the few default functions of the base importer class */
|
/** @file Implementation of the few default functions of the base importer class */
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
#include "../include/aiAssert.h"
|
#include "../include/aiAssert.h"
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
|
@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "CalcTangentsProcess.h"
|
#include "CalcTangentsProcess.h"
|
||||||
#include "SpatialSort.h"
|
#include "SpatialSort.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
|
|
|
@ -61,7 +61,7 @@ class CalcTangentsProcess : public BaseProcess
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
/** Constructor to be privately used by Importer */
|
/** Constructor to be privately used by Importer */
|
||||||
CalcTangentsProcess();
|
CalcTangentsProcess();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* to a left-handed coordinate system.
|
* to a left-handed coordinate system.
|
||||||
*/
|
*/
|
||||||
#include "ConvertToLHProcess.h"
|
#include "ConvertToLHProcess.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../include/aiMesh.h"
|
||||||
#include "../include/aiAnim.h"
|
#include "../include/aiAnim.h"
|
||||||
|
|
|
@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiAssert.h"
|
#include "../include/aiAssert.h"
|
||||||
#include "DefaultIOSystem.h"
|
#include "DefaultIOSystem.h"
|
||||||
#include "Win32DebugLogStream.h"
|
#include "Win32DebugLogStream.h"
|
||||||
|
|
|
@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* normals for all imported faces.
|
* normals for all imported faces.
|
||||||
*/
|
*/
|
||||||
#include "GenFaceNormalsProcess.h"
|
#include "GenFaceNormalsProcess.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../include/aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
|
|
|
@ -55,7 +55,7 @@ class GenFaceNormalsProcess : public BaseProcess
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
/** Constructor to be privately used by Importer */
|
/** Constructor to be privately used by Importer */
|
||||||
GenFaceNormalsProcess();
|
GenFaceNormalsProcess();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "GenVertexNormalsProcess.h"
|
#include "GenVertexNormalsProcess.h"
|
||||||
#include "SpatialSort.h"
|
#include "SpatialSort.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../include/aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
|
|
|
@ -54,7 +54,7 @@ class GenVertexNormalsProcess : public BaseProcess
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
/** Constructor to be privately used by Importer */
|
/** Constructor to be privately used by Importer */
|
||||||
GenVertexNormalsProcess();
|
GenVertexNormalsProcess();
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "GenVertexNormalsProcess.h"
|
#include "GenVertexNormalsProcess.h"
|
||||||
#include "KillNormalsProcess.h"
|
#include "KillNormalsProcess.h"
|
||||||
#include "SplitLargeMeshes.h"
|
#include "SplitLargeMeshes.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "JoinVerticesProcess.h"
|
#include "JoinVerticesProcess.h"
|
||||||
#include "SpatialSort.h"
|
#include "SpatialSort.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../include/aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
|
|
|
@ -63,7 +63,7 @@ class JoinVerticesProcess : public BaseProcess
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
/** Constructor to be privately used by Importer */
|
/** Constructor to be privately used by Importer */
|
||||||
JoinVerticesProcess();
|
JoinVerticesProcess();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file Implementation of the post processing step tokill mesh normals
|
/** @file Implementation of the post processing step tokill mesh normals
|
||||||
*/
|
*/
|
||||||
#include "KillNormalsProcess.h"
|
#include "KillNormalsProcess.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../include/aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
|
|
|
@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "MDLLoader.h"
|
#include "MDLLoader.h"
|
||||||
#include "MDLDefaultColorMap.h"
|
#include "MDLDefaultColorMap.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
|
|
||||||
#include "../include/IOStream.h"
|
#include "../include/IOStream.h"
|
||||||
#include "../include/IOSystem.h"
|
#include "../include/IOSystem.h"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
#include "../include/aiAssert.h"
|
#include "../include/aiAssert.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
|
@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "PLYLoader.h"
|
#include "PLYLoader.h"
|
||||||
#include "MaterialSystem.h"
|
#include "MaterialSystem.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwap.h"
|
||||||
|
|
||||||
#include "../include/IOStream.h"
|
#include "../include/IOStream.h"
|
||||||
|
|
|
@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file Implementation of the SplitLargeMeshes postprocessing step
|
/** @file Implementation of the SplitLargeMeshes postprocessing step
|
||||||
*/
|
*/
|
||||||
#include "SplitLargeMeshes.h"
|
#include "SplitLargeMeshes.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../include/aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
|
|
|
@ -1,10 +1,51 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
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.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
/** @file Implementation of the post processing step to split up
|
/** @file Implementation of the post processing step to split up
|
||||||
* all faces with more than three indices into triangles.
|
* all faces with more than three indices into triangles.
|
||||||
*/
|
*/
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "TriangulateProcess.h"
|
#include "TriangulateProcess.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../include/DefaultLogger.h"
|
||||||
#include "../include/aiPostProcess.h"
|
#include "../include/aiPostProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../include/aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../include/aiScene.h"
|
||||||
|
|
|
@ -60,7 +60,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "../../include/aiPostProcess.h"
|
#include "../../include/aiPostProcess.h"
|
||||||
#include "../../include/assimp.hpp"
|
#include "../../include/assimp.hpp"
|
||||||
|
|
||||||
#include "../DefaultLogger.h"
|
#include "../../include/DefaultLogger.h"
|
||||||
|
|
||||||
|
#include "JNIEnvironment.h"
|
||||||
|
#include "JNILogger.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -146,6 +149,24 @@ JNIEXPORT jlong JNICALL Java_assimp_Importer__1NativeInitContext
|
||||||
#if (defined _DEBUG)
|
#if (defined _DEBUG)
|
||||||
g_listActiveContexts.push_back(context);
|
g_listActiveContexts.push_back(context);
|
||||||
#endif // ! ASSIMP_DEBUG
|
#endif // ! ASSIMP_DEBUG
|
||||||
|
|
||||||
|
// need to setup the logger
|
||||||
|
JNILogDispatcher* pcLogger;
|
||||||
|
if (DefaultLogger::isNullLogger())
|
||||||
|
{
|
||||||
|
pcLogger = new JNILogDispatcher();
|
||||||
|
DefaultLogger::set (pcLogger);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JNILogDispatcher* pcLogger = ( JNILogDispatcher* )DefaultLogger::get();
|
||||||
|
pcLogger->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup the JNI environment ...
|
||||||
|
// simply setup the newest JNIEnv*
|
||||||
|
JNIEnvironment::Get()->AttachToCurrentThread(jvmenv);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -169,6 +190,8 @@ JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeFreeContext
|
||||||
#if (defined _DEBUG)
|
#if (defined _DEBUG)
|
||||||
g_listActiveContexts.remove(jvmcontext);
|
g_listActiveContexts.remove(jvmcontext);
|
||||||
#endif // ! ASSIMP_DEBUG
|
#endif // ! ASSIMP_DEBUG
|
||||||
|
|
||||||
|
JNIEnvironment::Get()->DetachFromCurrentThread();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -187,7 +210,7 @@ JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeLoad
|
||||||
#endif // ! ASSIMP_DEBUG
|
#endif // ! ASSIMP_DEBUG
|
||||||
|
|
||||||
// get the path from the jstring
|
// get the path from the jstring
|
||||||
const char* szPath = jvmenv->GetStringUTFChars(jvmpath,NULL);
|
const char* szPath = JNU_GetStringNativeChars(jvmenv,jvmpath);
|
||||||
if (!szPath)
|
if (!szPath)
|
||||||
{
|
{
|
||||||
DefaultLogger::get()->error("[jnibridge] Unable to get path string from the java vm");
|
DefaultLogger::get()->error("[jnibridge] Unable to get path string from the java vm");
|
||||||
|
@ -203,11 +226,11 @@ JNIEXPORT jint JNICALL Java_assimp_Importer__1NativeLoad
|
||||||
DefaultLogger::get()->error("[jnibridge] Unable to load asset");
|
DefaultLogger::get()->error("[jnibridge] Unable to load asset");
|
||||||
|
|
||||||
// release the path again
|
// release the path again
|
||||||
jvmenv->ReleaseStringUTFChars(jvmpath,szPath);
|
free((void*)szPath);
|
||||||
return AI_JNI_ERROR_RETURN;
|
return AI_JNI_ERROR_RETURN;
|
||||||
}
|
}
|
||||||
// release the path again
|
// release the path again
|
||||||
jvmenv->ReleaseStringUTFChars(jvmpath,szPath);
|
free((void*)szPath);
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,188 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
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.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Implementation of the JNI API for jAssimp */
|
||||||
|
|
||||||
|
#if (defined ASSIMP_JNI_EXPORT)
|
||||||
|
|
||||||
|
#include "JNIEnvironment.h"
|
||||||
|
#include "JNILogger.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
namespace JNIBridge {
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/ jclass JNIEnvironment::Class_java_lang_String = 0;
|
||||||
|
/*static*/ jmethodID JNIEnvironment::MID_String_getBytes = 0;
|
||||||
|
/*static*/ jmethodID JNIEnvironment::MID_String_init = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
bool JNIEnvironment::AttachToCurrentThread (JNIEnv* pcEnv)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcEnv);
|
||||||
|
|
||||||
|
// first initialize some members
|
||||||
|
if (0 == Class_java_lang_String)
|
||||||
|
{
|
||||||
|
if( 0 == (Class_java_lang_String = pcEnv->FindClass("java.lang.String")))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (0 == MID_String_getBytes)
|
||||||
|
{
|
||||||
|
if( 0 == (MID_String_getBytes = pcEnv->GetStaticMethodID(
|
||||||
|
Class_java_lang_String,"getBytes","()[byte")))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (0 == MID_String_init)
|
||||||
|
{
|
||||||
|
if( 0 == (MID_String_init = pcEnv->GetStaticMethodID(
|
||||||
|
Class_java_lang_String,"String","([byte)V")))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now initialize the thread-local storage
|
||||||
|
if (NULL == this->ptr.get())
|
||||||
|
{
|
||||||
|
// attach to the current thread
|
||||||
|
JavaVM* vm;
|
||||||
|
pcEnv->GetJavaVM(&vm);
|
||||||
|
vm->AttachCurrentThread((void **) &pcEnv, NULL);
|
||||||
|
|
||||||
|
this->ptr.reset(new JNIThreadData(pcEnv));
|
||||||
|
}
|
||||||
|
// increase the reference counter
|
||||||
|
else this->ptr->m_iNumRef++;
|
||||||
|
|
||||||
|
// attach the logger
|
||||||
|
((JNILogDispatcher*)DefaultLogger::get())->OnAttachToCurrentThread(this->ptr.get());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
bool JNIEnvironment::DetachFromCurrentThread ()
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcEnv);
|
||||||
|
|
||||||
|
// detach the logger
|
||||||
|
((JNILogDispatcher*)DefaultLogger::get())->OnDetachFromCurrentThread(this->ptr.get());
|
||||||
|
|
||||||
|
// decrease the reference counter
|
||||||
|
if (NULL != this->ptr.get())
|
||||||
|
{
|
||||||
|
this->ptr->m_iNumRef--;
|
||||||
|
if (0 == this->ptr->m_iNumRef)
|
||||||
|
{
|
||||||
|
JavaVM* vm;
|
||||||
|
this->ptr->m_pcEnv->GetJavaVM(&vm);
|
||||||
|
vm->DetachCurrentThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
JNIThreadData* JNIEnvironment::GetThread()
|
||||||
|
{
|
||||||
|
ai_assert(NULL != this->ptr.get());
|
||||||
|
return this->ptr.get();
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
jstring JNU_NewStringNative(JNIEnv *env, const char *str)
|
||||||
|
{
|
||||||
|
jstring result;
|
||||||
|
jbyteArray bytes = 0;
|
||||||
|
int len;
|
||||||
|
if (env->EnsureLocalCapacity( 2) < 0)
|
||||||
|
{
|
||||||
|
return NULL; /* out of memory error */
|
||||||
|
}
|
||||||
|
len = strlen(str);
|
||||||
|
bytes = env->NewByteArray(len);
|
||||||
|
if (bytes != NULL)
|
||||||
|
{
|
||||||
|
env->SetByteArrayRegion(bytes, 0, len,
|
||||||
|
(jbyte *)str);
|
||||||
|
result = (jstring)env->NewObject(JNIEnvironment::Class_java_lang_String,
|
||||||
|
JNIEnvironment::MID_String_init, bytes);
|
||||||
|
env->DeleteLocalRef(bytes);
|
||||||
|
return result;
|
||||||
|
} /* else fall through */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
char *JNU_GetStringNativeChars(JNIEnv *env, jstring jstr)
|
||||||
|
{
|
||||||
|
jbyteArray bytes = 0;
|
||||||
|
jthrowable exc;
|
||||||
|
char *result = 0;
|
||||||
|
if (env->EnsureLocalCapacity(2) < 0)
|
||||||
|
{
|
||||||
|
return 0; /* out of memory error */
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes = (jbyteArray)env->CallObjectMethod(jstr,JNIEnvironment::MID_String_getBytes);
|
||||||
|
exc = env->ExceptionOccurred();
|
||||||
|
if (!exc)
|
||||||
|
{
|
||||||
|
jint len = env->GetArrayLength(bytes);
|
||||||
|
result = (char *)malloc(len + 1);
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
env->DeleteLocalRef(bytes);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
env->GetByteArrayRegion(bytes, 0, len,
|
||||||
|
(jbyte *)result);
|
||||||
|
result[len] = 0; /* NULL-terminate */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
env->DeleteLocalRef(exc);
|
||||||
|
}
|
||||||
|
env->DeleteLocalRef(bytes);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
};};
|
||||||
|
|
||||||
|
#endif // ! JNI only
|
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
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.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (!defined AI_JNIENVIRONMENT_H_INCLUDED)
|
||||||
|
#define AI_JNIENVIRONMENT_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <boost/thread/thread.hpp>
|
||||||
|
#include <boost/thread/tss.hpp>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include "../../include/aiAssert.h"
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
namespace JNIBridge {
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** @class JNIThreadData
|
||||||
|
* @brief Manages a list of JNI data structures that are
|
||||||
|
* private to a thread.
|
||||||
|
*/
|
||||||
|
struct JNIThreadData
|
||||||
|
{
|
||||||
|
//! Default constructor
|
||||||
|
JNIThreadData() : m_pcEnv(NULL), m_iNumRef(1) {}
|
||||||
|
|
||||||
|
//! Construction from an existing JNIEnv
|
||||||
|
JNIThreadData(JNIEnv* env) : m_pcEnv(env), m_iNumRef(1) {}
|
||||||
|
|
||||||
|
//! JNI environment, is attached to the thread
|
||||||
|
JNIEnv* m_pcEnv;
|
||||||
|
|
||||||
|
//! Number of Importer instances that have been
|
||||||
|
//! created by this thread
|
||||||
|
unsigned int m_iNumRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** @class JNIEnvironment
|
||||||
|
* @brief Helper class to manage the JNI environment for multithreaded
|
||||||
|
* use of the library.
|
||||||
|
*/
|
||||||
|
class JNIEnvironment
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
JNIEnvironment() : m_iRefCnt(1) {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Create the JNI environment class
|
||||||
|
//! refcnt = 1
|
||||||
|
static JNIEnvironment* Create()
|
||||||
|
{
|
||||||
|
if (NULL == s_pcEnv)
|
||||||
|
{
|
||||||
|
s_pcEnv = new JNIEnvironment();
|
||||||
|
}
|
||||||
|
else s_pcEnv->AddRef();
|
||||||
|
return s_pcEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! static getter for the singleton instance
|
||||||
|
//! doesn't hange the reference counter
|
||||||
|
static JNIEnvironment* Get()
|
||||||
|
{
|
||||||
|
ai_assert(NULL != s_pcEnv);
|
||||||
|
return s_pcEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! COM-style reference counting mechanism
|
||||||
|
unsigned int AddRef()
|
||||||
|
{
|
||||||
|
return ++this->m_iRefCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! COM-style reference counting mechanism
|
||||||
|
unsigned int Release()
|
||||||
|
{
|
||||||
|
unsigned int iNew = --this->m_iRefCnt;
|
||||||
|
if (0 == iNew)delete this;
|
||||||
|
return iNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Attach to the current thread
|
||||||
|
bool AttachToCurrentThread (JNIEnv* pcEnv);
|
||||||
|
|
||||||
|
//! Detach from the current thread
|
||||||
|
bool DetachFromCurrentThread ();
|
||||||
|
|
||||||
|
//! Get the thread local data of the current thread
|
||||||
|
JNIThreadData* GetThread();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Handle to the java.lang.String class
|
||||||
|
static jclass Class_java_lang_String;
|
||||||
|
|
||||||
|
//! Handle to the java.lang.String.getBytes() class
|
||||||
|
static jmethodID MID_String_getBytes;
|
||||||
|
|
||||||
|
//! Handle to the java.lang.String.String(byte[]) c'tor
|
||||||
|
static jmethodID MID_String_init;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! Singleton instance
|
||||||
|
static JNIEnvironment* s_pcEnv;
|
||||||
|
|
||||||
|
//! TLS data
|
||||||
|
boost::thread_specific_ptr<JNIThreadData> ptr;
|
||||||
|
|
||||||
|
//! Reference counter of the whole class
|
||||||
|
unsigned int m_iRefCnt;
|
||||||
|
};
|
||||||
|
|
||||||
|
};};
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** @brief Helper function to create a java.lang.String from
|
||||||
|
* a native char*.
|
||||||
|
*
|
||||||
|
* This function has been taken from
|
||||||
|
* http://java.sun.com/docs/books/jni/html/other.html#26021
|
||||||
|
* I am not sure whether it is really necessary, but I trust the source
|
||||||
|
*/
|
||||||
|
jstring JNU_NewStringNative(JNIEnv *env, const char *str);
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** @brief Helper function to create a char* from
|
||||||
|
* a managed jstring
|
||||||
|
*
|
||||||
|
* This function has been taken from
|
||||||
|
* http://java.sun.com/docs/books/jni/html/other.html#26021
|
||||||
|
* I am not sure whether it is really necessary, but I trust the source
|
||||||
|
*/
|
||||||
|
char* JNU_GetStringNativeChars(JNIEnv *env, jstring jstr);
|
||||||
|
|
||||||
|
#endif //! AI_JNIENVIRONMENT_H_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "../../include/aiPostProcess.h"
|
#include "../../include/aiPostProcess.h"
|
||||||
#include "../../include/assimp.hpp"
|
#include "../../include/assimp.hpp"
|
||||||
|
|
||||||
#include "../DefaultLogger.h"
|
#include "../../include/DefaultLogger.h"
|
||||||
|
|
||||||
|
#include "JNIEnvironment.h"
|
||||||
#include "JNILogger.h"
|
#include "JNILogger.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
@ -65,67 +66,98 @@ namespace JNIBridge {
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void JNILogDispatcher::SetJNIEnvironment(JNIEnv* ptr)
|
bool JNILogDispatcher::OnAttachToCurrentThread(JNIThreadData* pcData)
|
||||||
{
|
{
|
||||||
|
ai_assert(NULL != pcData);
|
||||||
|
//this->AddRef(); - done at another position
|
||||||
|
|
||||||
// there is much error handling code in this function.
|
// there is much error handling code in this function.
|
||||||
// However, it is not impossible that the jAssimp package
|
// However, it is not impossible that the jAssimp package
|
||||||
// loaded by the JVM is incomplete ...
|
// loaded by the JVM is incomplete ...
|
||||||
|
JNIEnv* jvmenv = JNIEnvironment::Get()->GetThread()->m_pcEnv;
|
||||||
jclass java_lang_Exception = this->GetJNIEnv()->FindClass("java.lang.Exception");
|
|
||||||
|
|
||||||
// get a handle to the assimp.DefaultLogger class
|
// get a handle to the assimp.DefaultLogger class
|
||||||
this->m_pcJNIEnv = ptr;
|
if (NULL == this->m_pcClass)
|
||||||
if( NULL == (this->m_pcClass = this->GetJNIEnv()->FindClass("assimp.DefaultLogger")))
|
|
||||||
{
|
{
|
||||||
this->GetJNIEnv()->ThrowNew(java_lang_Exception,
|
if( NULL == (this->m_pcClass = jvmenv->FindClass("assimp.DefaultLogger")))
|
||||||
"Unable to get class handle to assimp.DefaultLogger");
|
{
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// get handles to the logging functions
|
// get handles to the logging functions
|
||||||
if( NULL == (this->m_pcMethodError = this->GetJNIEnv()->GetStaticMethodID(
|
if (NULL == this->m_pcMethodError)
|
||||||
this->m_pcClass,"_NativeCallWriteError","(Ljava/lang/String;)V")))
|
|
||||||
{
|
{
|
||||||
this->GetJNIEnv()->ThrowNew(java_lang_Exception,
|
if( NULL == (this->m_pcMethodError = jvmenv->GetStaticMethodID(
|
||||||
"Unable to get class handle to assimp.DefaultLogger._NativeCallWriteError()");
|
this->m_pcClass,"_NativeCallWriteError","(Ljava/lang/String;)V")))
|
||||||
return;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( NULL == (this->m_pcMethodWarn = this->GetJNIEnv()->GetStaticMethodID(
|
if (NULL == this->m_pcMethodWarn)
|
||||||
this->m_pcClass,"_NativeCallWriteWarn","(Ljava/lang/String;)V")))
|
|
||||||
{
|
{
|
||||||
this->GetJNIEnv()->ThrowNew(java_lang_Exception,
|
if( NULL == (this->m_pcMethodWarn = jvmenv->GetStaticMethodID(
|
||||||
"Unable to get class handle to assimp.DefaultLogger._NativeCallWriteWarn()");
|
this->m_pcClass,"_NativeCallWriteWarn","(Ljava/lang/String;)V")))
|
||||||
return;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( NULL == (this->m_pcMethodInfo = this->GetJNIEnv()->GetStaticMethodID(
|
if (NULL == this->m_pcMethodInfo)
|
||||||
this->m_pcClass,"_NativeCallWriteInfo","(Ljava/lang/String;)V")))
|
|
||||||
{
|
{
|
||||||
this->GetJNIEnv()->ThrowNew(java_lang_Exception,
|
if( NULL == (this->m_pcMethodInfo = jvmenv->GetStaticMethodID(
|
||||||
"Unable to get class handle to assimp.DefaultLogger._NativeCallWriteInfo()");
|
this->m_pcClass,"_NativeCallWriteInfo","(Ljava/lang/String;)V")))
|
||||||
return;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( NULL == (this->m_pcMethodDebug = this->GetJNIEnv()->GetStaticMethodID(
|
if (NULL == this->m_pcMethodDebug)
|
||||||
this->m_pcClass,"_NativeCallWriteDebug","(Ljava/lang/String;)V")))
|
|
||||||
{
|
{
|
||||||
this->GetJNIEnv()->ThrowNew(java_lang_Exception,
|
if( NULL == (this->m_pcMethodDebug = jvmenv->GetStaticMethodID(
|
||||||
"Unable to get class handle to assimp.DefaultLogger._NativeCallWriteDebug()");
|
this->m_pcClass,"_NativeCallWriteDebug","(Ljava/lang/String;)V")))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
bool JNILogDispatcher::OnDetachFromCurrentThread(JNIThreadData* pcData)
|
||||||
|
{
|
||||||
|
ai_assert(NULL != pcData);
|
||||||
|
|
||||||
|
this->Release();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void JNILogDispatcher::debug(const std::string &message)
|
void JNILogDispatcher::debug(const std::string &message)
|
||||||
{
|
{
|
||||||
|
JNIEnv* jvmenv = JNIEnvironment::Get()->GetThread()->m_pcEnv;
|
||||||
|
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
|
||||||
|
jvmenv->CallStaticVoidMethod(this->m_pcClass,this->m_pcMethodDebug,jstr);
|
||||||
|
jvmenv->DeleteLocalRef(jstr);
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void JNILogDispatcher::info(const std::string &message)
|
void JNILogDispatcher::info(const std::string &message)
|
||||||
{
|
{
|
||||||
|
JNIEnv* jvmenv = JNIEnvironment::Get()->GetThread()->m_pcEnv;
|
||||||
|
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
|
||||||
|
jvmenv->CallStaticVoidMethod(this->m_pcClass,this->m_pcMethodInfo,jstr);
|
||||||
|
jvmenv->DeleteLocalRef(jstr);
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void JNILogDispatcher::warn(const std::string &message)
|
void JNILogDispatcher::warn(const std::string &message)
|
||||||
{
|
{
|
||||||
|
JNIEnv* jvmenv = JNIEnvironment::Get()->GetThread()->m_pcEnv;
|
||||||
|
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
|
||||||
|
jvmenv->CallStaticVoidMethod(this->m_pcClass,this->m_pcMethodWarn,jstr);
|
||||||
|
jvmenv->DeleteLocalRef(jstr);
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void JNILogDispatcher::error(const std::string &message)
|
void JNILogDispatcher::error(const std::string &message)
|
||||||
{
|
{
|
||||||
|
JNIEnv* jvmenv = JNIEnvironment::Get()->GetThread()->m_pcEnv;
|
||||||
|
jstring jstr = JNU_NewStringNative(jvmenv,message.c_str());
|
||||||
|
jvmenv->CallStaticVoidMethod(this->m_pcClass,this->m_pcMethodError,jstr);
|
||||||
|
jvmenv->DeleteLocalRef(jstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#include "../../include/Logger.h"
|
#include "../../include/Logger.h"
|
||||||
|
#include "../../include/DefaultLogger.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
@ -62,7 +63,13 @@ struct LogStreamInfo;
|
||||||
*/
|
*/
|
||||||
class JNILogDispatcher : public Logger
|
class JNILogDispatcher : public Logger
|
||||||
{
|
{
|
||||||
|
friend class JNIEnvironment;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
|
JNILogDispatcher() : m_iRefCnt(1) {}
|
||||||
|
|
||||||
/** @brief Logs a debug message */
|
/** @brief Logs a debug message */
|
||||||
void debug(const std::string &message);
|
void debug(const std::string &message);
|
||||||
|
|
||||||
|
@ -84,22 +91,32 @@ public:
|
||||||
/** @brief Detach a still attached stream from logger */
|
/** @brief Detach a still attached stream from logger */
|
||||||
void detatchStream(LogStream *pStream, unsigned int severity) {}
|
void detatchStream(LogStream *pStream, unsigned int severity) {}
|
||||||
|
|
||||||
//! Setup the JNI environment to use
|
//! COM-style reference counting mechanism
|
||||||
//! (must be attached to the thread)
|
unsigned int AddRef()
|
||||||
//! \param ptr Java environment to be used. != 0
|
|
||||||
void SetJNIEnvironment(JNIEnv* ptr);
|
|
||||||
|
|
||||||
//! Get the current JNI environment
|
|
||||||
inline JNIEnv* GetJNIEnv()
|
|
||||||
{
|
{
|
||||||
ai_assert(NULL != m_pcJNIEnv);
|
return ++this->m_iRefCnt;
|
||||||
return m_pcJNIEnv;
|
}
|
||||||
|
|
||||||
|
//! COM-style reference counting mechanism
|
||||||
|
unsigned int Release()
|
||||||
|
{
|
||||||
|
unsigned int iNew = --this->m_iRefCnt;
|
||||||
|
if (0 == iNew)
|
||||||
|
{
|
||||||
|
delete this;
|
||||||
|
// don't forget to reset the logger to the default implementation
|
||||||
|
DefaultLogger::set(NULL);
|
||||||
|
}
|
||||||
|
return iNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! JNI environment pointer
|
//! Called by JNIEnvironment
|
||||||
JNIEnv* m_pcJNIEnv;
|
bool OnAttachToCurrentThread(JNIThreadData* pcData);
|
||||||
|
bool OnDetachFromCurrentThread(JNIThreadData* pcData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
//! Handle to assimp.DefaultLogger class
|
//! Handle to assimp.DefaultLogger class
|
||||||
jclass m_pcClass;
|
jclass m_pcClass;
|
||||||
|
@ -115,6 +132,9 @@ private:
|
||||||
|
|
||||||
//! Handle to the static assimp.DefaultLogger._NativeCallWriteWarn() method
|
//! Handle to the static assimp.DefaultLogger._NativeCallWriteWarn() method
|
||||||
jmethodID m_pcMethodWarn;
|
jmethodID m_pcMethodWarn;
|
||||||
|
|
||||||
|
//! Reference counter of the logger
|
||||||
|
unsigned int m_iRefCnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
};};
|
};};
|
||||||
|
|
|
@ -41,11 +41,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file Implementation of the post processing step "MakeVerboseFormat"
|
/** @file Implementation of the post processing step "MakeVerboseFormat"
|
||||||
*/
|
*/
|
||||||
#include "MakeVerboseFormat.h"
|
#include "MakeVerboseFormat.h"
|
||||||
#include "DefaultLogger.h"
|
#include "../../include/DefaultLogger.h"
|
||||||
|
|
||||||
#include "../include/aiMesh.h"
|
#include "../../include/aiMesh.h"
|
||||||
#include "../include/aiScene.h"
|
#include "../../include/aiScene.h"
|
||||||
#include "../include/aiAssert.h"
|
#include "../../include/aiAssert.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
|
@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_MAKEVERBOSEFORMAT_H_INC
|
#ifndef AI_MAKEVERBOSEFORMAT_H_INC
|
||||||
#define AI_MAKEVERBOSEFORMAT_H_INC
|
#define AI_MAKEVERBOSEFORMAT_H_INC
|
||||||
|
|
||||||
#include "BaseProcess.h"
|
#include "../BaseProcess.h"
|
||||||
#include "../include/aiMesh.h"
|
#include "../../include/aiMesh.h"
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class MakeVerboseFormatProcess : public BaseProcess
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
/** Constructor to be privately used by Importer, or by applications
|
/** Constructor to be privately used by Importer, or by applications
|
||||||
which know what they are doing if they modify the aiScene object */
|
which know what they are doing if they modify the aiScene object */
|
||||||
MakeVerboseFormatProcess();
|
MakeVerboseFormatProcess();
|
|
@ -61,7 +61,7 @@ public class Animation extends Mappable {
|
||||||
super(parent, index);
|
super(parent, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnMap() throws NativeError {
|
protected void onMap() throws NativeError {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,6 @@ import java.awt.*;
|
||||||
public class CompressedTexture extends Texture {
|
public class CompressedTexture extends Texture {
|
||||||
|
|
||||||
private String m_format = "";
|
private String m_format = "";
|
||||||
private byte[] m_data;
|
|
||||||
private int m_length = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,6 +68,12 @@ public class CompressedTexture extends Texture {
|
||||||
*/
|
*/
|
||||||
public CompressedTexture(Object parent, int index) throws NativeError {
|
public CompressedTexture(Object parent, int index) throws NativeError {
|
||||||
super(parent, index);
|
super(parent, index);
|
||||||
|
|
||||||
|
// need to get the format of the texture via the JNI
|
||||||
|
if ((m_format = this._NativeGetCTextureFormat(((Scene) this.getParent()).
|
||||||
|
getImporter().getContext(), this.getArrayIndex())).equals("")) {
|
||||||
|
throw new NativeError("Unable to get the format of the compressed texture");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,53 +87,89 @@ public class CompressedTexture extends Texture {
|
||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a pointer to the data of the compressed texture
|
||||||
|
* @return Data poiner
|
||||||
|
*/
|
||||||
public byte[] getData() {
|
public byte[] getData() {
|
||||||
return m_data;
|
if (null == data) {
|
||||||
|
try {
|
||||||
|
this.onMap();
|
||||||
|
} catch (NativeError nativeError) {
|
||||||
|
DefaultLogger.get().error(nativeError.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (byte[])data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the height of the texture image
|
* Get the length of the data of the compressed texture
|
||||||
*
|
* @return Data poiner
|
||||||
* @return Height, in pixels
|
|
||||||
*/
|
*/
|
||||||
public int getHeight() {
|
public int getLength() {
|
||||||
DefaultLogger.get()
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the width of the texture image
|
|
||||||
*
|
|
||||||
* @return Width, in pixels
|
|
||||||
*/
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 0 for compressed textures
|
||||||
|
* @return n/a
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 0 for compressed textures
|
||||||
|
* @return n/a
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public 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 Color[] getColorArray() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal helper function to map the native texture data into
|
* Internal helper function to map the native texture data into
|
||||||
* a <code>byte</code> array in the memory of the JVM
|
* a <code>byte</code> array in the memory of the JVM
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void OnMap() throws NativeError {
|
protected void onMap() throws NativeError {
|
||||||
|
|
||||||
// first allocate the output array
|
// first allocate the output array
|
||||||
data = new Color[iNumPixels];
|
data = new byte[this.width];
|
||||||
|
|
||||||
// now allocate a temporary output array
|
// now allocate a temporary output array
|
||||||
byte[] temp = new byte[(iNumPixels) << 2];
|
byte[] temp = new byte[this.width];
|
||||||
|
|
||||||
// and copy the native color data to it
|
// and copy the native color data to it
|
||||||
if (0xffffffff == this._NativeMapColorData(((Scene)this.getParent()).getImporter().getContext(),
|
if (0xffffffff == this._NativeMapColorData(
|
||||||
|
((Scene)this.getParent()).getImporter().getContext(),
|
||||||
this.getArrayIndex(),temp)) {
|
this.getArrayIndex(),temp)) {
|
||||||
throw new NativeError("Unable to map aiTexture into the Java-VM");
|
throw new NativeError("Unable to map compressed aiTexture into the Java-VM");
|
||||||
}
|
}
|
||||||
|
DefaultLogger.get().debug("CompressedTexture.onMap successful");
|
||||||
|
|
||||||
// now convert the temporary representation to a Color array
|
|
||||||
// (data is given in BGRA order, we need RGBA)
|
|
||||||
for (int i = 0, iBase = 0; i < iNumPixels; ++i, iBase += 4) {
|
|
||||||
data[i] = new Color(temp[iBase + 2], temp[iBase + 1], temp[iBase], temp[iBase + 3]);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private native String _NativeGetCTextureFormat(long context, int arrayIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public abstract class Mappable {
|
||||||
* be ready to be used without an underyling native aiScene
|
* be ready to be used without an underyling native aiScene
|
||||||
* @throws NativeError
|
* @throws NativeError
|
||||||
*/
|
*/
|
||||||
protected abstract void OnMap() throws NativeError;
|
protected abstract void onMap() throws NativeError;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class Material extends Mappable {
|
||||||
super(parent, index);
|
super(parent, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnMap() throws NativeError {
|
protected void onMap() throws NativeError {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -713,7 +713,7 @@ public class Mesh extends Mappable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void OnMap() throws NativeError {
|
protected void onMap() throws NativeError {
|
||||||
// map all vertex component arrays into JVM memory
|
// map all vertex component arrays into JVM memory
|
||||||
if (this.hasPositions()) this.mapVertices();
|
if (this.hasPositions()) this.mapVertices();
|
||||||
if (this.hasNormals()) this.mapNormals();
|
if (this.hasNormals()) this.mapNormals();
|
||||||
|
@ -727,7 +727,7 @@ public class Mesh extends Mappable {
|
||||||
for (int i = 0; i < MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
for (int i = 0; i < MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||||
if (this.hasUVCoords(i)) this.mapUVs(i);
|
if (this.hasUVCoords(i)) this.mapUVs(i);
|
||||||
}
|
}
|
||||||
// LOG
|
DefaultLogger.get().debug("Mesh.onMap successful");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -738,7 +738,7 @@ public class Mesh extends Mappable {
|
||||||
this.m_vVertices)) {
|
this.m_vVertices)) {
|
||||||
// this should occur rarely. No need to throw an exception,
|
// this should occur rarely. No need to throw an exception,
|
||||||
// simply write to log and let the array at 0.0f
|
// simply write to log and let the array at 0.0f
|
||||||
// LOG
|
DefaultLogger.get().error("Unable to map vertices into JVM memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ public class Mesh extends Mappable {
|
||||||
this.m_vNormals)) {
|
this.m_vNormals)) {
|
||||||
// this should occur rarely. No need to throw an exception,
|
// this should occur rarely. No need to throw an exception,
|
||||||
// simply write to log and let the array at 0.0f
|
// simply write to log and let the array at 0.0f
|
||||||
// LOG
|
DefaultLogger.get().error("Unable to map normals into JVM memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,7 +760,7 @@ public class Mesh extends Mappable {
|
||||||
this.m_vTangents)) {
|
this.m_vTangents)) {
|
||||||
// this should occur rarely. No need to throw an exception,
|
// this should occur rarely. No need to throw an exception,
|
||||||
// simply write to log and let the array at 0.0f
|
// simply write to log and let the array at 0.0f
|
||||||
// LOG
|
DefaultLogger.get().error("Unable to map tangents into JVM memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,7 +771,7 @@ public class Mesh extends Mappable {
|
||||||
this.m_vBitangents)) {
|
this.m_vBitangents)) {
|
||||||
// this should occur rarely. No need to throw an exception,
|
// this should occur rarely. No need to throw an exception,
|
||||||
// simply write to log and let the array at 0.0f
|
// simply write to log and let the array at 0.0f
|
||||||
// LOG
|
DefaultLogger.get().error("Unable to map bitangents into JVM memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,7 +782,7 @@ public class Mesh extends Mappable {
|
||||||
this.m_vFaces)) {
|
this.m_vFaces)) {
|
||||||
// this should occur rarely. No need to throw an exception,
|
// this should occur rarely. No need to throw an exception,
|
||||||
// simply write to log and let the array at 0
|
// simply write to log and let the array at 0
|
||||||
// LOG
|
DefaultLogger.get().error("Unable to map faces into JVM memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +793,7 @@ public class Mesh extends Mappable {
|
||||||
channel, this.m_avUVs[channel])) {
|
channel, this.m_avUVs[channel])) {
|
||||||
// this should occur rarely. No need to throw an exception,
|
// this should occur rarely. No need to throw an exception,
|
||||||
// simply write to log and let the array at 0.0f
|
// simply write to log and let the array at 0.0f
|
||||||
// LOG
|
DefaultLogger.get().error("Unable to map UV coordinate set " + channel + " into JVM memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,7 +804,7 @@ public class Mesh extends Mappable {
|
||||||
channel, this.m_avColors[channel])) {
|
channel, this.m_avColors[channel])) {
|
||||||
// this should occur rarely. No need to throw an exception,
|
// this should occur rarely. No need to throw an exception,
|
||||||
// simply write to log and let the array at 0.0f
|
// simply write to log and let the array at 0.0f
|
||||||
// LOG
|
DefaultLogger.get().error("Unable to map vertex color channel " + channel + " into JVM memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class Texture extends Mappable {
|
||||||
protected int width = 0;
|
protected int width = 0;
|
||||||
protected int height = 0;
|
protected int height = 0;
|
||||||
|
|
||||||
protected Color[] data = null;
|
protected Object data = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction from a given parent object and array index
|
* Construction from a given parent object and array index
|
||||||
|
@ -114,12 +114,12 @@ public class Texture extends Mappable {
|
||||||
// map the color data in memory if required ...
|
// map the color data in memory if required ...
|
||||||
if (null == data) {
|
if (null == data) {
|
||||||
try {
|
try {
|
||||||
this.OnMap();
|
this.onMap();
|
||||||
} catch (NativeError nativeError) {
|
} catch (NativeError nativeError) {
|
||||||
return Color.black;
|
return Color.black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data[y * width + x];
|
return ((Color[])data)[y * width + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,12 +131,12 @@ public class Texture extends Mappable {
|
||||||
// map the color data in memory if required ...
|
// map the color data in memory if required ...
|
||||||
if (null == data) {
|
if (null == data) {
|
||||||
try {
|
try {
|
||||||
this.OnMap();
|
this.onMap();
|
||||||
} catch (NativeError nativeError) {
|
} catch (NativeError nativeError) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return (Color[])data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +144,7 @@ public class Texture extends Mappable {
|
||||||
* a <code>java.awt.Color</code> array
|
* a <code>java.awt.Color</code> array
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void OnMap() throws NativeError {
|
protected void onMap() throws NativeError {
|
||||||
final int iNumPixels = width * height;
|
final int iNumPixels = width * height;
|
||||||
|
|
||||||
// first allocate the output array
|
// first allocate the output array
|
||||||
|
@ -159,10 +159,12 @@ public class Texture extends Mappable {
|
||||||
throw new NativeError("Unable to map aiTexture into the Java-VM");
|
throw new NativeError("Unable to map aiTexture into the Java-VM");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefaultLogger.get().debug("Texture.onMap successful");
|
||||||
|
|
||||||
// now convert the temporary representation to a Color array
|
// now convert the temporary representation to a Color array
|
||||||
// (data is given in BGRA order, we need RGBA)
|
// (data is given in BGRA order, we need RGBA)
|
||||||
for (int i = 0, iBase = 0; i < iNumPixels; ++i, iBase += 4) {
|
for (int i = 0, iBase = 0; i < iNumPixels; ++i, iBase += 4) {
|
||||||
data[i] = new Color(temp[iBase + 2], temp[iBase + 1], temp[iBase], temp[iBase + 3]);
|
((Color[])data)[i] = new Color(temp[iBase + 2], temp[iBase + 1], temp[iBase], temp[iBase + 3]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +179,7 @@ public class Texture extends Mappable {
|
||||||
* @param temp Output array. Assumed to be width * height * 4 in size
|
* @param temp Output array. Assumed to be width * height * 4 in size
|
||||||
* @return 0xffffffff if an error occured
|
* @return 0xffffffff if an error occured
|
||||||
*/
|
*/
|
||||||
private native int _NativeMapColorData(long context, long index, byte[] temp);
|
protected native int _NativeMapColorData(long context, long index, byte[] temp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JNI bridge call. For internal use only
|
* JNI bridge call. For internal use only
|
||||||
|
|
|
@ -47,11 +47,50 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "GenVertexNormalsProcess.h"
|
#include "GenVertexNormalsProcess.h"
|
||||||
#include "JoinVerticesProcess.h"
|
#include "JoinVerticesProcess.h"
|
||||||
#include "CalcTangentsProcess.h"
|
#include "CalcTangentsProcess.h"
|
||||||
#include "MakeVerboseFormat.h"
|
#include "unused/MakeVerboseFormat.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: These classes are necessary since the c'tors of all
|
||||||
|
// postprocess steps are protected. Generally they're not
|
||||||
|
// intended to be used directly by applications.
|
||||||
|
//
|
||||||
|
// However, the viewer is an exception. It does nothing than
|
||||||
|
// displaxing the aiScene, so it wouldn't make sense to copy
|
||||||
|
// the data to another data structure.
|
||||||
|
//
|
||||||
|
class MyGenFaceNormalsProcess : public Assimp::GenFaceNormalsProcess
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyGenFaceNormalsProcess() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MyGenVertexNormalsProcess : public Assimp::GenVertexNormalsProcess
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyGenVertexNormalsProcess() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MyMakeVerboseFormatProcess : public Assimp::MakeVerboseFormatProcess
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyMakeVerboseFormatProcess() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MyCalcTangentsProcess : public Assimp::CalcTangentsProcess
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyCalcTangentsProcess() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MyJoinVerticesProcess : public Assimp::JoinVerticesProcess
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyJoinVerticesProcess() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
bool g_bWasFlipped = false;
|
bool g_bWasFlipped = false;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -83,7 +122,7 @@ void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||||
|
|
||||||
// we need to build an unique set of vertices for this ...
|
// we need to build an unique set of vertices for this ...
|
||||||
{
|
{
|
||||||
Assimp::MakeVerboseFormatProcess* pcProcess = new Assimp::MakeVerboseFormatProcess();
|
MyMakeVerboseFormatProcess* pcProcess = new MyMakeVerboseFormatProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(this->pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
|
@ -104,13 +143,13 @@ void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||||
// now we can start to calculate a new set of normals
|
// now we can start to calculate a new set of normals
|
||||||
if (HARD == iSet)
|
if (HARD == iSet)
|
||||||
{
|
{
|
||||||
Assimp::GenFaceNormalsProcess* pcProcess = new Assimp::GenFaceNormalsProcess();
|
MyGenFaceNormalsProcess* pcProcess = new MyGenFaceNormalsProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(this->pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
else if (SMOOTH == iSet)
|
else if (SMOOTH == iSet)
|
||||||
{
|
{
|
||||||
Assimp::GenVertexNormalsProcess* pcProcess = new Assimp::GenVertexNormalsProcess();
|
MyGenVertexNormalsProcess* pcProcess = new MyGenVertexNormalsProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(this->pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
|
@ -128,12 +167,12 @@ void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
// recalculate tangents and bitangents
|
// recalculate tangents and bitangents
|
||||||
Assimp::BaseProcess* pcProcess = new Assimp::CalcTangentsProcess();
|
Assimp::BaseProcess* pcProcess = new MyCalcTangentsProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(this->pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
// join the mesh vertices again
|
// join the mesh vertices again
|
||||||
pcProcess = new Assimp::JoinVerticesProcess();
|
pcProcess = new MyJoinVerticesProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(this->pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
|
|
|
@ -584,10 +584,6 @@
|
||||||
RelativePath="..\..\code\KillNormalsProcess.h"
|
RelativePath="..\..\code\KillNormalsProcess.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\code\MakeVerboseFormat.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\code\MaterialSystem.h"
|
RelativePath="..\..\code\MaterialSystem.h"
|
||||||
>
|
>
|
||||||
|
@ -795,11 +791,23 @@
|
||||||
RelativePath="..\..\code\jAssimp\assimp_Texture.h"
|
RelativePath="..\..\code\jAssimp\assimp_Texture.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\code\jAssimp\JNIEnvironment.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\code\jAssimp\JNILogger.h"
|
RelativePath="..\..\code\jAssimp\JNILogger.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="extra"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\code\unused\MakeVerboseFormat.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="sources"
|
Name="sources"
|
||||||
|
@ -852,10 +860,6 @@
|
||||||
RelativePath="..\..\code\KillNormalsProcess.cpp"
|
RelativePath="..\..\code\KillNormalsProcess.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\code\MakeVerboseFormat.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\code\MaterialSystem.cpp"
|
RelativePath="..\..\code\MaterialSystem.cpp"
|
||||||
>
|
>
|
||||||
|
@ -991,11 +995,23 @@
|
||||||
RelativePath="..\..\code\jAssimp\JNICalls.cpp"
|
RelativePath="..\..\code\jAssimp\JNICalls.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\code\jAssimp\JNIEnvironment.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\code\jAssimp\JNILogger.cpp"
|
RelativePath="..\..\code\jAssimp\JNILogger.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="extra"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\code\unused\MakeVerboseFormat.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="doc"
|
Name="doc"
|
||||||
|
|
Loading…
Reference in New Issue