Пример #1
0
//! Changes the current Working Directory to the given string.
bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory)
{
	bool success=false;

	if (FileSystemType != FILESYSTEM_NATIVE)
	{
		WorkingDirectory[FILESYSTEM_VIRTUAL].append(newDirectory);
		flattenFilename(WorkingDirectory[FILESYSTEM_VIRTUAL], "");
		success = 1;
	}
	else
	{
		WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory;

#if defined(_IRR_WINDOWS_CE_PLATFORM_)
		success = true;
#elif defined(_MSC_VER)
	#if defined(_IRR_WCHAR_FILESYSTEM)
		success=(_wchdir(newDirectory.c_str()) == 0);
	#else
		success=(_chdir(newDirectory.c_str()) == 0);
	#endif
#else
		success=(chdir(newDirectory.c_str()) == 0);
#endif
	}

	return success;
}
Пример #2
0
//! determines if a file exists and would be able to be opened.
bool CFileSystem::existFile(const io::path& filename) const
{
	for (u32 i=0; i < FileArchives.size(); ++i)
		if (FileArchives[i]->getFileList()->findFile(filename)!=-1)
			return true;

	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
#if defined(_IRR_WCHAR_FILESYSTEM)
	return (_waccess(filename.c_str(), 0) != -1);
#elif defined(_MSC_VER)
	return (_access(filename.c_str(), 0) != -1);
#else
	return (access(filename.c_str(), F_OK) != -1);
#endif
}
Пример #3
0
io::path CFileSystem::getAbsolutePath(const io::path& filename) const
{
	fschar_t *p=0;

#if defined(_IRR_WINDOWS_CE_PLATFORM_)
	return filename;
#elif defined(_IRR_WINDOWS_API_)

	#if defined(_IRR_WCHAR_FILESYSTEM )
		c16 fpath[_MAX_PATH];
		p = _wfullpath(fpath, filename.c_str(), _MAX_PATH);
	#else
		c8 fpath[_MAX_PATH];
		p = _fullpath(fpath, filename.c_str(), _MAX_PATH);
	#endif

#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
	c8 fpath[4096];
	fpath[0]=0;
	p = realpath(filename.c_str(), fpath);
	if (!p)
	{
		// content in fpath is undefined at this point
		if (!fpath[0]) // seems like fpath wasn't altered
		{
			// at least remove a ./ prefix
			if ('.'==filename[0] && '/'==filename[1])
				return filename.subString(2, filename.size()-2);
			else
				return filename;
		}
		else
			return io::path(fpath);
	}

#endif

	return io::path(p);
}
//! Writes attributes of the scene node.
void CMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
{
	IMeshSceneNode::serializeAttributes(out, options);

	if (options && (options->Flags&io::EARWF_USE_RELATIVE_PATHS) && options->Filename)
	{
		const io::path path = SceneManager->getFileSystem()->getRelativeFilename(
				SceneManager->getFileSystem()->getAbsolutePath(SceneManager->getMeshCache()->getMeshName(Mesh).getPath()),
				options->Filename);
		out->addString("Mesh", path.c_str());
	}
	else
		out->addString("Mesh", SceneManager->getMeshCache()->getMeshName(Mesh).getPath().c_str());
	out->addBool("ReadOnlyMaterials", ReadOnlyMaterials);
}
Пример #5
0
//! Writes attributes of the scene node.
void CAnimatedMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
{
	IAnimatedMeshSceneNode::serializeAttributes(out, options);

	if (options && (options->Flags&io::EARWF_USE_RELATIVE_PATHS) && options->Filename)
	{
		const io::path path = SceneManager->getFileSystem()->getRelativeFilename(
				SceneManager->getFileSystem()->getAbsolutePath(SceneManager->getMeshCache()->getMeshName(Mesh).getPath()),
				options->Filename);
		out->addString("Mesh", path.c_str());
	}
	else
		out->addString("Mesh", SceneManager->getMeshCache()->getMeshName(Mesh).getPath().c_str());
	out->addBool("Looping", Looping);
	out->addBool("ReadOnlyMaterials", ReadOnlyMaterials);
	out->addFloat("FramesPerSecond", FramesPerSecond);
	out->addInt("StartFrame", StartFrame);
	out->addInt("EndFrame", EndFrame);
}
Пример #6
0
        void loadHeightmap(io::path path)
        {
            Height= video->getTexture(path.c_str());

            video::IImage* image= video->createImage(Height, core::position2d<s32>(0,0), Height->getSize());
            Normal= video->addTexture("normal", image);
            video->makeNormalMapTexture(Normal, ((gui::IGUISpinBox*)gui->getRootGUIElement()->getElementFromId(EGI_HEIGHT, true))->getValue());
            image->drop();

            gui::IGUIEditBox* edit= (gui::IGUIEditBox*)gui->getRootGUIElement()->getElementFromId(EGI_FILENAME, true);
            core::stringw name= path;
            core::array<core::stringw> splited;
            //name.split(splited, ".");

            edit->setText(name.c_str());

            Node->setMaterialTexture(0, Height);
            Node->setMaterialTexture(1, Normal);
        }
Пример #7
0
bool CVMDCustomSkinMotion::load(const io::path &path)
{
	std::vector<char> buf;
	{
		std::ifstream io(path.c_str(), std::ios::binary);
		if(!io){
			return false;
		}

		// get filesize
		io.seekg(0, std::fstream::end);
		size_t filesize = static_cast<size_t>(io.tellg());
		io.clear();
		io.seekg(0, std::fstream::beg);
		if (filesize==0){
			std::cout << "empty file" << std::endl;
			return false;
		}

		// read all file
		buf.resize(filesize);
		io.read(&buf[0], filesize);
	}

	// parse vmd
	vmd::Loader loader;
	if(!loader.parse(&buf[0], buf.size())){
		return false;
	}

	std::cout << loader << std::endl;

	// store bone motions
	u32 lastFrame=0;
	for(vmd::Loader::BoneMap::iterator it=loader.boneMap.begin();
			it!=loader.boneMap.end();
			++it){
		SRotPosLinearCurve *curve=addBoneCurve(it->first.c_str());
		vmd::BoneBuffer::Ptr buf=it->second;
		curve->reallocate(buf->bones.size());
		for(size_t i=0; i<buf->bones.size(); ++i){
			vmd::Bone &frame=buf->bones[i];
			curve->addKeyFrame(frame.frame,
					SRotPosKey(
						core::vector3df(frame.pos.x, frame.pos.y, frame.pos.z),
						core::quaternion(
							frame.q.x, frame.q.y, frame.q.z, frame.q.w))
					);
		}
		curve->sort();
		lastFrame=std::max(lastFrame, curve->getFrameCount());
	}

	// store morphing motions
	for(vmd::Loader::MorphMap::iterator it=loader.morphMap.begin();
			it!=loader.morphMap.end();
			++it){
		SMorphLinearCurve *curve=addMorphingCurve(it->first.c_str());
		vmd::MorphBuffer::Ptr buf=it->second;
		curve->reallocate(buf->morphs.size());
		for(size_t i=0; i<buf->morphs.size(); ++i){
			vmd::Morph &frame=buf->morphs[i];
			curve->addKeyFrame(frame.frame, frame.influence);
		}
		curve->sort();
		lastFrame=std::max(lastFrame, curve->getFrameCount());
	}

	

	FrameCount=lastFrame;

	return true;
}