aboutsummaryrefslogtreecommitdiff
path: root/advtrains/textures/drwho_screwdriver.png
blob: b50bcaec7bd10141cc2d9b4a6883b5927ef0d882 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 06 00 00 00 1f f3 ff .PNG........IHDR................
0020 61 00 00 00 06 62 4b 47 44 00 ff 00 ff 00 ff a0 bd a7 93 00 00 00 09 70 48 59 73 00 00 0b 13 00 a....bKGD..............pHYs.....
0040 00 0b 13 01 00 9a 9c 18 00 00 00 07 74 49 4d 45 07 e0 03 05 10 1e 37 da 34 02 60 00 00 00 d5 49 ............tIME......7.4.`....I
0060 44 41 54 38 cb cd 93 a1 6e c2 50 14 40 cf a3 cd 5e 4d 2b c8 0c 4d f5 3c 09 6a 09 41 81 c4 f4 0b DAT8....n.P.@...^M+..M.<.j.A....
0080 ea ca 5f f0 03 fb 80 b9 fd 40 ed c4 24 92 54 23 27 b0 75 37 81 a4 a4 ed 9b 21 64 a2 8c 5b b7 63 .._......@..$.T#'.u7.....!d..[.c
00a0 df 3d 47 dc 9b 67 50 b2 dd ba 31 b0 04 56 40 0d 7c 02 3b 1f 3d f3 a6 e1 4d 84 18 70 51 c4 c2 f7 .=G..gP...1..V@.|.;.=...M..pQ...
00c0 d9 8c 06 04 5e 45 98 94 25 a6 2c 19 89 f0 02 cc 86 04 8e 5d 57 ff 9e 6f 81 b3 a7 b5 a7 53 d9 db ....^E..%.,........]W..o.....S..
00e0 4b cd f3 24 21 49 ec 29 0c f9 f2 3c 3e 8c 46 ce b2 cc 05 41 40 db b6 c4 f1 fb 1a 78 02 0e c0 b7 K..$!I.)...<>.F....A@......x....
0100 4a 76 e0 d2 34 75 7d ef e6 91 6c ad a5 aa 2a 8a a2 30 83 02 1a f9 6e 40 2b f7 06 86 c8 7d 38 fe Jv..4u}...l...*..0....n@+....}8.
0120 58 d8 c3 6d e7 79 ee ae 11 35 b7 bf 20 22 aa cb fc 3f 7e 00 74 11 56 74 01 0e 49 92 00 00 00 00 X..m.y...5..."...?~.t.Vt..I.....
0140 49 45 4e 44 ae 42 60 82 IEND.B`.
> 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
/*
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.
*/

#include "irrlichttypes_extrabloated.h"
#include <ISceneNode.h>
#include "camera.h"

#ifndef SKY_HEADER
#define SKY_HEADER

#define SKY_MATERIAL_COUNT 5
#define SKY_STAR_COUNT 200

class ITextureSource;

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

	virtual void OnRegisterSceneNode();

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

	virtual const core::aabbox3d<f32>& getBoundingBox() const;

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

	// Used by Irrlicht for optimizing rendering
	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; }

	video::SColor getBgColor(){
		return m_visible ? m_bgcolor : m_fallback_bg_color;
	}
	video::SColor getSkyColor(){
		return m_visible ? m_skycolor : m_fallback_bg_color;
	}
	
	bool getCloudsVisible(){ return m_clouds_visible && m_visible; }
	video::SColorf getCloudColor(){ return m_cloudcolor_f; }

	void setVisible(bool visible){ m_visible = visible; }
	void setFallbackBgColor(const video::SColor &fallback_bg_color){
		m_fallback_bg_color = fallback_bg_color;
	}

private:
	core::aabbox3d<f32> 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)
			return 0;
		if (x <= 0.4) // when the sun and moon are aligned
			return (x - 0.3) * 10;
		if (x <= 0.5)
			return (0.5 - x) * 10;
		return 0;
	}

	// Mix two colors by a given amount
	video::SColor m_mix_scolor(video::SColor col1, video::SColor col2, f32 factor)
	{
		video::SColor result = video::SColor(
			col1.getAlpha() * (1 - factor) + col2.getAlpha() * factor,
			col1.getRed() * (1 - factor) + col2.getRed() * factor,
			col1.getGreen() * (1 - factor) + col2.getGreen() * factor,
			col1.getBlue() * (1 - factor) + col2.getBlue() * factor);
		return result;
	}
	video::SColorf m_mix_scolorf(video::SColorf col1, video::SColorf col2, f32 factor)
	{
		video::SColorf result = video::SColorf(
			col1.r * (1 - factor) + col2.r * factor,
			col1.g * (1 - factor) + col2.g * factor,
			col1.b * (1 - factor) + col2.b * factor,
			col1.a * (1 - factor) + col2.a * factor);
		return result;
	}

	bool m_visible;
	video::SColor m_fallback_bg_color; // Used when m_visible=false
	bool m_first_update;
	float m_time_of_day;
	float m_time_brightness;
	bool m_sunlight_seen;
	float m_brightness;
	float m_cloud_brightness;
	bool m_clouds_visible;
	bool m_directional_colored_fog;
	video::SColorf m_bgcolor_bright_f;
	video::SColorf m_skycolor_bright_f;
	video::SColorf m_cloudcolor_bright_f;
	video::SColor m_bgcolor;
	video::SColor m_skycolor;
	video::SColorf m_cloudcolor_f;
	v3f m_stars[SKY_STAR_COUNT];
	video::S3DVertex m_star_vertices[SKY_STAR_COUNT*4];
	video::ITexture* m_sun_texture;
	video::ITexture* m_moon_texture;
	video::ITexture* m_sun_tonemap;
	video::ITexture* m_moon_tonemap;
};

#endif