Revision: 8570
http://playerstage.svn.sourceforge.net/playerstage/?rev=8570&view=rev
Author: hsujohnhsu
Date: 2010-03-09 19:36:03 +0000 (Tue, 09 Mar 2010)
Log Message:
-----------
* fix texture by passing path of dae to Material for adding as Ogre resource.
* auto generate texture coordinates if none exists by spherical projection
from mesh origin.
Modified Paths:
--------------
code/gazebo/trunk/server/AssimpLoader.cc
Modified: code/gazebo/trunk/server/AssimpLoader.cc
===================================================================
--- code/gazebo/trunk/server/AssimpLoader.cc 2010-03-09 19:20:44 UTC (rev
8569)
+++ code/gazebo/trunk/server/AssimpLoader.cc 2010-03-09 19:36:03 UTC (rev
8570)
@@ -66,7 +66,9 @@
std::string texture_fqfn = dae_pathname + texName.data;
struct stat st;
if (stat(texture_fqfn.c_str(), &st) == 0)
- mat->SetTextureImage(texture_fqfn); // use fqfn if it exists
+ {
+ mat->SetTextureImage(texName.data,dae_pathname); // use fqfn if it
exists
+ }
else
mat->SetTextureImage(texName.data); // use defaut filename, rely on
ogre path
}
@@ -223,7 +225,20 @@
subMesh->AddTexCoord(aMesh->mTextureCoords[0][j].x,
1.0-aMesh->mTextureCoords[0][j].y);
else
- subMesh->AddTexCoord(0,0);
+ {
+ // Auto-generate projected texture coordinates, projected from center
of aabb
+ // @todo: implement globally for all meshes as an option, or move this
to Material.cc
+ double x = p.x;
+ double y = p.y;
+ double z = p.z;
+ double r = std::max(0.000001,sqrt(x*x+y*y+z*z));
+ double s = std::min(1.0,std::max(-1.0,z/r));
+ double t = std::min(1.0,std::max(-1.0,y/r));
+ double u = acos(s) / M_PI;
+ double v = acos(t) / M_PI;
+ //std::cerr << "uv1 debug: " << u << "," << v << std::endl;
+ subMesh->AddTexCoord(u,v);
+ }
}
mesh->AddSubMesh(subMesh);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit