Merge branch 'master' of github.com:assimp/assimp

pull/145/merge
acgessler 2013-10-03 17:10:38 +02:00
commit 45178dc3af
2 changed files with 62 additions and 39 deletions

View File

@ -958,19 +958,41 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co
}
// ------------------------------------------------------------------------------------------------
aiCamera* BlenderImporter::ConvertCamera(const Scene& /*in*/, const Object* /*obj*/, const Camera* /*mesh*/, ConversionData& /*conv_data*/)
aiCamera* BlenderImporter::ConvertCamera(const Scene& /*in*/, const Object* obj, const Camera* camera, ConversionData& /*conv_data*/)
{
ScopeGuard<aiCamera> out(new aiCamera());
return NULL ; //out.dismiss();
out->mName = obj->id.name+2;
out->mPosition = aiVector3D(0.f, 0.f, 0.f);
out->mUp = aiVector3D(0.f, 1.f, 0.f);
out->mLookAt = aiVector3D(0.f, 0.f, -1.f);
return out.dismiss();
}
// ------------------------------------------------------------------------------------------------
aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* /*obj*/, const Lamp* /*mesh*/, ConversionData& /*conv_data*/)
aiLight* BlenderImporter::ConvertLight(const Scene& in, const Object* obj, const Lamp* lamp, ConversionData& conv_data)
{
ScopeGuard<aiLight> out(new aiLight());
out->mName = obj->id.name+2;
return NULL ; //out.dismiss();
switch (lamp->type)
{
case Lamp::Type_Local:
out->mType = aiLightSource_POINT;
break;
case Lamp::Type_Sun:
out->mType = aiLightSource_DIRECTIONAL;
// blender orients directional lights as facing toward -z
out->mDirection = aiVector3D(0.f, 0.f, -1.f);
break;
default:
break;
}
out->mColorAmbient = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
out->mColorSpecular = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
out->mColorDiffuse = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
return out.dismiss();
}
// ------------------------------------------------------------------------------------------------

View File

@ -36,9 +36,8 @@
#include "assimp/LogStream.hpp"
// currently these are hardcoded
static const std::string basepath = "../../test/models/OBJ/";
static const std::string modelname = "spider.obj";
// The default hardcoded path. Can be overridden by supplying a path through the commandline.
static std::string modelpath = "../../test/models/OBJ/spider.obj";
HGLRC hRC=NULL; // Permanent Rendering Context
@ -165,6 +164,11 @@ void ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
}
std::string getBasePath(const std::string& path)
{
size_t pos = path.find_last_of("\\/");
return (std::string::npos == pos) ? "" : path.substr(0, pos + 1);
}
int LoadGLTextures(const aiScene* scene)
{
@ -220,6 +224,7 @@ int LoadGLTextures(const aiScene* scene)
/* get iterator */
std::map<std::string, GLuint*>::iterator itr = textureIdMap.begin();
std::string basepath = getBasePath(modelpath);
for (int i=0; i<numTextures; i++)
{
@ -799,52 +804,52 @@ LRESULT CALLBACK WndProc(HWND hWnd, // Handles for this Window
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int WINAPI WinMain( HINSTANCE hInstance, // Instance
HINSTANCE hPrevInstance, // Previous Instance
LPSTR lpCmdLine, // Command Line Parameters
int nShowCmd ) // Window Show State
{
MSG msg; // Windows Message Structure
BOOL done=FALSE; // Bool Variable To Exit Loop
MSG msg;
BOOL done=FALSE;
createAILogger();
logInfo("App fired!");
// load scene
// Check the command line for an override file path.
int argc;
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argv != NULL && argc > 1)
{
std::wstring modelpathW(argv[1]);
modelpath = std::string(modelpathW.begin(), modelpathW.end());
}
if (!Import3DFromFile(basepath+modelname)) return 0;
if (!Import3DFromFile(modelpath)) return 0;
logInfo("=============== Post Import ====================");
// Ask The User Which Screen Mode They Prefer
if (MessageBox(NULL, "Would You Like To Run In Fullscreen Mode?", "Start Fullscreen?", MB_YESNO|MB_ICONEXCLAMATION)==IDNO)
{
fullscreen=FALSE; // Windowed Mode
fullscreen=FALSE;
}
// Create Our OpenGL Window (also calls GLinit und LoadGLTextures)
if (!CreateGLWindow(windowTitle, 640, 480, 16, fullscreen))
{
return 0;
}
while(!done) // Game Loop
{
if (PeekMessage(&msg, NULL, 0,0, PM_REMOVE)) // Is There A Message Waiting
if (PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
{
if (msg.message==WM_QUIT) // Have we received A Quit Message?
if (msg.message==WM_QUIT)
{
done=TRUE; // If So done=TRUE
done=TRUE;
}
else
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
@ -852,26 +857,25 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
// Draw The Scene. Watch For ESC Key And Quit Messaged From DrawGLScene()
if (active)
{
if (keys[VK_ESCAPE]) // Was ESC pressed?
if (keys[VK_ESCAPE])
{
done=TRUE; // ESC signalled A quit
done=TRUE;
}
else
{
DrawGLScene(); // Draw The Scene
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
DrawGLScene();
SwapBuffers(hDC);
}
}
if (keys[VK_F1]) // Is F1 Being Pressed?
if (keys[VK_F1])
{
keys[VK_F1]=FALSE; // If so make Key FALSE
KillGLWindow(); // Kill Our Current Window
fullscreen=!fullscreen; // Toggle Fullscreen
//recreate Our OpenGL Window
keys[VK_F1]=FALSE;
KillGLWindow();
fullscreen=!fullscreen;
if (!CreateGLWindow(windowTitle, 640, 480, 16, fullscreen))
{
return 0; // Quit if Window Was Not Created
return 0;
}
}
}
@ -879,10 +883,8 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
// *** cleanup ***
// clear map
textureIdMap.clear(); //no need to delete pointers in it manually here. (Pointers point to textureIds deleted in next step)
// clear texture ids
if (textureIds)
{
delete[] textureIds;
@ -891,8 +893,7 @@ int WINAPI WinMain( HINSTANCE hInstance, // Instance
// *** cleanup end ***
// Shutdown
destroyAILogger();
KillGLWindow();
return (msg.wParam); // Exit The Program
return (msg.wParam);
}