Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sun position algorithm #2870

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/appleseed.python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ set (sources
bindshadercompiler.cpp
bindshadergroup.cpp
bindshaderquery.cpp
bindsunpositioner.cpp
bindsurfaceshader.cpp
bindtexture.cpp
bindtilecallback.cpp
Expand Down
75 changes: 75 additions & 0 deletions src/appleseed.python/bindsunpositioner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

//
// This source file is part of appleseed.
// Visit https://appleseedhq.net/ for additional information and resources.
//
// This software is released under the MIT license.
//
// Copyright (c) 2020 Joao Marcos Costa, The appleseedhq Organization
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

// appleseed.python headers.
#include "bindentitycontainers.h"
#include "dict2dict.h"
#include "metadata.h"

// appleseed.renderer header.
#include "renderer/utility/solarpositionalgorithm.h"

// appleseed.foundation headers.
#include "foundation/platform/python.h"

namespace bpy = boost::python;
using namespace foundation;
using namespace renderer;

namespace
{
auto_release_ptr<SunPositioner> create_sun_positioner(const bpy::dict& params)
{
return SunPositionerFactory::create("Sun Positioner", bpy_dict_to_param_array(params));
}

void compute_sun_position(SunPositioner* sun_position)
{
sun_position->fetch_data();
sun_position->compute_sun_position();
}

bpy::list get_input_metadata()
{
return dictionary_array_to_bpy_list(SunPositionerFactory::get_input_metadata());
}
}

void bind_sun_positioner()
{
bpy::class_<SunPositioner, auto_release_ptr<SunPositioner>, bpy::bases<Entity>, boost::noncopyable>("SunPositioner", bpy::no_init)
.def("get_input_metadata", get_input_metadata).staticmethod("get_input_metadata")
.def("__init__", bpy::make_constructor(create_sun_positioner))
.def("compute_sun_position", compute_sun_position)

.def("get_zenith", &SunPositioner::get_zenith)
.def("get_azimuth", &SunPositioner::get_azimuth)
.def("get_solar_noon", &SunPositioner::get_solar_noon)
.def("get_sunrise", &SunPositioner::get_sunrise)
.def("get_sunset", &SunPositioner::get_sunset);
}
2 changes: 2 additions & 0 deletions src/appleseed.python/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void bind_scene();
void bind_shader_compiler();
void bind_shader_group();
void bind_shader_query();
void bind_sun_positioner();
void bind_surface_shader();
void bind_texture();
void bind_tile_callback();
Expand Down Expand Up @@ -132,6 +133,7 @@ extern "C" void bind_appleseed_python_classes()
bind_fresnel();
bind_display();
bind_project();
bind_sun_positioner();

bind_renderer_controller();
bind_tile_callback();
Expand Down
2 changes: 2 additions & 0 deletions src/appleseed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,8 @@ set (renderer_utility_sources
renderer/utility/settingsparsing.cpp
renderer/utility/settingsparsing.h
renderer/utility/shadowterminator.h
renderer/utility/solarpositionalgorithm.cpp
renderer/utility/solarpositionalgorithm.h
renderer/utility/spectrumclamp.h
renderer/utility/stochasticcast.h
renderer/utility/testutils.cpp
Expand Down
Loading