aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules/FindJson.cmake
blob: 1558b0fcfab63c894ca61546b51188172a46f201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Look for JSONCPP if asked to.
# We use a bundled version by default because some distros ship versions of
# JSONCPP that cause segfaults and other memory errors when we link with them.
# See https://github.com/minetest/minetest/issues/1793

mark_as_advanced(JSON_LIBRARY JSON_INCLUDE_DIR)
option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JSONCPP.  May cause segfaults and other memory errors!" FALSE)

if(ENABLE_SYSTEM_JSONCPP)
	find_library(JSON_LIBRARY NAMES jsoncpp)
	find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp)

	include(FindPackageHandleStandardArgs)
	find_package_handle_standard_args(JSONCPP DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)

	if(JSONCPP_FOUND)
		message(STATUS "Using system JSONCPP library.")
	endif()
endif()

if(NOT JSONCPP_FOUND)
	message(STATUS "Using bundled JSONCPP library.")
	set(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/json)
	set(JSON_LIBRARY jsoncpp)
	add_subdirectory(json)
endif()

'#n136'>136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#pragma once

#include "irrlichttypes_extrabloated.h"
#include <ISceneNode.h>
#include <array>
#include "camera.h"
#include "irr_ptr.h"
#include "shader.h"
#include "skyparams.h"

#define SKY_MATERIAL_COUNT 12

class ITextureSource;

// Skybox, rendered with zbuffer turned off, before all other nodes.
class Sky : public scene::ISceneNode
{
public:
	//! constructor
	Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShaderSource *ssrc);

	virtual void OnRegisterSceneNode();

	//! renders the node.
	virtual void render();

	virtual const aabb3f &getBoundingBox() const { return m_box; }

	// Used by Irrlicht for optimizing rendering
	virtual video::SMaterial &getMaterial(u32 i) { return m_materials[i]; }
	virtual u32 getMaterialCount() const { return SKY_MATERIAL_COUNT; }

	void update(float m_time_of_day, float time_brightness, float direct_brightness,
			bool sunlight_seen, CameraMode cam_mode, float yaw, float pitch);

	float getBrightness() { return m_brightness; }

	const video::SColor &getBgColor() const
	{
		return m_visible ? m_bgcolor : m_fallback_bg_color;
	}

	const video::SColor &getSkyColor() const
	{
		return m_visible ? m_skycolor : m_fallback_bg_color;
	}

	void setSunVisible(bool sun_visible) { m_sun_params.visible = sun_visible; }
	bool getSunVisible() const { return m_sun_params.visible; }
	void setSunTexture(const std::string &sun_texture,
		const std::string &sun_tonemap, ITextureSource *tsrc);
	void setSunScale(f32 sun_scale) { m_sun_params.scale = sun_scale; }
	void setSunriseVisible(bool glow_visible) { m_sun_params.sunrise_visible = glow_visible; }
	void setSunriseTexture(const std::string &sunglow_texture, ITextureSource* tsrc);

	void setMoonVisible(bool moon_visible) { m_moon_params.visible = moon_visible; }
	bool getMoonVisible() const { return m_moon_params.visible; }
	void setMoonTexture(const std::string &moon_texture,
		const std::string &moon_tonemap, ITextureSource *tsrc);
	void setMoonScale(f32 moon_scale) { m_moon_params.scale = moon_scale; }

	void setStarsVisible(bool stars_visible) { m_star_params.visible = stars_visible; }
	void setStarCount(u16 star_count);
	void setStarColor(video::SColor star_color) { m_star_params.starcolor = star_color; }
	void setStarScale(f32 star_scale) { m_star_params.scale = star_scale; updateStars(); }

	bool getCloudsVisible() const { return m_clouds_visible && m_clouds_enabled; }
	const video::SColorf &getCloudColor() const { return m_cloudcolor_f; }

	void setVisible(bool visible) { m_visible = visible; }
	// Set only from set_sky API
	void setCloudsEnabled(bool clouds_enabled) { m_clouds_enabled = clouds_enabled; }
	void setFallbackBgColor(video::SColor fallback_bg_color)
	{
		m_fallback_bg_color = fallback_bg_color;
	}
	void overrideColors(video::SColor bgcolor, video::SColor skycolor)
	{
		m_bgcolor = bgcolor;
		m_skycolor = skycolor;
	}
	void setSkyColors(const SkyColor &sky_color);
	void setHorizonTint(video::SColor sun_tint, video::SColor moon_tint,
		const std::string &use_sun_tint);
	void setInClouds(bool clouds) { m_in_clouds = clouds; }
	void clearSkyboxTextures() { m_sky_params.textures.clear(); }
	void addTextureToSkybox(const  std::string &texture, int material_id,
		ITextureSource *tsrc);
	const video::SColorf &getCurrentStarColor() const { return m_star_color; }

	float getSkyBodyOrbitTilt() const { return m_sky_body_orbit_tilt; }

private:
	aabb3f m_box;
	video::SMaterial m_materials[SKY_MATERIAL_COUNT];
	// How much sun & moon transition should affect horizon color
	float m_horizon_blend()
	{
		if (!m_sunlight_seen)
			return 0;
		float x = m_time_of_day >= 0.5 ? (1 - m_time_of_day) * 2
					       : m_time_of_day * 2;

		if (x <= 0.3)