Minor code cleanup
Implemented new constructor for KRQuaternion for creating "from - to" rotation quaternions Implemented billboards by adding a "faces_camera" boolean attribute to KRInstance --HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40169
This commit is contained in:
@@ -21,14 +21,13 @@
|
|||||||
E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = E42CB1EB158446940066E0D8 /* KRQuaternion.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = E42CB1EB158446940066E0D8 /* KRQuaternion.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E42CB1F0158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
E42CB1F0158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
||||||
E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
||||||
E431C1B8164DB7B200BE1575 /* volumetric_fog_downsampled.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E431C1B7164DB7B200BE1575 /* volumetric_fog_downsampled.fsh */; };
|
|
||||||
E4324BA416444C0D0043185B /* KRParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BA316444C0D0043185B /* KRParticleSystem.h */; };
|
E4324BA416444C0D0043185B /* KRParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BA316444C0D0043185B /* KRParticleSystem.h */; };
|
||||||
E4324BA516444C0D0043185B /* KRParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BA316444C0D0043185B /* KRParticleSystem.h */; };
|
E4324BA516444C0D0043185B /* KRParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BA316444C0D0043185B /* KRParticleSystem.h */; };
|
||||||
E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BA716444C230043185B /* KRParticleSystem.cpp */; };
|
E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BA716444C230043185B /* KRParticleSystem.cpp */; };
|
||||||
E4324BAB16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */; };
|
E4324BAB16444DEF0043185B /* KRParticleSystemNewtonian.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BAA16444DEF0043185B /* KRParticleSystemNewtonian.h */; };
|
||||||
E4324BAC16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */; };
|
E4324BAC16444DEF0043185B /* KRParticleSystemNewtonian.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BAA16444DEF0043185B /* KRParticleSystemNewtonian.h */; };
|
||||||
E4324BAE16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */; };
|
E4324BAE16444E120043185B /* KRParticleSystemNewtonian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BAD16444E120043185B /* KRParticleSystemNewtonian.cpp */; };
|
||||||
E4324BAF16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */; };
|
E4324BAF16444E120043185B /* KRParticleSystemNewtonian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BAD16444E120043185B /* KRParticleSystemNewtonian.cpp */; };
|
||||||
E4324BB0164458930043185B /* KRParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BA716444C230043185B /* KRParticleSystem.cpp */; };
|
E4324BB0164458930043185B /* KRParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BA716444C230043185B /* KRParticleSystem.cpp */; };
|
||||||
E43B0AD615DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; };
|
E43B0AD615DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; };
|
||||||
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; };
|
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; };
|
||||||
@@ -220,8 +219,8 @@
|
|||||||
E431C1B7164DB7B200BE1575 /* volumetric_fog_downsampled.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = volumetric_fog_downsampled.fsh; path = Shaders/volumetric_fog_downsampled.fsh; sourceTree = "<group>"; };
|
E431C1B7164DB7B200BE1575 /* volumetric_fog_downsampled.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = volumetric_fog_downsampled.fsh; path = Shaders/volumetric_fog_downsampled.fsh; sourceTree = "<group>"; };
|
||||||
E4324BA316444C0D0043185B /* KRParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRParticleSystem.h; path = Classes/KRParticleSystem.h; sourceTree = "<group>"; };
|
E4324BA316444C0D0043185B /* KRParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRParticleSystem.h; path = Classes/KRParticleSystem.h; sourceTree = "<group>"; };
|
||||||
E4324BA716444C230043185B /* KRParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRParticleSystem.cpp; path = Classes/KRParticleSystem.cpp; sourceTree = "<group>"; };
|
E4324BA716444C230043185B /* KRParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRParticleSystem.cpp; path = Classes/KRParticleSystem.cpp; sourceTree = "<group>"; };
|
||||||
E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRParticleSystemBrownian.h; path = Classes/KRParticleSystemBrownian.h; sourceTree = "<group>"; };
|
E4324BAA16444DEF0043185B /* KRParticleSystemNewtonian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRParticleSystemNewtonian.h; path = Classes/KRParticleSystemNewtonian.h; sourceTree = "<group>"; };
|
||||||
E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRParticleSystemBrownian.cpp; path = Classes/KRParticleSystemBrownian.cpp; sourceTree = "<group>"; };
|
E4324BAD16444E120043185B /* KRParticleSystemNewtonian.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRParticleSystemNewtonian.cpp; path = Classes/KRParticleSystemNewtonian.cpp; sourceTree = "<group>"; };
|
||||||
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRContextObject.cpp; path = Classes/KRContextObject.cpp; sourceTree = "<group>"; };
|
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRContextObject.cpp; path = Classes/KRContextObject.cpp; sourceTree = "<group>"; };
|
||||||
E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRContextObject.h; path = Classes/KRContextObject.h; sourceTree = "<group>"; };
|
E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRContextObject.h; path = Classes/KRContextObject.h; sourceTree = "<group>"; };
|
||||||
E443C612164B5BE500FC4FD8 /* volumetric_fog.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = volumetric_fog.fsh; path = Shaders/volumetric_fog.fsh; sourceTree = "<group>"; };
|
E443C612164B5BE500FC4FD8 /* volumetric_fog.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = volumetric_fog.fsh; path = Shaders/volumetric_fog.fsh; sourceTree = "<group>"; };
|
||||||
@@ -236,8 +235,8 @@
|
|||||||
E45AC0331641D67300DC3C3B /* simple_blit.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = simple_blit.fsh; path = Shaders/simple_blit.fsh; sourceTree = "<group>"; };
|
E45AC0331641D67300DC3C3B /* simple_blit.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = simple_blit.fsh; path = Shaders/simple_blit.fsh; sourceTree = "<group>"; };
|
||||||
E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = debug_font.vsh; path = Shaders/debug_font.vsh; sourceTree = "<group>"; };
|
E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = debug_font.vsh; path = Shaders/debug_font.vsh; sourceTree = "<group>"; };
|
||||||
E45AC0411641DE6D00DC3C3B /* debug_font.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = debug_font.fsh; path = Shaders/debug_font.fsh; sourceTree = "<group>"; };
|
E45AC0411641DE6D00DC3C3B /* debug_font.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = debug_font.fsh; path = Shaders/debug_font.fsh; sourceTree = "<group>"; };
|
||||||
E45AC0461643451200DC3C3B /* particle.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = particle.fsh; path = Shaders/particle.fsh; sourceTree = "<group>"; };
|
E45AC0461643451200DC3C3B /* dust_particle.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = dust_particle.fsh; path = Shaders/dust_particle.fsh; sourceTree = "<group>"; };
|
||||||
E45AC0491643452000DC3C3B /* particle.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = particle.vsh; path = Shaders/particle.vsh; sourceTree = "<group>"; };
|
E45AC0491643452000DC3C3B /* dust_particle.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = dust_particle.vsh; path = Shaders/dust_particle.vsh; sourceTree = "<group>"; };
|
||||||
E461A151152E54B500F2044A /* KRLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRLight.h; path = Classes/KRLight.h; 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; lineEnding = 0; name = KRLight.cpp; path = Classes/KRLight.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E461A155152E54F700F2044A /* KRLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRLight.cpp; path = Classes/KRLight.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E461A157152E555400F2044A /* KRPointLight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRPointLight.h; path = Classes/KRPointLight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E461A157152E555400F2044A /* KRPointLight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRPointLight.h; path = Classes/KRPointLight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
@@ -378,8 +377,8 @@
|
|||||||
children = (
|
children = (
|
||||||
E4324BA316444C0D0043185B /* KRParticleSystem.h */,
|
E4324BA316444C0D0043185B /* KRParticleSystem.h */,
|
||||||
E4324BA716444C230043185B /* KRParticleSystem.cpp */,
|
E4324BA716444C230043185B /* KRParticleSystem.cpp */,
|
||||||
E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */,
|
E4324BAA16444DEF0043185B /* KRParticleSystemNewtonian.h */,
|
||||||
E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */,
|
E4324BAD16444E120043185B /* KRParticleSystemNewtonian.cpp */,
|
||||||
);
|
);
|
||||||
name = "Particle Systems";
|
name = "Particle Systems";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -411,8 +410,8 @@
|
|||||||
E45AC0331641D67300DC3C3B /* simple_blit.fsh */,
|
E45AC0331641D67300DC3C3B /* simple_blit.fsh */,
|
||||||
E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */,
|
E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */,
|
||||||
E45AC0411641DE6D00DC3C3B /* debug_font.fsh */,
|
E45AC0411641DE6D00DC3C3B /* debug_font.fsh */,
|
||||||
E45AC0461643451200DC3C3B /* particle.fsh */,
|
E45AC0461643451200DC3C3B /* dust_particle.fsh */,
|
||||||
E45AC0491643452000DC3C3B /* particle.vsh */,
|
E45AC0491643452000DC3C3B /* dust_particle.vsh */,
|
||||||
E443C612164B5BE500FC4FD8 /* volumetric_fog.fsh */,
|
E443C612164B5BE500FC4FD8 /* volumetric_fog.fsh */,
|
||||||
E443C615164B5BFB00FC4FD8 /* volumetric_fog.vsh */,
|
E443C615164B5BFB00FC4FD8 /* volumetric_fog.vsh */,
|
||||||
E431C1B6164DB79A00BE1575 /* volumetric_fog_downsampled.vsh */,
|
E431C1B6164DB79A00BE1575 /* volumetric_fog_downsampled.vsh */,
|
||||||
@@ -754,7 +753,7 @@
|
|||||||
E4CA10EC1637BD47005D9400 /* KRTextureTGA.h in Headers */,
|
E4CA10EC1637BD47005D9400 /* KRTextureTGA.h in Headers */,
|
||||||
E4CA11741639CBD6005D9400 /* KRViewport.h in Headers */,
|
E4CA11741639CBD6005D9400 /* KRViewport.h in Headers */,
|
||||||
E4324BA416444C0D0043185B /* KRParticleSystem.h in Headers */,
|
E4324BA416444C0D0043185B /* KRParticleSystem.h in Headers */,
|
||||||
E4324BAB16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */,
|
E4324BAB16444DEF0043185B /* KRParticleSystemNewtonian.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -807,7 +806,7 @@
|
|||||||
E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
||||||
E461A169152E570700F2044A /* KRSpotLight.h in Headers */,
|
E461A169152E570700F2044A /* KRSpotLight.h in Headers */,
|
||||||
E4324BA516444C0D0043185B /* KRParticleSystem.h in Headers */,
|
E4324BA516444C0D0043185B /* KRParticleSystem.h in Headers */,
|
||||||
E4324BAC16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */,
|
E4324BAC16444DEF0043185B /* KRParticleSystemNewtonian.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -933,8 +932,7 @@
|
|||||||
E4CA10EF1637BD58005D9400 /* KRTextureTGA.cpp in Sources */,
|
E4CA10EF1637BD58005D9400 /* KRTextureTGA.cpp in Sources */,
|
||||||
E4CA11781639CC90005D9400 /* KRViewport.cpp in Sources */,
|
E4CA11781639CC90005D9400 /* KRViewport.cpp in Sources */,
|
||||||
E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */,
|
E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */,
|
||||||
E4324BAE16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */,
|
E4324BAE16444E120043185B /* KRParticleSystemNewtonian.cpp in Sources */,
|
||||||
E431C1B8164DB7B200BE1575 /* volumetric_fog_downsampled.fsh in Sources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -982,7 +980,7 @@
|
|||||||
E4CA10EA1637BD2B005D9400 /* KRTexturePVR.cpp in Sources */,
|
E4CA10EA1637BD2B005D9400 /* KRTexturePVR.cpp in Sources */,
|
||||||
E4CA10F01637BD58005D9400 /* KRTextureTGA.cpp in Sources */,
|
E4CA10F01637BD58005D9400 /* KRTextureTGA.cpp in Sources */,
|
||||||
E4CA11791639CC90005D9400 /* KRViewport.cpp in Sources */,
|
E4CA11791639CC90005D9400 /* KRViewport.cpp in Sources */,
|
||||||
E4324BAF16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */,
|
E4324BAF16444E120043185B /* KRParticleSystemNewtonian.cpp in Sources */,
|
||||||
E4324BB0164458930043185B /* KRParticleSystem.cpp in Sources */,
|
E4324BB0164458930043185B /* KRParticleSystem.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
@@ -223,3 +223,10 @@ float KRAABB::coverage(const KRMat4 &matVP, const KRVector2 viewportSize) const
|
|||||||
return (screen_max.x - screen_min.x) * (screen_max.y - screen_min.y);
|
return (screen_max.x - screen_min.x) * (screen_max.y - screen_min.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float KRAABB::longest_radius() const
|
||||||
|
{
|
||||||
|
float radius1 = (center() - min).magnitude();
|
||||||
|
float radius2 = (max - center()).magnitude();
|
||||||
|
return radius1 > radius2 ? radius1 : radius2;
|
||||||
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public:
|
|||||||
|
|
||||||
static KRAABB Infinite();
|
static KRAABB Infinite();
|
||||||
float coverage(const KRMat4 &matVP, const KRVector2 viewportSize) const;
|
float coverage(const KRMat4 &matVP, const KRVector2 viewportSize) const;
|
||||||
|
float longest_radius() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,14 +33,16 @@
|
|||||||
#import "KRInstance.h"
|
#import "KRInstance.h"
|
||||||
#import "KRContext.h"
|
#import "KRContext.h"
|
||||||
#import "KRModel.h"
|
#import "KRModel.h"
|
||||||
|
#import "KRQuaternion.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
KRInstance::KRInstance(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow) : KRNode(scene, instance_name) {
|
KRInstance::KRInstance(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow, bool faces_camera) : KRNode(scene, instance_name) {
|
||||||
m_lightMap = light_map;
|
m_lightMap = light_map;
|
||||||
m_pLightMap = NULL;
|
m_pLightMap = NULL;
|
||||||
m_model_name = model_name;
|
m_model_name = model_name;
|
||||||
m_min_lod_coverage = lod_min_coverage;
|
m_min_lod_coverage = lod_min_coverage;
|
||||||
m_receivesShadow = receives_shadow;
|
m_receivesShadow = receives_shadow;
|
||||||
|
m_faces_camera = faces_camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRInstance::~KRInstance() {
|
KRInstance::~KRInstance() {
|
||||||
@@ -58,6 +60,7 @@ tinyxml2::XMLElement *KRInstance::saveXML( tinyxml2::XMLNode *parent)
|
|||||||
e->SetAttribute("light_map", m_lightMap.c_str());
|
e->SetAttribute("light_map", m_lightMap.c_str());
|
||||||
e->SetAttribute("lod_min_coverage", m_min_lod_coverage);
|
e->SetAttribute("lod_min_coverage", m_min_lod_coverage);
|
||||||
e->SetAttribute("receives_shadow", m_receivesShadow ? "true" : "false");
|
e->SetAttribute("receives_shadow", m_receivesShadow ? "true" : "false");
|
||||||
|
e->SetAttribute("faces_camera", m_faces_camera ? "true" : "false");
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,9 +70,6 @@ void KRInstance::loadModel() {
|
|||||||
if(m_models.size() > 0) {
|
if(m_models.size() > 0) {
|
||||||
getScene().notify_sceneGraphModify(this);
|
getScene().notify_sceneGraphModify(this);
|
||||||
}
|
}
|
||||||
// if(m_pModel == NULL) {
|
|
||||||
// fprintf(stderr, "KREngine - Model not found: %s\n", m_model_name.c_str());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,14 @@ void KRInstance::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const
|
|||||||
m_pContext->getTextureManager()->selectTexture(5, m_pLightMap);
|
m_pContext->getTextureManager()->selectTexture(5, m_pLightMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
pModel->render(pCamera, lights, viewport, getModelMatrix(), m_pLightMap, renderPass);
|
KRMat4 matModel = getModelMatrix();
|
||||||
|
if(m_faces_camera) {
|
||||||
|
KRVector3 model_center = KRMat4::Dot(matModel, KRVector3::Zero());
|
||||||
|
KRVector3 camera_pos = viewport.getCameraPosition();
|
||||||
|
matModel = KRQuaternion(KRVector3::Forward(), KRVector3::Normalize(camera_pos - model_center)).rotationMatrix() * matModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
pModel->render(pCamera, lights, viewport, matModel, m_pLightMap, renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,7 +136,13 @@ bool KRInstance::hasTransparency() {
|
|||||||
KRAABB KRInstance::getBounds() {
|
KRAABB KRInstance::getBounds() {
|
||||||
loadModel();
|
loadModel();
|
||||||
if(m_models.size() > 0) {
|
if(m_models.size() > 0) {
|
||||||
|
if(m_faces_camera) {
|
||||||
|
KRAABB normal_bounds = KRAABB(m_models[0]->getMinPoint(), m_models[0]->getMaxPoint(), getModelMatrix());
|
||||||
|
float max_dimension = normal_bounds.longest_radius();
|
||||||
|
return KRAABB(normal_bounds.center()-KRVector3(max_dimension), normal_bounds.center() + KRVector3(max_dimension));
|
||||||
|
} else {
|
||||||
return KRAABB(m_models[0]->getMinPoint(), m_models[0]->getMaxPoint(), getModelMatrix());
|
return KRAABB(m_models[0]->getMinPoint(), m_models[0]->getMaxPoint(), getModelMatrix());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return KRAABB::Infinite();
|
return KRAABB::Infinite();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
class KRInstance : public KRNode {
|
class KRInstance : public KRNode {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KRInstance(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow);
|
KRInstance(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow, bool faces_camera);
|
||||||
virtual ~KRInstance();
|
virtual ~KRInstance();
|
||||||
|
|
||||||
virtual std::string getElementName();
|
virtual std::string getElementName();
|
||||||
@@ -77,6 +77,7 @@ private:
|
|||||||
void loadModel();
|
void loadModel();
|
||||||
|
|
||||||
bool m_receivesShadow;
|
bool m_receivesShadow;
|
||||||
|
bool m_faces_camera;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KR
|
|||||||
std::vector<KRLight *> this_light;
|
std::vector<KRLight *> this_light;
|
||||||
this_light.push_back(this);
|
this_light.push_back(this);
|
||||||
|
|
||||||
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("particle", pCamera, this_light, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, this_light, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_light, renderPass)) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_light, renderPass)) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#import "KRDirectionalLight.h"
|
#import "KRDirectionalLight.h"
|
||||||
#import "KRInstance.h"
|
#import "KRInstance.h"
|
||||||
#import "KRParticleSystem.h"
|
#import "KRParticleSystem.h"
|
||||||
#import "KRParticleSystemBrownian.h"
|
#import "KRParticleSystemNewtonian.h"
|
||||||
#import "KRAABB.h"
|
#import "KRAABB.h"
|
||||||
#import "KRQuaternion.h"
|
#import "KRQuaternion.h"
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ tinyxml2::XMLElement *KRNode::saveXML(tinyxml2::XMLNode *parent) {
|
|||||||
tinyxml2::XMLElement *e = doc->NewElement(getElementName().c_str());
|
tinyxml2::XMLElement *e = doc->NewElement(getElementName().c_str());
|
||||||
tinyxml2::XMLNode *n = parent->InsertEndChild(e);
|
tinyxml2::XMLNode *n = parent->InsertEndChild(e);
|
||||||
e->SetAttribute("name", m_name.c_str());
|
e->SetAttribute("name", m_name.c_str());
|
||||||
e->SetAttribute("translate_x", m_localTranslation.x);
|
e->SetAttribute("translate_x", m_localTranslation.x); // TODO - Increase number of digits after the decimal in floating point format (6 -> 12?)
|
||||||
e->SetAttribute("translate_y", m_localTranslation.y);
|
e->SetAttribute("translate_y", m_localTranslation.y);
|
||||||
e->SetAttribute("translate_z", m_localTranslation.z);
|
e->SetAttribute("translate_z", m_localTranslation.z);
|
||||||
e->SetAttribute("scale_x", m_localScale.x);
|
e->SetAttribute("scale_x", m_localScale.x);
|
||||||
@@ -145,8 +145,8 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
|
|||||||
new_node = new KRDirectionalLight(scene, szName);
|
new_node = new KRDirectionalLight(scene, szName);
|
||||||
} else if(strcmp(szElementName, "spot_light") == 0) {
|
} else if(strcmp(szElementName, "spot_light") == 0) {
|
||||||
new_node = new KRSpotLight(scene, szName);
|
new_node = new KRSpotLight(scene, szName);
|
||||||
} else if(strcmp(szElementName, "brownian_particles") == 0) {
|
} else if(strcmp(szElementName, "particles_newtonian") == 0) {
|
||||||
new_node = new KRParticleSystemBrownian(scene, szName);
|
new_node = new KRParticleSystemNewtonian(scene, szName);
|
||||||
} else if(strcmp(szElementName, "mesh") == 0) {
|
} else if(strcmp(szElementName, "mesh") == 0) {
|
||||||
float lod_min_coverage = 0.0f;
|
float lod_min_coverage = 0.0f;
|
||||||
if(e->QueryFloatAttribute("lod_min_coverage", &lod_min_coverage) != tinyxml2::XML_SUCCESS) {
|
if(e->QueryFloatAttribute("lod_min_coverage", &lod_min_coverage) != tinyxml2::XML_SUCCESS) {
|
||||||
@@ -156,7 +156,11 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
|
|||||||
if(e->QueryBoolAttribute("receives_shadow", &receives_shadow) != tinyxml2::XML_SUCCESS) {
|
if(e->QueryBoolAttribute("receives_shadow", &receives_shadow) != tinyxml2::XML_SUCCESS) {
|
||||||
receives_shadow = true;
|
receives_shadow = true;
|
||||||
}
|
}
|
||||||
new_node = new KRInstance(scene, szName, szName, e->Attribute("light_map"), lod_min_coverage, receives_shadow);
|
bool faces_camera = false;
|
||||||
|
if(e->QueryBoolAttribute("faces_camera", &faces_camera) != tinyxml2::XML_SUCCESS) {
|
||||||
|
faces_camera = false;
|
||||||
|
}
|
||||||
|
new_node = new KRInstance(scene, szName, szName, e->Attribute("light_map"), lod_min_coverage, receives_shadow, faces_camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(new_node) {
|
if(new_node) {
|
||||||
@@ -203,14 +207,24 @@ const KRMat4 &KRNode::getModelMatrix()
|
|||||||
{
|
{
|
||||||
|
|
||||||
if(!m_modelMatrixValid) {
|
if(!m_modelMatrixValid) {
|
||||||
if(m_parentNode) {
|
|
||||||
m_modelMatrix = m_parentNode->getModelMatrix();
|
|
||||||
} else {
|
|
||||||
m_modelMatrix = KRMat4();
|
m_modelMatrix = KRMat4();
|
||||||
|
if(m_parentNode) {
|
||||||
|
m_modelMatrix *= m_parentNode->getModelMatrix();
|
||||||
}
|
}
|
||||||
m_modelMatrix.scale(m_localScale);
|
|
||||||
m_modelMatrix.rotate(KRQuaternion(m_localRotation));
|
|
||||||
m_modelMatrix.translate(m_localTranslation);
|
m_modelMatrix.translate(m_localTranslation);
|
||||||
|
m_modelMatrix.rotate(KRQuaternion(m_localRotation));
|
||||||
|
m_modelMatrix.scale(m_localScale);
|
||||||
|
|
||||||
|
// m_modelMatrix = KRMat4();
|
||||||
|
//
|
||||||
|
// m_modelMatrix.scale(m_localScale);
|
||||||
|
// m_modelMatrix.rotate(KRQuaternion(m_localRotation));
|
||||||
|
// m_modelMatrix.translate(m_localTranslation);
|
||||||
|
//
|
||||||
|
// if(m_parentNode) {
|
||||||
|
// m_modelMatrix *= m_parentNode->getModelMatrix();
|
||||||
|
// }
|
||||||
|
|
||||||
m_modelMatrixValid = true;
|
m_modelMatrixValid = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
//
|
//
|
||||||
// KRParticleSystemBrownian.cpp
|
// KRParticleSystemNewtonian.cpp
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Created by Kearwood Gilbert on 2012-11-02.
|
// Created by Kearwood Gilbert on 2012-11-02.
|
||||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "KRParticleSystemBrownian.h"
|
#include "KRParticleSystemNewtonian.h"
|
||||||
#include "KRAABB.h"
|
#include "KRAABB.h"
|
||||||
#include "KRTexture.h"
|
#include "KRTexture.h"
|
||||||
#include "KRContext.h"
|
#include "KRContext.h"
|
||||||
|
|
||||||
KRParticleSystemBrownian::KRParticleSystemBrownian(KRScene &scene, std::string name) : KRParticleSystem(scene, name)
|
KRParticleSystemNewtonian::KRParticleSystemNewtonian(KRScene &scene, std::string name) : KRParticleSystem(scene, name)
|
||||||
{
|
{
|
||||||
m_particlesAbsoluteTime = 0.0f;
|
m_particlesAbsoluteTime = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRParticleSystemBrownian::~KRParticleSystemBrownian()
|
KRParticleSystemNewtonian::~KRParticleSystemNewtonian()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string KRParticleSystemBrownian::getElementName()
|
std::string KRParticleSystemNewtonian::getElementName()
|
||||||
{
|
{
|
||||||
return "brownian_particles";
|
return "newtonian_particles";
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRParticleSystemBrownian::loadXML(tinyxml2::XMLElement *e)
|
void KRParticleSystemNewtonian::loadXML(tinyxml2::XMLElement *e)
|
||||||
{
|
{
|
||||||
KRParticleSystem::loadXML(e);
|
KRParticleSystem::loadXML(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyxml2::XMLElement *KRParticleSystemBrownian::saveXML( tinyxml2::XMLNode *parent)
|
tinyxml2::XMLElement *KRParticleSystemNewtonian::saveXML( tinyxml2::XMLNode *parent)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLElement *e = KRParticleSystem::saveXML(parent);
|
tinyxml2::XMLElement *e = KRParticleSystem::saveXML(parent);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KRAABB KRParticleSystemBrownian::getBounds()
|
KRAABB KRParticleSystemNewtonian::getBounds()
|
||||||
{
|
{
|
||||||
return KRAABB(-KRVector3::One(), KRVector3::One(), getModelMatrix());
|
return KRAABB(-KRVector3::One(), KRVector3::One(), getModelMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRParticleSystemBrownian::physicsUpdate(float deltaTime)
|
void KRParticleSystemNewtonian::physicsUpdate(float deltaTime)
|
||||||
{
|
{
|
||||||
KRParticleSystem::physicsUpdate(deltaTime);
|
KRParticleSystem::physicsUpdate(deltaTime);
|
||||||
m_particlesAbsoluteTime += deltaTime;
|
m_particlesAbsoluteTime += deltaTime;
|
||||||
@@ -52,7 +52,7 @@ void KRParticleSystemBrownian::physicsUpdate(float deltaTime)
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
void KRParticleSystemBrownian::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
|
|
||||||
KRNode::render(pCamera, lights, viewport, renderPass);
|
KRNode::render(pCamera, lights, viewport, renderPass);
|
||||||
@@ -71,7 +71,7 @@ void KRParticleSystemBrownian::render(KRCamera *pCamera, std::vector<KRLight *>
|
|||||||
|
|
||||||
int particle_count = 10000;
|
int particle_count = 10000;
|
||||||
|
|
||||||
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("particle", pCamera, lights, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, lights, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), lights, renderPass)) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), lights, renderPass)) {
|
||||||
GLDEBUG(glUniform1f(
|
GLDEBUG(glUniform1f(
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
//
|
//
|
||||||
// KRParticleSystemBrownian.h
|
// KRParticleSystemNewtonian.h
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Created by Kearwood Gilbert on 2012-11-02.
|
// Created by Kearwood Gilbert on 2012-11-02.
|
||||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef KRPARTICLESYSTEMBROWNIAN_H
|
#ifndef KRPARTICLESYSTEMNEWTONIAN_H
|
||||||
#define KRPARTICLESYSTEMBROWNIAN_H
|
#define KRPARTICLESYSTEMNEWTONIAN_H
|
||||||
|
|
||||||
#import "KRParticleSystem.h"
|
#import "KRParticleSystem.h"
|
||||||
|
|
||||||
class KRParticleSystemBrownian : public KRParticleSystem {
|
class KRParticleSystemNewtonian : public KRParticleSystem {
|
||||||
public:
|
public:
|
||||||
KRParticleSystemBrownian(KRScene &scene, std::string name);
|
KRParticleSystemNewtonian(KRScene &scene, std::string name);
|
||||||
virtual ~KRParticleSystemBrownian();
|
virtual ~KRParticleSystemNewtonian();
|
||||||
|
|
||||||
virtual std::string getElementName();
|
virtual std::string getElementName();
|
||||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
@@ -65,6 +65,16 @@ KRQuaternion::KRQuaternion(const KRVector3 &euler) {
|
|||||||
setEuler(euler);
|
setEuler(euler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRQuaternion::KRQuaternion(const KRVector3 &from_vector, const KRVector3 &to_vector) {
|
||||||
|
|
||||||
|
KRVector3 a = KRVector3::Cross(from_vector, to_vector);
|
||||||
|
m_val[0] = a[0];
|
||||||
|
m_val[1] = a[1];
|
||||||
|
m_val[2] = a[2];
|
||||||
|
m_val[3] = sqrt(from_vector.sqrMagnitude() * to_vector.sqrMagnitude()) + KRVector3::Dot(from_vector, to_vector);
|
||||||
|
normalize();
|
||||||
|
}
|
||||||
|
|
||||||
KRQuaternion::~KRQuaternion() {
|
KRQuaternion::~KRQuaternion() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public:
|
|||||||
KRQuaternion(float w, float x, float y, float z);
|
KRQuaternion(float w, float x, float y, float z);
|
||||||
KRQuaternion(const KRQuaternion& p);
|
KRQuaternion(const KRQuaternion& p);
|
||||||
KRQuaternion(const KRVector3 &euler);
|
KRQuaternion(const KRVector3 &euler);
|
||||||
|
KRQuaternion(const KRVector3 &from_vector, const KRVector3 &to_vector);
|
||||||
~KRQuaternion();
|
~KRQuaternion();
|
||||||
|
|
||||||
KRQuaternion& operator =( const KRQuaternion& p );
|
KRQuaternion& operator =( const KRQuaternion& p );
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "KRSpotLight.h"
|
#include "KRSpotLight.h"
|
||||||
#include "KRNode.h"
|
#include "KRNode.h"
|
||||||
#include "KRScene.h"
|
#include "KRScene.h"
|
||||||
|
#include "KRQuaternion.h"
|
||||||
|
|
||||||
#ifdef IOS_REF
|
#ifdef IOS_REF
|
||||||
#undef IOS_REF
|
#undef IOS_REF
|
||||||
@@ -40,11 +41,15 @@ void InitializeSdkObjects(KFbxSdkManager*& pSdkManager, KFbxScene*& pScene);
|
|||||||
void DestroySdkObjects(KFbxSdkManager* pSdkManager);
|
void DestroySdkObjects(KFbxSdkManager* pSdkManager);
|
||||||
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename);
|
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename);
|
||||||
void LoadNode(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
void LoadNode(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
||||||
|
void BakeNode(KFbxNode* pNode);
|
||||||
KRNode *LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
KRNode *LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
||||||
KRNode *LoadLight(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode);
|
KRNode *LoadLight(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode);
|
||||||
|
|
||||||
|
const float KRAKEN_FBX_ANIMATION_FRAMERATE = 30.0f; // FINDME - This should be configurable
|
||||||
|
|
||||||
std::vector<KRResource *> KRResource::LoadFbx(KRContext &context, const std::string& path)
|
std::vector<KRResource *> KRResource::LoadFbx(KRContext &context, const std::string& path)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<KRResource *> resources;
|
std::vector<KRResource *> resources;
|
||||||
KRScene *pScene = new KRScene(context, KRResource::GetFileBase(path));
|
KRScene *pScene = new KRScene(context, KRResource::GetFileBase(path));
|
||||||
resources.push_back(pScene);
|
resources.push_back(pScene);
|
||||||
@@ -163,8 +168,12 @@ bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pF
|
|||||||
|
|
||||||
printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision);
|
printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision);
|
||||||
|
|
||||||
if (lImporter->IsFBX())
|
if(!lImporter->IsFBX()) {
|
||||||
{
|
printf("ERROR Unrecognized FBX File\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision);
|
printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision);
|
||||||
|
|
||||||
// From this point, it is possible to access animation stack information without
|
// From this point, it is possible to access animation stack information without
|
||||||
@@ -205,7 +214,6 @@ bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pF
|
|||||||
IOS_REF.SetBoolProp(IMP_FBX_GOBO, true);
|
IOS_REF.SetBoolProp(IMP_FBX_GOBO, true);
|
||||||
IOS_REF.SetBoolProp(IMP_FBX_ANIMATION, true);
|
IOS_REF.SetBoolProp(IMP_FBX_ANIMATION, true);
|
||||||
IOS_REF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true);
|
IOS_REF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true);
|
||||||
}
|
|
||||||
|
|
||||||
// Import the scene.
|
// Import the scene.
|
||||||
lStatus = lImporter->Import(pScene);
|
lStatus = lImporter->Import(pScene);
|
||||||
@@ -230,24 +238,110 @@ bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----====---- Start: Bake pivots into transforms, as Kraken doesn't support them directly ----====----
|
||||||
|
|
||||||
|
printf("Baking pivots...\n");
|
||||||
|
KFbxNode* pNode = ((KFbxScene*)pScene)->GetRootNode();
|
||||||
|
// BakeNode(pNode);
|
||||||
|
|
||||||
|
for(i = 0; i < lAnimStackCount; i++)
|
||||||
|
{
|
||||||
|
KFbxTakeInfo* lTakeInfo = lImporter->GetTakeInfo(i);
|
||||||
|
|
||||||
|
printf(" Animation: \"%s\"\n", lTakeInfo->mName.Buffer());
|
||||||
|
// pNode->ConvertPivotAnimationRecursive(lTakeInfo->mName.Buffer(), KFbxNode::eDESTINATION_SET, KRAKEN_FBX_ANIMATION_FRAMERATE);
|
||||||
|
pNode->ResetPivotSetAndConvertAnimation();
|
||||||
|
pNode->UpdatePropertiesFromPivotsAndLimits();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----====---- End: Bake pivots into transforms, as Kraken doesn't support them directly ----====----
|
||||||
|
|
||||||
// Destroy the importer.
|
// Destroy the importer.
|
||||||
lImporter->Destroy();
|
lImporter->Destroy();
|
||||||
|
|
||||||
return lStatus;
|
return lStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BakeNode(KFbxNode *pNode) {
|
||||||
|
pNode->SetPivotState(KFbxNode::eSOURCE_SET, KFbxNode::ePIVOT_STATE_ACTIVE);
|
||||||
|
pNode->SetPivotState(KFbxNode::eDESTINATION_SET, KFbxNode::ePIVOT_STATE_ACTIVE);
|
||||||
|
|
||||||
|
// Pass the current value to the source pivot.
|
||||||
|
// * - Rotation offset (Roff)
|
||||||
|
// * - Rotation pivot (Rp)
|
||||||
|
// * - Pre-rotation (Rpre)
|
||||||
|
// * - Post-rotation (Rpost)
|
||||||
|
// * - Scaling offset (Soff)
|
||||||
|
// * - Scaling pivot (Sp)
|
||||||
|
// * - Geometric translation (Gt)
|
||||||
|
// * - Geometric rotation (Gr)
|
||||||
|
// * - Geometric scaling (Gs)
|
||||||
|
pNode->SetPostRotation(KFbxNode::eSOURCE_SET, pNode->PostRotation.Get());
|
||||||
|
pNode->SetPreRotation(KFbxNode::eSOURCE_SET, pNode->PreRotation.Get());
|
||||||
|
pNode->SetRotationOffset(KFbxNode::eSOURCE_SET, pNode->RotationOffset.Get());
|
||||||
|
pNode->SetScalingOffset(KFbxNode::eSOURCE_SET, pNode->ScalingOffset.Get());
|
||||||
|
pNode->SetRotationPivot(KFbxNode::eSOURCE_SET, pNode->RotationPivot.Get());
|
||||||
|
pNode->SetScalingPivot(KFbxNode::eSOURCE_SET, pNode->ScalingPivot.Get());
|
||||||
|
pNode->SetGeometricRotation(KFbxNode::eSOURCE_SET, pNode->GeometricRotation.Get());
|
||||||
|
pNode->SetGeometricTranslation(KFbxNode::eSOURCE_SET, pNode->GeometricTranslation.Get());
|
||||||
|
pNode->SetGeometricScaling(KFbxNode::eSOURCE_SET, pNode->GeometricScaling.Get());
|
||||||
|
pNode->SetRotationOrder(KFbxNode::eSOURCE_SET, pNode->RotationOrder.Get());
|
||||||
|
|
||||||
|
// We want to set all these to 0 and bake them into the transforms.
|
||||||
|
KFbxVector4 lZero(0, 0, 0);
|
||||||
|
KFbxVector4 lOne(1.0, 1.0, 1.0);
|
||||||
|
pNode->SetPostRotation(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetPreRotation(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetRotationOffset(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetScalingOffset(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetRotationPivot(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetScalingPivot(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetGeometricRotation(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetGeometricTranslation(KFbxNode::eDESTINATION_SET, lZero);
|
||||||
|
pNode->SetGeometricScaling(KFbxNode::eDESTINATION_SET, lOne);
|
||||||
|
pNode->SetRotationOrder(KFbxNode::eDESTINATION_SET, eEULER_XYZ);
|
||||||
|
|
||||||
|
// Bake child nodes
|
||||||
|
for(int i = 0; i < pNode->GetChildCount(); i++)
|
||||||
|
{
|
||||||
|
BakeNode(pNode->GetChild(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LoadNode(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
void LoadNode(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
||||||
KFbxVector4 lTmpVector;
|
KFbxVector4 lTmpVector;
|
||||||
|
pNode->UpdatePropertiesFromPivotsAndLimits();
|
||||||
|
// Transform = T * Roff * Rp * Rpre * R * Rpost * inverse(Rp) * Soff * Sp * S * inverse(Sp)
|
||||||
fbxDouble3 local_rotation = pNode->LclRotation.Get(); // pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET);
|
fbxDouble3 local_rotation = pNode->LclRotation.Get(); // pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET);
|
||||||
fbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET);
|
fbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET);
|
||||||
fbxDouble3 local_scale = pNode->LclScaling.Get(); // pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET);
|
fbxDouble3 local_scale = pNode->LclScaling.Get(); // pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET);
|
||||||
|
|
||||||
printf(" Translation: %f %f %f\n", local_translation[0], local_translation[1], local_translation[2]);
|
// fbxDouble3 post_rotation = pNode->PostRotation.Get();
|
||||||
printf(" Rotation: %f %f %f\n", local_rotation[0], local_rotation[1], local_rotation[2]);
|
// fbxDouble3 pre_rotation = pNode->PreRotation.Get();
|
||||||
printf(" Scaling: %f %f %f\n", local_scale[0], local_scale[1], local_scale[2]);
|
// fbxDouble3 rotation_offset = pNode->RotationOffset.Get();
|
||||||
|
// fbxDouble3 scaling_offset = pNode->ScalingOffset.Get();
|
||||||
|
// fbxDouble3 rotation_pivot = pNode->RotationPivot.Get();
|
||||||
|
// fbxDouble3 scaling_pivot = pNode->ScalingPivot.Get();
|
||||||
|
// fbxDouble3 geometric_rotation = pNode->GeometricRotation.Get();
|
||||||
|
// fbxDouble3 geometric_translation = pNode->GeometricTranslation.Get();
|
||||||
|
// fbxDouble3 geometric_scaling = pNode->GeometricScaling.Get();
|
||||||
|
// ERotationOrder rotation_order = pNode->RotationOrder.Get();
|
||||||
|
//
|
||||||
|
// bool rotation_active = pNode->RotationActive.Get();
|
||||||
|
|
||||||
|
// KRVector3 node_translation = KRVector3(local_translation[0] + rotation_offset[0] + rotation_pivot[0], local_translation[1] + rotation_offset[1] + rotation_pivot[1], local_translation[2] + rotation_offset[2] + rotation_pivot[2]); // T * Roff * Rp
|
||||||
|
KRVector3 node_translation = KRVector3(local_translation[0], local_translation[1], local_translation[2]); // T * Roff * Rp
|
||||||
|
|
||||||
|
KRVector3 node_rotation = KRQuaternion(KRVector3(local_rotation[0], local_rotation[1], local_rotation[2]) / 180.0 * M_PI).euler(); // R
|
||||||
|
// if(rotation_active) {
|
||||||
|
// node_rotation = (KRQuaternion(KRVector3(post_rotation[0], post_rotation[1], post_rotation[2]) / 180.0 * M_PI) * KRQuaternion(KRVector3(local_rotation[0], local_rotation[1], local_rotation[2]) / 180.0 * M_PI) * KRQuaternion(KRVector3(pre_rotation[0], pre_rotation[1], pre_rotation[2]) / 180.0 * M_PI)).euler(); // Rpre * R * Rpost
|
||||||
|
// }
|
||||||
|
|
||||||
|
KRVector3 node_scale = KRVector3(local_scale[0], local_scale[1], local_scale[2]);
|
||||||
|
|
||||||
|
printf(" Local Translation: %f %f %f\n", local_translation[0], local_translation[1], local_translation[2]);
|
||||||
|
printf(" Local Rotation: %f %f %f\n", local_rotation[0], local_rotation[1], local_rotation[2]);
|
||||||
|
printf(" Local Scaling: %f %f %f\n", local_scale[0], local_scale[1], local_scale[2]);
|
||||||
|
|
||||||
KRNode *new_node = NULL;
|
KRNode *new_node = NULL;
|
||||||
|
|
||||||
@@ -271,9 +365,9 @@ void LoadNode(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeo
|
|||||||
|
|
||||||
|
|
||||||
if(new_node != NULL) {
|
if(new_node != NULL) {
|
||||||
new_node->setLocalRotation(KRVector3(local_rotation[0], local_rotation[1], local_rotation[2]) / 180.0 * M_PI);
|
new_node->setLocalRotation(node_rotation);
|
||||||
new_node->setLocalTranslation(KRVector3(local_translation[0], local_translation[1], local_translation[2]));
|
new_node->setLocalTranslation(node_translation);
|
||||||
new_node->setLocalScale(KRVector3(local_scale[0], local_scale[1], local_scale[2]));
|
new_node->setLocalScale(node_scale);
|
||||||
parent_node->addChild(new_node);
|
parent_node->addChild(new_node);
|
||||||
|
|
||||||
// Load child nodes
|
// Load child nodes
|
||||||
@@ -617,16 +711,6 @@ KRNode *LoadLight(KRNode *parent_node, std::vector<KRResource *> &resources, KFb
|
|||||||
// KFbxLight::eQUADRATIC - attenuation of 1/d^2
|
// KFbxLight::eQUADRATIC - attenuation of 1/d^2
|
||||||
// KFbxLight::eCUBIC - attenuation of
|
// KFbxLight::eCUBIC - attenuation of
|
||||||
|
|
||||||
KFbxVector4 v4; // Default translation values
|
|
||||||
v4 = pNode->LclTranslation.Get();
|
|
||||||
|
|
||||||
//KFbxVector4 light_translation = pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET);
|
|
||||||
//KFbxVector4 light_rotation = pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET);
|
|
||||||
//KFbxVector4 light_scaling = pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET);
|
|
||||||
|
|
||||||
|
|
||||||
//KRVector3 translation = KRVector3(light_translation[0], light_translation[1], light_translation[2]);
|
|
||||||
|
|
||||||
KRLight *new_light = NULL;
|
KRLight *new_light = NULL;
|
||||||
|
|
||||||
switch(pLight->LightType.Get()) {
|
switch(pLight->LightType.Get()) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// particle.fsh
|
// dust_particle.fsh
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
@@ -39,10 +39,5 @@ uniform mediump vec3 light_color;
|
|||||||
varying lowp float intensity_modulate;
|
varying lowp float intensity_modulate;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
//gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0);
|
|
||||||
// gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
|
||||||
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1) * max(1.0 - texCoord.x*texCoord.x-texCoord.y*texCoord.y, 0.0) * intensity_modulate;
|
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1) * max(1.0 - texCoord.x*texCoord.x-texCoord.y*texCoord.y, 0.0) * intensity_modulate;
|
||||||
// gl_FragColor.rgb = shadowMapCoord1.xyz / shadowMapCoord1.w;
|
|
||||||
// gl_FragColor.a = 1.0;
|
|
||||||
// gl_FragColor.b = 1.0;
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// particle.vsh
|
// dust_particle.vsh
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
@@ -44,7 +44,6 @@ uniform highp float time_absolute;
|
|||||||
varying lowp float intensity_modulate;
|
varying lowp float intensity_modulate;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// highp vec4 particle_center = mvp_matrix * (mod(vertex_position - vec4(particle_origin, 0.0), 2.0) - 1.0);
|
|
||||||
highp vec4 offset_center = vertex_position + vec4(particle_origin, 0.0);
|
highp vec4 offset_center = vertex_position + vec4(particle_origin, 0.0);
|
||||||
offset_center.xyz += vec3(sin((time_absolute + vertex_position.x * 100.0) * 0.05), sin((time_absolute + vertex_position.y * 100.0) * 0.07), sin((time_absolute + vertex_position.z * 100.0) * 0.03)) * 0.05;
|
offset_center.xyz += vec3(sin((time_absolute + vertex_position.x * 100.0) * 0.05), sin((time_absolute + vertex_position.y * 100.0) * 0.07), sin((time_absolute + vertex_position.z * 100.0) * 0.03)) * 0.05;
|
||||||
offset_center = vec4(mod(offset_center.x + 1.0, 2.0) - 1.0, mod(offset_center.y + 1.0, 2.0) - 1.0, mod(offset_center.z + 1.0, 2.0) - 1.0, 1.0);
|
offset_center = vec4(mod(offset_center.x + 1.0, 2.0) - 1.0, mod(offset_center.y + 1.0, 2.0) - 1.0, mod(offset_center.z + 1.0, 2.0) - 1.0, 1.0);
|
||||||
Reference in New Issue
Block a user