00001 #include <stdlib.h>
00002 #include <iostream>
00003
00004 int main( int argc, char **argv )
00005 {
00006 if( argc != 3 )
00007 {
00008 std::cerr << "Must give the number of points on x and y\n";
00009 exit(-1);
00010 }
00011
00012 unsigned int nX = atoi(argv[1]);
00013 unsigned int nY = atoi(argv[2]);
00014
00015
00016 std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<X3D>\n<Scene>\n\n <DeformableOctreeNode> \n <DeformableOctreeShapeNode DEF=\"DOSN\"> \n <IndexedFaceSet DEF=\"DOSN_IFS1\" coordIndex=\" ";
00017
00018
00019 for( unsigned i=0 ; i<nX-1 ; ++i )
00020 {
00021 for( unsigned int j=0 ; j<nY-1 ; ++j )
00022 {
00023 std::cout << i*nY+j << " " << (i+1)*nY+j << " " << i*nY+j+1 << " -1 ";
00024 std::cout << i*nY+j+1 << " " << (i+1)*nY+j << " " << (i+1)*nY+j+1 << " -1 ";
00025 }
00026 }
00027
00028
00029 for( unsigned i=nX ; i<2*nX-1 ; ++i )
00030 {
00031 for( unsigned int j=0 ; j<nY-1 ; ++j )
00032 {
00033 std::cout << i*nY+j << " " << (i+1)*nY+j << " " << i*nY+j+1 << " -1 ";
00034 std::cout << i*nY+j+1 << " " << (i+1)*nY+j << " " << (i+1)*nY+j+1 << " -1 ";
00035 }
00036 }
00037
00038
00039
00040
00041 std::cout << " \" solid=\"false\"> \n <Coordinate DEF=\"DOSN_coord1\" point=\" ";
00042
00043 for( unsigned i=0 ; i<nX ; ++i )
00044 {
00045 static float dx = 0.1;
00046 float x = i*dx;
00047 float z = 0.0;
00048
00049 for( unsigned j=0 ; j < nY ; ++j )
00050 {
00051 std::cout << x << " " << dx*j << " " << z << ", ";
00052 }
00053 }
00054
00055
00056 for( unsigned i=nX ; i<nX*2 ; ++i )
00057 {
00058 static float dx = 0.1;
00059 float x = (i-nX)*dx;
00060 float z = nX*dx*dx*4;
00061
00062 for( unsigned j=0 ; j < nY ; ++j )
00063 {
00064 std::cout << x << " " << dx*j << " " << z << ", ";
00065 }
00066 }
00067
00068
00069
00070 std::cout << "\"/> \n </IndexedFaceSet> \n <Appearance> \n <Material diffuseColor=\"0.5 0.0 0.0\" shininess=\"30\" specularColor=\"0.6 0.6 0.6\" /> \n </Appearance> \n \n </DeformableOctreeShapeNode> \n\n </DeformableOctreeNode> \n\n </Scene> \n</X3D> \n";
00071
00072
00073 }