Creating object model to store lights returned by FBX import in preparation of deferred rendering.

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4029
This commit is contained in:
kearwood
2012-04-05 23:09:41 +00:00
parent 384068eb9c
commit 33c5b754de
14 changed files with 399 additions and 253 deletions

View File

@@ -13,6 +13,27 @@
E414BAE91435585A00A668C4 /* KRScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E414BAE81435585A00A668C4 /* KRScene.cpp */; };
E414BAEB14355E5500A668C4 /* KRBoundingVolume.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAEA14355E5500A668C4 /* KRBoundingVolume.h */; };
E414BAED14355EFF00A668C4 /* KRBoundingVolume.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */; };
E461A152152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; };
E461A153152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
E461A156152E54F800F2044A /* KRLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A155152E54F700F2044A /* KRLight.cpp */; };
E461A159152E557E00F2044A /* KRPointLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A158152E557E00F2044A /* KRPointLight.cpp */; };
E461A15A152E557E00F2044A /* KRPointLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A158152E557E00F2044A /* KRPointLight.cpp */; };
E461A15C152E563100F2044A /* KRDirectionalLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A15B152E563000F2044A /* KRDirectionalLight.h */; };
E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A15B152E563000F2044A /* KRDirectionalLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
E461A15F152E565700F2044A /* KRDirectionalLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A15E152E565700F2044A /* KRDirectionalLight.cpp */; };
E461A160152E565700F2044A /* KRDirectionalLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A15E152E565700F2044A /* KRDirectionalLight.cpp */; };
E461A165152E56C000F2044A /* KRSpotLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A164152E56C000F2044A /* KRSpotLight.cpp */; };
E461A166152E56C000F2044A /* KRSpotLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A164152E56C000F2044A /* KRSpotLight.cpp */; };
E461A168152E570700F2044A /* KRSpotLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A167152E570500F2044A /* KRSpotLight.h */; };
E461A169152E570700F2044A /* KRSpotLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A167152E570500F2044A /* KRSpotLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
E461A16B152E575800F2044A /* KRLightManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A16A152E575700F2044A /* KRLightManager.h */; };
E461A16C152E575800F2044A /* KRLightManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A16A152E575700F2044A /* KRLightManager.h */; };
E461A16E152E576700F2044A /* KRLightManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A16D152E576700F2044A /* KRLightManager.cpp */; };
E461A16F152E576700F2044A /* KRLightManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A16D152E576700F2044A /* KRLightManager.cpp */; };
E461A175152E5C4800F2044A /* KRLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A155152E54F700F2044A /* KRLight.cpp */; };
E461A176152E5C5600F2044A /* KRPointLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A157152E555400F2044A /* KRPointLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
E461A177152E5C6600F2044A /* KRMat4.h in Headers */ = {isa = PBXBuildFile; fileRef = E491017613C99BDC0098455B /* KRMat4.h */; settings = {ATTRIBUTES = (Public, ); }; };
E461A17A152E5C9100F2044A /* KRMat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017713C99BDC0098455B /* KRMat4.cpp */; };
E46DBE7B1512ACE600D59F86 /* KRMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49E79FE1512615F009CF99C /* KRMesh.cpp */; };
E46DBE7F1512AF0200D59F86 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E46DBE7D1512AD4900D59F86 /* OpenGL.framework */; };
E46DBE801512AF4600D59F86 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E491016413C99B9E0098455B /* Foundation.framework */; };
@@ -94,6 +115,16 @@
E45772F413C9A13C0037BEEA /* ObjectShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = ObjectShader.fsh; path = Shaders/ObjectShader.fsh; sourceTree = "<group>"; };
E45772F513C9A13C0037BEEA /* ObjectShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; lineEnding = 0; name = ObjectShader.vsh; path = Shaders/ObjectShader.vsh; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.glsl; };
E45772F613C9A13C0037BEEA /* PostShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = PostShader.vsh; path = Shaders/PostShader.vsh; sourceTree = "<group>"; };
E461A151152E54B500F2044A /* KRLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRLight.h; path = Classes/KRLight.h; sourceTree = "<group>"; };
E461A155152E54F700F2044A /* KRLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRLight.cpp; path = Classes/KRLight.cpp; sourceTree = "<group>"; };
E461A157152E555400F2044A /* KRPointLight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KRPointLight.h; path = Classes/KRPointLight.h; sourceTree = "<group>"; };
E461A158152E557E00F2044A /* KRPointLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRPointLight.cpp; path = Classes/KRPointLight.cpp; sourceTree = "<group>"; };
E461A15B152E563000F2044A /* KRDirectionalLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRDirectionalLight.h; path = Classes/KRDirectionalLight.h; sourceTree = "<group>"; };
E461A15E152E565700F2044A /* KRDirectionalLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRDirectionalLight.cpp; path = Classes/KRDirectionalLight.cpp; sourceTree = "<group>"; };
E461A164152E56C000F2044A /* KRSpotLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRSpotLight.cpp; path = Classes/KRSpotLight.cpp; sourceTree = "<group>"; };
E461A167152E570500F2044A /* KRSpotLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRSpotLight.h; path = Classes/KRSpotLight.h; sourceTree = "<group>"; };
E461A16A152E575700F2044A /* KRLightManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRLightManager.h; path = Classes/KRLightManager.h; sourceTree = "<group>"; };
E461A16D152E576700F2044A /* KRLightManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRLightManager.cpp; path = Classes/KRLightManager.cpp; sourceTree = "<group>"; };
E46DBE7D1512AD4900D59F86 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/OpenGL.framework; sourceTree = DEVELOPER_DIR; };
E46DBE841512B9E200D59F86 /* KREngine-common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "KREngine-common.h"; path = "Classes/KREngine-common.h"; sourceTree = "<group>"; };
E47C25A113F4F65A00FF4370 /* KRShaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRShaderManager.h; path = Classes/KRShaderManager.h; sourceTree = "<group>"; };
@@ -188,6 +219,68 @@
name = Shaders;
sourceTree = "<group>";
};
E461A170152E598200F2044A /* Resources */ = {
isa = PBXGroup;
children = (
E461A174152E5A1300F2044A /* Models */,
E461A172152E59BC00F2044A /* Materials */,
E461A171152E599E00F2044A /* Lights */,
E497B949151BCEE900D3DC67 /* KRResource.h */,
E497B94C151BCF2500D3DC67 /* KRResource.cpp */,
E497B94F151BD2CE00D3DC67 /* KRResource+obj.cpp */,
E497B952151BEDA600D3DC67 /* KRResource+fbx.cpp */,
);
name = Resources;
sourceTree = "<group>";
};
E461A171152E599E00F2044A /* Lights */ = {
isa = PBXGroup;
children = (
E461A151152E54B500F2044A /* KRLight.h */,
E461A155152E54F700F2044A /* KRLight.cpp */,
E461A157152E555400F2044A /* KRPointLight.h */,
E461A158152E557E00F2044A /* KRPointLight.cpp */,
E461A15B152E563000F2044A /* KRDirectionalLight.h */,
E461A15E152E565700F2044A /* KRDirectionalLight.cpp */,
E461A167152E570500F2044A /* KRSpotLight.h */,
E461A164152E56C000F2044A /* KRSpotLight.cpp */,
);
name = Lights;
sourceTree = "<group>";
};
E461A172152E59BC00F2044A /* Materials */ = {
isa = PBXGroup;
children = (
E491017C13C99BDC0098455B /* KRMaterial.cpp */,
E491017D13C99BDC0098455B /* KRMaterial.h */,
);
name = Materials;
sourceTree = "<group>";
};
E461A173152E59DF00F2044A /* Math */ = {
isa = PBXGroup;
children = (
E414BAEA14355E5500A668C4 /* KRBoundingVolume.h */,
E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */,
E491017613C99BDC0098455B /* KRMat4.h */,
E491017713C99BDC0098455B /* KRMat4.cpp */,
E491017E13C99BDC0098455B /* KRVector3.h */,
E491017F13C99BDC0098455B /* KRVector3.cpp */,
E497B943151BA93400D3DC67 /* KRVector2.h */,
E497B945151BA99400D3DC67 /* KRVector2.cpp */,
);
name = Math;
sourceTree = "<group>";
};
E461A174152E5A1300F2044A /* Models */ = {
isa = PBXGroup;
children = (
E49E79FC15126146009CF99C /* KRMesh.h */,
E49E79FE1512615F009CF99C /* KRMesh.cpp */,
);
name = Models;
sourceTree = "<group>";
};
E491015613C99B9D0098455B = {
isa = PBXGroup;
children = (
@@ -238,17 +331,13 @@
E491016E13C99BAE0098455B /* Classes */ = {
isa = PBXGroup;
children = (
E461A173152E59DF00F2044A /* Math */,
E461A170152E598200F2044A /* Resources */,
E491016F13C99BDC0098455B /* KREngine.mm */,
E491017213C99BDC0098455B /* KREngine.h */,
E491017613C99BDC0098455B /* KRMat4.h */,
E491017713C99BDC0098455B /* KRMat4.cpp */,
E491017913C99BDC0098455B /* KRModel.cpp */,
E491017A13C99BDC0098455B /* KRModel.h */,
E491017B13C99BDC0098455B /* KRMaterialManager.cpp */,
E491017C13C99BDC0098455B /* KRMaterial.cpp */,
E491017D13C99BDC0098455B /* KRMaterial.h */,
E491017E13C99BDC0098455B /* KRVector3.h */,
E491017F13C99BDC0098455B /* KRVector3.cpp */,
E491018013C99BDC0098455B /* KRTextureManager.cpp */,
E491018113C99BDC0098455B /* KRTexture.cpp */,
E491018213C99BDC0098455B /* KRModelManager.cpp */,
@@ -264,19 +353,11 @@
E414BAE41435558800A668C4 /* KRInstance.cpp */,
E414BAE6143557D200A668C4 /* KRScene.h */,
E414BAE81435585A00A668C4 /* KRScene.cpp */,
E414BAEA14355E5500A668C4 /* KRBoundingVolume.h */,
E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */,
E48B3CBC14393DF5000C50E2 /* KRCamera.h */,
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */,
E49E79FC15126146009CF99C /* KRMesh.h */,
E49E79FE1512615F009CF99C /* KRMesh.cpp */,
E46DBE841512B9E200D59F86 /* KREngine-common.h */,
E497B943151BA93400D3DC67 /* KRVector2.h */,
E497B945151BA99400D3DC67 /* KRVector2.cpp */,
E497B949151BCEE900D3DC67 /* KRResource.h */,
E497B94C151BCF2500D3DC67 /* KRResource.cpp */,
E497B94F151BD2CE00D3DC67 /* KRResource+obj.cpp */,
E497B952151BEDA600D3DC67 /* KRResource+fbx.cpp */,
E461A16A152E575700F2044A /* KRLightManager.h */,
E461A16D152E576700F2044A /* KRLightManager.cpp */,
);
name = Classes;
sourceTree = "<group>";
@@ -339,6 +420,10 @@
E414BAEB14355E5500A668C4 /* KRBoundingVolume.h in Headers */,
E48B3CBD14393DF5000C50E2 /* KRCamera.h in Headers */,
E497B94A151BCEE900D3DC67 /* KRResource.h in Headers */,
E461A152152E54B500F2044A /* KRLight.h in Headers */,
E461A15C152E563100F2044A /* KRDirectionalLight.h in Headers */,
E461A168152E570700F2044A /* KRSpotLight.h in Headers */,
E461A16B152E575800F2044A /* KRLightManager.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -348,10 +433,16 @@
files = (
E497B948151BB89D00D3DC67 /* KRVector2.h in Headers */,
E4D0683F1512A790005FFBEB /* KRVector3.h in Headers */,
E461A177152E5C6600F2044A /* KRMat4.h in Headers */,
E497B94B151BCEE900D3DC67 /* KRResource.h in Headers */,
E4B2A4391523B027004CB0EC /* KRMaterial.h in Headers */,
E46DBE811512AFE600D59F86 /* KRMesh.h in Headers */,
E46DBE851512B9FA00D59F86 /* KREngine-common.h in Headers */,
E461A153152E54B500F2044A /* KRLight.h in Headers */,
E461A176152E5C5600F2044A /* KRPointLight.h in Headers */,
E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */,
E461A169152E570700F2044A /* KRSpotLight.h in Headers */,
E461A16C152E575800F2044A /* KRLightManager.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -456,6 +547,11 @@
E497B946151BA99500D3DC67 /* KRVector2.cpp in Sources */,
E497B94D151BCF2500D3DC67 /* KRResource.cpp in Sources */,
E497B950151BD2CE00D3DC67 /* KRResource+obj.cpp in Sources */,
E461A156152E54F800F2044A /* KRLight.cpp in Sources */,
E461A159152E557E00F2044A /* KRPointLight.cpp in Sources */,
E461A15F152E565700F2044A /* KRDirectionalLight.cpp in Sources */,
E461A165152E56C000F2044A /* KRSpotLight.cpp in Sources */,
E461A16E152E576700F2044A /* KRLightManager.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -463,6 +559,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E461A17A152E5C9100F2044A /* KRMat4.cpp in Sources */,
E461A175152E5C4800F2044A /* KRLight.cpp in Sources */,
E46DBE7B1512ACE600D59F86 /* KRMesh.cpp in Sources */,
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */,
E4B2A43B1523B02E004CB0EC /* KRMaterial.cpp in Sources */,
@@ -471,6 +569,10 @@
E497B94E151BCF2500D3DC67 /* KRResource.cpp in Sources */,
E497B951151BD2CE00D3DC67 /* KRResource+obj.cpp in Sources */,
E497B954151BEDA600D3DC67 /* KRResource+fbx.cpp in Sources */,
E461A15A152E557E00F2044A /* KRPointLight.cpp in Sources */,
E461A160152E565700F2044A /* KRDirectionalLight.cpp in Sources */,
E461A166152E56C000F2044A /* KRSpotLight.cpp in Sources */,
E461A16F152E576700F2044A /* KRLightManager.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -0,0 +1,26 @@
//
// KRDirectionalLight.cpp
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#include <iostream>
#import "KRDirectionalLight.h"
KRDirectionalLight::KRDirectionalLight(std::string name) : KRLight(name)
{
}
KRDirectionalLight::~KRDirectionalLight()
{
}
bool KRDirectionalLight::save(const std::string& path)
{
return true;
}

View File

@@ -0,0 +1,24 @@
//
// KRDirectionalLight.h
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#ifndef KREngine_KRDirectionalLight_h
#define KREngine_KRDirectionalLight_h
#import "KRLight.h"
class KRDirectionalLight : public KRLight {
public:
KRDirectionalLight(std::string name);
~KRDirectionalLight();
virtual bool save(const std::string& path);
};
#endif

View File

@@ -39,6 +39,7 @@
#import "KRMaterialManager.h"
#import "KRShaderManager.h"
#import "KRModelManager.h"
#import "KRLightManager.h"
#import "KRCamera.h"
#import "KREngine-common.h"
@@ -84,6 +85,7 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F
KRMaterialManager *m_pMaterialManager;
KRShaderManager *m_pShaderManager;
KRModelManager *m_pModelManager;
KRLightManager *m_pLightManager;
int m_iFrame;

View File

@@ -82,6 +82,7 @@ double const PI = 3.141592653589793f;
m_pTextureManager = new KRTextureManager();
m_pMaterialManager = new KRMaterialManager(m_pTextureManager, m_pShaderManager);
m_pModelManager = new KRModelManager(m_pMaterialManager);
m_pLightManager = new KRLightManager();
if (![self createBuffers] || ![self loadShaders] /*|| ![self loadObjects]*/ )
{
@@ -548,6 +549,8 @@ double const PI = 3.141592653589793f;
} else if([path hasSuffix: @".mtl"]) {
NSLog(@"material: %@", path);
m_pMaterialManager->loadFile([path UTF8String]);
} else if([path hasSuffix: @".krlight"]) {
m_pLightManager->loadFile([path UTF8String]);
}
return TRUE;
@@ -575,7 +578,10 @@ double const PI = 3.141592653589793f;
m_pShaderManager = NULL;
}
if(m_pLightManager) {
delete m_pLightManager;
m_pLightManager = NULL;
}
[self invalidatePostShader];
[self destroyBuffers];

View File

@@ -0,0 +1,26 @@
//
// KRLight.cpp
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#include <iostream>
#import "KRLight.h"
KRLight::KRLight(std::string name) : KRResource(name)
{
}
KRLight::~KRLight()
{
}
std::string KRLight::getExtension()
{
return "krlight";
}

View File

@@ -0,0 +1,24 @@
//
// KRLight.h
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#ifndef KREngine_KRLight_h
#define KREngine_KRLight_h
#import "KRResource.h"
class KRLight : public KRResource {
public:
~KRLight();
virtual std::string getExtension();
virtual bool save(const std::string& path) = 0;
protected:
KRLight(std::string name);
};
#endif

View File

@@ -0,0 +1,26 @@
//
// KRLightManager.cpp
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#include <iostream>
#include "KRLightManager.h"
KRLightManager::KRLightManager()
{
}
KRLightManager::~KRLightManager()
{
}
bool KRLightManager::loadFile(const char *szPath)
{
return true;
}

View File

@@ -0,0 +1,20 @@
//
// KRLightManager.h
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#ifndef KREngine_KRLightManager_h
#define KREngine_KRLightManager_h
class KRLightManager {
public:
KRLightManager();
~KRLightManager();
bool loadFile(const char *szPath);
};
#endif

View File

@@ -0,0 +1,26 @@
//
// KRPointLight.cpp
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#include <iostream>
#import "KRPointLight.h"
KRPointLight::KRPointLight(std::string name) : KRLight(name)
{
}
KRPointLight::~KRPointLight()
{
}
bool KRPointLight::save(const std::string& path)
{
return true;
}

View File

@@ -0,0 +1,23 @@
//
// KRPointLight.h
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#ifndef KREngine_KRPointLight_h
#define KREngine_KRPointLight_h
#import "KRLight.h"
class KRPointLight : public KRLight {
public:
KRPointLight(std::string name);
~KRPointLight();
virtual bool save(const std::string& path);
};
#endif

View File

@@ -24,6 +24,10 @@
#include "KRResource.h"
#include "KRMesh.h"
#include "KRMaterial.h"
#include "KRLight.h"
#include "KRPointLight.h"
#include "KRDirectionalLight.h"
#include "KRSpotLight.h"
#ifdef IOS_REF
#undef IOS_REF
@@ -35,6 +39,7 @@ void DestroySdkObjects(KFbxSdkManager* pSdkManager);
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename);
void LoadNode(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
void LoadLight(std::vector<KRResource *> &resources, KFbxNode* pNode);
std::vector<KRResource *> KRResource::LoadFbx(const std::string& path)
@@ -72,21 +77,6 @@ std::vector<KRResource *> KRResource::LoadFbx(const std::string& path)
DestroySdkObjects(lSdkManager);
/*
KRMesh *new_mesh = new KRMesh(KRResource::GetFileBase(path));
std::vector<KRVector3> vertices;
std::vector<KRVector2> uva;
std::vector<KRVector3> normals;
std::vector<KRVector3> tangents;
std::vector<int> submesh_lengths;
std::vector<int> submesh_starts;
std::vector<std::string> material_names;
new_mesh->LoadData(vertices, uva, normals, tangents, submesh_starts, submesh_lengths, material_names);
resources.push_back(new_mesh);
*/
return resources;
}
@@ -259,6 +249,9 @@ void LoadNode(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
case KFbxNodeAttribute::eMESH:
LoadMesh(resources, pGeometryConverter, pNode);
break;
case KFbxNodeAttribute::eLIGHT:
LoadLight(resources, pNode);
break;
}
@@ -336,156 +329,6 @@ void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
// ----====---- Read UVs ----====----
// for (int l = 0; l < uv_count; ++l)
// {
// KFbxVector2 uv;
// KFbxGeometryElementUV* leUV = pMesh->GetElementUV(l);
//
// switch (leUV->GetMappingMode()) {
// case KFbxGeometryElement::eBY_CONTROL_POINT:
// switch (leUV->GetReferenceMode()) {
// case KFbxGeometryElement::eDIRECT:
// uv = leUV->GetDirectArray().GetAt(lControlPointIndex);
// break;
// case KFbxGeometryElement::eINDEX_TO_DIRECT:
// {
// int id = leUV->GetIndexArray().GetAt(lControlPointIndex);
// uv = leUV->GetDirectArray().GetAt(id);
// }
// break;
// default:
// break; // other reference modes not shown here!
// }
// break;
//
// case KFbxGeometryElement::eBY_POLYGON_VERTEX:
// switch (leUV->GetReferenceMode()) {
// case KFbxGeometryElement::eDIRECT:
// uv = leUV->GetDirectArray().GetAt(source_vertex_id);
// break;
// case KFbxGeometryElement::eINDEX_TO_DIRECT:
// {
// int id = leUV->GetIndexArray().GetAt(source_vertex_id);
// uv = leUV->GetDirectArray().GetAt(id);
// }
// break;
// default:
// break; // other reference modes not shown here!
// }
// break;
//
//
//// case KFbxGeometryElement::eBY_POLYGON_VERTEX:
//// {
//// int lTextureUVIndex = pMesh->GetTextureUVIndex(iPolygon, iVertex);
//// switch (leUV->GetReferenceMode())
//// {
//// case KFbxGeometryElement::eDIRECT:
//// case KFbxGeometryElement::eINDEX_TO_DIRECT:
//// {
//// uv = leUV->GetDirectArray().GetAt(lTextureUVIndex);
//// }
//// break;
//// default:
//// break; // other reference modes not shown here!
//// }
//// }
//// break;
////
//
// case KFbxGeometryElement::eBY_POLYGON: // doesn't make much sense for UVs
// case KFbxGeometryElement::eALL_SAME: // doesn't make much sense for UVs
// case KFbxGeometryElement::eNONE: // doesn't make much sense for UVs
// break;
// }
//
//
//
//
//
// if(l == 0) {
// new_uva = KRVector2(uv[0], uv[1]);
// // uva.push_back(KRVector2(uv[0], uv[1]));
// } else if(l == 1) {
// new_uvb = KRVector2(uv[0], uv[1]);
// // uvb.push_back(KRVector2(uv[0], uv[1]));
// }
// }
//
// if(uv_count > 0) {
// uva.push_back(new_uva);
// }
// if(uv_count > 1) {
// uvb.push_back(new_uvb);
// }
// KFbxLayerElementArrayTemplate<KFbxVector2>* lUVArray = NULL;
// pMesh->GetTextureUV(&lUVArray, KFbxLayerElement::eDIFFUSE_TEXTURES);
//
// int lCurrentUVIndex = pMesh->GetTextureUVIndex(iPolygon, iVertex, KFbxLayerElement::eDIFFUSE_TEXTURES);
//
// KFbxVector2 uv = lUVArray->GetAt(lCurrentUVIndex);
// new_uva = KRVector2(uv[0], uv[1]);
// if(pMesh->GetLayerCount() >= 1) {
// KFbxLayerElementUV* uvs = pMesh->GetLayer(0)->GetUVs();
// KFbxVector2 uv;
// int index = 0;
// switch (uvs->GetMappingMode())
// {
// case KFbxLayerElement::eBY_CONTROL_POINT:
// index = pMesh->GetPolygonVertex(iPolygon, iVertex);
// break;
// case KFbxLayerElement::eBY_POLYGON_VERTEX:
// index = source_vertex_id;
// break;
// case KFbxLayerElement::eBY_POLYGON:
// index = iPolygon;
// break;
// }
//
// if (uvs->GetReferenceMode() != KFbxLayerElement::eDIRECT)
// {
// index = uvs->GetIndexArray().GetAt(index);
// }
//
//
// uv = uvs->GetDirectArray().GetAt(index);
//
// new_uva = KRVector2(uv[0], uv[1]);
// }
//
// if(pMesh->GetLayerCount() >= 2) {
// KFbxLayerElementUV* uvs = pMesh->GetLayer(1)->GetUVs();
// KFbxVector2 uv;
// int index = 0;
// switch (uvs->GetMappingMode())
// {
// case KFbxLayerElement::eBY_CONTROL_POINT:
// index = pMesh->GetPolygonVertex(iPolygon, iVertex);
// break;
// case KFbxLayerElement::eBY_POLYGON_VERTEX:
// index = source_vertex_id;
// break;
// case KFbxLayerElement::eBY_POLYGON:
// index = iPolygon;
// break;
// }
//
// if (uvs->GetReferenceMode() != KFbxLayerElement::eDIRECT)
// {
// index = uvs->GetIndexArray().GetAt(index);
// }
//
//
// uv = uvs->GetDirectArray().GetAt(index);
//
// new_uva = KRVector2(uv[0], uv[1]);
// }
KStringList uvNames;
pMesh->GetUVSetNames(uvNames);
@@ -495,6 +338,7 @@ void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
if(pMesh->GetPolygonVertexUV(iPolygon, iVertex, setName, uv)) {
new_uva = KRVector2(uv[0], uv[1]);
}
uva.push_back(new_uva);
}
if(uv_count >= 2) {
@@ -503,78 +347,8 @@ void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
if(pMesh->GetPolygonVertexUV(iPolygon, iVertex, setName, uv)) {
new_uvb = KRVector2(uv[0], uv[1]);
}
}
/*
for (int iLayer = 0; iLayer < pMesh->GetLayerCount(); iLayer++)
{
KFbxLayerElementUV* uvs = pMesh->GetLayer(iLayer)->GetUVs();
KFbxVector2 uv;
if (uvs == NULL) continue;
switch (uvs->GetMappingMode())
{
case KFbxLayerElement::eBY_CONTROL_POINT:
//uvs_index_vector[iLayer] = cpIndex; break;
switch (uvs->GetReferenceMode())
{
case KFbxLayerElement::eDIRECT:
uv = uvs->GetDirectArray().GetAt(cpIndex));
break;
case KFbxLayerElement::eINDEX_TO_DIRECT:
{
int id = uvs->GetIndexArray().GetAt(cpIndex);
uv = uvs->GetDirectArray().GetAt(id));
}
break;
default:
break; // other reference modes not shown here!
}
break;
case KFbxLayerElement::eBY_POLYGON_VERTEX: //BUG: This wont work in some FBXs, so we will skip the uvs
{
//int id = fbxmesh->GetTextureUVIndex(lPolygonIndex, iVertex);
int id = lCurrentPolygonIndex + iVertex;
switch (uvs->GetReferenceMode() )
{
case KFbxLayerElement::eDIRECT:
break;
case KFbxLayerElement::eINDEX_TO_DIRECT:
//uvs_index_vector[iLayer] = id;
id = uvs->GetIndexArray().GetAt(id);
break;
default:
break;
}
Display2DVector(header, uvs->GetDirectArray().GetAt(id));
int numuvs = uvs->GetDirectArray().GetCount();
assert( id < numuvs );
}
break;
}
if(iLayer == 0) {
new_uva = KRVector2(uv[0], uv[1]);
// uva.push_back(KRVector2(uv[0], uv[1]));
} else if(iLayer == 1) {
new_uvb = KRVector2(uv[0], uv[1]);
// uvb.push_back(KRVector2(uv[0], uv[1]));
}
}
*/
if(uv_count > 0) {
uva.push_back(new_uva);
}
if(uv_count > 1) {
uvb.push_back(new_uvb);
}
}
// ----====---- Read Normals ----====----
@@ -778,3 +552,22 @@ void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
}
void LoadLight(std::vector<KRResource *> &resources, KFbxNode* pNode) {
KFbxLight* pLight = (KFbxLight*) pNode->GetNodeAttribute();
const char *szName = pNode->GetName();
switch(pLight->LightType.Get()) {
case KFbxLight::ePOINT:
resources.push_back(new KRPointLight(szName));
break;
case KFbxLight::eDIRECTIONAL:
resources.push_back(new KRDirectionalLight(szName));
break;
case KFbxLight::eSPOT:
resources.push_back(new KRSpotLight(szName));
break;
case KFbxLight::eAREA:
// Not supported yet
break;
}
}

View File

@@ -0,0 +1,25 @@
//
// KRSpotLight.cpp
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#include <iostream>
#import "KRSpotLight.h"
KRSpotLight::KRSpotLight(std::string name) : KRLight(name)
{
}
KRSpotLight::~KRSpotLight()
{
}
bool KRSpotLight::save(const std::string& path)
{
return true;
}

View File

@@ -0,0 +1,23 @@
//
// KRSpotLight.h
// KREngine
//
// Created by Kearwood Gilbert on 12-04-05.
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#ifndef KREngine_KRSpotLight_h
#define KREngine_KRSpotLight_h
#import "KRLight.h"
class KRSpotLight : public KRLight {
public:
KRSpotLight(std::string name);
~KRSpotLight();
virtual bool save(const std::string& path);
};
#endif