문제

안녕하세요, 기본 L-System 작업을 받았으며 응용 프로그램 렌더링을 최적화하기로 결정했습니다. 이전에 나는 스위치 케이스와 드로잉으로 l- 시스템의 전체 문자열을 반복하고있었습니다.

for(unsigned int stringLoop = 0; stringLoop < _buildString.length(); stringLoop++)
{

        switch(_buildString.at(stringLoop))
        {
        case'X':
            //Do Nothing
            //X is there just to facilitate the Curve of the plant
            break;
        case'F':

            _prevState = _currState;
            _currState.position += _currState.direction * stdBranchLength; 
            //Set the previous state to the current state
            _graphics.SetColour3f(0.0f, 1.0f, 0.0f);

            _graphics.Begin(OGLFlags::LINE_STRIP);
                _graphics.Vertex3f(_prevState.position.X(), _prevState.position.Y(), _prevState.position.Z());
                _graphics.Vertex3f(_currState.position.X(), _currState.position.Y(), _currState.position.Z());
            _graphics.End();

            break;
        case'[':
            _prevStack.push(_currState);
            break;
        case']':
            _prevState = _currState;
            _currState = _prevStack.top();
            _prevStack.pop();               
            break;
        case'-':

            _currState.direction = _currState.direction.RotatedAboutZ(-(ROTATION) * Math::DegreesToRadians);

            break;
        case'+':
            _currState.direction = _currState.direction.RotatedAboutZ(ROTATION * Math::DegreesToRadians);

            break;
        };

}

나는 문자 그대로 모든 프레임마다 트리를 해결하고 있었기 때문에이 모든 것을 제거했고,이 루프를 STD 벡터의 모든 Verticies를 절약 할 수 있도록이 루프를 변경했습니다.

    for(unsigned int stringLoop = 0; stringLoop < _buildString.length(); stringLoop++)
{

        switch(_buildString.at(stringLoop))
        {
        case'X':
            break;
        case'F':

            //_prevState = _currState;
            _currState.position += _currState.direction * stdBranchLength;
            _vertexVector.push_back(_currState.position);

            break;
        case'[':
            _prevStack.push(_currState);
            break;
        case']':
            _currState = _prevStack.top();
            _prevStack.pop();               
            break;
        case'-':            
            _currState.direction = _currState.direction.RotatedAboutZ(-(ROTATION) * Math::DegreesToRadians);
            break;
        case'+':
            _currState.direction = _currState.direction.RotatedAboutZ(ROTATION * Math::DegreesToRadians);
            break;
        };
}

이제 렌더 루프를 변경하여 벡터 배열에서 곧바로 읽습니다.

    DesignPatterns::Facades::OpenGLFacade _graphics = DesignPatterns::Facades::openGLFacade::Instance();

_graphics.Begin(OGLFlags::LINE_STRIP);
    for(unsigned int i = 0; i < _vertexVector.size(); i++)
    {
        _graphics.Vertex3f(_vertexVector.at(i).X(), _vertexVector.at(i).Y(), _vertexVector.at(i).Z());
    }
_graphics.End();

이제 내 문제는 벡터 어레이를 사용할 때 라인 스티브를 사용하면 여분의 아티팩트가 발생한다는 것입니다. 첫 번째 이미지는 최적화되지 않은 렌더 인 원래 이미지이며, 두 번째 이미지는 더 빨리 실행되는 최신 렌더이며, 3 차는 푸시를 사용하지 않고 첫 번째 두 개가 사용하는 팝을 사용하는 드래곤 곡선의 렌더입니다 (I Am Pretty 확실히 푸시와 팝은 문제가 발생하는 곳입니다). Verticies 저장의 논리에 문제가 있는가, 아니면 라인 스트립을 사용하고 있기 때문입니까? 나는 단지 라인을 사용하지만 실제로는 전혀 작동하지 않으며 Line_stipple을 더 많이 보게됩니다. 또한이 게시물의 길이에 대해 죄송합니다.

Alt Text http://img197.imageshack.us/img197/8030/bettera.jpg Alt Text http://img23.imageshack.us/img23/3924/buggyrender.jpg Alt Text http://img8.imageshack.us/img8/627/dragoncurve.jpg

도움이 되었습니까?

해결책

line_strip을 사용하고 있기 때문에 추가 라인을 받고 있습니다.

'F'케이스에서는 라인의 두 엔드 포인트를 벡터로 밀어 넣습니다 (원래 수행 한 것처럼).

_vertexVector.push_back(_prevState.position);
_vertexVector.push_back(_currState.position);

그리고 그리면 대신 line_list를 사용하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top