void QTerrainNode::addRepresentation()
{
	m_heightMapID = h3dAddResource(
		H3DResTypes::Texture, 
		qPrintable(m_xmlNode.attribute("heightmap")), 
		H3DResFlags::NoTexCompression | H3DResFlags::NoTexMipmaps );
	m_materialID = h3dAddResource(H3DResTypes::Material, qPrintable(m_xmlNode.attribute("material")), 0);
	// Load resource immediately since a later call to loadResourceFromDisk results in a bad behaviour of the Horde3D engine
	QDir textureDir( QDir::current() );
	QFile file(textureDir.absoluteFilePath(m_xmlNode.attribute("heightmap")));
	if (!file.open(QIODevice::ReadOnly))
		qWarning("Error opening resource %s", qPrintable(m_xmlNode.attribute("heightmap")));
	
	// Stupid return value, if false it can also be the case that the resource was loaded before instead of that their was an error
	h3dLoadResource(m_heightMapID, file.readAll().constData(), file.size());
	file.close();

	QSceneNode* parentNode = static_cast<QSceneNode*>(parent());
	unsigned int rootID = parentNode ? parentNode->hordeId() : H3DRootNode;

	m_hordeID = h3dextAddTerrainNode(rootID, qPrintable(m_xmlNode.attribute("name", "ATTENTION No Node Name")), m_heightMapID, m_materialID);
	h3dSetNodeParamI(m_hordeID, H3DEXTTerrain::BlockSizeI, blockSize());
	h3dSetNodeParamF(m_hordeID, H3DEXTTerrain::MeshQualityF, 0, meshQuality());
	h3dSetNodeParamF(m_hordeID, H3DEXTTerrain::SkirtHeightF, 0, skirtHeight());

	float x, y, z, rx, ry, rz, sx, sy, sz;
	getTransformation(x,y,z,rx,ry,rz,sx,sy,sz);
	h3dSetNodeTransform(m_hordeID, x, y, z, rx, ry, rz, sx, sy, sz);

	// Attachment		
	QDomElement attachment = m_xmlNode.firstChildElement("Attachment");	
	SceneTreeModel* model = static_cast<SceneTreeModel*>(m_model);
	AttachmentPlugIn* plugIn = model->nodeFactory()->attachmentPlugIn();
	if (!attachment.isNull() &&  plugIn != 0)
		plugIn->initNodeAttachment(this);
}
Пример #2
0
// ##################################################################
// begin main program
// ##################################################################
int main(int argc, char **argv)
{
   int i,ierr,nproc,myid;

   // start MPI communication
   ierr = MPI_Init(&argc,&argv);
   ierr = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
   ierr = MPI_Comm_size(MPI_COMM_WORLD, &nproc);

   // welcome
   if(myid == 0) welcome();
 
   // read inputs
   readInputs(myid);

   ierr = MPI_Barrier(MPI_COMM_WORLD);

   // create output folder to store data in
   createOutputFolder(myid);
   
   // create list of triangles containing a given node
   createTriangleList(&g[myid]);

   // find cell loops and vertex loops
   triCellAndVertexLoops(&g[myid]);

   // colouring algorithm
   greedyColouringAlgorithm(&g[myid]);

   // extract edges from triangulation 
   findTriangleEdges(&g[myid]);
            
   // invert edge list (reverse list)
   createEdgeList(&g[myid]);

   // create vertices on each edge (and quad edges)
   createVerticesOnEdge(&g[myid]);

   // create quad cells
   createInteriorVertices(&g[myid]);

   // find quad loops
   quadLoops(&g[myid]);

   // smoothing
   if(strcmp(smoothTechnique,"lagrangian")==0)
   {
   	smoothGrid(&g[myid],numSmooth);
	}
	else if(strcmp(smoothTechnique,"blend")==0)
	{
		smoothTriangleGrid(&g[myid],numSmooth);
     	recreateVerticesOnEdge(&g[myid]);
     	recreateInteriorVertices(&g[myid]);
	}

   // create boundary information
   boundaryNodeConnection_MPI(myid); 

   // create strand template
   if(iStrand) 
   {      
      // wait till thread 0 has finished
      ierr = MPI_Barrier(MPI_COMM_WORLD);

      createStrands(myid, &g[myid]);
   }

   // check quality and output statistics
   meshQuality(myid,&g[myid]);   
      
   // write tecplot outputs
   writeTecplot(myid,&g[myid]);

   ierr = MPI_Barrier(MPI_COMM_WORLD);

   //thanks
   if(myid == 0) thanks();

   MPI_Finalize();
	return 0;	
}