#include #include namespace IMG { Cluster::Cluster(){ id = Cluster::ID_CLUSTER++; } Cluster::~Cluster() { } void Cluster::setNormal(Ogre::Vector3* n) { normal = *n; } Ogre::Vector3* Cluster::getNormal() { return &normal; } BBox* Cluster::getBound() { return &bound; } Box2d* Cluster::getBspNodeBound() { return &bspnodebound; } void Cluster::setBspNodeBound(Box2d* box) { bspnodebound = (*box); } int Cluster::getId() const { return id; } void Cluster::setId(int id_) { id = id; } std::vector* Cluster::getVector3sVector() { return &Vector3s_vector; } Ogre::Vector3* Cluster::getVector3sTex() const { return Vector3s_triangle_text; } void Cluster::setPlane(Ogre::Vector3* normal, Ogre::Vector3 * point) { plane.normal = *normal; plane.normal = -plane.normal; plane.d = -normal->dotProduct (*point); } Plane3 * Cluster::getPlane() { return &plane; } Cluster & Cluster::operator =(const Cluster & p) { uv = p.uv; id = p.id; //get the lumel_origin becaus if get Inc[0] the value is not correct lumel_origin = p.lumel_origin; lumel_x_axis = p.lumel_x_axis; lumel_y_axis = p.lumel_y_axis; axisproj = p.axisproj; order = p.order; triangle2d_text = p.triangle2d_text; bound = p.bound; normal = p.normal; bspnodebound = p.bspnodebound; return *this; } Cluster::Cluster(const Cluster & p) { uv = p.uv; id = p.id; //get the lumel_origin becaus if get Inc[0] the value is not correct lumel_origin = p.lumel_origin; lumel_x_axis = p.lumel_x_axis; lumel_y_axis = p.lumel_y_axis; axisproj = p.axisproj; order = p.order; triangle2d_text = p.triangle2d_text; bound = p.bound; normal = p.normal; bspnodebound = p.bspnodebound; } void Cluster::print() { //Ogre::LogManager::getSingleton().logMessage("\n\nCluster: " + Ogre::StringConverter::toString(id) + ", axisproj: " + Ogre::StringConverter::toString(axisproj) + ", order: " + Ogre::StringConverter::toString(order)); plane.print(); //Ogre::LogManager::getSingleton().logMessage("\nOrigin (" + Ogre::StringConverter::toString(lumel_origin) + ")"); //Ogre::LogManager::getSingleton().logMessage("Inc U (" + Ogre::StringConverter::toString(lumel_x_axis) + ")"); //Ogre::LogManager::getSingleton().logMessage("Inc V (" + Ogre::StringConverter::toString(lumel_y_axis.z) + ")"); bound.print(); bspnodebound.print(); //Ogre::LogManager::getSingleton().logMessage("Printant els vertexs: "); } //* return the dominant normal axis, for calculate the 2d projection int Cluster::axisProjected() { Ogre::Vector3 *normal = plane.getNormal(); if (Ogre::Math::Abs(normal->x) >= Ogre::Math::Abs(normal->y) && Ogre::Math::Abs(normal->x) >= Ogre::Math::Abs(normal->z)) { return (0); } if (Ogre::Math::Abs(normal->y) >= Ogre::Math::Abs(normal->x) && Ogre::Math::Abs(normal->y) >= Ogre::Math::Abs(normal->z)) { return (1); } else { return (2); } } void Cluster::finish() { //Ogre::LogManager::getSingleton().logMessage("\nCluster::Finish()"); Plane3 *plane = getPlane(); Ogre::Vector3 normal = *plane->getNormal(); float distance = plane->getDistance(); Ogre::Vector3 corner; Cluster2d cluster2d; Ogre::Vector3 vertexfinal[3]; int num_vertexs = 4; Ogre::Vector3 min; Ogre::Vector3 max; bool type = true; //Ogre::LogManager::getSingleton().logMessage("\tCreant cluster 2d"); axisproj = cluster2d.create2d (this, 0, true); //Ogre::LogManager::getSingleton().logMessage("\t Imprimint el que hi al del cluster"); std::vector vector2; vector2 =*cluster2d.getVector3sVector(); for (unsigned int i = 0; i < vector2.size(); i++) { bound.addBoundingVector3 (vector2[i].x, vector2[i].y, 0); } min = bound.getMinimum(); max = bound.getMaximum(); //Ogre::LogManager::getSingleton().logMessage("Caixa Englobant del cluster 2d"); bound.print(); Ogre::Vector3 aux (-9999,-9999,-9999); //Ogre::LogManager::getSingleton().logMessage("Axisproj:" + Ogre::StringConverter::toString(axisproj)); } //* Return the increment in U (lumel increment in x). For patchs calculation Ogre::Vector3 Cluster::getIncU() { return lumel_x_axis; } //* Return the increment in V (lumel increment in x). For patchs calculation Ogre::Vector3 Cluster::getIncV() { return lumel_y_axis; } Ogre::Vector3 Cluster::getOrigin() { return lumel_origin; } unsigned int Cluster::ID_CLUSTER = 0; }