include/material.h
author Radek Brich <radek.brich@devl.cz>
Wed, 23 Apr 2008 14:39:33 +0200
branchpyrit
changeset 79 062b1c4143f7
child 80 907929fa9b59
permissions -rw-r--r--
material and texture classes moved to material.(cc,h) 2D texture mappings from textures.cc polished and moved to material.h add ColourMap class and subclasses to make textures more flexible two example textures: CheckersTexture and CloudTexture (using Perlin noise)
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"
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
#include "noise.h"
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() {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
	virtual Colour evaluate(const Vector3 &point) = 0;
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:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    55
	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
    56
};
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
 * linear colour map
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    60
 * 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
    61
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    62
class LinearColourMap: public ColourMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    63
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    64
	Colour col,cdiff;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    65
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    66
	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
    67
		col(clow), cdiff(chigh-clow) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    68
	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
    69
};
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
 * bound colour map
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    73
 * 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
    74
 * 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
    75
 * 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
    76
 * 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
    77
 * implicit bottom bound)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    78
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    79
class BoundColourMap: public ColourMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    80
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    81
	Float *bounds;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    82
	Colour *colours;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    83
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    84
	BoundColourMap(Float *abounds, Colour *acolours):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    85
		bounds(abounds), colours(acolours) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    86
	Colour map(const Float &val)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    87
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    88
		Float *b = bounds;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    89
		Colour *c = colours;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    90
		while (val > *b)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    91
		{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    92
			b++;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    93
			c++;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    94
		}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    95
		return *c;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    96
	};
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
 * general texture mapping
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   101
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   102
class TextureMap
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   103
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   104
protected:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   105
	Vector3 center;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   106
	Float invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   107
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   108
	TextureMap(const Vector3 &acenter, const Float &size):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   109
		center(acenter), invsize(1./size) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   110
	virtual void map(const Vector3 &point, Float &u, Float &v) = 0;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   111
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   112
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
 * planar mapping
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
class PlanarMap: public TextureMap
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
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   119
	PlanarMap(const Vector3 &acenter, const Float &size):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   120
		TextureMap(acenter, size) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   121
	void map(const Vector3 &point, Float &u, Float &v)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   122
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   123
		const Vector3 p = point - center;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   124
		u = p.x*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   125
		v = p.y*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   126
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   127
};
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
 * cubic mapping
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
class CubicMap: public TextureMap
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
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   135
	CubicMap(const Vector3 &acenter, const Float &size):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   136
		TextureMap(acenter, size) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   137
	void map(const Vector3 &point, Float &u, Float &v)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   138
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   139
		const Vector3 p = point - center;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   140
		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
   141
		{
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.z))
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 (p.x < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   145
					u = -p.y;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   146
				else
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
				v = p.z;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   149
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   150
			else
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
				if (p.z < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   153
					u = -p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   154
				else
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
				v = p.y;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   157
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   158
		}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   159
		else
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
			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
   162
			{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   163
				if (p.y < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   164
					u = -p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   165
				else
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
				v = p.z;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   168
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   169
			else
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
				if (p.z < 0)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   172
					u = -p.x;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   173
				else
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
				v = p.y;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   176
			}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   177
		}
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   178
		u = u*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   179
		v = v*invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   180
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   181
};
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
 * cylindrical mapping
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
class CylinderMap: public TextureMap
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
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   189
	CylinderMap(const Vector3 &acenter, const Float &size):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   190
		TextureMap(acenter, size) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   191
	void map(const Vector3 &point, Float &u, Float &v)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   192
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   193
		const Vector3 p = point - center;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   194
		u = ( M_PI + atan2(p.z, p.x) ) * invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   195
		v = p.y * invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   196
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   197
};
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
 * spherical mapping
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
class SphereMap: public TextureMap
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
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   205
	SphereMap(const Vector3 &acenter, const Float &size):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   206
		TextureMap(acenter, size) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   207
	void map(const Vector3 &point, Float &u, Float &v)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   208
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   209
		const Vector3 p = point - center;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   210
		u = ( M_PI + atan2(p.z, p.x) ) * invsize;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   211
		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
   212
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   213
};
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
 * general 2D texture
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
class Texture2D: public 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
protected:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   221
	TextureMap *map;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   222
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   223
	Texture2D(TextureMap *amap): map(amap) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   224
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   225
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
 * 2D checkers texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   228
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   229
class CheckersTexture: public Texture2D
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   230
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   231
	ColourMap *colourmap;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   232
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   233
	CheckersTexture(TextureMap *tmap, ColourMap *cmap):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   234
		Texture2D(tmap), colourmap(cmap) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   235
	Colour evaluate(const Vector3 &point)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   236
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   237
		Float u,v, val;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   238
		map->map(point, u,v);
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   239
		val = 0.5*(round(u - floor(u)) + round(v - floor(v)));
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   240
		return colourmap->map(val);
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   241
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   242
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   243
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   244
/**
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   245
 * 3D perlin cloud texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   246
 */
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   247
class CloudTexture: public Texture
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   248
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   249
	Float detail;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   250
	ColourMap *colourmap;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   251
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   252
	CloudTexture(const Float &adetail, ColourMap *cmap):
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   253
		detail(adetail), colourmap(cmap) {};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   254
	Colour evaluate(const Vector3 &point)
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   255
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   256
		Float sum = 0.0;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   257
		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
   258
			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
   259
		//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
   260
		return colourmap->map(sum);
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   261
	};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   262
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   263
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
 * material
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
class Material
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   268
{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   269
public:
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   270
	Colour colour;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   271
	Texture *texture;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   272
	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
   273
	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
   274
	Float transmissivity, refract_index; // part of light which can be refracted; index of refraction
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   275
	bool smooth; // triangle smoothing
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   276
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   277
	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
   278
	{
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   279
		ambient = 0.2;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   280
		diffuse = 0.8;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   281
		specular = 0.2;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   282
		shininess = 0.5;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   283
		reflectivity = 0.2;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   284
		transmissivity = 0.0;
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   285
		refract_index = 1.3;
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
	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
   289
		{ 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
   290
	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
   291
	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
   292
		{ transmissivity = trans; refract_index = rindex; };
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   293
	void setSmooth(bool sm) { smooth = sm; };
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   294
};
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   295
062b1c4143f7 material and texture classes moved to material.(cc,h)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   296
#endif