2017-05-02 12 views
1

현재 ROS 및 OGRE (Object-Oriented Graphics Rendering Engine)를 사용하여 도로 모델 (차선 중심, 차선 경계 등)을 시각화하는 ADAS 프로젝트를 진행 중입니다. 입력은 기하학적 점 (x, y, z)입니다.오거의 텍스처 좌표

Ogre :: RenderOperation :: OT_TRIANGLE_STRIP을 사용하여 선을 그릴 수 있습니다. 실선, 점선으로 된 거짓, 이중 실선 등을 고유하게 시각화 할 수있는 자료를 만들었습니다. 이러한 지오메트리 점에 대한 질감 좌표는 어떻게 찾을 수 있습니까?

현재 코드는 다음과 같습니다

geometry_msgs::Point p0 = _msg.shape_points.front(); 

    for(int i = 1; i < _msg.shape_points.size(); ++i) 
    { 
     const geometry_msgs::Point& p1(_msg.shape_points[i]); 
     const float dx = p1.x - p0.x; 
     const float dy = p1.y - p0.y; 
     const float phi = atan2(dy, dx); 
     const float wx = sin(phi) * lane_mark_width_; 
     const float wy = -cos(phi) * lane_mark_width_; 

     if (i == 1) 
     { 
      lane_boundary_->position(p0.x - wx, p0.y - wy, p0.z); 
      lane_boundary_->textureCoord(p0.x , p0.y); 

      lane_boundary_->position(p0.x + wx, p0.y + wy, p0.z); 
      lane_boundary_->textureCoord(p0.x, p0.y); 
     } 

     lane_boundary_->position(p1.x - wx, p1.y - wy, p1.z); 
     lane_boundary_->textureCoord(p1.x, p1.y); 

     lane_boundary_->position(p1.x + wx, p1.y + wy, p1.z); 
     lane_boundary_->textureCoord(p1.x, p1.y); 

     p0 = p1; 
    } 

이 범위에있을 필요가 당신에게

+0

'lane_boundary_'의 유형은 무엇입니까? – pergy

+0

그것의 수동 객체 : Ogre :: ManualObject * lane_boundary_ – StrongSoul

+0

그럼 어떻게 할 수 있을지 모르겠다. 왜냐하면 당신은 드로잉 호출을'begin'과'end' 호출 사이에 놓아야하기 때문이다. [docs ] (http://www.ogre3d.org/docs/api/1.9/class_ogre_1_1_manual_object.html#details). 업데이트를 위해서는 나중에'beginUpdate'를 사용하십시오. – pergy

답변

0

텍스처 좌표를 감사 [0, 1]. [0, 0]은 텍스처의 왼쪽 상단에 있고 [1,1]은 오른쪽 하단에 있습니다.

난 당신이 (Y 범위를 텍스처 좌표의 수직 축) 텍스처가 y 축 방향의 한 스트라이프에 매핑 할 할 있으리라 믿고있어. 또한 좌표 생성이 선을 따라 정렬되었다고 가정합니다.

geometry_msgs::Point p0 = _msg.shape_points.front(); 

//Offset in between two points is fixed 
const float uv_step = 1.0f/_msg.shape_points.size(); 

    for(int i = 1; i < _msg.shape_points.size(); ++i) 
    { 
     const geometry_msgs::Point& p1(_msg.shape_points[i]); 
     const float dx = p1.x - p0.x; 
     const float dy = p1.y - p0.y; 
     const float phi = atan2(dy, dx); 
     const float wx = sin(phi) * lane_mark_width_; 
     const float wy = -cos(phi) * lane_mark_width_; 

     //Compute the vertical texture coordinate 
     const float v = i * uv_step; 

     if (i == 1) 
     { 
      lane_boundary_->position(p0.x - wx, p0.y - wy, p0.z); 
      //First point is at the top left corner 
      lane_boundary_->textureCoord(0.0f, 0.0f); 

      lane_boundary_->position(p0.x + wx, p0.y + wy, p0.z); 
      //Second point is a the the top right corner 
      lane_boundary_->textureCoord(1.0f, 0.0f); 
     } 

     lane_boundary_->position(p1.x - wx, p1.y - wy, p1.z); 
     //Along the y axis on the left 
     lane_boundary_->textureCoord(0.0f, v); 

     lane_boundary_->position(p1.x + wx, p1.y + wy, p1.z); 
     //Along the Y axis on the right 
     lane_boundary_->textureCoord(1.0f, v); 

     p0 = p1; 
    } 

동일한 종류의 텍스처 매핑이 필요합니다. 텍스처 또는 좌표가 오른쪽 축에 없으면 원하는 축을 보간하도록 코드를 조정하십시오.

+0

답을 고맙습니다. 제 경우 축은 동적입니다. 입력은 실시간 시스템에서 발생하며 차량의 방향에 따라 변경됩니다.이 구현을 동적으로 만들 수 있습니까? – StrongSoul