Example #1
0
void CGUIFileOpenDialog::pathToStringW(irr::core::stringw& result, const irr::io::path& p)
{
#ifndef _IRR_WCHAR_FILESYSTEM
	char* oldLocale = setlocale(LC_CTYPE, NULL);
	setlocale(LC_CTYPE,"");	// multibyteToWString is affected by LC_CTYPE. Filenames seem to need the system-locale.
	core::multibyteToWString(result, p);
	setlocale(LC_CTYPE, oldLocale);
#else
	result = p.c_str();
#endif
}
Example #2
0
CGWIC_BodyPart::CGWIC_BodyPart(irr::io::path modelfile, irr::scene::ISceneNode* parentn, irr::IrrlichtDevice* dev, irrBulletWorld* phy)
{
	std::cout << "BodyPart[] c'tor()" << std::endl;
	std::cout << "modelfile: " << modelfile.c_str() << std::endl;
	irDevice = dev;
	phy_world = phy;
	scManager = dev->getSceneManager();
	irDriver = dev->getVideoDriver();
	parent = parentn;
	mesh = NULL;
	root = NULL;
	mass = 2.f;
	collider = NULL;
	colmesh = NULL;
	colbody = NULL;
	hinge = NULL;
	slots.push_back(NULL); //zero slot is in-slot
	success = LoadModelFile(GWIC_BPARTS_DIR+modelfile);
	active = false;
	visible = true;
}
 void MousePointerControl::createMousePointer(
     const uint32_t id,
     const irr::io::path& imageFileName,
     const irr::core::recti& imageArea,
     const irr::core::vector2di& hotSpot
 ) {
     irr::video::ITexture* texture = graphicDevice_->getVideoDriver()->getTexture(imageFileName);
     if (texture == nullptr) {
         logger_.text << "[Warning] - MousePointerControl - cannot load texture " << imageFileName.c_str() << "!";
         logger_.write(leviathan::core::Logger::Level::DEBUG);
         return;
     }
     if (baseImage_[id] != nullptr) {
         logger_.text << "[Warning] - MousePointerControl - id " << id << " already exists!";
         logger_.write(leviathan::core::Logger::Level::DEBUG);
         return;
     }
     baseImage_[id] = texture;
     graphicDevice_->getVideoDriver()->makeColorKeyTexture(baseImage_[id], COL_MAGICPINK);
     imageArea_[id] = imageArea;
     hotSpot_[id] = hotSpot;
 }
Example #4
0
bool CGWIC_BodyPart::LoadModelFile(irr::io::path fname)
{
	IXMLReader* mio = irDevice->getFileSystem()->createXMLReader(fname);
	if (!mio) return false;
	std::cout << "Reading model XML: " << fname.c_str() << std::endl;
	const stringw mt_model(L"Model");
	const stringw mt_inslot(L"InSlot");
	const stringw mt_outslot(L"OutSlot");
	const stringw mt_collision(L"Collision");
	const stringw mt_colbox(L"StandardBox");
	const stringw mt_colsph(L"StandardSphere");
	const stringw mt_coltri(L"TriMeshShape");
	const stringw mt_colcvx(L"ConvexHull");
	const stringw mt_colgim(L"GImpact");
	GWIC_BPSlot cslot;
	CIrrStrParser strparse;
	nocollision = true; //in case we can't load or found collision shape model
	while (mio->read()) {
		if (mt_model.equals_ignore_case(mio->getNodeName())) {
			mesh = scManager->getMesh(GWIC_BPARTS_DIR+mio->getAttributeValueSafe(L"file"));
			if (mesh) root = scManager->addAnimatedMeshSceneNode(
					mesh,parent,GWIC_PICKABLE_MASK | GWIC_ACTOR_MASK);
			if (root) {
				root->updateAbsolutePosition();
				root->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);
				ITriangleSelector* sel = scManager->createTriangleSelector(mesh,root);
				root->setTriangleSelector(sel);
				sel->drop();
			}
			//TODO: texturing
		} else if (mt_inslot.equals_ignore_case(mio->getNodeName())) {
			strparse = mio->getAttributeValueSafe(L"position");
			slot_in.posit = strparse.ToVector3f();
			strparse = mio->getAttributeValueSafe(L"rotation");
			slot_in.rotat = strparse.ToVector3f();
			strparse = mio->getAttributeValueSafe(L"axis");
			slot_in.axis = strparse.ToVector3f();
		} else if (mt_outslot.equals_ignore_case(mio->getNodeName())) {
			cslot.ID = mio->getAttributeValueAsInt(L"ID");
			strparse = mio->getAttributeValueSafe(L"position");
			cslot.posit = strparse.ToVector3f();
			strparse = mio->getAttributeValueSafe(L"rotation");
			cslot.rotat = strparse.ToVector3f();
			strparse = mio->getAttributeValueSafe(L"axis");
			cslot.axis = strparse.ToVector3f();
			slot_outs.push_back(cslot);
		} else if (mt_collision.equals_substring_ignore_case(mio->getNodeName())) {
			mass = mio->getAttributeValueAsFloat(L"mass");
			stringw data = mio->getAttributeValueSafe(L"type");
			nocollision = false;
			if (data.equals_substring_ignore_case(mt_colbox))
				coltype = ECST_BOX;
			else if (data.equals_substring_ignore_case(mt_colsph))
				coltype = ECST_SPHERE;
			else if (data.equals_substring_ignore_case(mt_coltri))
				coltype = ECST_BVHTRIMESH;
			else if (data.equals_substring_ignore_case(mt_colcvx))
				coltype = ECST_CONVEXHULL;
			else if (data.equals_substring_ignore_case(mt_colgim))
				coltype = ECST_GIMPACT;
			else {
				std::cerr << "Collision model unknown: " << data.c_str() << std::endl;
				nocollision = true;
			}
			//colmesh = scManager->getMesh(mio->getAttributeValueSafe(L"file"));
		}
	}
	mio->drop();
	return true;
}