2011-10-25 05:03:10 +00:00
|
|
|
//
|
|
|
|
|
// KREngine.mm
|
2012-03-15 20:09:01 +00:00
|
|
|
// KREngine
|
2011-10-25 05:03:10 +00:00
|
|
|
//
|
2012-03-15 20:09:01 +00:00
|
|
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
2011-10-25 06:16:47 +00:00
|
|
|
//
|
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
|
//
|
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
|
//
|
|
|
|
|
// 2. 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.
|
|
|
|
|
//
|
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''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 KEARWOOD GILBERT 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.
|
|
|
|
|
//
|
|
|
|
|
// The views and conclusions contained in the software and documentation are those of the
|
|
|
|
|
// authors and should not be interpreted as representing official policies, either expressed
|
|
|
|
|
// or implied, of Kearwood Gilbert.
|
2011-10-25 05:03:10 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "KREngine.h"
|
|
|
|
|
#import "KRVector3.h"
|
|
|
|
|
#import "KRScene.h"
|
2012-04-12 00:43:53 +00:00
|
|
|
#import "KRSceneManager.h"
|
2012-06-14 19:33:17 +00:00
|
|
|
#import "KRNode.h"
|
2011-10-25 05:03:10 +00:00
|
|
|
|
|
|
|
|
#import <string>
|
|
|
|
|
#import <sstream>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@interface KREngine (PrivateMethods)
|
|
|
|
|
- (BOOL)loadShaders;
|
|
|
|
|
- (BOOL)loadResource:(NSString *)path;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation KREngine
|
2012-08-15 21:26:06 +00:00
|
|
|
@synthesize debug_text = _debug_text;
|
2011-10-25 05:03:10 +00:00
|
|
|
double const PI = 3.141592653589793f;
|
|
|
|
|
|
2012-08-15 21:26:06 +00:00
|
|
|
- (id)initForWidth: (GLuint)width Height: (GLuint)height
|
|
|
|
|
{
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera = NULL;
|
|
|
|
|
_context = NULL;
|
2011-10-25 05:03:10 +00:00
|
|
|
if ((self = [super init])) {
|
2012-08-16 20:44:33 +00:00
|
|
|
_context = new KRContext();
|
|
|
|
|
_camera = new KRCamera(*_context, width, height);
|
2012-08-15 21:26:06 +00:00
|
|
|
[self loadShaders];
|
2011-10-25 05:03:10 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 22:57:20 +00:00
|
|
|
- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll
|
2011-10-25 05:03:10 +00:00
|
|
|
{
|
|
|
|
|
KRMat4 viewMatrix;
|
|
|
|
|
viewMatrix.translate(-position.x, -position.y, -position.z);
|
|
|
|
|
viewMatrix.rotate(yaw, Y_AXIS);
|
|
|
|
|
viewMatrix.rotate(pitch, X_AXIS);
|
|
|
|
|
viewMatrix.rotate(roll, Z_AXIS);
|
2012-04-20 00:17:15 +00:00
|
|
|
|
2011-10-25 05:03:10 +00:00
|
|
|
[self renderScene: pScene WithViewMatrix: viewMatrix];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix
|
|
|
|
|
{
|
2012-04-20 00:17:15 +00:00
|
|
|
viewMatrix.rotate(-90 * 0.0174532925199, Z_AXIS);
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->renderFrame(*_context, *pScene, viewMatrix);
|
2011-10-25 05:03:10 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)loadShaders
|
|
|
|
|
{
|
2012-04-13 23:24:07 +00:00
|
|
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
|
|
|
|
NSString *bundle_directory = [[NSBundle mainBundle] bundlePath];
|
|
|
|
|
for (NSString* fileName in [fileManager contentsOfDirectoryAtPath: bundle_directory error:nil]) {
|
|
|
|
|
if([fileName hasSuffix: @".vsh"] || [fileName hasSuffix: @".fsh"]) {
|
|
|
|
|
NSString* path = [NSString stringWithFormat:@"%@/%@", bundle_directory, fileName];
|
2012-08-16 20:44:33 +00:00
|
|
|
_context->loadResource([path UTF8String]);
|
2012-04-13 23:24:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-10-25 05:03:10 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)loadResource:(NSString *)path
|
|
|
|
|
{
|
2012-08-16 20:44:33 +00:00
|
|
|
_context->loadResource([path UTF8String]);
|
2011-10-25 05:03:10 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)dealloc
|
2012-04-12 00:43:53 +00:00
|
|
|
{
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera) {
|
|
|
|
|
delete _camera; _camera = NULL;
|
|
|
|
|
}
|
|
|
|
|
if(_context) {
|
|
|
|
|
delete _context; _context = NULL;
|
|
|
|
|
}
|
2011-10-25 05:03:10 +00:00
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(int)getParameterCount
|
|
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
return 31;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(NSString *)getParameterNameWithIndex: (int)i
|
|
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
NSString *parameter_names[31] = {
|
2011-10-25 05:03:10 +00:00
|
|
|
@"camera_fov",
|
|
|
|
|
@"shadow_quality",
|
|
|
|
|
@"enable_per_pixel",
|
|
|
|
|
@"enable_diffuse_map",
|
|
|
|
|
@"enable_normal_map",
|
|
|
|
|
@"enable_spec_map",
|
2012-05-08 23:39:52 +00:00
|
|
|
@"enable_reflection_map",
|
2012-04-12 06:25:44 +00:00
|
|
|
@"enable_light_map",
|
2011-10-25 05:03:10 +00:00
|
|
|
@"ambient_r",
|
|
|
|
|
@"ambient_g",
|
|
|
|
|
@"ambient_b",
|
|
|
|
|
@"sun_r",
|
|
|
|
|
@"sun_g",
|
|
|
|
|
@"sun_b",
|
|
|
|
|
@"dof_quality",
|
|
|
|
|
@"dof_depth",
|
|
|
|
|
@"dof_falloff",
|
|
|
|
|
@"flash_enable",
|
|
|
|
|
@"flash_intensity",
|
|
|
|
|
@"flash_depth",
|
|
|
|
|
@"flash_falloff",
|
|
|
|
|
@"vignette_enable",
|
|
|
|
|
@"vignette_radius",
|
|
|
|
|
@"vignette_falloff",
|
|
|
|
|
@"debug_shadowmap",
|
|
|
|
|
@"debug_pssm",
|
|
|
|
|
@"debug_enable_ambient",
|
|
|
|
|
@"debug_enable_diffuse",
|
|
|
|
|
@"debug_enable_specular",
|
2012-04-13 01:13:18 +00:00
|
|
|
@"debug_super_shiny",
|
|
|
|
|
@"enable_deferred_lighting"
|
2011-10-25 05:03:10 +00:00
|
|
|
};
|
|
|
|
|
return parameter_names[i];
|
|
|
|
|
}
|
|
|
|
|
-(NSString *)getParameterLabelWithIndex: (int)i
|
|
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
NSString *parameter_labels[31] = {
|
2011-10-25 05:03:10 +00:00
|
|
|
@"Camera FOV",
|
|
|
|
|
@"Shadow Quality (0 - 2)",
|
|
|
|
|
@"Enable per-pixel lighting",
|
|
|
|
|
@"Enable diffuse map",
|
|
|
|
|
@"Enable normal map",
|
|
|
|
|
@"Enable specular map",
|
2012-05-08 23:39:52 +00:00
|
|
|
@"Enable reflection map",
|
2012-04-12 06:25:44 +00:00
|
|
|
@"Enable light map",
|
2011-10-25 05:03:10 +00:00
|
|
|
@"Ambient light red intensity",
|
|
|
|
|
@"Ambient light green intensity",
|
|
|
|
|
@"Ambient light blue intensity",
|
|
|
|
|
@"Sun red intensity",
|
|
|
|
|
@"Sun green intensity",
|
|
|
|
|
@"Sun blue intensity",
|
|
|
|
|
@"DOF Quality",
|
|
|
|
|
@"DOF Depth",
|
|
|
|
|
@"DOF Falloff",
|
|
|
|
|
@"Enable Night/Flash Effect",
|
|
|
|
|
@"Flash Intensity",
|
|
|
|
|
@"Flash Depth",
|
|
|
|
|
@"Flash Falloff",
|
|
|
|
|
@"Enable Vignette",
|
|
|
|
|
@"Vignette Radius",
|
|
|
|
|
@"Vignette Falloff",
|
2012-03-29 19:39:28 +00:00
|
|
|
@"Debug - View Shadow Volume",
|
2011-10-25 05:03:10 +00:00
|
|
|
@"Debug - PSSM",
|
|
|
|
|
@"Debug - Enable Ambient",
|
|
|
|
|
@"Debug - Enable Diffuse",
|
|
|
|
|
@"Debug - Enable Specular",
|
2012-04-13 01:13:18 +00:00
|
|
|
@"Debug - Super Shiny",
|
|
|
|
|
@"Enable Deferred Lighting"
|
2011-10-25 05:03:10 +00:00
|
|
|
};
|
|
|
|
|
return parameter_labels[i];
|
|
|
|
|
}
|
|
|
|
|
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
|
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
KREngineParameterType types[31] = {
|
2012-04-13 01:13:18 +00:00
|
|
|
|
2011-10-25 05:03:10 +00:00
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_INT,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
2012-03-29 19:39:28 +00:00
|
|
|
KRENGINE_PARAMETER_BOOL,
|
2012-05-08 23:39:52 +00:00
|
|
|
KRENGINE_PARAMETER_BOOL,
|
2011-10-25 05:03:10 +00:00
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_INT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_FLOAT,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
|
|
|
|
KRENGINE_PARAMETER_BOOL,
|
2012-04-13 01:13:18 +00:00
|
|
|
KRENGINE_PARAMETER_BOOL,
|
2011-10-25 05:03:10 +00:00
|
|
|
KRENGINE_PARAMETER_BOOL
|
|
|
|
|
};
|
|
|
|
|
return types[i];
|
|
|
|
|
}
|
|
|
|
|
-(double)getParameterValueWithIndex: (int)i
|
|
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
double values[31] = {
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->perspective_fov,
|
|
|
|
|
(double)_camera->m_cShadowBuffers,
|
|
|
|
|
_camera->bEnablePerPixel ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableDiffuseMap ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableNormalMap ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableSpecMap ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableReflectionMap ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableLightMap ? 1.0f : 0.0f,
|
|
|
|
|
_camera->dAmbientR,
|
|
|
|
|
_camera->dAmbientG,
|
|
|
|
|
_camera->dAmbientB,
|
|
|
|
|
_camera->dSunR,
|
|
|
|
|
_camera->dSunG,
|
|
|
|
|
_camera->dSunB,
|
|
|
|
|
_camera->dof_quality,
|
|
|
|
|
_camera->dof_depth,
|
|
|
|
|
_camera->dof_falloff,
|
|
|
|
|
_camera->bEnableFlash ? 1.0f : 0.0f,
|
|
|
|
|
_camera->flash_intensity,
|
|
|
|
|
_camera->flash_depth,
|
|
|
|
|
_camera->flash_falloff,
|
|
|
|
|
_camera->bEnableVignette ? 1.0f : 0.0f,
|
|
|
|
|
_camera->vignette_radius,
|
|
|
|
|
_camera->vignette_falloff,
|
|
|
|
|
_camera->bShowShadowBuffer ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bDebugPSSM ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableAmbient ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableDiffuse ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableSpecular ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bDebugSuperShiny ? 1.0f : 0.0f,
|
|
|
|
|
_camera->bEnableDeferredLighting ? 1.0f : 0.0f
|
2011-10-25 05:03:10 +00:00
|
|
|
};
|
|
|
|
|
return values[i];
|
|
|
|
|
}
|
|
|
|
|
-(void)setParameterValueWithIndex: (int)i Value: (double)v
|
|
|
|
|
{
|
|
|
|
|
bool bNewBoolVal = v > 0.5;
|
|
|
|
|
NSLog(@"Set Parameter: (%s, %f)", [[self getParameterNameWithIndex: i] UTF8String], v);
|
|
|
|
|
switch(i) {
|
|
|
|
|
case 0: // FOV
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->perspective_fov = v;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 1: // Shadow Quality
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->m_cShadowBuffers = (int)v;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 2:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->bEnablePerPixel = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 3:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->bEnableDiffuseMap = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 4:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->bEnableNormalMap = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 5:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->bEnableSpecMap = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 6:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->bEnableReflectionMap = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 7:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->bEnableLightMap = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 8:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->dAmbientR = v;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 9:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->dAmbientG = v;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 10:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->dAmbientB = v;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 11:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->dSunR = v;
|
2011-10-25 05:03:10 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 12:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->dSunG = v;
|
2012-03-29 19:39:28 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 13:
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->dSunB = v;
|
2012-05-08 23:39:52 +00:00
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 14:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->dof_quality != (int)v) {
|
|
|
|
|
_camera->dof_quality = (int)v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 15:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->dof_depth != v) {
|
|
|
|
|
_camera->dof_depth = v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 16:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->dof_falloff != v) {
|
|
|
|
|
_camera->dof_falloff = v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 17:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bEnableFlash != bNewBoolVal) {
|
|
|
|
|
_camera->bEnableFlash = bNewBoolVal;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 18:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->flash_intensity != v) {
|
|
|
|
|
_camera->flash_intensity = v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 19:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->flash_depth != v) {
|
|
|
|
|
_camera->flash_depth = v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 20:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->flash_falloff != v) {
|
|
|
|
|
_camera->flash_falloff = v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 21:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bEnableVignette != bNewBoolVal) {
|
|
|
|
|
_camera->bEnableVignette = bNewBoolVal;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 22:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->vignette_radius != v) {
|
|
|
|
|
_camera->vignette_radius = v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 23:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->vignette_falloff != v) {
|
|
|
|
|
_camera->vignette_falloff = v;
|
|
|
|
|
_camera->invalidatePostShader();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 24:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bShowShadowBuffer != bNewBoolVal) {
|
|
|
|
|
_camera->bShowShadowBuffer = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 25:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bDebugPSSM != bNewBoolVal) {
|
|
|
|
|
_camera->bDebugPSSM = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 26:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bEnableAmbient != bNewBoolVal) {
|
|
|
|
|
_camera->bEnableAmbient = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 27:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bEnableDiffuse != bNewBoolVal) {
|
|
|
|
|
_camera->bEnableDiffuse = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 28:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bEnableSpecular != bNewBoolVal) {
|
|
|
|
|
_camera->bEnableSpecular = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 29:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bDebugSuperShiny != bNewBoolVal) {
|
|
|
|
|
_camera->bDebugSuperShiny = bNewBoolVal;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2012-08-15 21:26:06 +00:00
|
|
|
case 30:
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->bEnableDeferredLighting != bNewBoolVal) {
|
|
|
|
|
_camera->bEnableDeferredLighting = bNewBoolVal;
|
2012-04-13 01:13:18 +00:00
|
|
|
}
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(double)getParameterMinWithIndex: (int)i
|
|
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
double minValues[31] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
2011-10-25 05:03:10 +00:00
|
|
|
return minValues[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(double)getParameterMaxWithIndex: (int)i
|
|
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
double maxValues[31] = {PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 2.0f, 1.0f, 1.0f, 1.0f, 5.0f, 1.0f, 0.5f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
|
2011-10-25 05:03:10 +00:00
|
|
|
return maxValues[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)setParameterValueWithName: (NSString *)name Value: (double)v
|
|
|
|
|
{
|
|
|
|
|
int cParameters = [self getParameterCount];
|
|
|
|
|
for(int i=0; i < cParameters; i++) {
|
|
|
|
|
if([[self getParameterNameWithIndex: i] caseInsensitiveCompare:name] == NSOrderedSame) {
|
|
|
|
|
[self setParameterValueWithIndex:i Value:v];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setNearZ: (double)dNearZ
|
|
|
|
|
{
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->perspective_nearz != dNearZ) {
|
|
|
|
|
_camera->perspective_nearz = dNearZ;
|
|
|
|
|
_camera->invalidateShadowBuffers();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
- (void)setFarZ: (double)dFarZ
|
|
|
|
|
{
|
2012-08-16 20:44:33 +00:00
|
|
|
if(_camera->perspective_farz != dFarZ) {
|
|
|
|
|
_camera->perspective_farz = dFarZ;
|
|
|
|
|
_camera->invalidateShadowBuffers();
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-15 21:26:06 +00:00
|
|
|
- (void)setDebug_text:(NSString *)value
|
2011-10-25 05:03:10 +00:00
|
|
|
{
|
2012-08-15 21:26:06 +00:00
|
|
|
[_debug_text release];
|
|
|
|
|
_debug_text = value;
|
|
|
|
|
[_debug_text retain];
|
|
|
|
|
|
2012-08-16 20:44:33 +00:00
|
|
|
_camera->m_debug_text = value.UTF8String;
|
2011-10-25 05:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|