00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "g-map-vertex.hh"
00026 using namespace std;
00027 using namespace GMap3d;
00028
00029 #define PRINT_VERTEX(V) \
00030 AOutStream << "<" << (V)->getX() << "," << (V)->getZ() << "," \
00031 << (V)->getY() << ">"
00032
00033 bool CGMapVertex::exportToPov(ofstream & AOutStream)
00034 {
00035 int treated = getNewMark();
00036
00037 AOutStream
00038 << "// Compilation:" << endl
00039 << "// $ povray +A0.1 +W640 +H480 +I<thisFile.pov>" << endl
00040 << endl
00041 << "#include \"colors.inc\"" << endl
00042 << "#include \"textures.inc\"" << endl
00043 << "#include \"finish.inc\"" << endl
00044 << endl
00045 << "camera" << endl
00046 << "{" << endl
00047 << "\t" << "location <-1,3,-7>" << endl
00048 << "\t" << "right 640/480*x" << endl
00049 << "\t" << "look_at <0,0,0>" << endl
00050 << "}" << endl
00051 << endl
00052 << "light_source" << endl
00053 << "{"
00054 << "\t" << "<-10,20,-20>" << endl
00055 << "\t" << "color White" << endl
00056 << "}" << endl
00057 << endl
00058 << "light_source" << endl
00059 << "{"
00060 << "\t" << "<0,10,-20>" << endl
00061 << "\t" << "color White/2" << endl
00062 << "}" << endl
00063 << endl
00064 << "#declare the_texture =" << endl
00065 << "texture" << endl
00066 << "{" << endl
00067 << "\t" << "pigment { rgbf <0.5,0.9,1, 0.7> }" << endl
00068 << "\t" << "finish { phong 0.9 phong_size 10 reflection 0.1 }" << endl
00069 << "}" << endl
00070 << endl
00071 << "mesh" << endl
00072 << "{" << endl;
00073
00074 for (CDynamicCoverageAll it(this); it.cont(); ++it)
00075 if (!isMarked(*it, treated))
00076 {
00077 markOrbit(*it, ORBIT_FACE, treated);
00078
00079 if (isClosedPolyline(*it))
00080 {
00081 int nbVertices = getNbPolylineVertices(*it);
00082
00083 if (nbVertices >= 3)
00084 {
00085 if (nbVertices == 3)
00086 {
00087 AOutStream << "\ttriangle {";
00088
00089 for (CDynamicCoverage01 face(this, *it);
00090 face.cont(); ++face, ++face)
00091 {
00092 CVertex & vertex = * findVertex(*face);
00093
00094 if (*face != *it)
00095 AOutStream << ",";
00096
00097 AOutStream << " ";
00098 PRINT_VERTEX(& vertex);
00099 }
00100
00101 AOutStream << " }" << endl;
00102 }
00103 else
00104 {
00105 CVertex bary = barycenter(*it, ORBIT_01);
00106 CVertex * pred = findVertex(alpha10(*it));
00107
00108 for (CDynamicCoverage01 face(this, *it);
00109 face.cont(); ++face, ++face)
00110 {
00111 CVertex * vertex = findVertex(*face);
00112
00113 AOutStream << "\ttriangle { ";
00114 PRINT_VERTEX(& bary);
00115 AOutStream << ", ";
00116 PRINT_VERTEX(pred);
00117 AOutStream << ", ";
00118 PRINT_VERTEX(vertex);
00119 AOutStream << " }" << endl;
00120
00121 pred = vertex;
00122 }
00123 }
00124 }
00125 }
00126 }
00127
00128 negateMaskMark(treated);
00129 freeMark(treated);
00130
00131 AOutStream << endl
00132 << "\t" << "texture { the_texture }" << endl
00133 << "}" << endl;
00134
00135 return true;
00136 }
00137
00138 #undef PRINT_VERTEX
00139