1 #pragma once
2 
3 #ifndef Y_XMLINTERFACE_H
4 #define Y_XMLINTERFACE_H
5 
6 #include <interface/yafrayinterface.h>
7 #include <map>
8 #include <iostream>
9 #include <fstream>
10 
11 __BEGIN_YAFRAY
12 
13 class YAFRAYPLUGIN_EXPORT xmlInterface_t: public yafrayInterface_t
14 {
15 	public:
16 		xmlInterface_t();
17 		// directly related to scene_t:
18 		virtual void loadPlugins(const char *path);
19 		virtual bool setLoggingAndBadgeSettings();
20 		virtual bool setupRenderPasses(); //!< setup render passes information
21 		virtual bool startGeometry();
22 		virtual bool endGeometry();
23 		virtual unsigned int getNextFreeID();
24 		virtual bool startTriMesh(unsigned int id, int vertices, int triangles, bool hasOrco, bool hasUV=false, int type=0, int obj_pass_index=0);
25 		virtual bool startTriMeshPtr(unsigned int *id, int vertices, int triangles, bool hasOrco, bool hasUV=false, int type=0, int obj_pass_index=0);
26 		virtual bool startCurveMesh(unsigned int id, int vertices, int obj_pass_index=0);
27 		virtual bool endTriMesh();
28 		virtual bool addInstance(unsigned int baseObjectId, matrix4x4_t objToWorld);
29 		virtual bool endCurveMesh(const material_t *mat, float strandStart, float strandEnd, float strandShape);
30 		virtual int  addVertex(double x, double y, double z); //!< add vertex to mesh; returns index to be used for addTriangle
31 		virtual int  addVertex(double x, double y, double z, double ox, double oy, double oz); //!< add vertex with Orco to mesh; returns index to be used for addTriangle
32 		virtual void addNormal(double nx, double ny, double nz); //!< add vertex normal to mesh; the vertex that will be attached to is the last one inserted by addVertex method
33 		virtual bool addTriangle(int a, int b, int c, const material_t *mat);
34 		virtual bool addTriangle(int a, int b, int c, int uv_a, int uv_b, int uv_c, const material_t *mat);
35 		virtual int  addUV(float u, float v);
36 		virtual bool smoothMesh(unsigned int id, double angle);
37 
38 		// functions directly related to renderEnvironment_t
39 		virtual light_t* 		createLight			(const char* name);
40 		virtual texture_t* 		createTexture		(const char* name);
41 		virtual material_t* 	createMaterial		(const char* name);
42 		virtual camera_t* 		createCamera		(const char* name);
43 		virtual background_t* 	createBackground	(const char* name);
44 		virtual integrator_t* 	createIntegrator	(const char* name);
45 		virtual VolumeRegion* 	createVolumeRegion	(const char* name);
46 		virtual unsigned int 	createObject		(const char* name);
47 		virtual void clearAll(); //!< clear the whole environment + scene, i.e. free (hopefully) all memory.
48 		virtual void render(colorOutput_t &output, progressBar_t *pb = nullptr); //!< render the scene...
49 		virtual bool startScene(int type=0); //!< start a new scene; Must be called before any of the scene_t related callbacks!
50 
51 		virtual void setOutfile(const char *fname);
52 
53 		void setXMLColorSpace(std::string color_space_string, float gammaVal);
54 
55 	protected:
56 		void writeParamMap(const paraMap_t &pmap, int indent=1);
57 		void writeParamList(int indent);
58 
59 		std::map<const material_t *, std::string> materials;
60 		std::ofstream xmlFile;
61 		std::string xmlName;
62 		const material_t *last_mat;
63 		size_t nmat;
64 		int n_uvs;
65 		unsigned int nextObj;
66 		float XMLGamma;
67 		colorSpaces_t XMLColorSpace;
68 };
69 
70 typedef xmlInterface_t * xmlInterfaceConstructor();
71 
72 __END_YAFRAY
73 
74 #endif // Y_XMLINTERFACE_H
75