本文整理汇总了C++中CBlock::getRealPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlock::getRealPosition方法的具体用法?C++ CBlock::getRealPosition怎么用?C++ CBlock::getRealPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlock
的用法示例。
在下文中一共展示了CBlock::getRealPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool CRoomManager::init()
{
// register to console: TODO register some usefull stuff
CV_GAME_MANAGER->getConsole()->registerClass(this,"ROOM MANAGER");
CV_GAME_MANAGER->getConsole()->addParam(RLROOM,"() Reloads the rooms.");
CV_GAME_MANAGER->getConsole()->addParam(RC,"() Prints room count.");
CV_GAME_MANAGER->getConsole()->addParam(RC,"() Prints room count.");
CV_GAME_MANAGER->getConsole()->addParam(SRA,"() Shows room area.");
// construct new rooms
CLevelManager *lManager = CV_GAME_MANAGER->getLevelManager();
for (GLuint y=0; y<CV_LEVEL_MAP_SIZE; y++)
{
for (GLuint x=0; x<CV_LEVEL_MAP_SIZE; x++)
{
CBlock *block = lManager->getBlock(x,y);
if (block->isRoom() && !block->isInRoom())
{
if(block->getType() == CV_BLOCK_TYPE_HEART_ID && block->getOwner() == CV_PLAYER_0)
{
cml::vector3f position = block->getRealPosition();
CV_GAME_MANAGER->getControlManager()->getCamera()->setPosition(cml::vector3f(position[0]+0.3, CV_CAMERA_INITIAL_HEIGHT, position[2]+1));
}
// we found a room tile that isn't in a room yet. we create a new room.
CRoom *newRoom = new CRoom();
newRoom->init(block);
allRooms[newRoom->getIndex()] = newRoom;
roomColors[newRoom->getIndex()] = vector3f((GLfloat)(rand()%101)/100.0f,(GLfloat)(rand()%101)/100.0f,(GLfloat)(rand()%101)/100.0f);
}
}
}
return true;
}
示例2: locateRoom
GLvoid CRoomManager::locateRoom(GLint roomType, GLubyte owner)
{
CBlock *roomTile = getRoom(roomType, owner);
if(roomTile)
{
cml::vector3f currPos = roomTile->getRealPosition();
CV_GAME_MANAGER->getControlManager()->getCamera()->setPosition(cml::vector3f(currPos[0], CV_CAMERA_INITIAL_HEIGHT, currPos[2]+1));
}
}
示例3: addLightSource
GLvoid CLightingManager::addLightSource(vector2i position, GLint lightSourceType)
{
// depending on the block position we need to setup from 1 to 4 lights
CLevelManager *lManager = CV_GAME_MANAGER->getLevelManager();
GLint faces[4];
GLint bfVis = lManager->getBlock(position)->getFreeFaces(faces);
vector3f lPoss[] =
{
vector3f(CV_BLOCK_WIDTH/2,CV_BLOCK_HEIGHT,CV_BLOCK_DEPTH+CV_BLOCK_DEPTH/10.0f), // front
vector3f(CV_BLOCK_WIDTH/2,CV_BLOCK_HEIGHT,-CV_BLOCK_DEPTH/10.0f), // back
vector3f(CV_BLOCK_WIDTH+CV_BLOCK_DEPTH/10.0f,CV_BLOCK_HEIGHT,CV_BLOCK_DEPTH/2.0f), // left
vector3f(-CV_BLOCK_DEPTH/10.0f,CV_BLOCK_HEIGHT,CV_BLOCK_DEPTH/2.0f), // right
vector3f(CV_BLOCK_DEPTH/2.0f,CV_BLOCK_HEIGHT,CV_BLOCK_DEPTH/2.0f) // middle
};
if (bfVis==-1)
{
bfVis=1;
faces[0]=4;
}
for (GLint i=0; i<bfVis; i++)
{
// get a light from the light pool
//CLightSource *light = lightSourcePool[lightSourceType].popObject();
CLightSource *light = new CLightSource(lightIndexName[lightSourceType]);
if (light)
{
// set its position
light->setPosition(lManager->getBlock(position)->getRealPosition()+lPoss[faces[i]]);
// append to block
//blockLightData[position[1]][position[0]].add(light);
//blockLightData[position[1]][position[0]].add(light,lManager->getBlock(position));
// and add to the global list of used lights
lightSources.push_back(light);
GLint lightRadius = (int)ceil(light->getRadius()/CV_BLOCK_WIDTH)+2; // +2 is there for extended radius comparison
//vector2i lightPos = CConversions::realToLogical(light->getPosition());
// now for every block of this light, add references of this light to influenced neighbour blocks.
for (GLint y=-lightRadius; y<=lightRadius; y++)
{
for (GLint x=-lightRadius; x<=lightRadius; x++)
{
if (position[1]+y<0 || position[0]+x<0 || position[1]+y>=84 || position[0]+x>=84)
{
continue;
}
if (faces[i]==CBlock::BFS_FRONT && y<0)
{
continue;
}
if (faces[i]==CBlock::BFS_BACK && y>0)
{
continue;
}
if (faces[i]==CBlock::BFS_LEFT && x<0)
{
continue;
}
if (faces[i]==CBlock::BFS_RIGHT && x>0)
{
continue;
}
CBlock *block = lManager->getBlock(position[0]+x,position[1]+y);
vector3f lPos(light->getPosition()[0],0.0f,light->getPosition()[2]);
GLfloat d1 = (block->getRealPosition()-lPos).length();
GLfloat d2 = ((block->getRealPosition()+vector3f(CV_BLOCK_WIDTH,0.0f,0.0f))-lPos).length();
GLfloat d3 = ((block->getRealPosition()+vector3f(CV_BLOCK_WIDTH,0.0f,CV_BLOCK_DEPTH))-lPos).length();
GLfloat d4 = ((block->getRealPosition()+vector3f(0.0f,0.0f,CV_BLOCK_DEPTH))-lPos).length();
GLfloat rad =light->getRadius();
if (d1<=rad || d2<=rad || d3<=rad || d4<=rad)
{
blockLightData[position[1]+y][position[0]+x].add(light,block);
}
}
}
}
}
}