[MOgre] Grid 생성 함수 (펌)
Ogre/MOgre 2009. 3. 13. 03:05 |
private void CreateGrid(int numcols, int numrows, float unitsize)
{
// 생성
ManualObject grid = sceneMgr.CreateManualObject("grid");
grid.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_LIST);
float width = (float)numcols * unitsize;
float depth = (float)numrows * unitsize;
Vector3 center = new Vector3(-width / 2.0f, 0, -depth / 2.0f);
for (int i = 0; i < numrows; ++i)
{
Vector3 s, e;
s.x = 0.0f;
s.z = i * unitsize;
s.y = 0.0f;
e.x = width;
e.z = i * unitsize;
e.y = 0.0f;
grid.Position(s + center);
grid.Position(e + center);
}
grid.Position(new Vector3(0.0f, 0.0f, numrows * unitsize) + center);
grid.Position(new Vector3(width, 0.0f, numrows * unitsize) + center);
for (int i = 0; i < numcols; ++i)
{
Vector3 s, e;
s.x = i * unitsize;
s.z = depth;
s.y = 0.0f;
e.x = i * unitsize;
e.z = 0.0f;
e.y = 0.0f;
grid.Position(s + center);
grid.Position(e + center);
}
grid.Position(new Vector3(numcols * unitsize, 0.0f, 0.0f) + center);
grid.Position(new Vector3(numcols * unitsize, 0.0f, depth) + center);
grid.End();
sceneMgr.RootSceneNode.AttachObject(grid);
}