/s/KRVector4/Vector4/g

/s/KRFloat/Scalar/g
This commit is contained in:
Kearwood Kip Gilbert
2017-07-29 01:29:30 -07:00
parent 95ff5243c5
commit a4bc7267d3
31 changed files with 177 additions and 177 deletions

View File

@@ -98,7 +98,7 @@ void KRAmbientZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -182,7 +182,7 @@ void KRAudioSource::render(KRCamera *pCamera, std::vector<KRPointLight *> &point
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -63,7 +63,7 @@ void KRBone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
if(sphereModels.size()) {
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {

View File

@@ -55,7 +55,7 @@ KRCamera::KRCamera(KRScene &scene, std::string name) : KRNode(scene, name) {
m_frame_times_filled = 0;
m_downsample = Vector2::One();
m_fade_color = KRVector4::Zero();
m_fade_color = Vector4::Zero();
}
KRCamera::~KRCamera() {
@@ -312,7 +312,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
}
if(m_pSkyBoxTexture) {
getContext().getShaderManager()->selectShader("sky_box", *this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, m_viewport, KRMat4(), false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_OPAQUE, Vector3::Zero(), 0.0f, KRVector4::Zero());
getContext().getShaderManager()->selectShader("sky_box", *this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, m_viewport, KRMat4(), false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_OPAQUE, Vector3::Zero(), 0.0f, Vector4::Zero());
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
@@ -480,7 +480,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend
KRMat4 matModel = KRMat4();
matModel.scale((*itr).first.size() * 0.5f);
matModel.translate((*itr).first.center());
if(getContext().getShaderManager()->selectShader(*this, pVisShader, m_viewport, matModel, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*this, pVisShader, m_viewport, matModel, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero())) {
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
}
}
@@ -879,7 +879,7 @@ void KRCamera::renderPost()
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
KRShader *fontShader = m_pContext->getShaderManager()->getShader("debug_font", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
getContext().getShaderManager()->selectShader(*this, fontShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, KRVector4::Zero());
getContext().getShaderManager()->selectShader(*this, fontShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero());
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
@@ -1106,12 +1106,12 @@ void KRCamera::setDownsample(float v)
m_downsample = v;
}
void KRCamera::setFadeColor(const KRVector4 &fade_color)
void KRCamera::setFadeColor(const Vector4 &fade_color)
{
m_fade_color = fade_color;
}
KRVector4 KRCamera::getFadeColor()
Vector4 KRCamera::getFadeColor()
{
return m_fade_color;
}

View File

@@ -69,8 +69,8 @@ public:
Vector2 getDownsample();
void setDownsample(float v);
void setFadeColor(const KRVector4 &fade_color);
KRVector4 getFadeColor();
void setFadeColor(const Vector4 &fade_color);
Vector4 getFadeColor();
void setSkyBox(const std::string &skyBox);
const std::string getSkyBox() const;
@@ -99,7 +99,7 @@ private:
Vector2 m_downsample;
KRVector4 m_fade_color;
Vector4 m_fade_color;
typedef struct {
GLfloat x;

View File

@@ -198,7 +198,7 @@ void KRCollider::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_li
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -110,7 +110,7 @@ void KRDirectionalLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &
light_direction_view_space.normalize();
KRShader *pShader = getContext().getShaderManager()->getShader("light_directional", pCamera, std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_DIRECTION_VIEW_SPACE, light_direction_view_space);
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);

View File

@@ -14,7 +14,7 @@ void SetUniform(GLint location, const Vector3 &v)
if (location != -1) GLDEBUG(glUniform3f(location, v.x, v.y, v.z));
}
void SetUniform(GLint location, const KRVector4 &v)
void SetUniform(GLint location, const Vector4 &v)
{
if (location != -1) GLDEBUG(glUniform4f(location, v.x, v.y, v.z, v.w));
}

View File

@@ -19,7 +19,7 @@ float const D2R = PI * 2 / 360;
namespace kraken {
void SetUniform(GLint location, const Vector2 &v);
void SetUniform(GLint location, const Vector3 &v);
void SetUniform(GLint location, const KRVector4 &v);
void SetUniform(GLint location, const Vector4 &v);
void SetUniform(GLint location, const KRMat4 &v);
void setXMLAttribute(const std::string &base_name, ::tinyxml2::XMLElement *e, const Vector3 &value, const Vector3 &default_value);

View File

@@ -220,7 +220,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, this_point_light, this_directional_light, this_spot_light, 0, 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_point_light, this_directional_light, this_spot_light, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_point_light, this_directional_light, this_spot_light, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * pCamera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_PARTICLE_ORIGIN, KRMat4::DotWDiv(KRMat4::Invert(particleModelMatrix), Vector3::Zero()));
@@ -256,7 +256,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
KRShader *pFogShader = m_pContext->getShaderManager()->getShader(shader_name, pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_ADDITIVE_PARTICLES);
if(getContext().getShaderManager()->selectShader(*pCamera, pFogShader, viewport, KRMat4(), this_point_light, this_directional_light, this_spot_light, 0, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pFogShader, viewport, KRMat4(), this_point_light, this_directional_light, this_spot_light, 0, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, Vector3::Zero(), 0.0f, Vector4::Zero())) {
int slice_count = (int)(pCamera->settings.volumetric_environment_quality * 495.0) + 5;
float slice_near = -pCamera->settings.getPerspectiveNearZ();
@@ -284,7 +284,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix();
}
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
#if TARGET_OS_IPHONE
@@ -332,7 +332,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
// Render light flare on transparency pass
KRShader *pShader = getContext().getShaderManager()->getShader("flare", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture, 0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
@@ -449,7 +449,7 @@ void KRLight::renderShadowBuffers(KRCamera *pCamera)
// Use shader program
KRShader *shadowShader = m_pContext->getShaderManager()->getShader("ShadowShader", pCamera, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
getContext().getShaderManager()->selectShader(*pCamera, shadowShader, m_shadowViewports[iShadow], KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP, Vector3::Zero(), 0.0f, KRVector4::Zero());
getContext().getShaderManager()->selectShader(*pCamera, shadowShader, m_shadowViewports[iShadow], KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP, Vector3::Zero(), 0.0f, Vector4::Zero());
getScene().render(pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);

View File

@@ -322,10 +322,10 @@ Vector3 KRMat4::Dot(const KRMat4 &m, const Vector3 &v) {
);
}
KRVector4 KRMat4::Dot4(const KRMat4 &m, const KRVector4 &v) {
Vector4 KRMat4::Dot4(const KRMat4 &m, const Vector4 &v) {
#ifdef KRAKEN_USE_ARM_NEON
KRVector4 d;
Vector4 d;
asm volatile (
"vld1.32 {d0, d1}, [%1] \n\t" //Q0 = v
"vld1.32 {d18, d19}, [%0]! \n\t" //Q1 = m
@@ -345,7 +345,7 @@ KRVector4 KRMat4::Dot4(const KRMat4 &m, const KRVector4 &v) {
);
return d;
#else
return KRVector4(
return Vector4(
v.c[0] * m.c[0] + v.c[1] * m.c[4] + v.c[2] * m.c[8] + m.c[12],
v.c[0] * m.c[1] + v.c[1] * m.c[5] + v.c[2] * m.c[9] + m.c[13],
v.c[0] * m.c[2] + v.c[1] * m.c[6] + v.c[2] * m.c[10] + m.c[14],
@@ -364,14 +364,14 @@ Vector3 KRMat4::DotNoTranslate(const KRMat4 &m, const Vector3 &v)
);
}
/* Dot Product, returning w component as if it were a KRVector4 (This will be deprecated once KRVector4 is implemented instead*/
/* Dot Product, returning w component as if it were a Vector4 (This will be deprecated once Vector4 is implemented instead*/
float KRMat4::DotW(const KRMat4 &m, const Vector3 &v) {
return v.x * m.c[0*4 + 3] + v.y * m.c[1*4 + 3] + v.z * m.c[2*4 + 3] + m.c[3*4 + 3];
}
/* Dot Product followed by W-divide */
Vector3 KRMat4::DotWDiv(const KRMat4 &m, const Vector3 &v) {
KRVector4 r = Dot4(m, KRVector4(v, 1.0f));
Vector4 r = Dot4(m, Vector4(v, 1.0f));
return Vector3(r) / r.w;
}

View File

@@ -322,7 +322,7 @@ bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
KRShader *pShader = getContext().getShaderManager()->getShader("ObjectShader", pCamera, point_lights, directional_lights, spot_lights, bones.size(), bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_reflectionMapScale != default_scale && bReflectionMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, m_reflectionMapOffset != default_offset && bReflectionMap, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
KRVector4 fade_color;
Vector4 fade_color;
if(!getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, rim_power, fade_color)) {
return false;
}

View File

@@ -76,8 +76,8 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRPointLig
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
Vector3 rim_color; KRVector4 fade_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
Vector3 rim_color; Vector4 fade_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
KRDataBlock index_data;

View File

@@ -68,7 +68,7 @@ void KRPointLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
bool bInsideLight = view_light_position.sqrMagnitude() <= (influence_radius + pCamera->settings.getPerspectiveNearZ()) * (influence_radius + pCamera->settings.getPerspectiveNearZ());
KRShader *pShader = getContext().getShaderManager()->getShader(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"), pCamera, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);

View File

@@ -97,7 +97,7 @@ void KRReverbZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -298,7 +298,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visi
GLDEBUG(glDepthMask(GL_FALSE));
}
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, matModel, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, matModel, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero())) {
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
m_pContext->getMeshManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14);
}

View File

@@ -313,7 +313,7 @@ void KRShader::setUniform(int location, const Vector3 &value)
}
}
}
void KRShader::setUniform(int location, const KRVector4 &value)
void KRShader::setUniform(int location, const Vector4 &value)
{
if(m_uniforms[location] != -1) {
int value_index = m_uniform_value_index[location];
@@ -351,7 +351,7 @@ void KRShader::setUniform(int location, const KRMat4 &value)
}
}
bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const KRVector4 &fade_color) {
bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color) {
if(m_iProgram == 0) {
return false;
}
@@ -503,7 +503,7 @@ bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &
}
if(m_uniforms[KRENGINE_UNIFORM_VIEWPORT] != -1) {
setUniform(KRENGINE_UNIFORM_VIEWPORT, KRVector4(
setUniform(KRENGINE_UNIFORM_VIEWPORT, Vector4(
(GLfloat)0.0,
(GLfloat)0.0,
(GLfloat)viewport.getSize().x,

View File

@@ -46,7 +46,7 @@ public:
virtual ~KRShader();
const char *getKey() const;
bool bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const KRVector4 &fade_color);
bool bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
enum {
KRENGINE_UNIFORM_MATERIAL_AMBIENT = 0,
@@ -141,7 +141,7 @@ public:
std::vector<int> m_uniform_value_int;
std::vector<Vector2> m_uniform_value_vector2;
std::vector<Vector3> m_uniform_value_vector3;
std::vector<KRVector4> m_uniform_value_vector4;
std::vector<Vector4> m_uniform_value_vector4;
std::vector<KRMat4> m_uniform_value_mat4;
@@ -151,7 +151,7 @@ public:
void setUniform(int location, int value);
void setUniform(int location, const Vector2 &value);
void setUniform(int location, const Vector3 &value);
void setUniform(int location, const KRVector4 &value);
void setUniform(int location, const Vector4 &value);
void setUniform(int location, const KRMat4 &value);
private:

View File

@@ -233,7 +233,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
KRContext::Log(KRContext::LOG_LEVEL_ERROR, "Fragment Shader Missing: %s", platform_shader_name.c_str());
}
KRVector4 fade_color = pCamera->getFadeColor();
Vector4 fade_color = pCamera->getFadeColor();
char szKey[256];
sprintf(szKey, "%i_%i_%i_%i_%i_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%i_%s_%i_%d_%d_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f", light_directional_count, light_point_count, light_spot_count, bone_count, pCamera->settings.fog_type, pCamera->settings.bEnablePerPixel,bAlphaTest, bAlphaBlend, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, pCamera->settings.bDebugPSSM, iShadowQuality, pCamera->settings.bEnableAmbient, pCamera->settings.bEnableDiffuse, pCamera->settings.bEnableSpecular, bLightMap, bDiffuseMapScale, bSpecMapScale, bReflectionMapScale, bNormalMapScale, bDiffuseMapOffset, bSpecMapOffset, bReflectionMapOffset, bNormalMapOffset,pCamera->settings.volumetric_environment_enable && pCamera->settings.volumetric_environment_downsample != 0, renderPass, shader_name.c_str(),pCamera->settings.dof_quality,pCamera->settings.bEnableFlash,pCamera->settings.bEnableVignette,pCamera->settings.dof_depth,pCamera->settings.dof_falloff,pCamera->settings.flash_depth,pCamera->settings.flash_falloff,pCamera->settings.flash_intensity,pCamera->settings.vignette_radius,pCamera->settings.vignette_falloff, fade_color.x, fade_color.y, fade_color.z, fade_color.w);
@@ -245,13 +245,13 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
return pShader;
}
bool KRShaderManager::selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const KRVector4 &fade_color)
bool KRShaderManager::selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color)
{
KRShader *pShader = getShader(shader_name, &camera, point_lights, directional_lights, spot_lights, bone_count, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, bDiffuseMapScale, bSpecMapScale, bNormalMapScale, bReflectionMapScale, bDiffuseMapOffset, bSpecMapOffset, bNormalMapOffset, bReflectionMapOffset, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
return selectShader(camera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, bone_count, renderPass, rim_color, rim_power, fade_color);
}
bool KRShaderManager::selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const KRVector4 &fade_color)
bool KRShaderManager::selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color)
{
if(pShader) {
return pShader->bind(camera, viewport, matModel, point_lights, directional_lights, spot_lights, renderPass, rim_color, rim_power, fade_color);

View File

@@ -60,9 +60,9 @@ public:
KRShader *getShader(const std::string &shader_name, KRCamera *pCamera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, bool bRimColor = false);
bool selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const KRVector4 &fade_color);
bool selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
bool selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const KRVector4 &fade_color);
bool selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const Vector3 &rim_color, float rim_power, const Vector4 &fade_color);
long getShaderHandlesUsed();

