Renamed Vector3 class to KRVector3
KRObjPacker project updated to use KREngine_osx framework rather than having a copy of the files --HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4015
This commit is contained in:
@@ -50,8 +50,8 @@
|
|||||||
E4BBBB9D1512A4AC00F43B5B /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4BBBB981512A47500F43B5B /* CoreData.framework */; };
|
E4BBBB9D1512A4AC00F43B5B /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4BBBB981512A47500F43B5B /* CoreData.framework */; };
|
||||||
E4BBBB9E1512A4AE00F43B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4BBBB961512A46700F43B5B /* AppKit.framework */; };
|
E4BBBB9E1512A4AE00F43B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4BBBB961512A46700F43B5B /* AppKit.framework */; };
|
||||||
E4BBBB9F1512A4B100F43B5B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4BBBB941512A45500F43B5B /* Cocoa.framework */; };
|
E4BBBB9F1512A4B100F43B5B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4BBBB941512A45500F43B5B /* Cocoa.framework */; };
|
||||||
E4BBBBA61512A6DC00F43B5B /* KRVector3.h in Sources */ = {isa = PBXBuildFile; fileRef = E491017E13C99BDC0098455B /* KRVector3.h */; };
|
|
||||||
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017F13C99BDC0098455B /* KRVector3.cpp */; };
|
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017F13C99BDC0098455B /* KRVector3.cpp */; };
|
||||||
|
E4D0683F1512A790005FFBEB /* KRVector3.h in Headers */ = {isa = PBXBuildFile; fileRef = E491017E13C99BDC0098455B /* KRVector3.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXBuildRule section */
|
/* Begin PBXBuildRule section */
|
||||||
@@ -69,8 +69,8 @@
|
|||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
E414BAE11435557300A668C4 /* KRInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRInstance.h; path = Classes/KRInstance.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E414BAE11435557300A668C4 /* KRInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRInstance.h; path = Classes/KRInstance.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E414BAE41435558800A668C4 /* KRInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRInstance.cpp; path = Classes/KRInstance.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E414BAE41435558800A668C4 /* KRInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRInstance.cpp; path = Classes/KRInstance.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E414BAE6143557D200A668C4 /* KRScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRScene.h; path = Classes/KRScene.h; sourceTree = "<group>"; };
|
E414BAE6143557D200A668C4 /* KRScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRScene.h; path = Classes/KRScene.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E414BAE81435585A00A668C4 /* KRScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRScene.cpp; path = Classes/KRScene.cpp; sourceTree = "<group>"; };
|
E414BAE81435585A00A668C4 /* KRScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRScene.cpp; path = Classes/KRScene.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E414BAEA14355E5500A668C4 /* KRBoundingVolume.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRBoundingVolume.h; path = Classes/KRBoundingVolume.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E414BAEA14355E5500A668C4 /* KRBoundingVolume.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRBoundingVolume.h; path = Classes/KRBoundingVolume.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRBoundingVolume.cpp; path = Classes/KRBoundingVolume.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRBoundingVolume.cpp; path = Classes/KRBoundingVolume.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E45772F113C9A13C0037BEEA /* ShadowShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; lineEnding = 0; name = ShadowShader.vsh; path = Shaders/ShadowShader.vsh; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.glsl; };
|
E45772F113C9A13C0037BEEA /* ShadowShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; lineEnding = 0; name = ShadowShader.vsh; path = Shaders/ShadowShader.vsh; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.glsl; };
|
||||||
@@ -80,9 +80,9 @@
|
|||||||
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; };
|
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>"; };
|
E45772F613C9A13C0037BEEA /* PostShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = PostShader.vsh; path = Shaders/PostShader.vsh; sourceTree = "<group>"; };
|
||||||
E47C25A113F4F65A00FF4370 /* KRShaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRShaderManager.h; path = Classes/KRShaderManager.h; sourceTree = "<group>"; };
|
E47C25A113F4F65A00FF4370 /* KRShaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRShaderManager.h; path = Classes/KRShaderManager.h; sourceTree = "<group>"; };
|
||||||
E47C25A413F4F66F00FF4370 /* KRShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRShader.h; path = Classes/KRShader.h; sourceTree = "<group>"; };
|
E47C25A413F4F66F00FF4370 /* KRShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRShader.h; path = Classes/KRShader.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRShaderManager.cpp; path = Classes/KRShaderManager.cpp; sourceTree = "<group>"; };
|
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRShaderManager.cpp; path = Classes/KRShaderManager.cpp; sourceTree = "<group>"; };
|
||||||
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRShader.cpp; path = Classes/KRShader.cpp; sourceTree = "<group>"; };
|
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRShader.cpp; path = Classes/KRShader.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E48B3CBC14393DF5000C50E2 /* KRCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRCamera.h; path = Classes/KRCamera.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E48B3CBC14393DF5000C50E2 /* KRCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRCamera.h; path = Classes/KRCamera.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRCamera.cpp; path = Classes/KRCamera.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRCamera.cpp; path = Classes/KRCamera.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E491016113C99B9E0098455B /* libKREngine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKREngine.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
E491016113C99B9E0098455B /* libKREngine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKREngine.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@@ -308,6 +308,7 @@
|
|||||||
isa = PBXHeadersBuildPhase;
|
isa = PBXHeadersBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
E4D0683F1512A790005FFBEB /* KRVector3.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -356,6 +357,7 @@
|
|||||||
E491015813C99B9D0098455B /* Project object */ = {
|
E491015813C99B9D0098455B /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0430;
|
||||||
ORGANIZATIONNAME = "Kearwood Software";
|
ORGANIZATIONNAME = "Kearwood Software";
|
||||||
};
|
};
|
||||||
buildConfigurationList = E491015B13C99B9D0098455B /* Build configuration list for PBXProject "KREngine" */;
|
buildConfigurationList = E491015B13C99B9D0098455B /* Build configuration list for PBXProject "KREngine" */;
|
||||||
@@ -415,7 +417,6 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
E4BBBBA61512A6DC00F43B5B /* KRVector3.h in Sources */,
|
|
||||||
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */,
|
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */,
|
||||||
E4BBBB8E1512A40300F43B5B /* krengine_osx.m in Sources */,
|
E4BBBB8E1512A40300F43B5B /* krengine_osx.m in Sources */,
|
||||||
);
|
);
|
||||||
@@ -475,6 +476,7 @@
|
|||||||
);
|
);
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "KREngine/KREngine-Prefix.pch";
|
GCC_PREFIX_HEADER = "KREngine/KREngine-Prefix.pch";
|
||||||
|
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
};
|
};
|
||||||
@@ -491,6 +493,7 @@
|
|||||||
);
|
);
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "KREngine/KREngine-Prefix.pch";
|
GCC_PREFIX_HEADER = "KREngine/KREngine-Prefix.pch";
|
||||||
|
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
};
|
};
|
||||||
@@ -587,6 +590,7 @@
|
|||||||
E4BBBB901512A40300F43B5B /* Release */,
|
E4BBBB901512A40300F43B5B /* Release */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,21 +34,21 @@
|
|||||||
#import "KRBoundingVolume.h"
|
#import "KRBoundingVolume.h"
|
||||||
|
|
||||||
|
|
||||||
KRBoundingVolume::KRBoundingVolume(const Vector3 *pVertices) {
|
KRBoundingVolume::KRBoundingVolume(const KRVector3 *pVertices) {
|
||||||
for(int iVertex=0; iVertex < 8; iVertex++) {
|
for(int iVertex=0; iVertex < 8; iVertex++) {
|
||||||
m_vertices[iVertex] = pVertices[iVertex];
|
m_vertices[iVertex] = pVertices[iVertex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KRBoundingVolume::KRBoundingVolume(const Vector3 &corner1, const Vector3 &corner2, const KRMat4 modelMatrix) {
|
KRBoundingVolume::KRBoundingVolume(const KRVector3 &corner1, const KRVector3 &corner2, const KRMat4 modelMatrix) {
|
||||||
m_vertices[0] = Vector3(corner1.x, corner1.y, corner1.z);
|
m_vertices[0] = KRVector3(corner1.x, corner1.y, corner1.z);
|
||||||
m_vertices[1] = Vector3(corner2.x, corner1.y, corner1.z);
|
m_vertices[1] = KRVector3(corner2.x, corner1.y, corner1.z);
|
||||||
m_vertices[2] = Vector3(corner2.x, corner2.y, corner1.z);
|
m_vertices[2] = KRVector3(corner2.x, corner2.y, corner1.z);
|
||||||
m_vertices[3] = Vector3(corner1.x, corner2.y, corner1.z);
|
m_vertices[3] = KRVector3(corner1.x, corner2.y, corner1.z);
|
||||||
m_vertices[4] = Vector3(corner1.x, corner1.y, corner2.z);
|
m_vertices[4] = KRVector3(corner1.x, corner1.y, corner2.z);
|
||||||
m_vertices[5] = Vector3(corner2.x, corner1.y, corner2.z);
|
m_vertices[5] = KRVector3(corner2.x, corner1.y, corner2.z);
|
||||||
m_vertices[6] = Vector3(corner2.x, corner2.y, corner2.z);
|
m_vertices[6] = KRVector3(corner2.x, corner2.y, corner2.z);
|
||||||
m_vertices[7] = Vector3(corner1.x, corner2.y, corner2.z);
|
m_vertices[7] = KRVector3(corner1.x, corner2.y, corner2.z);
|
||||||
|
|
||||||
for(int iVertex=0; iVertex < 8; iVertex++) {
|
for(int iVertex=0; iVertex < 8; iVertex++) {
|
||||||
m_vertices[iVertex] = modelMatrix.dot(m_vertices[iVertex]);
|
m_vertices[iVertex] = modelMatrix.dot(m_vertices[iVertex]);
|
||||||
@@ -63,14 +63,14 @@ KRBoundingVolume::KRBoundingVolume(const KRMat4 &matView, GLfloat fov, GLfloat a
|
|||||||
|
|
||||||
GLfloat r = tan(fov / 2.0);
|
GLfloat r = tan(fov / 2.0);
|
||||||
|
|
||||||
m_vertices[0] = Vector3(-1.0 * r * nearz * aspect, -1.0 * r * nearz, -nearz);
|
m_vertices[0] = KRVector3(-1.0 * r * nearz * aspect, -1.0 * r * nearz, -nearz);
|
||||||
m_vertices[1] = Vector3(1.0 * r * nearz * aspect, -1.0 * r * nearz, -nearz);
|
m_vertices[1] = KRVector3(1.0 * r * nearz * aspect, -1.0 * r * nearz, -nearz);
|
||||||
m_vertices[2] = Vector3(1.0 * r * nearz * aspect, 1.0 * r * nearz, -nearz);
|
m_vertices[2] = KRVector3(1.0 * r * nearz * aspect, 1.0 * r * nearz, -nearz);
|
||||||
m_vertices[3] = Vector3(-1.0 * r * nearz * aspect, 1.0 * r * nearz, -nearz);
|
m_vertices[3] = KRVector3(-1.0 * r * nearz * aspect, 1.0 * r * nearz, -nearz);
|
||||||
m_vertices[4] = Vector3(-1.0 * r * farz * aspect, -1.0 * r * farz, -farz);
|
m_vertices[4] = KRVector3(-1.0 * r * farz * aspect, -1.0 * r * farz, -farz);
|
||||||
m_vertices[5] = Vector3(1.0 * r * farz * aspect, -1.0 * r * farz, -farz);
|
m_vertices[5] = KRVector3(1.0 * r * farz * aspect, -1.0 * r * farz, -farz);
|
||||||
m_vertices[6] = Vector3(1.0 * r * farz * aspect, 1.0 * r * farz, -farz);
|
m_vertices[6] = KRVector3(1.0 * r * farz * aspect, 1.0 * r * farz, -farz);
|
||||||
m_vertices[7] = Vector3(-1.0 * r * farz * aspect, 1.0 * r * farz, -farz);
|
m_vertices[7] = KRVector3(-1.0 * r * farz * aspect, 1.0 * r * farz, -farz);
|
||||||
|
|
||||||
for(int iVertex=0; iVertex < 8; iVertex++) {
|
for(int iVertex=0; iVertex < 8; iVertex++) {
|
||||||
m_vertices[iVertex] = invView.dot(m_vertices[iVertex]);
|
m_vertices[iVertex] = invView.dot(m_vertices[iVertex]);
|
||||||
@@ -97,7 +97,7 @@ KRBoundingVolume& KRBoundingVolume::operator = ( const KRBoundingVolume& p ) {
|
|||||||
KRBoundingVolume KRBoundingVolume::get_union(const KRBoundingVolume &p) const {
|
KRBoundingVolume KRBoundingVolume::get_union(const KRBoundingVolume &p) const {
|
||||||
// Simple, non-aligned bounding box calculated that contains both volumes.
|
// Simple, non-aligned bounding box calculated that contains both volumes.
|
||||||
|
|
||||||
Vector3 minPoint = m_vertices[0], maxPoint = m_vertices[0];
|
KRVector3 minPoint = m_vertices[0], maxPoint = m_vertices[0];
|
||||||
for(int iVertex=1; iVertex < 8; iVertex++) {
|
for(int iVertex=1; iVertex < 8; iVertex++) {
|
||||||
if(m_vertices[iVertex].x < minPoint.x) {
|
if(m_vertices[iVertex].x < minPoint.x) {
|
||||||
minPoint.x = m_vertices[iVertex].x;
|
minPoint.x = m_vertices[iVertex].x;
|
||||||
@@ -144,7 +144,7 @@ KRBoundingVolume KRBoundingVolume::get_union(const KRBoundingVolume &p) const {
|
|||||||
bool KRBoundingVolume::test_intersect(const KRBoundingVolume &p) const {
|
bool KRBoundingVolume::test_intersect(const KRBoundingVolume &p) const {
|
||||||
// Simple, non-aligned bounding box intersection test
|
// Simple, non-aligned bounding box intersection test
|
||||||
|
|
||||||
Vector3 minPoint = m_vertices[0], maxPoint = m_vertices[0], minPoint2 = p.m_vertices[0], maxPoint2 = p.m_vertices[0];
|
KRVector3 minPoint = m_vertices[0], maxPoint = m_vertices[0], minPoint2 = p.m_vertices[0], maxPoint2 = p.m_vertices[0];
|
||||||
for(int iVertex=1; iVertex < 8; iVertex++) {
|
for(int iVertex=1; iVertex < 8; iVertex++) {
|
||||||
if(m_vertices[iVertex].x < minPoint.x) {
|
if(m_vertices[iVertex].x < minPoint.x) {
|
||||||
minPoint.x = m_vertices[iVertex].x;
|
minPoint.x = m_vertices[iVertex].x;
|
||||||
@@ -202,9 +202,9 @@ KRMat4 KRBoundingVolume::calcShadowProj(KRScene *pScene, GLfloat sun_yaw, GLfloa
|
|||||||
shadowvp.invert();
|
shadowvp.invert();
|
||||||
shadowvp.scale(1.0, 1.0, -1.0);
|
shadowvp.scale(1.0, 1.0, -1.0);
|
||||||
|
|
||||||
Vector3 minPointFrustrum = shadowvp.dot(m_vertices[0]), maxPointFrustrum = minPointFrustrum;
|
KRVector3 minPointFrustrum = shadowvp.dot(m_vertices[0]), maxPointFrustrum = minPointFrustrum;
|
||||||
for(int iVertex=1; iVertex < 8; iVertex++) {
|
for(int iVertex=1; iVertex < 8; iVertex++) {
|
||||||
Vector3 v = shadowvp.dot(m_vertices[iVertex]);
|
KRVector3 v = shadowvp.dot(m_vertices[iVertex]);
|
||||||
if(v.x < minPointFrustrum.x) {
|
if(v.x < minPointFrustrum.x) {
|
||||||
minPointFrustrum.x = v.x;
|
minPointFrustrum.x = v.x;
|
||||||
}
|
}
|
||||||
@@ -226,9 +226,9 @@ KRMat4 KRBoundingVolume::calcShadowProj(KRScene *pScene, GLfloat sun_yaw, GLfloa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vector3 minPointScene = shadowvp.dot(sceneVolume.m_vertices[0]), maxPointScene = minPointScene;
|
KRVector3 minPointScene = shadowvp.dot(sceneVolume.m_vertices[0]), maxPointScene = minPointScene;
|
||||||
for(int iVertex=1; iVertex < 8; iVertex++) {
|
for(int iVertex=1; iVertex < 8; iVertex++) {
|
||||||
Vector3 v = shadowvp.dot(sceneVolume.m_vertices[iVertex]);
|
KRVector3 v = shadowvp.dot(sceneVolume.m_vertices[iVertex]);
|
||||||
if(v.x < minPointScene.x) {
|
if(v.x < minPointScene.x) {
|
||||||
minPointScene.x = v.x;
|
minPointScene.x = v.x;
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ KRMat4 KRBoundingVolume::calcShadowProj(KRScene *pScene, GLfloat sun_yaw, GLfloa
|
|||||||
GLfloat maxFrustrumDepth = maxPointFrustrum.z;
|
GLfloat maxFrustrumDepth = maxPointFrustrum.z;
|
||||||
|
|
||||||
for(int i=0; i<8; i++) {
|
for(int i=0; i<8; i++) {
|
||||||
Vector3 v = shadowvp.dot(sceneVolume.m_vertices[i]);
|
KRVector3 v = shadowvp.dot(sceneVolume.m_vertices[i]);
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
minPointFrustrum.z = v.z;
|
minPointFrustrum.z = v.z;
|
||||||
maxPointFrustrum.z = v.z;
|
maxPointFrustrum.z = v.z;
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ class KRScene;
|
|||||||
|
|
||||||
class KRBoundingVolume {
|
class KRBoundingVolume {
|
||||||
public:
|
public:
|
||||||
KRBoundingVolume(const Vector3 *pVertices);
|
KRBoundingVolume(const KRVector3 *pVertices);
|
||||||
KRBoundingVolume(const Vector3 &corner1, const Vector3 &corner2, const KRMat4 modelMatrix);
|
KRBoundingVolume(const KRVector3 &corner1, const KRVector3 &corner2, const KRMat4 modelMatrix);
|
||||||
KRBoundingVolume(const KRMat4 &matView, GLfloat fov, GLfloat aspect, GLfloat nearz, GLfloat farz);
|
KRBoundingVolume(const KRMat4 &matView, GLfloat fov, GLfloat aspect, GLfloat nearz, GLfloat farz);
|
||||||
~KRBoundingVolume();
|
~KRBoundingVolume();
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
KRMat4 calcShadowProj(KRScene *pScene, GLfloat sun_yaw, GLfloat sun_pitch) const;
|
KRMat4 calcShadowProj(KRScene *pScene, GLfloat sun_yaw, GLfloat sun_pitch) const;
|
||||||
private:
|
private:
|
||||||
Vector3 m_vertices[8];
|
KRVector3 m_vertices[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F
|
|||||||
- (BOOL)loadResource:(NSString *)path;
|
- (BOOL)loadResource:(NSString *)path;
|
||||||
|
|
||||||
- (void)renderShadowBufferNumber: (int)iShadow ForScene: (KRScene *)pScene;
|
- (void)renderShadowBufferNumber: (int)iShadow ForScene: (KRScene *)pScene;
|
||||||
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix LightDirection: (Vector3)lightDirection CameraPosition: (Vector3)cameraPosition;
|
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix LightDirection: (KRVector3)lightDirection CameraPosition: (KRVector3)cameraPosition;
|
||||||
- (KRModelManager *)getModelManager;
|
- (KRModelManager *)getModelManager;
|
||||||
- (void)invalidateShadowBuffers;
|
- (void)invalidateShadowBuffers;
|
||||||
- (void)allocateShadowBuffers;
|
- (void)allocateShadowBuffers;
|
||||||
@@ -120,7 +120,7 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F
|
|||||||
-(void)setParameterValueWithName: (NSString *)name Value: (double)v;
|
-(void)setParameterValueWithName: (NSString *)name Value: (double)v;
|
||||||
|
|
||||||
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix;
|
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix;
|
||||||
- (void)renderScene: (KRScene *)pScene WithPosition: (Vector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll;
|
- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll;
|
||||||
- (void)setNearZ: (double)dNearZ;
|
- (void)setNearZ: (double)dNearZ;
|
||||||
- (void)setFarZ: (double)dFarZ;
|
- (void)setFarZ: (double)dFarZ;
|
||||||
- (void)setAspect: (double)dAspect;
|
- (void)setAspect: (double)dAspect;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ double const PI = 3.141592653589793f;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)renderScene: (KRScene *)pScene WithPosition: (Vector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll
|
- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll
|
||||||
{
|
{
|
||||||
KRMat4 viewMatrix;
|
KRMat4 viewMatrix;
|
||||||
viewMatrix.translate(-position.x, -position.y, -position.z);
|
viewMatrix.translate(-position.x, -position.y, -position.z);
|
||||||
@@ -198,9 +198,9 @@ double const PI = 3.141592653589793f;
|
|||||||
KRMat4 invViewMatrix = viewMatrix;
|
KRMat4 invViewMatrix = viewMatrix;
|
||||||
invViewMatrix.invert();
|
invViewMatrix.invert();
|
||||||
|
|
||||||
Vector3 cameraPosition = invViewMatrix.dot(Vector3(0.0,0.0,0.0));
|
KRVector3 cameraPosition = invViewMatrix.dot(KRVector3(0.0,0.0,0.0));
|
||||||
|
|
||||||
Vector3 lightDirection(0.0, 0.0, 1.0);
|
KRVector3 lightDirection(0.0, 0.0, 1.0);
|
||||||
|
|
||||||
// ----- Render Model -----
|
// ----- Render Model -----
|
||||||
KRMat4 shadowvp;
|
KRMat4 shadowvp;
|
||||||
@@ -312,29 +312,29 @@ double const PI = 3.141592653589793f;
|
|||||||
KRMat4 matInvShadow = shadowmvpmatrix[iShadow];
|
KRMat4 matInvShadow = shadowmvpmatrix[iShadow];
|
||||||
matInvShadow.invert();
|
matInvShadow.invert();
|
||||||
|
|
||||||
Vector3 vertices[8];
|
KRVector3 vertices[8];
|
||||||
vertices[0] = Vector3(-1.0, -1.0, 0.0);
|
vertices[0] = KRVector3(-1.0, -1.0, 0.0);
|
||||||
vertices[1] = Vector3(1.0, -1.0, 0.0);
|
vertices[1] = KRVector3(1.0, -1.0, 0.0);
|
||||||
vertices[2] = Vector3(1.0, 1.0, 0.0);
|
vertices[2] = KRVector3(1.0, 1.0, 0.0);
|
||||||
vertices[3] = Vector3(-1.0, 1.0, 0.0);
|
vertices[3] = KRVector3(-1.0, 1.0, 0.0);
|
||||||
vertices[4] = Vector3(-1.0, -1.0, 1.0);
|
vertices[4] = KRVector3(-1.0, -1.0, 1.0);
|
||||||
vertices[5] = Vector3(1.0, -1.0, 1.0);
|
vertices[5] = KRVector3(1.0, -1.0, 1.0);
|
||||||
vertices[6] = Vector3(1.0, 1.0, 1.0);
|
vertices[6] = KRVector3(1.0, 1.0, 1.0);
|
||||||
vertices[7] = Vector3(-1.0, 1.0, 1.0);
|
vertices[7] = KRVector3(-1.0, 1.0, 1.0);
|
||||||
|
|
||||||
for(int iVertex=0; iVertex < 8; iVertex++) {
|
for(int iVertex=0; iVertex < 8; iVertex++) {
|
||||||
vertices[iVertex] = matInvShadow.dot(vertices[iVertex]);
|
vertices[iVertex] = matInvShadow.dot(vertices[iVertex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 cameraPosition;
|
KRVector3 cameraPosition;
|
||||||
Vector3 lightDirection;
|
KRVector3 lightDirection;
|
||||||
KRBoundingVolume shadowVolume = KRBoundingVolume(vertices);
|
KRBoundingVolume shadowVolume = KRBoundingVolume(vertices);
|
||||||
pScene->render(&m_camera, shadowVolume, m_pMaterialManager, true, shadowmvpmatrix[iShadow], cameraPosition, lightDirection, shadowmvpmatrix, NULL, 0);
|
pScene->render(&m_camera, shadowVolume, m_pMaterialManager, true, shadowmvpmatrix[iShadow], cameraPosition, lightDirection, shadowmvpmatrix, NULL, 0);
|
||||||
|
|
||||||
glViewport(0, 0, 768, 1024);
|
glViewport(0, 0, 768, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix LightDirection: (Vector3)lightDirection CameraPosition: (Vector3)cameraPosition
|
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix LightDirection: (KRVector3)lightDirection CameraPosition: (KRVector3)cameraPosition
|
||||||
{
|
{
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, compositeFramebuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, compositeFramebuffer);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ KRModel *KRInstance::getModel() {
|
|||||||
return m_pModel;
|
return m_pModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRInstance::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
void KRInstance::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
||||||
|
|
||||||
KRMat4 projectionMatrix;
|
KRMat4 projectionMatrix;
|
||||||
if(!bRenderShadowMap) {
|
if(!bRenderShadowMap) {
|
||||||
@@ -59,8 +59,8 @@ void KRInstance::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager,
|
|||||||
// Transform location of camera to object space for calculation of specular halfVec
|
// Transform location of camera to object space for calculation of specular halfVec
|
||||||
KRMat4 inverseModelMatrix = m_modelMatrix;
|
KRMat4 inverseModelMatrix = m_modelMatrix;
|
||||||
inverseModelMatrix.invert();
|
inverseModelMatrix.invert();
|
||||||
Vector3 cameraPosObject = inverseModelMatrix.dot(cameraPosition);
|
KRVector3 cameraPosObject = inverseModelMatrix.dot(cameraPosition);
|
||||||
Vector3 lightDirObject = inverseModelMatrix.dot(lightDirection);
|
KRVector3 lightDirObject = inverseModelMatrix.dot(lightDirection);
|
||||||
|
|
||||||
m_pModel->render(pCamera, pMaterialManager, bRenderShadowMap, mvpmatrix, cameraPosObject, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers);
|
m_pModel->render(pCamera, pMaterialManager, bRenderShadowMap, mvpmatrix, cameraPosObject, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers);
|
||||||
|
|
||||||
@@ -68,5 +68,5 @@ void KRInstance::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager,
|
|||||||
|
|
||||||
KRBoundingVolume KRInstance::getExtents() {
|
KRBoundingVolume KRInstance::getExtents() {
|
||||||
KRMesh *pMesh = m_pModel->getMesh();
|
KRMesh *pMesh = m_pModel->getMesh();
|
||||||
return KRBoundingVolume(Vector3(pMesh->getMinX(), pMesh->getMinY(), pMesh->getMinZ()), Vector3(pMesh->getMaxX(), pMesh->getMaxY(), pMesh->getMaxZ()), m_modelMatrix);
|
return KRBoundingVolume(KRVector3(pMesh->getMinX(), pMesh->getMinY(), pMesh->getMinZ()), KRVector3(pMesh->getMaxX(), pMesh->getMaxY(), pMesh->getMaxZ()), m_modelMatrix);
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class KRInstance {
|
|||||||
public:
|
public:
|
||||||
KRInstance(KRModel *pModel, const KRMat4 modelMatrix);
|
KRInstance(KRModel *pModel, const KRMat4 modelMatrix);
|
||||||
~KRInstance();
|
~KRInstance();
|
||||||
void render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
void render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
||||||
|
|
||||||
KRBoundingVolume getExtents();
|
KRBoundingVolume getExtents();
|
||||||
|
|
||||||
|
|||||||
@@ -242,8 +242,8 @@ bool KRMat4::invert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Dot Product */
|
/* Dot Product */
|
||||||
Vector3 KRMat4::dot(const Vector3 &v) const {
|
KRVector3 KRMat4::dot(const KRVector3 &v) const {
|
||||||
return Vector3(
|
return KRVector3(
|
||||||
v.x * (float)m_mat[0*4 + 0] + v.y * (float)m_mat[1*4 + 0] + v.z * (float)m_mat[2*4 + 0] + (float)m_mat[3*4 + 0],
|
v.x * (float)m_mat[0*4 + 0] + v.y * (float)m_mat[1*4 + 0] + v.z * (float)m_mat[2*4 + 0] + (float)m_mat[3*4 + 0],
|
||||||
v.x * (float)m_mat[0*4 + 1] + v.y * (float)m_mat[1*4 + 1] + v.z * (float)m_mat[2*4 + 1] + (float)m_mat[3*4 + 1],
|
v.x * (float)m_mat[0*4 + 1] + v.y * (float)m_mat[1*4 + 1] + v.z * (float)m_mat[2*4 + 1] + (float)m_mat[3*4 + 1],
|
||||||
v.x * (float)m_mat[0*4 + 2] + v.y * (float)m_mat[1*4 + 2] + v.z * (float)m_mat[2*4 + 2] + (float)m_mat[3*4 + 2]
|
v.x * (float)m_mat[0*4 + 2] + v.y * (float)m_mat[1*4 + 2] + v.z * (float)m_mat[2*4 + 2] + (float)m_mat[3*4 + 2]
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public:
|
|||||||
void rotate(GLfloat angle, AXIS axis);
|
void rotate(GLfloat angle, AXIS axis);
|
||||||
void bias();
|
void bias();
|
||||||
bool invert();
|
bool invert();
|
||||||
Vector3 dot(const Vector3 &v) const;
|
KRVector3 dot(const KRVector3 &v) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KRMAT4_I
|
#endif // KRMAT4_I
|
||||||
@@ -102,7 +102,7 @@ bool KRMaterial::isTransparent() {
|
|||||||
return m_tr != 0.0;
|
return m_tr != 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRCamera *pCamera, KRMat4 &mvpMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRCamera *pCamera, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
||||||
bool bSameMaterial = *prevBoundMaterial == this;
|
bool bSameMaterial = *prevBoundMaterial == this;
|
||||||
|
|
||||||
bool bDiffuseMap = m_pDiffuseMap != NULL && pCamera->bEnableDiffuseMap;
|
bool bDiffuseMap = m_pDiffuseMap != NULL && pCamera->bEnableDiffuseMap;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
void setTransparency(GLfloat a);
|
void setTransparency(GLfloat a);
|
||||||
void setShininess(GLfloat s);
|
void setShininess(GLfloat s);
|
||||||
|
|
||||||
void bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRCamera *pCamera, KRMat4 &mvpMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
void bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRCamera *pCamera, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
||||||
bool isTransparent();
|
bool isTransparent();
|
||||||
char *getName();
|
char *getName();
|
||||||
|
|
||||||
|
|||||||
@@ -173,9 +173,9 @@ void KRMesh::renderSubmesh(int iSubmesh, int *iPrevBuffer) {
|
|||||||
|
|
||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_NORMAL, 3, GL_FLOAT, 0, sizeof(VertexData), BUFFER_OFFSET(sizeof(Vertex3D)));
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_NORMAL, 3, GL_FLOAT, 0, sizeof(VertexData), BUFFER_OFFSET(sizeof(Vertex3D)));
|
||||||
|
|
||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TANGENT, 3, GL_FLOAT, 0, sizeof(VertexData), BUFFER_OFFSET(sizeof(Vertex3D) + sizeof(Vector3D)));
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TANGENT, 3, GL_FLOAT, 0, sizeof(VertexData), BUFFER_OFFSET(sizeof(Vertex3D) + sizeof(KRVector3D)));
|
||||||
|
|
||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TEXUV, 2, GL_FLOAT, 0, sizeof(VertexData), BUFFER_OFFSET(sizeof(Vertex3D) + sizeof(Vector3D) * 2));
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TEXUV, 2, GL_FLOAT, 0, sizeof(VertexData), BUFFER_OFFSET(sizeof(Vertex3D) + sizeof(KRVector3D) * 2));
|
||||||
|
|
||||||
|
|
||||||
*iPrevBuffer = iBuffer;
|
*iPrevBuffer = iBuffer;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ protected:
|
|||||||
GLfloat x;
|
GLfloat x;
|
||||||
GLfloat y;
|
GLfloat y;
|
||||||
GLfloat z;
|
GLfloat z;
|
||||||
} Vertex3D, Vector3D;
|
} Vertex3D, KRVector3D;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GLfloat u;
|
GLfloat u;
|
||||||
@@ -104,8 +104,8 @@ protected:
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Vertex3D vertex;
|
Vertex3D vertex;
|
||||||
Vector3D normal;
|
KRVector3D normal;
|
||||||
Vector3D tangent;
|
KRVector3D tangent;
|
||||||
TexCoord texcoord;
|
TexCoord texcoord;
|
||||||
} VertexData;
|
} VertexData;
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ KRModel::~KRModel() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRModel::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &mvpMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
void KRModel::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
||||||
KRMaterial *pPrevBoundMaterial = NULL;
|
KRMaterial *pPrevBoundMaterial = NULL;
|
||||||
int iPrevBuffer = -1;
|
int iPrevBuffer = -1;
|
||||||
char szPrevShaderKey[128];
|
char szPrevShaderKey[128];
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
KRModel(std::string path, KRMaterialManager *pMaterialManager);
|
KRModel(std::string path, KRMaterialManager *pMaterialManager);
|
||||||
~KRModel();
|
~KRModel();
|
||||||
|
|
||||||
void render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &mvpMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
void render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
||||||
|
|
||||||
KRMesh *getMesh();
|
KRMesh *getMesh();
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ KRInstance *KRScene::addInstance(KRModel *pModel, KRMat4 modelMatrix) {
|
|||||||
m_instances.push_back(pInstance);
|
m_instances.push_back(pInstance);
|
||||||
return pInstance;
|
return pInstance;
|
||||||
}
|
}
|
||||||
void KRScene::render(KRCamera *pCamera, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
void KRScene::render(KRCamera *pCamera, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
||||||
|
|
||||||
if(cShadowBuffers > 0 && !bRenderShadowMap) {
|
if(cShadowBuffers > 0 && !bRenderShadowMap) {
|
||||||
glActiveTexture(GL_TEXTURE3);
|
glActiveTexture(GL_TEXTURE3);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
KRScene();
|
KRScene();
|
||||||
~KRScene();
|
~KRScene();
|
||||||
KRInstance *addInstance(KRModel *pModel, KRMat4 modelMatrix);
|
KRInstance *addInstance(KRModel *pModel, KRMat4 modelMatrix);
|
||||||
void render(KRCamera *pCamera, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
void render(KRCamera *pCamera, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
||||||
KRBoundingVolume getExtents();
|
KRBoundingVolume getExtents();
|
||||||
private:
|
private:
|
||||||
vector<KRInstance *> m_instances;
|
vector<KRInstance *> m_instances;
|
||||||
|
|||||||
@@ -122,14 +122,14 @@ KRShader::~KRShader() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRShader::bind(KRCamera *pCamera, KRMat4 &mvpMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
void KRShader::bind(KRCamera *pCamera, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers) {
|
||||||
glUseProgram(m_iProgram);
|
glUseProgram(m_iProgram);
|
||||||
|
|
||||||
|
|
||||||
// Bind our modelmatrix variable to be a uniform called mvpmatrix in our shaderprogram
|
// Bind our modelmatrix variable to be a uniform called mvpmatrix in our shaderprogram
|
||||||
glUniformMatrix4fv(m_uniforms[KRENGINE_UNIFORM_MVP], 1, GL_FALSE, mvpMatrix.getPointer());
|
glUniformMatrix4fv(m_uniforms[KRENGINE_UNIFORM_MVP], 1, GL_FALSE, mvpMatrix.getPointer());
|
||||||
|
|
||||||
Vector3 nLightDir = lightDirection;
|
KRVector3 nLightDir = lightDirection;
|
||||||
nLightDir.normalize();
|
nLightDir.normalize();
|
||||||
|
|
||||||
// Bind the light direction vector
|
// Bind the light direction vector
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
GLuint getProgram();
|
GLuint getProgram();
|
||||||
char *getKey();
|
char *getKey();
|
||||||
|
|
||||||
void bind(KRCamera *pCamera, KRMat4 &mvpMatrix, Vector3 &cameraPosition, Vector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
void bind(KRCamera *pCamera, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
KRENGINE_ATTRIB_VERTEX,
|
KRENGINE_ATTRIB_VERTEX,
|
||||||
|
|||||||
@@ -32,27 +32,27 @@
|
|||||||
#include "KRVector3.h"
|
#include "KRVector3.h"
|
||||||
|
|
||||||
//default constructor
|
//default constructor
|
||||||
Vector3::Vector3()
|
KRVector3::KRVector3()
|
||||||
{
|
{
|
||||||
x = 0.0f;
|
x = 0.0f;
|
||||||
y = 0.0f;
|
y = 0.0f;
|
||||||
z = 0.0f;
|
z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3::Vector3(float X = 0, float Y = 0, float Z = 0)
|
KRVector3::KRVector3(float X, float Y, float Z)
|
||||||
{
|
{
|
||||||
x = X;
|
x = X;
|
||||||
y = Y;
|
y = Y;
|
||||||
z = Z;
|
z = Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3::Vector3(const Vector3& p) {
|
KRVector3::KRVector3(const KRVector3& p) {
|
||||||
x = p.x;
|
x = p.x;
|
||||||
y = p.y;
|
y = p.y;
|
||||||
z = p.z;
|
z = p.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3& Vector3::operator = ( const Vector3& p ) {
|
KRVector3& KRVector3::operator = ( const KRVector3& p ) {
|
||||||
x = p.x;
|
x = p.x;
|
||||||
y = p.y;
|
y = p.y;
|
||||||
z = p.z;
|
z = p.z;
|
||||||
@@ -60,44 +60,44 @@ Vector3& Vector3::operator = ( const Vector3& p ) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3::~Vector3()
|
KRVector3::~KRVector3()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//calculate and return the magnitude of this vector
|
//calculate and return the magnitude of this vector
|
||||||
float Vector3::GetMagnitude()
|
float KRVector3::GetMagnitude()
|
||||||
{
|
{
|
||||||
return sqrtf(x * x + y * y + z * z);
|
return sqrtf(x * x + y * y + z * z);
|
||||||
}
|
}
|
||||||
|
|
||||||
//multiply this vector by a scalar
|
//multiply this vector by a scalar
|
||||||
Vector3 Vector3::operator*(float num) const
|
KRVector3 KRVector3::operator*(float num) const
|
||||||
{
|
{
|
||||||
return Vector3(x * num, y * num, z * num);
|
return KRVector3(x * num, y * num, z * num);
|
||||||
}
|
}
|
||||||
|
|
||||||
//pass in a vector, pass in a scalar, return the product
|
//pass in a vector, pass in a scalar, return the product
|
||||||
/*
|
/*
|
||||||
Vector3 Vector3::operator*(float num, Vector3 const &vec)
|
KRVector3 KRVector3::operator*(float num, KRVector3 const &vec)
|
||||||
{
|
{
|
||||||
return Vector3(vec.x * num, vec.y * num, vec.z * num);
|
return KRVector3(vec.x * num, vec.y * num, vec.z * num);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//add two vectors
|
//add two vectors
|
||||||
Vector3 Vector3::operator+(const Vector3 &vec) const
|
KRVector3 KRVector3::operator+(const KRVector3 &vec) const
|
||||||
{
|
{
|
||||||
return Vector3(x + vec.x, y + vec.y, z + vec.z);
|
return KRVector3(x + vec.x, y + vec.y, z + vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
//subtract two vectors
|
//subtract two vectors
|
||||||
Vector3 Vector3::operator-(const Vector3 &vec) const
|
KRVector3 KRVector3::operator-(const KRVector3 &vec) const
|
||||||
{
|
{
|
||||||
return Vector3(x - vec.x, y - vec.y, z - vec.z);
|
return KRVector3(x - vec.x, y - vec.y, z - vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
//normalize this vector
|
//normalize this vector
|
||||||
void Vector3::normalize()
|
void KRVector3::normalize()
|
||||||
{
|
{
|
||||||
float magnitude = sqrtf(x * x + y * y + z * z);
|
float magnitude = sqrtf(x * x + y * y + z * z);
|
||||||
x /= magnitude;
|
x /= magnitude;
|
||||||
@@ -106,15 +106,15 @@ void Vector3::normalize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//calculate and return dot product
|
//calculate and return dot product
|
||||||
float Vector3::dot(const Vector3 &vec) const
|
float KRVector3::dot(const KRVector3 &vec) const
|
||||||
{
|
{
|
||||||
return x * vec.x + y * vec.y + z * vec.z;
|
return x * vec.x + y * vec.y + z * vec.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
//calculate and return cross product
|
//calculate and return cross product
|
||||||
Vector3 Vector3::cross(const Vector3 &vec) const
|
KRVector3 KRVector3::cross(const KRVector3 &vec) const
|
||||||
{
|
{
|
||||||
return Vector3(y * vec.z - z * vec.y,
|
return KRVector3(y * vec.z - z * vec.y,
|
||||||
z * vec.x - x * vec.z,
|
z * vec.x - x * vec.z,
|
||||||
x * vec.y - y * vec.x);
|
x * vec.y - y * vec.x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
#define KRVECTOR3
|
#define KRVECTOR3
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
class Vector3
|
class KRVector3
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -41,37 +41,37 @@ public:
|
|||||||
|
|
||||||
//default constructor
|
//default constructor
|
||||||
|
|
||||||
Vector3(float X, float Y, float Z);
|
KRVector3(float X = 0, float Y = 0, float Z = 0);
|
||||||
Vector3();
|
KRVector3();
|
||||||
~Vector3();
|
~KRVector3();
|
||||||
|
|
||||||
Vector3(const Vector3& p);
|
KRVector3(const KRVector3& p);
|
||||||
Vector3& operator = ( const Vector3& p );
|
KRVector3& operator = ( const KRVector3& p );
|
||||||
|
|
||||||
|
|
||||||
//calculate and return the magnitude of this vector
|
//calculate and return the magnitude of this vector
|
||||||
float GetMagnitude();
|
float GetMagnitude();
|
||||||
|
|
||||||
//multiply this vector by a scalar
|
//multiply this vector by a scalar
|
||||||
Vector3 operator*(float num) const;
|
KRVector3 operator*(float num) const;
|
||||||
|
|
||||||
//pass in a vector, pass in a scalar, return the product
|
//pass in a vector, pass in a scalar, return the product
|
||||||
//friend Vector3 operator*(float num, Vector3 const &vec);
|
//friend KRVector3 operator*(float num, KRVector3 const &vec);
|
||||||
|
|
||||||
//add two vectors
|
//add two vectors
|
||||||
Vector3 operator+(const Vector3 &vec) const;
|
KRVector3 operator+(const KRVector3 &vec) const;
|
||||||
|
|
||||||
//subtract two vectors
|
//subtract two vectors
|
||||||
Vector3 operator-(const Vector3 &vec) const;
|
KRVector3 operator-(const KRVector3 &vec) const;
|
||||||
|
|
||||||
//normalize this vector
|
//normalize this vector
|
||||||
void normalize();
|
void normalize();
|
||||||
|
|
||||||
//calculate and return dot product
|
//calculate and return dot product
|
||||||
float dot(const Vector3 &vec) const;
|
float dot(const KRVector3 &vec) const;
|
||||||
|
|
||||||
//calculate and return cross product
|
//calculate and return cross product
|
||||||
Vector3 cross(const Vector3 &vec) const;
|
KRVector3 cross(const KRVector3 &vec) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0430"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -39,11 +40,12 @@
|
|||||||
</MacroExpansion>
|
</MacroExpansion>
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<BuildableProductRunnable>
|
<BuildableProductRunnable>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
E404C89E136B8E2F00B6C99B /* objpack.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = objpack.1; sourceTree = "<group>"; };
|
E404C89E136B8E2F00B6C99B /* objpack.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = objpack.1; sourceTree = "<group>"; };
|
||||||
E404C8A4136B901400B6C99B /* KROBJPacker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KROBJPacker.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E404C8A4136B901400B6C99B /* KROBJPacker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KROBJPacker.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E404C8A5136B901400B6C99B /* KROBJPacker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KROBJPacker.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E404C8A5136B901400B6C99B /* KROBJPacker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KROBJPacker.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E4BBBBA01512A51200F43B5B /* krengine_osx.framework */ = {isa = PBXFileReference; lastKnownFileType = file; name = krengine_osx.framework; path = ../KREngine/build/Release/krengine_osx.framework; sourceTree = "<group>"; };
|
E4BBBBA01512A51200F43B5B /* krengine_osx.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = krengine_osx.framework; path = ../KREngine/build/Release/krengine_osx.framework; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
E404C88F136B8E2F00B6C99B /* Project object */ = {
|
E404C88F136B8E2F00B6C99B /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastUpgradeCheck = 0420;
|
LastUpgradeCheck = 0430;
|
||||||
ORGANIZATIONNAME = "Kearwood Software";
|
ORGANIZATIONNAME = "Kearwood Software";
|
||||||
};
|
};
|
||||||
buildConfigurationList = E404C892136B8E2F00B6C99B /* Build configuration list for PBXProject "objpack" */;
|
buildConfigurationList = E404C892136B8E2F00B6C99B /* Build configuration list for PBXProject "objpack" */;
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
HEADER_SEARCH_PATHS = /Users/kearwood/Documents/dev/svn/sarofax/tools/krengine/trunk/KREngine/KREngine/Classes;
|
HEADER_SEARCH_PATHS = "";
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
@@ -168,7 +168,7 @@
|
|||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
HEADER_SEARCH_PATHS = /Users/kearwood/Documents/dev/svn/sarofax/tools/krengine/trunk/KREngine/KREngine/Classes;
|
HEADER_SEARCH_PATHS = "";
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <vector.h>
|
#include <vector.h>
|
||||||
|
|
||||||
#include "KROBJPacker.h"
|
#include "KROBJPacker.h"
|
||||||
#import <KRVector3.h>
|
#import <KREngine_osx/KRVector3.h>
|
||||||
|
|
||||||
|
|
||||||
KROBJPacker::KROBJPacker() {
|
KROBJPacker::KROBJPacker() {
|
||||||
@@ -60,7 +60,7 @@ void KROBJPacker::pack(const char *szPath) {
|
|||||||
std::vector<std::string> materials;
|
std::vector<std::string> materials;
|
||||||
|
|
||||||
Vertex3D *pVertices = NULL;
|
Vertex3D *pVertices = NULL;
|
||||||
Vector3D *pNormals = NULL;
|
KRVector3D *pNormals = NULL;
|
||||||
TexCoord *pTexCoords = NULL;
|
TexCoord *pTexCoords = NULL;
|
||||||
int *pFaces = NULL;
|
int *pFaces = NULL;
|
||||||
|
|
||||||
@@ -155,13 +155,13 @@ void KROBJPacker::pack(const char *szPath) {
|
|||||||
cout << " Pass 2 - Populate vertexes and faces\n";
|
cout << " Pass 2 - Populate vertexes and faces\n";
|
||||||
|
|
||||||
Vertex3D *pVertices = (Vertex3D *)malloc(sizeof(Vertex3D) * cVertices);
|
Vertex3D *pVertices = (Vertex3D *)malloc(sizeof(Vertex3D) * cVertices);
|
||||||
Vector3D *pNormals = (Vector3D *)malloc(sizeof(Vector3D) *cNormals);
|
KRVector3D *pNormals = (KRVector3D *)malloc(sizeof(KRVector3D) *cNormals);
|
||||||
TexCoord *pTexCoords = (TexCoord *)malloc(sizeof(TexCoord) * cTexCoords);
|
TexCoord *pTexCoords = (TexCoord *)malloc(sizeof(TexCoord) * cTexCoords);
|
||||||
int *pFaces = (int *)malloc(sizeof(int *) * (cFaces + 1));
|
int *pFaces = (int *)malloc(sizeof(int *) * (cFaces + 1));
|
||||||
|
|
||||||
|
|
||||||
Vertex3D *pVertice = pVertices;
|
Vertex3D *pVertice = pVertices;
|
||||||
Vector3D *pNormal = pNormals;
|
KRVector3D *pNormal = pNormals;
|
||||||
TexCoord *pTexCoord = pTexCoords;
|
TexCoord *pTexCoord = pTexCoords;
|
||||||
int *pFace = pFaces;
|
int *pFace = pFaces;
|
||||||
int *pMaterialFaces = pFace++;
|
int *pMaterialFaces = pFace++;
|
||||||
@@ -332,7 +332,7 @@ void KROBJPacker::pack(const char *szPath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(pFace[iFaceVertex*3+3] >= 0){
|
if(pFace[iFaceVertex*3+3] >= 0){
|
||||||
Vector3D *pNormal = pNormals + pFace[iFaceVertex*3+3];
|
KRVector3D *pNormal = pNormals + pFace[iFaceVertex*3+3];
|
||||||
pData->normal.x = pNormal -> x;
|
pData->normal.x = pNormal -> x;
|
||||||
pData->normal.y = pNormal -> y;
|
pData->normal.y = pNormal -> y;
|
||||||
pData->normal.z = pNormal -> z;
|
pData->normal.z = pNormal -> z;
|
||||||
@@ -386,17 +386,17 @@ void KROBJPacker::pack(const char *szPath) {
|
|||||||
|
|
||||||
|
|
||||||
for(VertexData *pVertex = pStart; pVertex < pEnd; pVertex+=3) {
|
for(VertexData *pVertex = pStart; pVertex < pEnd; pVertex+=3) {
|
||||||
Vector3 p1(pVertex[0].vertex.x, pVertex[0].vertex.y, pVertex[0].vertex.z);
|
KRVector3 p1(pVertex[0].vertex.x, pVertex[0].vertex.y, pVertex[0].vertex.z);
|
||||||
Vector3 p2(pVertex[1].vertex.x, pVertex[1].vertex.y, pVertex[1].vertex.z);
|
KRVector3 p2(pVertex[1].vertex.x, pVertex[1].vertex.y, pVertex[1].vertex.z);
|
||||||
Vector3 p3(pVertex[2].vertex.x, pVertex[2].vertex.y, pVertex[2].vertex.z);
|
KRVector3 p3(pVertex[2].vertex.x, pVertex[2].vertex.y, pVertex[2].vertex.z);
|
||||||
Vector3 v1 = p2 - p1;
|
KRVector3 v1 = p2 - p1;
|
||||||
Vector3 v2 = p3 - p1;
|
KRVector3 v2 = p3 - p1;
|
||||||
|
|
||||||
// -- Calculate normal --
|
// -- Calculate normal --
|
||||||
if(pVertex->normal.x == 0 && pVertex->normal.y == 0 && pVertex->normal.z == 0) {
|
if(pVertex->normal.x == 0 && pVertex->normal.y == 0 && pVertex->normal.z == 0) {
|
||||||
|
|
||||||
|
|
||||||
Vector3 normal = v1.cross( v2 );
|
KRVector3 normal = v1.cross( v2 );
|
||||||
|
|
||||||
normal.normalize();
|
normal.normalize();
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ void KROBJPacker::pack(const char *szPath) {
|
|||||||
pVertex[0].tangent.y = coef * ((v1.y * st2.v) + (v2.y * -st1.v));
|
pVertex[0].tangent.y = coef * ((v1.y * st2.v) + (v2.y * -st1.v));
|
||||||
pVertex[0].tangent.z = coef * ((v1.z * st2.v) + (v2.z * -st1.v));
|
pVertex[0].tangent.z = coef * ((v1.z * st2.v) + (v2.z * -st1.v));
|
||||||
|
|
||||||
Vector3 tangent(
|
KRVector3 tangent(
|
||||||
coef * ((v1.x * st2.v) + (v2.x * -st1.v)),
|
coef * ((v1.x * st2.v) + (v2.x * -st1.v)),
|
||||||
coef * ((v1.y * st2.v) + (v2.y * -st1.v)),
|
coef * ((v1.y * st2.v) + (v2.y * -st1.v)),
|
||||||
coef * ((v1.z * st2.v) + (v2.z * -st1.v))
|
coef * ((v1.z * st2.v) + (v2.z * -st1.v))
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
float z;
|
float z;
|
||||||
} Vertex3D, Vector3D;
|
} Vertex3D, KRVector3D;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float u;
|
float u;
|
||||||
@@ -69,8 +69,8 @@ private:
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Vertex3D vertex;
|
Vertex3D vertex;
|
||||||
Vector3D normal;
|
KRVector3D normal;
|
||||||
Vector3D tangent;
|
KRVector3D tangent;
|
||||||
TexCoord texcoord;
|
TexCoord texcoord;
|
||||||
} VertexData;
|
} VertexData;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
float heading;
|
float heading;
|
||||||
|
|
||||||
Vector3 camera_position;
|
KRVector3 camera_position;
|
||||||
double camera_pitch;
|
double camera_pitch;
|
||||||
double camera_yaw;
|
double camera_yaw;
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@
|
|||||||
bLoadedTestInstances = false;
|
bLoadedTestInstances = false;
|
||||||
cParamDisplayFrames = 0;
|
cParamDisplayFrames = 0;
|
||||||
|
|
||||||
camera_position = Vector3(-850, -10, -700);
|
camera_position = KRVector3(-850, -10, -700);
|
||||||
|
|
||||||
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView:)];
|
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView:)];
|
||||||
[displayLink setFrameInterval:1]; // Maximum 60fps
|
[displayLink setFrameInterval:1]; // Maximum 60fps
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 45;
|
objectVersion = 46;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
@@ -227,8 +227,11 @@
|
|||||||
/* Begin PBXProject section */
|
/* Begin PBXProject section */
|
||||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0430;
|
||||||
|
};
|
||||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "KRObjView" */;
|
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "KRObjView" */;
|
||||||
compatibilityVersion = "Xcode 3.1";
|
compatibilityVersion = "Xcode 3.2";
|
||||||
developmentRegion = English;
|
developmentRegion = English;
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
knownRegions = (
|
knownRegions = (
|
||||||
@@ -337,7 +340,6 @@
|
|||||||
GCC_C_LANGUAGE_STANDARD = c99;
|
GCC_C_LANGUAGE_STANDARD = c99;
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
PREBINDING = NO;
|
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@@ -351,7 +353,6 @@
|
|||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||||
PREBINDING = NO;
|
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
@@ -365,7 +366,6 @@
|
|||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||||
PREBINDING = NO;
|
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
};
|
};
|
||||||
name = "Ad Hoc";
|
name = "Ad Hoc";
|
||||||
|
|||||||
Reference in New Issue
Block a user