Ejemplo n.º 1
0
void ReportEntityLabel::buildXML(QDomDocument & doc, QDomElement & parent)
{
    kDebug();
    //kdDebug() << "ReportEntityLabel::buildXML()");
    QDomElement entity = doc.createElement("label");

    // bounding rect
    buildXMLRect(doc, entity, pointRect());

    // name
    QDomElement n = doc.createElement("name");
    n.appendChild(doc.createTextNode(entityName()));
    entity.appendChild(n);

    // z
    QDomElement z = doc.createElement("zvalue");
    z.appendChild(doc.createTextNode(QString::number(zValue())));
    entity.appendChild(z);

    // font info
    //buildXMLFont ( doc,entity,font() );

    //text style info
    buildXMLTextStyle(doc, entity, textStyle());

    //Line Style
    buildXMLLineStyle(doc, entity, lineStyle());

    // text alignment
    int align = textFlags();
    // horizontal
    if ((align & Qt::AlignRight) == Qt::AlignRight)
        entity.appendChild(doc.createElement("right"));
    else if ((align & Qt::AlignHCenter) == Qt::AlignHCenter)
        entity.appendChild(doc.createElement("hcenter"));
    else // Qt::AlignLeft
        entity.appendChild(doc.createElement("left"));
    // vertical
    if ((align & Qt::AlignBottom) == Qt::AlignBottom)
        entity.appendChild(doc.createElement("bottom"));
    else if ((align & Qt::AlignVCenter) == Qt::AlignVCenter)
        entity.appendChild(doc.createElement("vcenter"));
    else // Qt::AlignTop
        entity.appendChild(doc.createElement("top"));

    // the text string
    QDomElement string = doc.createElement("string");
    string.appendChild(doc.createTextNode(text()));
    entity.appendChild(string);

    parent.appendChild(entity);
}
Ejemplo n.º 2
0
void OgreEntityRenderer::showEntity(const std::string& mesh)
{
	unloadEntity();
	try {
		std::string entityName(mTexture->getImage()->getName().c_str());
		entityName += "_entity";
		mEntity = mTexture->getRenderContext()->getSceneNode()->getCreator()->createEntity(entityName, mesh);
		setEntity(mEntity);
		mTexture->getRenderContext()->setActive(true);
	} catch (const std::exception& ex) {
		S_LOG_FAILURE("Error when creating entity." << ex);
	}
}
Ejemplo n.º 3
0
Renderable* World::createRenderable(const char* name) {
    std::string entityName(name);
    Renderable* entity = new Renderable();
    std::string modelPath = ENTITIES_DIR+entityName+PATH_SEPARATOR+entityName+OBJ_EXTENSION;

	Mesh* mesh = ResourceManager::instance()->createMesh(modelPath.c_str()).get(); // objLoader->loadOBJ(modelPath.c_str());
    //VertexBuffer *buffer = objLoader->loadOBJ(modelPath.c_str());
    //mesh->setVertexBuffer(buffer);
    entity->mesh = mesh;


    renderables.push_back(entity);
    return entity;
}
Ejemplo n.º 4
0
void ReportEntityCheck::buildXML(QDomDocument & doc, QDomElement & parent)
{
    kDebug() << endl;

    QDomElement entity = doc.createElement("check");

    // bounding rect
    buildXMLRect(doc, entity, pointRect());

    // name
    QDomElement n = doc.createElement("name");
    n.appendChild(doc.createTextNode(entityName()));
    entity.appendChild(n);

    // z
    QDomElement z = doc.createElement("zvalue");
    z.appendChild(doc.createTextNode(QString::number(zValue())));
    entity.appendChild(z);

    //Line Style
    buildXMLLineStyle(doc, entity, lineStyle());

    //Color
    QDomElement fc = doc.createElement("fgcolor");
    fc.appendChild(doc.createTextNode(m_foregroundColor->value().value<QColor>().name()));
    entity.appendChild(fc);

    QDomElement cs = doc.createElement("controlsource");
    cs.appendChild(doc.createTextNode(m_controlSource->value().toString()));
    entity.appendChild(cs);

    // the check style
    QDomElement sty = doc.createElement("checkstyle");
    sty.appendChild(doc.createTextNode(m_checkStyle->value().toString()));
    entity.appendChild(sty);

    parent.appendChild(entity);
}
Ejemplo n.º 5
0
void AssetLoader::readModel(Ogre::SceneManager* sceneMgr, Ogre::SceneNode* scnNode, const aiScene* scene, aiNode* nd)
{
	for (size_t n = 0; n < nd->mNumChildren; n++) 
	{	
		aiNode* cnd = nd->mChildren[n];
		Ogre::SceneNode* cnode = createChildSceneNodeWithTransform(scnNode, cnd);

		for (size_t i = 0; i < cnd->mNumMeshes; i++) {
			aiMesh* m = scene->mMeshes[cnd->mMeshes[i]];	
			aiMaterial* mat = scene->mMaterials[m->mMaterialIndex];

			std::string nodeName = getFullPathName(cnd);
			Ogre::MaterialPtr omat = createMaterial(Ogre::String(nodeName), m->mMaterialIndex, mat);

			aiVector3D* vec  = m->mVertices;
			aiVector3D* norm = m->mNormals;
			aiVector3D* uv   = m->mTextureCoords[0];
			aiColor4D*  vcol = NULL;	
			if (m->HasVertexColors(0)) vcol = m->mColors[0];

			// 頂点情報の読み込み
			Ogre::AxisAlignedBox aab;
			Ogre::ManualObject* mobj = new Ogre::ManualObject(nodeName+"_MObj");
			mobj->begin(omat->getName());
			//mobj->begin("Ogre/Skin");
			for (size_t n = 0; n < m->mNumVertices; n ++) {
				Ogre::Vector3 position(vec->x, vec->y, vec->z);
				aab.merge(position);

				mobj->position(vec->x, vec->y, vec->z); 
				vec++;  

				mobj->normal(norm->x, norm->y, norm->z);
				norm++; 

				if (uv)   { 
					mobj->textureCoord(uv->x, uv->y);        
					uv++;   
				}
				if (vcol) { 
					mobj->colour(vcol->r, vcol->g, vcol->b, vcol->a); 
					vcol++;
				}
			}

			// ポリゴンの構築
			for (size_t n = 0; n < m->mNumFaces; n++) {
				aiFace* face = &m->mFaces[n];
				for (size_t k = 0; k < face->mNumIndices; k++) {
					mobj->index(face->mIndices[k]);
				}
			}
			mobj->end();
			mobj->setBoundingBox(aab);

			Ogre::String meshName(nodeName+"_Mesh");
			mobj->convertToMesh(meshName);
			delete mobj;

			Ogre::String entityName(nodeName+"_Entity");
			std::cout << "entity: " << entityName << std::endl;
			Ogre::Entity* ent = sceneMgr->createEntity(entityName, meshName);
			cnode->attachObject(ent);
		}

		readModel(sceneMgr, cnode, scene, cnd);
	}
}