- Material manager now matches material names in a case-insensitive manner

- KREngine object is now a singleton
- Removed temporary test harnesses for cubemap reflections

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40134
This commit is contained in:
kearwood
2012-10-19 18:28:18 +00:00
parent 6ad15ea510
commit 9e96e765c4
6 changed files with 26 additions and 24 deletions

View File

@@ -62,15 +62,15 @@ KRCamera::KRCamera(KRContext &context) : KRContextObject(context) {
bDebugPSSM = false; bDebugPSSM = false;
bEnableAmbient = true; bEnableAmbient = true;
bEnableDiffuse = true; bEnableDiffuse = true;
bEnableSpecular = false; // FINDME - Should be "true" bEnableSpecular = true;
bEnableLightMap = true; bEnableLightMap = true;
bDebugSuperShiny = false; bDebugSuperShiny = false;
bEnableDeferredLighting = false; // FINDME - should be "true" bEnableDeferredLighting = true;
dAmbientR = 0.25f; // FINDME - should be "0.0f" dAmbientR = 0.0f;
dAmbientG = 0.25f; // FINDME - should be "0.0f" dAmbientG = 0.0f;
dAmbientB = 0.25f; // FINDME - should be "0.0f" dAmbientB = 0.0f;
dSunR = 1.0f; dSunR = 1.0f;
dSunG = 1.0f; dSunG = 1.0f;

View File

@@ -45,6 +45,8 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F
@interface KREngine : NSObject @interface KREngine : NSObject
+ (KREngine *)sharedInstance;
@property(nonatomic, readonly) NSDictionary *parameter_names; @property(nonatomic, readonly) NSDictionary *parameter_names;
@property(nonatomic, assign) KRContext *context; @property(nonatomic, assign) KRContext *context;
@property(nonatomic, assign) KRCamera *camera; @property(nonatomic, assign) KRCamera *camera;

View File

@@ -51,6 +51,17 @@ using namespace std;
@synthesize debug_text = _debug_text; @synthesize debug_text = _debug_text;
double const PI = 3.141592653589793f; double const PI = 3.141592653589793f;
+ (KREngine *)sharedInstance
{
static KREngine *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[KREngine alloc] init];
});
return sharedInstance;
}
- (id)init - (id)init
{ {
_camera = NULL; _camera = NULL;
@@ -150,7 +161,7 @@ double const PI = 3.141592653589793f;
-(int)getParameterCount -(int)getParameterCount
{ {
return 31; return 32;
} }
-(NSString *)getParameterNameWithIndex: (int)i -(NSString *)getParameterNameWithIndex: (int)i

View File

@@ -68,12 +68,6 @@ KRMaterial::KRMaterial(KRContext &context, const char *szName) : KRResource(cont
m_reflectionMapOffset = KRVector2(0.0f, 0.0f); m_reflectionMapOffset = KRVector2(0.0f, 0.0f);
m_reflectionMapScale = KRVector2(1.0f, 1.0f); m_reflectionMapScale = KRVector2(1.0f, 1.0f);
m_alpha_mode = KRMATERIAL_ALPHA_MODE_OPAQUE; m_alpha_mode = KRMATERIAL_ALPHA_MODE_OPAQUE;
// // FINDME - HACK - Test Code:
// m_reflectionCube = "skycube";
// m_reflectionColor = KRVector3(0.75, 0.75, 0.75);
} }
KRMaterial::~KRMaterial() { KRMaterial::~KRMaterial() {
@@ -165,9 +159,6 @@ void KRMaterial::setReflectionMap(std::string texture_name, KRVector2 texture_sc
void KRMaterial::setReflectionCube(std::string texture_name) { void KRMaterial::setReflectionCube(std::string texture_name) {
m_reflectionCube = texture_name; m_reflectionCube = texture_name;
// // FINDME - HACK - Test Code:
// m_reflectionCube = "skycube";
// m_reflectionColor = KRVector3(0.75, 0.75, 0.75);
} }
void KRMaterial::setAlphaMode(KRMaterial::alpha_mode_type alpha_mode) { void KRMaterial::setAlphaMode(KRMaterial::alpha_mode_type alpha_mode) {
@@ -192,9 +183,6 @@ void KRMaterial::setSpecular(const KRVector3 &c) {
void KRMaterial::setReflection(const KRVector3 &c) { void KRMaterial::setReflection(const KRVector3 &c) {
m_reflectionColor = c; m_reflectionColor = c;
// // FINDME - HACK - Test Code:
// m_reflectionCube = "skycube";
// m_reflectionColor = KRVector3(0.75, 0.75, 0.75);
} }
void KRMaterial::setTransparency(GLfloat a) { void KRMaterial::setTransparency(GLfloat a) {

View File

@@ -51,7 +51,12 @@ KRMaterialManager::~KRMaterialManager() {
KRMaterial *KRMaterialManager::getMaterial(const char *szName) { KRMaterial *KRMaterialManager::getMaterial(const char *szName) {
map<std::string, KRMaterial *>::iterator itr = m_materials.find(szName); std::string lowerName = szName;
std::transform(lowerName.begin(), lowerName.end(),
lowerName.begin(), ::tolower);
map<std::string, KRMaterial *>::iterator itr = m_materials.find(lowerName);
if(itr == m_materials.end()) { if(itr == m_materials.end()) {
fprintf(stderr, "Material not found: %s\n", szName); fprintf(stderr, "Material not found: %s\n", szName);
// Not found // Not found

View File

@@ -177,14 +177,10 @@ void KRScene::render(int childOrder[], KROctreeNode *pOctreeNode, std::set<KRAAB
float lod_coverage = pOctreeNode->getBounds().coverage(matVP, pCamera->getViewportSize()); // This also checks the view frustrum culling float lod_coverage = pOctreeNode->getBounds().coverage(matVP, pCamera->getViewportSize()); // This also checks the view frustrum culling
if(lod_coverage > min_coverage) { if(lod_coverage > min_coverage) {
// if(pOctreeNode->getBounds().visible(viewMatrix * projectionMatrix)) { // Only recurse deeper if within the view frustrum
// ----====---- Rendering and occlusion test pass ----====---- // ----====---- Rendering and occlusion test pass ----====----
bool bVisible = false; bool bVisible = false;
bool bNeedOcclusionTest = true; bool bNeedOcclusionTest = true;
//bVisible = true; // FINDME - Test Code
if(!bVisible) { if(!bVisible) {
// Assume bounding boxes are visible without occlusion test queries if the camera is inside the box. // Assume bounding boxes are visible without occlusion test queries if the camera is inside the box.
// The near clipping plane of the camera is taken into consideration by expanding the match area // The near clipping plane of the camera is taken into consideration by expanding the match area