Welcome to mirror list, hosted at ThFree Co, Russian Federation.

yafexternal.h « intern « yafray « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7130bd554664a0b3cf852c2af58d446cc8ec3620 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#ifndef __YAFINTERFACE_H
#define __YAFINTERFACE_H

#include<vector>
#include<string>
#include<list>
#include<map>

namespace yafray
{

typedef float PFLOAT;
typedef float GFLOAT;
typedef float CFLOAT;

class point3d_t
{
	public:
		point3d_t() { x = y = z = 0; }
		point3d_t(PFLOAT ix) { x = y = z = ix; }
		point3d_t(PFLOAT ix, PFLOAT iy, PFLOAT iz=0) { x=ix;  y=iy;  z=iz; }
		point3d_t(const point3d_t &s) { x=s.x;  y=s.y;  z=s.z; }
		void set(PFLOAT ix, PFLOAT iy, PFLOAT iz=0) { x=ix;  y=iy;  z=iz; }
		point3d_t& operator= (const point3d_t &s) { x=s.x;  y=s.y;  z=s.z;  return *this; }
		~point3d_t() {};
		PFLOAT x,y,z;
};

class color_t
{
	public:
		color_t() {R=G=B=0;};
		color_t(CFLOAT r,CFLOAT g,CFLOAT b) {R=r;G=g;B=b;};
		~color_t() {};
		void set(CFLOAT r,CFLOAT g,CFLOAT b) {R=r;G=g;B=b;};

		CFLOAT R,G,B;
};

class colorA_t : public color_t
{
	public:
		colorA_t() { A=1; }
		colorA_t(const color_t &c):color_t(c) { A=1; }
		colorA_t(CFLOAT r, CFLOAT g, CFLOAT b, CFLOAT a=0):color_t(r,g,b) {A=a;}
		~colorA_t() {};
		void set(CFLOAT r, CFLOAT g, CFLOAT b, CFLOAT a=0) {color_t::set(r,g,b);A=a; };

	protected:
		CFLOAT A;
};

#define TYPE_FLOAT  0
#define TYPE_STRING 1
#define TYPE_POINT  2
#define TYPE_COLOR  3
#define TYPE_NONE   -1

class parameter_t
{
	public:
		parameter_t(const std::string &s);
		parameter_t(float f);
		parameter_t(const colorA_t &c);
		parameter_t(const point3d_t &p);
		parameter_t();
		~parameter_t();

		const std::string 		&getStr() {used=true;return str;};
		float 					&getFnum() {used=true;return fnum;};
		const point3d_t &getP() {used=true;return P;};
		const color_t 	&getC() {used=true;return C;};
		const colorA_t 	&getAC() {used=true;return C;};
		int type;
		bool used;
	protected:
		std::string str;
		float fnum;
		point3d_t P;
		colorA_t C;
};

class paramMap_t
{
	public:
		paramMap_t();
		virtual bool getParam(const std::string &name,const std::string *&s);
		virtual bool getParam(const std::string &name,bool &b);
		virtual bool getParam(const std::string &name,float &f);
		virtual bool getParam(const std::string &name,double &f);
		virtual bool getParam(const std::string &name,int &i);
		virtual bool getParam(const std::string &name,point3d_t &p);
		virtual bool getParam(const std::string &name,color_t &c);
		virtual bool getParam(const std::string &name,colorA_t &c);
		virtual bool includes(const std::string &label,int type)const;
		virtual void checkUnused(const std::string &env)const;
		virtual parameter_t & operator [] (const std::string &key);
		virtual void clear();
		virtual ~paramMap_t();
	protected:
		std::map<std::string,parameter_t> dicc;
};

class light_t;
class shader_t;
class texture_t;
class filter_t;
class background_t;

class renderEnvironment_t
{
	public:
		typedef light_t * light_factory_t(paramMap_t &,renderEnvironment_t &);
		typedef shader_t *shader_factory_t(paramMap_t &,std::list<paramMap_t> &,
				renderEnvironment_t &);
		typedef texture_t *texture_factory_t(paramMap_t &,renderEnvironment_t &);
		typedef filter_t *filter_factory_t(paramMap_t &,renderEnvironment_t &);
		typedef background_t *background_factory_t(paramMap_t &,renderEnvironment_t &);
		
		virtual shader_t *getShader(const std::string name)const=0;
		virtual texture_t *getTexture(const std::string name)const=0;

		virtual void repeatFirstPass()=0;

		virtual void registerFactory(const std::string &name,light_factory_t *f)=0;
		virtual void registerFactory(const std::string &name,shader_factory_t *f)=0;
		virtual void registerFactory(const std::string &name,texture_factory_t *f)=0;
		virtual void registerFactory(const std::string &name,filter_factory_t *f)=0;
		virtual void registerFactory(const std::string &name,background_factory_t *f)=0;

		renderEnvironment_t() {};
		virtual ~renderEnvironment_t() {};

};

class colorOutput_t
{
	public:
		virtual ~colorOutput_t() {};
		virtual bool putPixel(int x, int y,const color_t &c, 
				CFLOAT alpha=0,PFLOAT depth=0)=0;
		virtual void flush()=0;
};

class yafrayInterface_t : public renderEnvironment_t
{
	public:
		virtual void transformPush(float *m)=0;
		virtual void transformPop()=0;
		virtual void addObject_trimesh(const std::string &name,
				std::vector<point3d_t> &verts, const std::vector<int> &faces,
				std::vector<GFLOAT> &uvcoords, std::vector<CFLOAT> &vcol,
				const std::vector<std::string> &shaders,const std::vector<int> &faceshader,
				float sm_angle,bool castShadows,bool useR,bool receiveR,bool caus,bool has_orco,
				const color_t &caus_rcolor,const color_t &caus_tcolor,float caus_IOR)=0;

		virtual void addObject_reference(const std::string &name,const std::string &original)=0;
		// lights
		virtual void addLight(paramMap_t &p)=0;
    // textures
		virtual void addTexture(paramMap_t &p)=0;
		// shaders
		virtual void addShader(paramMap_t &p,std::list<paramMap_t> &modulators)=0;
		// filters
		virtual void addFilter(paramMap_t &p)=0;
		// backgrounds
		virtual void addBackground(paramMap_t &p)=0;
		//camera
    virtual void addCamera(paramMap_t &p)=0;
		//render
		virtual void render(paramMap_t &p)=0;
		//render
		virtual void render(paramMap_t &p,colorOutput_t &output)=0;
		
		virtual void clear()=0;

		virtual ~yafrayInterface_t() {};
};

typedef yafrayInterface_t * yafrayConstructor(int,const std::string &);

}

#define YAFRAY_SYMBOL "getYafray"

#endif