tdev
16-12-2008 16:43:52
since vista tries to make the application folder read-only you should write all your data into the users folder. This patch add a method to specify the path where the impostor images should be written to.
patch:
usage:
patch:
Index: include/ImpostorPage.h
===================================================================
--- include/ImpostorPage.h (revision 1634)
+++ include/ImpostorPage.h (working copy)
@@ -311,6 +311,7 @@
Ogre::SceneManager *sceneMgr;
Ogre::Entity *entity;
Ogre::String entityKey;
+ ImpostorPage *group;
Ogre::MaterialPtr material[IMPOSTOR_PITCH_ANGLES][IMPOSTOR_YAW_ANGLES];
Ogre::TexturePtr texture;
Index: include/PagedGeometry.h
===================================================================
--- include/PagedGeometry.h (revision 1634)
+++ include/PagedGeometry.h (working copy)
@@ -179,6 +179,8 @@
*/
void setCamera(Ogre::Camera *cam);
+ void setTempDir(Ogre::String dir);
+
/**
\brief Gets the camera which is used to calculate levels of detail.
\returns The camera assigned to this PagedGeometry object.
@@ -613,6 +615,8 @@
/** INTERNAL FUNCTION - DO NOT USE */
Ogre::Vector3 _convertToLocal(const Ogre::Vector3 &globalVec);
+ Ogre::String getTempdir() { return this->tempdir; };
+
protected:
//Internal function - do not use
void _addDetailLevel(GeometryPageManager *mgr, Ogre::Real maxRange, Ogre::Real transitionLength);
@@ -645,6 +649,8 @@
//Time-related data
Ogre::Timer timer;
unsigned long lastTime;
+
+ Ogre::String tempdir;
};
Index: source/ImpostorPage.cpp
===================================================================
--- source/ImpostorPage.cpp (revision 1634)
+++ source/ImpostorPage.cpp (working copy)
@@ -321,6 +321,7 @@
{
//Store scene manager and entity
ImpostorTexture::sceneMgr = group->sceneMgr;
+ ImpostorTexture::group = group;
ImpostorTexture::entity = entity;
//Add self to list of ImpostorTexture's
@@ -529,7 +530,8 @@
for (i = 0; i < sizeof(key); ++i)
key[i] = (key[i] % 26) + 'A';
- ResourceGroupManager::getSingleton().addResourceLocation(".", "FileSystem", "BinFolder");
+ String tempdir = this->group->geom->getTempdir();
+ ResourceGroupManager::getSingleton().addResourceLocation(tempdir, "FileSystem", "BinFolder");
String fileName = "Impostor." + String(key, sizeof(key)) + '.' + StringConverter::toString(textureSize) + ".png";
//Attempt to load the pre-render file if allowed
@@ -569,7 +571,7 @@
#if IMPOSTOR_FILE_SAVE
//Save RTT to file
- renderTarget->writeContentsToFile(fileName);
+ renderTarget->writeContentsToFile(tempdir + fileName);
//Load the render into the appropriate texture view
texture = TextureManager::getSingleton().load(fileName, "BinFolder", TEX_TYPE_2D, MIP_UNLIMITED);
Index: source/PagedGeometry.cpp
===================================================================
--- source/PagedGeometry.cpp (revision 1634)
+++ source/PagedGeometry.cpp (working copy)
@@ -59,6 +59,8 @@
//Misc.
pageLoader = NULL;
+
+ this->tempdir = ".";
}
PagedGeometry::~PagedGeometry()
@@ -73,6 +75,11 @@
removeDetailLevels();
}
+void PagedGeometry::setTempDir(Ogre::String dir)
+{
+ this->tempdir = dir;
+}
+
void PagedGeometry::setPageLoader(PageLoader *loader)
{
pageLoader = loader;
usage:
PagedGeometry *p = new PagedGeometry();
// you should look up the MSDN how to get some system path
p->setTempDir(yourWindowsUserPath);