include/material.h
author Radek Brich <radek.brich@devl.cz>
Tue, 06 May 2008 09:39:58 +0200
branchpyrit
changeset 93 96d65f841791
parent 92 9af5c039b678
child 94 4c8abb8977dc
permissions -rw-r--r--
more build script tuning make all float constants single precision solve many warnings from msvc and gcc with various -W... flags add common.cc file for dbgmsg() function witch apparently cannot be inlined fix python module building with msvc, add manifest file handling remove forgotten RenderrowData class add stanford models download script for windows (.bat)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
/*
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
 * material.h: material and texture classes
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
 *
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
 * This file is part of Pyrit Ray Tracer.
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
 *
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
 * Copyright 2006, 2007, 2008  Radek Brich
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
 *
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
 * of this software and associated documentation files (the "Software"), to deal
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
 * in the Software without restriction, including without limitation the rights
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
 * copies of the Software, and to permit persons to whom the Software is
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
 * furnished to do so, subject to the following conditions:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
 *
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
 * The above copyright notice and this permission notice shall be included in
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
 * all copies or substantial portions of the Software.
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
 *
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
 * THE SOFTWARE.
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
#ifndef MATERIAL_H
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
#define MATERIAL_H
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
#include "common.h"
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
#include "vector.h"
88
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 82
diff changeset
    32
#include "pixmap.h"
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
 * perlin noise
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
Float perlin(Float x, Float y, Float z);
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    39
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
 * general texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
class Texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    43
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    44
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
	virtual ~Texture() {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
    46
	virtual Colour evaluate(const Vector &point) = 0;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    48
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    49
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    50
 * general colour map
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    51
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    52
class ColourMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    53
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
public:
82
930a2d3ecaed prepare structures for packet tracing
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    55
	virtual ~ColourMap() {};
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    56
	virtual Colour map(const Float &val) = 0;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    57
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    58
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    59
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    60
 * linear colour map
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    61
 * maps value lineary between two colours
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    62
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    63
class LinearColourMap: public ColourMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    64
{
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    65
	Colour col, cdiff;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    66
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    67
	LinearColourMap(const Colour &clow, const Colour &chigh):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    68
		col(clow), cdiff(chigh-clow) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    69
	Colour map(const Float &val) { return col + cdiff*val; };
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    70
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    71
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    72
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    73
 * bound colour map
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    74
 * initialize with two arrays, bounds and colours, of same size
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    75
 * bounds must contain numbers between 0 and 1 in rising order,
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    76
 * last number should be larger than max 'val'
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    77
 * colours are mapped to slices between bounds (with zero being
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    78
 * implicit bottom bound)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    79
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    80
class BoundColourMap: public ColourMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    81
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    82
	Float *bounds;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    83
	Colour *colours;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    84
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    85
	BoundColourMap(Float *abounds, Colour *acolours):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    86
		bounds(abounds), colours(acolours) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    87
	Colour map(const Float &val)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    88
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    89
		Float *b = bounds;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    90
		Colour *c = colours;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    91
		while (val > *b)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    92
		{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    93
			b++;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    94
			c++;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    95
		}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    96
		return *c;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    97
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    98
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    99
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   100
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   101
 * general texture mapping
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   102
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   103
class TextureMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   104
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   105
protected:
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   106
	Vector center;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   107
	Float invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   108
public:
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   109
	TextureMap(const Vector &acenter, const Float &size):
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   110
		center(acenter), invsize(1.0f/size) {};
82
930a2d3ecaed prepare structures for packet tracing
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
   111
	virtual ~TextureMap() {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   112
	virtual void map(const Vector &point, Float &u, Float &v) = 0;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   113
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   114
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   115
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   116
 * planar mapping
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   117
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   118
class PlanarMap: public TextureMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   119
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   120
public:
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   121
	PlanarMap(const Vector &acenter, const Float &size):
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   122
		TextureMap(acenter, size) {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   123
	void map(const Vector &point, Float &u, Float &v)
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   124
	{
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   125
		const Vector p = point - center;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   126
		u = p.x*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   127
		v = p.y*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   128
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   129
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   130
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   131
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   132
 * cubic mapping
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   133
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   134
class CubicMap: public TextureMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   135
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   136
public:
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   137
	CubicMap(const Vector &acenter, const Float &size):
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   138
		TextureMap(acenter, size) {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   139
	void map(const Vector &point, Float &u, Float &v)
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   140
	{
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   141
		const Vector p = point - center;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   142
		if (fabs(p.x) > fabs(p.y))
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   143
		{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   144
			if (fabs(p.x) > fabs(p.z))
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   145
			{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   146
				if (p.x < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   147
					u = -p.y;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   148
				else
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   149
					u = p.y;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   150
				v = p.z;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   151
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   152
			else
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   153
			{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   154
				if (p.z < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   155
					u = -p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   156
				else
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   157
					u = p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   158
				v = p.y;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   159
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   160
		}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   161
		else
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   162
		{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   163
			if (fabs(p.y) > fabs(p.z))
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   164
			{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   165
				if (p.y < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   166
					u = -p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   167
				else
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   168
					u = p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   169
				v = p.z;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   170
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   171
			else
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   172
			{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   173
				if (p.z < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   174
					u = -p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   175
				else
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   176
					u = p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   177
				v = p.y;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   178
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   179
		}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   180
		u = u*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   181
		v = v*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   182
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   183
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   184
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   185
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   186
 * cylindrical mapping
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   187
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   188
class CylinderMap: public TextureMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   189
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   190
public:
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   191
	CylinderMap(const Vector &acenter, const Float &size):
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   192
		TextureMap(acenter, size) {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   193
	void map(const Vector &point, Float &u, Float &v)
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   194
	{
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   195
		const Vector p = point - center;
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
   196
		u = ( PI + atan2(p.z, p.x) ) * invsize;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   197
		v = p.y * invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   198
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   199
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   200
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   201
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   202
 * spherical mapping
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   203
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   204
class SphereMap: public TextureMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   205
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   206
public:
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   207
	SphereMap(const Vector &acenter, const Float &size):
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   208
		TextureMap(acenter, size) {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   209
	void map(const Vector &point, Float &u, Float &v)
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   210
	{
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   211
		const Vector p = point - center;
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
   212
		u = ( PI + atan2(p.z, p.x) ) * invsize;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   213
		v = acos(p.y / p.mag()) * invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   214
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   215
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   216
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   217
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   218
 * general 2D texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   219
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   220
class Texture2D: public Texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   221
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   222
protected:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   223
	TextureMap *map;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   224
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   225
	Texture2D(TextureMap *amap): map(amap) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   226
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   227
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   228
/**
81
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   229
 * 2D image texture
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   230
 */
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   231
class ImageTexture: public Texture2D
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   232
{
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   233
	Pixmap *pixmap;
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   234
public:
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   235
	ImageTexture(TextureMap *tmap, Pixmap *image):
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   236
		Texture2D(tmap), pixmap(image) {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   237
	Colour evaluate(const Vector &point)
81
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   238
	{
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   239
		Float u,v;
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   240
		map->map(point, u,v);
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   241
		u = u - 0.5f;
81
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   242
		u -= floor(u);
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   243
		v = -(v - 0.5f);
81
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   244
		v -= floor(v);
82
930a2d3ecaed prepare structures for packet tracing
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
   245
		return pixmap->get((int)(u*pixmap->getWidth()), (int)(v*pixmap->getHeight()));
81
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   246
	};
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   247
};
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   248
9dbb9c8c115b add 2D pixmap texture class
Radek Brich <radek.brich@devl.cz>
parents: 80
diff changeset
   249
/**
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   250
 * 2D checkers texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   251
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   252
class CheckersTexture: public Texture2D
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   253
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   254
	ColourMap *colourmap;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   255
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   256
	CheckersTexture(TextureMap *tmap, ColourMap *cmap):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   257
		Texture2D(tmap), colourmap(cmap) {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   258
	Colour evaluate(const Vector &point)
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   259
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   260
		Float u,v, val;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   261
		map->map(point, u,v);
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   262
		val = 0.5f*(floor(0.5f + u - floor(u)) + floor(0.5f + v - floor(v)));
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   263
		return colourmap->map(val);
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   264
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   265
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   266
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   267
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   268
 * 3D perlin cloud texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   269
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   270
class CloudTexture: public Texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   271
{
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
   272
	ColourMap *colourmap;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   273
	Float detail;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   274
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   275
	CloudTexture(const Float &adetail, ColourMap *cmap):
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
   276
		colourmap(cmap), detail(adetail) {};
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   277
	Colour evaluate(const Vector &point)
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   278
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   279
		Float sum = 0.0;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   280
		for (int i = 1; i < detail; i++)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   281
			sum += fabs(perlin(point.x*i, point.y*i, point.z*i))/i;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   282
		//Float value = sinf(point.x + sum)/2 + 0.5;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   283
		return colourmap->map(sum);
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   284
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   285
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   286
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   287
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   288
 * material
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   289
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   290
class Material
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   291
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   292
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   293
	Colour colour;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   294
	Texture *texture;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   295
	Float ambient, diffuse, specular, shininess; // Phong constants
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   296
	Float reflectivity; // how much reflective is the surface
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   297
	Float transmissivity, refract_index; // part of light which can be refracted; index of refraction
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
   298
	int smooth; // triangle smoothing
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   299
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   300
	Material(const Colour &acolour): colour(acolour), texture(NULL), smooth(false)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   301
	{
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   302
		ambient = 0.2f;
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   303
		diffuse = 0.8f;
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   304
		specular = 0.2f;
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   305
		shininess = 0.5f;
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   306
		reflectivity = 0.2f;
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   307
		transmissivity = 0.0f;
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
   308
		refract_index = 1.3f;
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   309
	}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   310
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   311
	void setPhong(const Float amb, const Float dif, const Float spec, const Float shin)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   312
		{ ambient = amb; diffuse = dif; specular = spec; shininess = shin; };
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   313
	void setReflectivity(const Float refl) { reflectivity = refl; };
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   314
	void setTransmissivity(const Float trans, const Float rindex)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   315
		{ transmissivity = trans; refract_index = rindex; };
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
   316
	void setSmooth(int sm) { smooth = sm; };
80
907929fa9b59 remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents: 79
diff changeset
   317
	void setTexture(Texture *tex) { texture = tex; };
79
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   318
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   319
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   320
#endif