お元気ですか、私は基本的なL-Systemを使っています。アプリケーションのレンダリングを試してみることにしました。以前、私はL-Systemの全体の文字列をスイッチケースと図面でループしていました...しかし、私は何をしているかを見せてくれるでしょう。それはSTDベクターにverticiesのすべてを救うように、私は文字通り、ツリーごとに単一のフレームを解決したためOpenGL L-Systemレンダリング
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;
};
}
が、私はこのすべてを削除し、私はこのループを変更しました。
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();
私の問題は、私がベクトル配列を使用していて、私がLine Stipを使用しているときに、余分なアーティファクトを得ることです。 最初のイメージは、最適化されていない元のレンダリングです。次に、より速く実行される2番目のレンダリング、3番目は、最初の2つが使用しているようなプッシュ/ポップを使用しないドラゴンカーブのレンダリングですプッシュとポップはどこに問題が入っているのかかなり確かです)。 ここで私のロジックに問題がありますか?それとも、私はラインストリップを使用しているのですか?私は単に行を使用しますが、実際にはまったく動作しません。それは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
あなたの赤い木がXでもっと「つぶれている」という問題はありますか? –