本文整理汇总了C++中Cube::calcNormal方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::calcNormal方法的具体用法?C++ Cube::calcNormal怎么用?C++ Cube::calcNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cube
的用法示例。
在下文中一共展示了Cube::calcNormal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cube
Gnd::Gnd(int width, int height)
{
version = 0x0107;
this->width = width;
this->height = height;
tileScale = 10.0f;
maxTexName = 80;
lightmapWidth = 8;
lightmapHeight = 8;
gridSizeCell = 1;
cubes.resize(width, std::vector<Cube*>(height, NULL));
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Cube* cube = new Cube();
cube->h1 = cube->h2 = cube->h3 = cube->h4 = 0;
cube->tileUp = -1;
cube->tileSide = -1;
cube->tileFront = -1;
cube->calcNormal();
cubes[x][y] = cube;
}
}
}
示例2: Texture
//.........这里部分代码省略.........
Lightmap* lightmap = new Lightmap();
file->read(lightmap->data, 256);
lightmaps.push_back(lightmap);
}
int tileCount = file->readInt();
tiles.reserve(tileCount);
for(int i = 0; i < tileCount; i++)
{
Tile* tile = new Tile();
tile->v1.x = file->readFloat();
tile->v2.x = file->readFloat();
tile->v3.x = file->readFloat();
tile->v4.x = file->readFloat();
tile->v1.y = file->readFloat();
tile->v2.y = file->readFloat();
tile->v3.y = file->readFloat();
tile->v4.y = file->readFloat();
tile->textureIndex = file->readWord();
tile->lightmapIndex= file->readWord();
if (tile->lightmapIndex < 0)
{
tile->lightmapIndex = 0;
}
tile->color.b = (unsigned char)file->get();
tile->color.g = (unsigned char)file->get();
tile->color.r = (unsigned char)file->get();
tile->color.a = (unsigned char)file->get();
tiles.push_back(tile);
}
cubes.resize(width, std::vector<Cube*>(height, NULL));
for(int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Cube* cube = new Cube();
cube->h1 = file->readFloat();
cube->h2 = file->readFloat();
cube->h3 = file->readFloat();
cube->h4 = file->readFloat();
cube->calcNormal();
if (version >= 0x0106)
{
cube->tileUp = file->readInt();
cube->tileSide = file->readInt();
cube->tileFront = file->readInt();
}
else
{
cube->tileUp = file->readWord();
cube->tileSide = file->readWord();
cube->tileFront = file->readWord();
}
if (cube->tileUp >= (int)tiles.size())
{
Log::out << "Wrong value for tileup at " << x << ", " << y << Log::newline;
cube->tileUp = -1;
}
if (cube->tileSide >= (int)tiles.size())
{
Log::out << "Wrong value for tileside at " << x << ", " << y << Log::newline;
cube->tileSide = -1;
}
if (cube->tileFront >= (int)tiles.size())
{
Log::out << "Wrong value for tilefront at " << x << ", " << y << Log::newline;
cube->tileFront = -1;
}
cubes[x][y] = cube;
}
}
}
else
{
//TODO: port code...too lazy for now
}
delete file;
Log::out<<"GND: Done reading gnd file"<<Log::newline;
for (int x = 1; x < width-1; x++)
{
for (int y = 1; y < height-1; y++)
{
cubes[x][y]->calcNormals(this, x, y);
}
}
Log::out<<"GND: Done calculating normals" << Log::newline;
}