Skip to content

Commit

Permalink
Light Radius changes automatic
Browse files Browse the repository at this point in the history
  • Loading branch information
mizquierdo97 committed May 8, 2018
1 parent 41050c4 commit 8054e5f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Engine/CompLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void CompLight::Update(float dt)
{
parent->box_fixed.SetFromCenterAndSize(GetGameObjectPos(), float3(radius, radius, radius));
}

}

void CompLight::Draw()
Expand Down Expand Up @@ -296,6 +297,13 @@ void CompLight::Load(const JSON_Object * object, std::string name)
parent->box_fixed.SetFromCenterAndSize(GetGameObjectPos(), float3(radius, radius, radius));

if (radius == 0) radius = 50;

if (properties[3] > 0.0001f) {
radius = (-properties[2] + sqrt(properties[2] - 4 * (properties[1] - 100) * properties[3]) / (2 * properties[3]));
}
else {
radius = (properties[1] - 100) / -properties[2];
}
}

void CompLight::GetOwnBufferSize(uint& buffer_size)
Expand Down Expand Up @@ -351,6 +359,14 @@ void CompLight::LoadBinary(char** cursor)
parent->box_fixed.SetFromCenterAndSize(GetGameObjectPos(), float3(radius, radius, radius));

if (radius == 0) radius = 50;

float k = 0.1f;
if (properties[3] > 0.0001f) {
radius = (-(properties[2] * k) + sqrt(properties[2] * k - 4 * (properties[1]*k -properties[0]) * properties[3]*k) / (2 * properties[3] * k));
}
else {
radius = 1-(properties[1] * k) / properties[2]*k;
}
}

void CompLight::UpdateFrustum()
Expand Down
Binary file modified Engine/Game/Assets/SceneBinary/LVL2_Zone_3.culverinscene
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Default MaterialShaderName:":"DefaultShader","Default MaterialNum Textures:":4,"Default MaterialAlpha:":1,"Default MaterialGlow:":false,"Default MaterialCastShadow:":true,"Default MaterialSource Blend:":1,"Default MaterialDestiny Blend:":771,"Default MaterialResource Material UUID 0":1493343184,"Default MaterialResource Material Var Name 0":"albedo","Default MaterialResource Material UUID 1":1198054584,"Default MaterialResource Material Var Name 1":"glossines_map","Default MaterialResource Material UUID 2":1197634842,"Default MaterialResource Material Var Name 2":"normal_map","Default MaterialResource Material UUID 3":187772813,"Default MaterialResource Material Var Name 3":"specular_map","Default MaterialNum Bools:":1,"Default MaterialBool:0":false,"Default MaterialBool Name:0":"activate_fresnel","Default MaterialNum Ints:":0,"Default MaterialNum Floats:":5,"Default MaterialFloat:0":1,"Default MaterialFloat Name:0":"a_Kd","Default MaterialFloat:1":1,"Default MaterialFloat Name:1":"fresnel_bias","Default MaterialFloat:2":1,"Default MaterialFloat Name:2":"fresnel_lerp","Default MaterialFloat:3":1,"Default MaterialFloat Name:3":"fresnel_power","Default MaterialFloat:4":1,"Default MaterialFloat Name:4":"fresnel_scale","Default MaterialNum Float3:":0,"Default MaterialNum Colors:":0,"Default MaterialNum Cubes:":0}
{"Default MaterialShaderName:":"DefaultShader","Default MaterialNum Textures:":4,"Default MaterialAlpha:":1,"Default MaterialGlow:":false,"Default MaterialCastShadow:":true,"Default MaterialSource Blend:":1,"Default MaterialDestiny Blend:":771,"Default MaterialResource Material UUID 0":26315541,"Default MaterialResource Material Var Name 0":"albedo","Default MaterialResource Material UUID 1":1198054584,"Default MaterialResource Material Var Name 1":"glossines_map","Default MaterialResource Material UUID 2":1463945749,"Default MaterialResource Material Var Name 2":"normal_map","Default MaterialResource Material UUID 3":187772813,"Default MaterialResource Material Var Name 3":"specular_map","Default MaterialNum Bools:":1,"Default MaterialBool:0":false,"Default MaterialBool Name:0":"activate_fresnel","Default MaterialNum Ints:":0,"Default MaterialNum Floats:":5,"Default MaterialFloat:0":1,"Default MaterialFloat Name:0":"a_Kd","Default MaterialFloat:1":1,"Default MaterialFloat Name:1":"fresnel_bias","Default MaterialFloat:2":1,"Default MaterialFloat Name:2":"fresnel_lerp","Default MaterialFloat:3":1,"Default MaterialFloat Name:3":"fresnel_power","Default MaterialFloat:4":1,"Default MaterialFloat Name:4":"fresnel_scale","Default MaterialNum Float3:":0,"Default MaterialNum Colors:":0,"Default MaterialNum Cubes:":0}

0 comments on commit 8054e5f

Please sign in to comment.