View File

@@ -128,7 +128,7 @@ void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
// Render light sprite on transparency pass
KRShader *pShader = getContext().getShaderManager()->getShader("sprite", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, KRVector4::Zero())) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, Vector3::Zero(), 0.0f, Vector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture, 0.0f, KRTexture::TEXTURE_USAGE_SPRITE);
m_pContext->getMeshManager()->bindVBO(&m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);

View File

@@ -221,12 +221,12 @@ bool KRViewport::visible(const KRAABB &b) const
int outside_count[6] = {0, 0, 0, 0, 0, 0};
for(int iCorner=0; iCorner<8; iCorner++) {
KRVector4 sourceCornerVertex = KRVector4(
Vector4 sourceCornerVertex = Vector4(
(iCorner & 1) == 0 ? b.min.x : b.max.x,
(iCorner & 2) == 0 ? b.min.y : b.max.y,
(iCorner & 4) == 0 ? b.min.z : b.max.z, 1.0f);
KRVector4 cornerVertex = KRMat4::Dot4(m_matViewProjection, sourceCornerVertex);
Vector4 cornerVertex = KRMat4::Dot4(m_matViewProjection, sourceCornerVertex);
if(cornerVertex.x < -cornerVertex.w) {
outside_count[0]++;

View File

@@ -31,7 +31,7 @@
#include "Vector3.h"
#include "KRVector4.h"
#include "Vector4.h"
#ifndef KRMAT4_H
#define KRMAT4_H
@@ -99,7 +99,7 @@ class KRMat4 {
static KRMat4 Invert(const KRMat4 &m);
static KRMat4 Transpose(const KRMat4 &m);
static Vector3 Dot(const KRMat4 &m, const Vector3 &v);
static KRVector4 Dot4(const KRMat4 &m, const KRVector4 &v);
static Vector4 Dot4(const KRMat4 &m, const Vector4 &v);
static float DotW(const KRMat4 &m, const Vector3 &v);
static Vector3 DotWDiv(const KRMat4 &m, const Vector3 &v);

View File

@@ -1,10 +1,10 @@
#ifndef KRAKEN_H
#define KRAKEN_H
#include "KRFloat.h"
#include "scalar.h"
#include "vector2.h"
#include "vector3.h"
#include "KRVector4.h"
#include "vector4.h"
#include "KRMat4.h"
#include "KRQuaternion.h"
#include "KRAABB.h"

View File

@@ -29,8 +29,8 @@
// or implied, of Kearwood Gilbert.
//
#ifndef KRFLOAT_H
#define KRFLOAT_H
#ifndef KRAKEN_SCALAR_H
#define KRAKEN_SCALAR_H
namespace kraken {
@@ -38,4 +38,4 @@ namespace kraken {
}; // namespace kraken
#endif /* defined(KRFLOAT_H) */
#endif // KRAKEN_SCALAR_H

View File

@@ -35,7 +35,7 @@
#include <functional> // for hash<>
#include "Vector2.h"
#include "KRVector4.h"
#include "Vector4.h"
namespace kraken {
@@ -55,7 +55,7 @@ public:
Vector3(float *v);
Vector3(double *v);
Vector3(const Vector3 &v);
Vector3(const KRVector4 &v);
Vector3(const Vector4 &v);
~Vector3();
// Vector2 swizzle getters
@@ -78,7 +78,7 @@ public:
void zy(const Vector2 &v);
Vector3& operator =(const Vector3& b);
Vector3& operator =(const KRVector4& b);
Vector3& operator =(const Vector4& b);
Vector3 operator +(const Vector3& b) const;
Vector3 operator -(const Vector3& b) const;
Vector3 operator +() const;

View File

@@ -1,5 +1,5 @@
//
// KRVector4.h
// Vector4.h
// Kraken
//
// Copyright 2017 Kearwood Gilbert. All rights reserved.
@@ -29,8 +29,8 @@
// or implied, of Kearwood Gilbert.
//
#ifndef KRVECTOR4_H
#define KRVECTOR4_H
#ifndef KRAKEN_VECTOR4_H
#define KRAKEN_VECTOR4_H
#include <functional> // for hash<>
@@ -38,7 +38,7 @@ namespace kraken {
class Vector3;
class KRVector4 {
class Vector4 {
public:
union {
@@ -48,34 +48,34 @@ public:
float c[4];
};
KRVector4();
KRVector4(float X, float Y, float Z, float W);
KRVector4(float v);
KRVector4(float *v);
KRVector4(const KRVector4 &v);
KRVector4(const Vector3 &v, float W);
~KRVector4();
Vector4();
Vector4(float X, float Y, float Z, float W);
Vector4(float v);
Vector4(float *v);
Vector4(const Vector4 &v);
Vector4(const Vector3 &v, float W);
~Vector4();
KRVector4& operator =(const KRVector4& b);
KRVector4 operator +(const KRVector4& b) const;
KRVector4 operator -(const KRVector4& b) const;
KRVector4 operator +() const;
KRVector4 operator -() const;
KRVector4 operator *(const float v) const;
KRVector4 operator /(const float v) const;
Vector4& operator =(const Vector4& b);
Vector4 operator +(const Vector4& b) const;
Vector4 operator -(const Vector4& b) const;
Vector4 operator +() const;
Vector4 operator -() const;
Vector4 operator *(const float v) const;
Vector4 operator /(const float v) const;
KRVector4& operator +=(const KRVector4& b);
KRVector4& operator -=(const KRVector4& b);
KRVector4& operator *=(const float v);
KRVector4& operator /=(const float v);
Vector4& operator +=(const Vector4& b);
Vector4& operator -=(const Vector4& b);
Vector4& operator *=(const float v);
Vector4& operator /=(const float v);
bool operator ==(const KRVector4& b) const;
bool operator !=(const KRVector4& b) const;
bool operator ==(const Vector4& b) const;
bool operator !=(const Vector4& b) const;
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
bool operator >(const KRVector4& b) const;
bool operator <(const KRVector4& b) const;
bool operator >(const Vector4& b) const;
bool operator <(const Vector4& b) const;
float& operator[](unsigned i);
float operator[](unsigned i) const;
@@ -84,31 +84,31 @@ public:
float magnitude() const;
void normalize();
static KRVector4 Normalize(const KRVector4 &v);
static Vector4 Normalize(const Vector4 &v);
static float Dot(const KRVector4 &v1, const KRVector4 &v2);
static KRVector4 Min();
static KRVector4 Max();
static const KRVector4 &Zero();
static KRVector4 One();
static KRVector4 Forward();
static KRVector4 Backward();
static KRVector4 Up();
static KRVector4 Down();
static KRVector4 Left();
static KRVector4 Right();
static KRVector4 Lerp(const KRVector4 &v1, const KRVector4 &v2, float d);
static KRVector4 Slerp(const KRVector4 &v1, const KRVector4 &v2, float d);
static void OrthoNormalize(KRVector4 &normal, KRVector4 &tangent); // Gram-Schmidt Orthonormalization
static float Dot(const Vector4 &v1, const Vector4 &v2);
static Vector4 Min();
static Vector4 Max();
static const Vector4 &Zero();
static Vector4 One();
static Vector4 Forward();
static Vector4 Backward();
static Vector4 Up();
static Vector4 Down();
static Vector4 Left();
static Vector4 Right();
static Vector4 Lerp(const Vector4 &v1, const Vector4 &v2, float d);
static Vector4 Slerp(const Vector4 &v1, const Vector4 &v2, float d);
static void OrthoNormalize(Vector4 &normal, Vector4 &tangent); // Gram-Schmidt Orthonormalization
};
} // namespace kraken
namespace std {
template<>
struct hash<kraken::KRVector4> {
struct hash<kraken::Vector4> {
public:
size_t operator()(const kraken::KRVector4 &s) const
size_t operator()(const kraken::Vector4 &s) const
{
size_t h1 = hash<float>()(s.x);
size_t h2 = hash<float>()(s.y);
@@ -119,4 +119,4 @@ namespace std {
};
}
#endif // KRVECTOR4_H
#endif // KRAKEN_VECTOR4_H

View File

@@ -48,7 +48,7 @@ Vector3::Vector3(const Vector3 &v) {
z = v.z;
}
Vector3::Vector3(const KRVector4 &v) {
Vector3::Vector3(const Vector4 &v) {
x = v.x;
y = v.y;
z = v.z;
@@ -253,7 +253,7 @@ Vector3& Vector3::operator =(const Vector3& b) {
return *this;
}
Vector3& Vector3::operator =(const KRVector4 &b) {
Vector3& Vector3::operator =(const Vector4 &b) {
x = b.x;
y = b.y;
z = b.z;

126
kraken/KRVector4.cpp → kraken/vector4.cpp Executable file → Normal file
View File

@@ -1,5 +1,5 @@
//
// KRVector4.cpp
// Vector4.cpp
// KREngine
//
// Copyright 2012 Kearwood Gilbert. All rights reserved.
@@ -33,10 +33,10 @@
namespace kraken {
const KRVector4 KRVECTOR4_ZERO(0.0f, 0.0f, 0.0f, 0.0f);
const Vector4 Vector4_ZERO(0.0f, 0.0f, 0.0f, 0.0f);
//default constructor
KRVector4::KRVector4()
Vector4::Vector4()
{
x = 0.0f;
y = 0.0f;
@@ -44,75 +44,75 @@ KRVector4::KRVector4()
w = 0.0f;
}
KRVector4::KRVector4(const KRVector4 &v) {
Vector4::Vector4(const Vector4 &v) {
x = v.x;
y = v.y;
z = v.z;
w = v.w;
}
KRVector4::KRVector4(const Vector3 &v, float W) {
Vector4::Vector4(const Vector3 &v, float W) {
x = v.x;
y = v.y;
z = v.z;
w = W;
}
KRVector4::KRVector4(float *v) {
Vector4::Vector4(float *v) {
x = v[0];
y = v[1];
z = v[2];
w = v[3];
}
KRVector4 KRVector4::Min() {
return KRVector4(-std::numeric_limits<float>::max());
Vector4 Vector4::Min() {
return Vector4(-std::numeric_limits<float>::max());
}
KRVector4 KRVector4::Max() {
return KRVector4(std::numeric_limits<float>::max());
Vector4 Vector4::Max() {
return Vector4(std::numeric_limits<float>::max());
}
const KRVector4 &KRVector4::Zero() {
return KRVECTOR4_ZERO;
const Vector4 &Vector4::Zero() {
return Vector4_ZERO;
}
KRVector4 KRVector4::One() {
return KRVector4(1.0f, 1.0f, 1.0f, 1.0f);
Vector4 Vector4::One() {
return Vector4(1.0f, 1.0f, 1.0f, 1.0f);
}
KRVector4 KRVector4::Forward() {
return KRVector4(0.0f, 0.0f, 1.0f, 1.0f);
Vector4 Vector4::Forward() {
return Vector4(0.0f, 0.0f, 1.0f, 1.0f);
}
KRVector4 KRVector4::Backward() {
return KRVector4(0.0f, 0.0f, -1.0f, 1.0f);
Vector4 Vector4::Backward() {
return Vector4(0.0f, 0.0f, -1.0f, 1.0f);
}
KRVector4 KRVector4::Up() {
return KRVector4(0.0f, 1.0f, 0.0f, 1.0f);
Vector4 Vector4::Up() {
return Vector4(0.0f, 1.0f, 0.0f, 1.0f);
}
KRVector4 KRVector4::Down() {
return KRVector4(0.0f, -1.0f, 0.0f, 1.0f);
Vector4 Vector4::Down() {
return Vector4(0.0f, -1.0f, 0.0f, 1.0f);
}
KRVector4 KRVector4::Left() {
return KRVector4(-1.0f, 0.0f, 0.0f, 1.0f);
Vector4 Vector4::Left() {
return Vector4(-1.0f, 0.0f, 0.0f, 1.0f);
}
KRVector4 KRVector4::Right() {
return KRVector4(1.0f, 0.0f, 0.0f, 1.0f);
Vector4 Vector4::Right() {
return Vector4(1.0f, 0.0f, 0.0f, 1.0f);
}
KRVector4 KRVector4::Lerp(const KRVector4 &v1, const KRVector4 &v2, float d) {
Vector4 Vector4::Lerp(const Vector4 &v1, const Vector4 &v2, float d) {
return v1 + (v2 - v1) * d;
}
KRVector4 KRVector4::Slerp(const KRVector4 &v1, const KRVector4 &v2, float d) {
Vector4 Vector4::Slerp(const Vector4 &v1, const Vector4 &v2, float d) {
// From: http://keithmaggio.wordpress.com/2011/02/15/math-magician-lerp-slerp-and-nlerp/
// Dot product - the cosine of the angle between 2 vectors.
float dot = KRVector4::Dot(v1, v2);
float dot = Vector4::Dot(v1, v2);
// Clamp it to be in the range of Acos()
if(dot < -1.0f) dot = -1.0f;
if(dot > 1.0f) dot = 1.0f;
@@ -120,28 +120,28 @@ KRVector4 KRVector4::Slerp(const KRVector4 &v1, const KRVector4 &v2, float d) {
// And multiplying that by percent returns the angle between
// start and the final result.
float theta = acos(dot)*d;
KRVector4 RelativeVec = v2 - v1*dot;
Vector4 RelativeVec = v2 - v1*dot;
RelativeVec.normalize(); // Orthonormal basis
// The final result.
return ((v1*cos(theta)) + (RelativeVec*sin(theta)));
}
void KRVector4::OrthoNormalize(KRVector4 &normal, KRVector4 &tangent) {
void Vector4::OrthoNormalize(Vector4 &normal, Vector4 &tangent) {
// Gram-Schmidt Orthonormalization
normal.normalize();
KRVector4 proj = normal * Dot(tangent, normal);
Vector4 proj = normal * Dot(tangent, normal);
tangent = tangent - proj;
tangent.normalize();
}
KRVector4::KRVector4(float v) {
Vector4::Vector4(float v) {
x = v;
y = v;
z = v;
w = v;
}
KRVector4::KRVector4(float X, float Y, float Z, float W)
Vector4::Vector4(float X, float Y, float Z, float W)
{
x = X;
y = Y;
@@ -149,39 +149,39 @@ KRVector4::KRVector4(float X, float Y, float Z, float W)
w = W;
}
KRVector4::~KRVector4()
Vector4::~Vector4()
{
}
KRVector4& KRVector4::operator =(const KRVector4& b) {
Vector4& Vector4::operator =(const Vector4& b) {
x = b.x;
y = b.y;
z = b.z;
w = b.w;
return *this;
}
KRVector4 KRVector4::operator +(const KRVector4& b) const {
return KRVector4(x + b.x, y + b.y, z + b.z, w + b.w);
Vector4 Vector4::operator +(const Vector4& b) const {
return Vector4(x + b.x, y + b.y, z + b.z, w + b.w);
}
KRVector4 KRVector4::operator -(const KRVector4& b) const {
return KRVector4(x - b.x, y - b.y, z - b.z, w - b.w);
Vector4 Vector4::operator -(const Vector4& b) const {
return Vector4(x - b.x, y - b.y, z - b.z, w - b.w);
}
KRVector4 KRVector4::operator +() const {
Vector4 Vector4::operator +() const {
return *this;
}
KRVector4 KRVector4::operator -() const {
return KRVector4(-x, -y, -z, -w);
Vector4 Vector4::operator -() const {
return Vector4(-x, -y, -z, -w);
}
KRVector4 KRVector4::operator *(const float v) const {
return KRVector4(x * v, y * v, z * v, w * v);
Vector4 Vector4::operator *(const float v) const {
return Vector4(x * v, y * v, z * v, w * v);
}
KRVector4 KRVector4::operator /(const float v) const {
return KRVector4(x / v, y / v, z / v, w/ v);
Vector4 Vector4::operator /(const float v) const {
return Vector4(x / v, y / v, z / v, w/ v);
}
KRVector4& KRVector4::operator +=(const KRVector4& b) {
Vector4& Vector4::operator +=(const Vector4& b) {
x += b.x;
y += b.y;
z += b.z;
@@ -190,7 +190,7 @@ KRVector4& KRVector4::operator +=(const KRVector4& b) {
return *this;
}
KRVector4& KRVector4::operator -=(const KRVector4& b) {
Vector4& Vector4::operator -=(const Vector4& b) {
x -= b.x;
y -= b.y;
z -= b.z;
@@ -199,7 +199,7 @@ KRVector4& KRVector4::operator -=(const KRVector4& b) {
return *this;
}
KRVector4& KRVector4::operator *=(const float v) {
Vector4& Vector4::operator *=(const float v) {
x *= v;
y *= v;
z *= v;
@@ -208,7 +208,7 @@ KRVector4& KRVector4::operator *=(const float v) {
return *this;
}
KRVector4& KRVector4::operator /=(const float v) {
Vector4& Vector4::operator /=(const float v) {
float inv_v = 1.0f / v;
x *= inv_v;
y *= inv_v;
@@ -218,15 +218,15 @@ KRVector4& KRVector4::operator /=(const float v) {
return *this;
}
bool KRVector4::operator ==(const KRVector4& b) const {
bool Vector4::operator ==(const Vector4& b) const {
return x == b.x && y == b.y && z == b.z && w == b.w;
}
bool KRVector4::operator !=(const KRVector4& b) const {
bool Vector4::operator !=(const Vector4& b) const {
return x != b.x || y != b.y || z != b.z || w != b.w;
}
float& KRVector4::operator[](unsigned i) {
float& Vector4::operator[](unsigned i) {
switch(i) {
case 0:
return x;
@@ -240,7 +240,7 @@ float& KRVector4::operator[](unsigned i) {
}
}
float KRVector4::operator[](unsigned i) const {
float Vector4::operator[](unsigned i) const {
switch(i) {
case 0:
return x;
@@ -254,33 +254,33 @@ float KRVector4::operator[](unsigned i) const {
}
}
float KRVector4::sqrMagnitude() const {
float Vector4::sqrMagnitude() const {
// calculate the square of the magnitude (useful for comparison of magnitudes without the cost of a sqrt() function)
return x * x + y * y + z * z + w * w;
}
float KRVector4::magnitude() const {
float Vector4::magnitude() const {
return sqrtf(x * x + y * y + z * z + w * w);
}
void KRVector4::normalize() {
void Vector4::normalize() {
float inv_magnitude = 1.0f / sqrtf(x * x + y * y + z * z + w * w);
x *= inv_magnitude;
y *= inv_magnitude;
z *= inv_magnitude;
w *= inv_magnitude;
}
KRVector4 KRVector4::Normalize(const KRVector4 &v) {
Vector4 Vector4::Normalize(const Vector4 &v) {
float inv_magnitude = 1.0f / sqrtf(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w);
return KRVector4(v.x * inv_magnitude, v.y * inv_magnitude, v.z * inv_magnitude, v.w * inv_magnitude);
return Vector4(v.x * inv_magnitude, v.y * inv_magnitude, v.z * inv_magnitude, v.w * inv_magnitude);
}
float KRVector4::Dot(const KRVector4 &v1, const KRVector4 &v2) {
float Vector4::Dot(const Vector4 &v1, const Vector4 &v2) {
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
}
bool KRVector4::operator >(const KRVector4& b) const
bool Vector4::operator >(const Vector4& b) const
{
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
if(x != b.x) return x > b.x;
@@ -290,7 +290,7 @@ bool KRVector4::operator >(const KRVector4& b) const
return false;
}
bool KRVector4::operator <(const KRVector4& b) const
bool Vector4::operator <(const Vector4& b) const
{
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
if(x != b.x) return x < b.x;

View File

@@ -197,7 +197,7 @@
<ClCompile Include="..\kraken\KRUnknownManager.cpp" />
<ClCompile Include="..\kraken\vector2.cpp" />
<ClCompile Include="..\kraken\vector3.cpp" />
<ClCompile Include="..\kraken\KRVector4.cpp" />
<ClCompile Include="..\kraken\vector4.cpp" />
<ClCompile Include="..\kraken\KRViewport.cpp" />
</ItemGroup>
<ItemGroup>
@@ -273,13 +273,13 @@
<ClInclude Include="..\kraken\KRViewport.h" />
<ClInclude Include="..\kraken\public\KRAABB.h" />
<ClInclude Include="..\kraken\public\kraken.h" />
<ClInclude Include="..\kraken\public\KRFloat.h" />
<ClInclude Include="..\kraken\public\scalar.h" />
<ClInclude Include="..\kraken\public\KRMat4.h" />
<ClInclude Include="..\kraken\public\KRQuaternion.h" />
<ClInclude Include="..\kraken\public\KRTriangle3.h" />
<ClInclude Include="..\kraken\public\vector2.h" />
<ClInclude Include="..\kraken\public\vector3.h" />
<ClInclude Include="..\kraken\public\KRVector4.h" />
<ClInclude Include="..\kraken\public\vector4.h" />
<ClInclude Include="3rdparty\glew\glew-1.13.0\include\GL\glew.h" />
<ClInclude Include="3rdparty\glew\glew-1.13.0\include\GL\glxew.h" />
<ClInclude Include="3rdparty\glew\glew-1.13.0\include\GL\wglew.h" />

View File

@@ -30,9 +30,6 @@
<ClCompile Include="..\3rdparty\forsyth\forsyth.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\kraken\KRVector4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\kraken\KRMat4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -252,6 +249,9 @@
<ClCompile Include="..\kraken\vector3.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\kraken\vector4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\3rdparty\tinyxml2\tinyxml2.h">
@@ -473,15 +473,9 @@
<ClInclude Include="..\kraken\KRHelpers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\kraken\public\KRFloat.h">
<Filter>Header Files\public</Filter>
</ClInclude>
<ClInclude Include="..\kraken\public\KRMat4.h">
<Filter>Header Files\public</Filter>
</ClInclude>
<ClInclude Include="..\kraken\public\KRVector4.h">
<Filter>Header Files\public</Filter>
</ClInclude>
<ClInclude Include="..\kraken\public\kraken.h">
<Filter>Header Files\public</Filter>
</ClInclude>
@@ -500,5 +494,11 @@
<ClInclude Include="..\kraken\public\vector3.h">
<Filter>Header Files\public</Filter>
</ClInclude>
<ClInclude Include="..\kraken\public\vector4.h">
<Filter>Header Files\public</Filter>
</ClInclude>
<ClInclude Include="..\kraken\public\scalar.h">
<Filter>Header Files\public</Filter>
</ClInclude>
</ItemGroup>
</Project>