예제 #1
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
PhysicsActor::setScale(float _x, float _y, float _z)
{
    m_scaleX = _x;
    m_scaleY = _y;
    m_scaleZ = _z;

#if 0
    NewtonCollision* collision = createCollision();

    NewtonBodySetCollision(m_pActor, collision);
    NewtonReleaseCollision(dynamic_cast<PhysicsZone*>(m_pZone.get())->getZonePtr(), collision);
#else
    std::cout << "Warning: PhysicsActor::setScale() not implemented!" << std::endl;
#endif
    
}
bool PlaneNodeProcessor::processNode(DOMElement *nodeElem, bool loadGameObjects)
{
    if (!hasNodeName(nodeElem, "plane"))
    {
        return false;
    }

    Ogre::String entName = getAttributeValueAsStdString(nodeElem, "name");

    LOG_DEBUG(Logger::RULES,
              "Processing plane node "
              + entName);
    if(entName=="")
    {
        entName = getRandomName("Plane");
    }

    Quaternion orientation(Quaternion::IDENTITY);
    Vector3 position(Vector3::ZERO);
    Vector2 scale(1,1);

    DOMElement* oriElem = getChildNamed(nodeElem, "rotation");
    if (oriElem != NULL)
    {
        orientation = processQuaternion(oriElem);
    }
    else
    {
        LOG_WARNING(Logger::RULES, "No orientation given for plane, used Identity");
    }

    DOMElement* posElem = getChildNamed(nodeElem, "position");
    if (posElem != NULL)
    {
        position = processVector3(posElem);
    }
    else
    {
        LOG_WARNING(Logger::RULES, "No position given for plane, used (0,0,0)");
    }

    DOMElement* scaleElem = getChildNamed(nodeElem, "scale");
    if (posElem != NULL)
    {
        scale = processVector2(scaleElem);
    }
    else
    {
        LOG_WARNING(Logger::RULES, "No scale given for plane, used (0,0)");
    }

    while(!MeshManager::getSingleton().getByName(entName).isNull())
    {
        entName = getRandomName("Plane");
    }

    SceneNode* node = getRootSceneNode()->createChildSceneNode(entName + "Node", position, orientation);

    MovablePlane* plane = new MovablePlane(entName + "Plane");
    plane->d = 0;
    plane->normal = Vector3::UNIT_Y;

    MeshManager::getSingleton().createPlane(entName + "Mesh", "custom", *plane, scale.x, scale.y, 10, 10, true, 1, 1, 1, Vector3::UNIT_Z);

    Entity* ent = CoreSubsystem::getSingleton().getWorld()->getSceneManager()->createEntity(entName, entName + "Mesh");

    LOG_DEBUG(Logger::RULES, " Loaded plane "+entName);

    node->attachObject(ent);
    node->attachObject(plane);
    //node->scale(scale.x,1,scale.y);

    createCollision(ent, getChildNamed(nodeElem, "physicsproxy"));

    DOMElement* materialElem = getChildNamed(nodeElem, "material");
    if(materialElem)
    {
        if(getChildNamed(nodeElem, "renderToTexture"))
        {
            Ogre::String matName = getAttributeValueAsStdString(materialElem, "name");
            MaterialPtr material = static_cast<MaterialPtr>(MaterialManager::getSingleton().getByName(matName))->clone(matName + entName);
            createRenderToTextures(ent, plane, material, getChildNamed(nodeElem, "renderToTexture"));
            ent->setMaterialName(matName + entName);
        }
        else
            ent->setMaterialName(getAttributeValueAsStdString(materialElem, "name"));
    }
    else
    {
        LOG_WARNING(Logger::RULES, "No material given for plane "+entName);
    }
    return true;
}
예제 #3
0
RobotLink::RobotLink(Robot* robot,
                      const urdf::LinkConstPtr& link,
                      const std::string& parent_joint_name,
                      bool visual,
                      bool collision,
                      bool use_model_path,
                      MetaPointCloud& link_pointclouds)
: robot_( robot )
, name_( link->name )
, parent_joint_name_( parent_joint_name )
, visual_node_( NULL )
, collision_node_( NULL )
, link_pointclouds_(link_pointclouds)
, pose_calculated_(false)
, use_model_path_(use_model_path)
{
  pose_property_ = KDL::Frame();

  visual_node_ = new node;
  collision_node_ = new node;

  // we prefer collisions over visuals
  if (collision) createCollision(link);
  else if (visual) createVisual(link);


  // create description and fill in child_joint_names_ vector
  std::stringstream desc;
  if (parent_joint_name_.empty())
  {
    desc << "Root Link " << name_;
  }
  else
  {
    desc << "Link " << name_;
    desc << " with parent joint " << parent_joint_name_;
  }

  if (link->child_joints.empty())
  {
    desc << " has no children.";
  }
  else
  {
    desc
      << " has " 
      << link->child_joints.size();

    if (link->child_joints.size() > 1)
    {
      desc << " child joints: ";
    }
    else
    {
      desc << " child joint: ";
    }

    std::vector<boost::shared_ptr<urdf::Joint> >::const_iterator child_it = link->child_joints.begin();
    std::vector<boost::shared_ptr<urdf::Joint> >::const_iterator child_end = link->child_joints.end();
    for ( ; child_it != child_end ; ++child_it )
    {
      urdf::Joint *child_joint = child_it->get();
      if (child_joint && !child_joint->name.empty())
      {
        child_joint_names_.push_back(child_joint->name);
        desc << child_joint->name << ((child_it+1 == child_end) ? "." : ", ");
      }
    }
  }
  if (hasGeometry())
  {
    if (visual_meshes_.empty())
    {
      desc << "  This link has collision geometry but no visible geometry.";
    }
    else if (collision_meshes_.empty())
    {
      desc << "  This link has visible geometry but no collision geometry.";
    }
  }
  else
  {
    desc << "  This link has NO geometry.";
  }

  LOGGING_DEBUG_C(RobotLog, RobotLink, desc << endl);

}