Hi,
I was able to get a matrix for every geode in my model using the path variable
in nodevisitor.
However at present I am printing out the triangle vertices to a file using the
printTriangles() and a struct, similar to the method show in the osggeometry
example. I'm a little confused about how to incorporate the matrices list that
I have collected and apply them to each vertex ? Do I need to modify
TriangleFunctor and give it a new member variable 'matrix' ?
I was hoping for some help in this direction.
Code for printing vertices is below:
Code:
// decompose Drawable primitives into triangles, print
//out these triangles and computed normals.
void printTriangles(const std::string& name, osg::Drawable& drawable,
const osg::Matrix &matrix)
{
std::cout << name << std::endl;
osg::TriangleFunctor<NormalPrint> tf;
drawable.accept(tf);
std::cout << std::endl;
}
struct NormalPrint
{
void operator() (const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec3& v3,
bool) const
{
ofstream outFile2;
static int i;
//open a text file to write the data out
if(i == 0)
{
outFile2.open("backhoe.tris", ios::trunc);
}
else
{
outFile2.open("backhoe.tris", ios::app);
}
assert(!outFile2.fail());
osg::Vec3 normal = (v2-v1)^(v3-v2);
normal.normalize();
if ( !outFile2.is_open() )
{
std::cout << "The file could not be opened" <<
std::endl;
}
else
{
// Safely use the file stream
outFile2 << i << "\t("<<v1<<"), ("<<v2<<"), ("<<v3<<")"
<< std::endl;
Thanks
Sincerely,
Sanat
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=31547#31547
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org