本文整理汇总了C++中StaticObject类的典型用法代码示例。如果您正苦于以下问题:C++ StaticObject类的具体用法?C++ StaticObject怎么用?C++ StaticObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StaticObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
int SearObject::shutdown() {
assert(m_initialised == true);
// Clean up OpenGL bits
contextDestroyed(true);
StaticObjectList::const_iterator I = m_static_objects.begin();
StaticObjectList::const_iterator Iend = m_static_objects.end();
for (; I != Iend; ++I) {
StaticObject* so = *I;
assert(so);
int id, mask_id;
// Clean up textures
if (so->getTexture(0, id, mask_id) == 0) {
RenderSystem::getInstance().releaseTexture(id);
RenderSystem::getInstance().releaseTexture(mask_id);
}
delete so;
}
m_static_objects.clear();
m_initialised = false;
return 0;
}
示例2: render
void SearObject::render(bool select_mode) {
StaticObjectList::const_iterator I = m_static_objects.begin();
StaticObjectList::const_iterator Iend = m_static_objects.end();
for (; I != Iend; ++I) {
StaticObject* so = *I;
assert(so);
so->render(select_mode);
}
}
示例3: contextDestroyed
void SearObject::contextDestroyed(bool check) {
StaticObjectList::const_iterator I = m_static_objects.begin();
StaticObjectList::const_iterator Iend = m_static_objects.end();
for (; I != Iend; ++I) {
StaticObject* so = *I;
assert(so);
so->contextDestroyed(check);
}
}
示例4: contextCreated
void SearObject::contextCreated() {
StaticObjectList::const_iterator I = m_static_objects.begin();
StaticObjectList::const_iterator Iend = m_static_objects.end();
for (; I != Iend; ++I) {
StaticObject* so = *I;
assert(so);
so->contextCreated();
}
}
示例5: StaticObject
StaticObject* CreationTool::CreateStaticModel(XMFLOAT3 position, ModelData data)
{
StaticObject* object = new StaticObject(mModelImporter, data.filename);
object->SetPosition(position);
object->SetMaterials(Material(Colors::White));
object->SetName(data.name);
object->SetDefualtScale(data.defaultScale);
return object;
}
示例6: SetOn_OffFlag
void SetOn_OffFlag( StaticObject& light, StaticObject::Lights::Flag2 flag )
{
bool IsLight = light.checkFlag( flag );
//라이트 off 상태면
if( !IsLight )
light.resetFlag( flag ); //라이트 on
//라이트 on 상태면
else
light.setFlag( flag ); //라이트 off
}
示例7: clearTerrains
void IceWorld::loadPhase2(irr::IrrlichtDevice * device){
//Unload the terrains from the scene
clearTerrains();
//Make sure the previous phase is no longer considered loaded
phase1Loaded = false;
//Get the references
irr::scene::ISceneManager *smgr = device->getSceneManager();
irr::video::IVideoDriver *driver = device->getVideoDriver();
//Set the random seed
srand(1);
//Reset the player position
player->changePosition(irr::core::vector3df(0, 0, 0));
//Make an array for the spawn order
int spawnOrder[10] = {1, 1, 2, 1, 2, 3, 1, 1, 3, 2};
//Set up the enemy positions
irr::f32 x = 0; irr::f32 y = 0; irr::f32 z = 500;
for(int i = 0; i < 20; i++){
//Deside which enemy to place
if(spawnOrder[i] == 1){
BasicEnemy *basicEnemy = new BasicEnemy(player, irr::core::vector3df(x, y, z), device->getTimer(), smgr);
} else if(spawnOrder[i] == 2){
FastEnemy *fastEnemy = new FastEnemy(player, irr::core::vector3df(x, y, z), device->getTimer(), smgr);
} else if(spawnOrder[i] == 3){
StrongEnemy *strongEnemy = new StrongEnemy(player, irr::core::vector3df(x, y, z), device->getTimer(), smgr);
}
z += 1500 + (player->getMovementSpeed() * 2.7f);
}
//Add some gems to the level
x = 0; y = 0; z = 1200;
for(int i = 0; i < 3; i++){
y = (irr::f32)(rand() % 40 + 1) - 20;
BronzeGem *gem = new BronzeGem(irr::core::vector3df(x, y, z), smgr);
gem->moveAwayFromPlayer(true, Game::getCurrentPlayer()->getMovementSpeed());
z += (rand() % 3000 + 1000) + (player->getMovementSpeed() * 2.7f);
}
//Add some asteroids to the level
x = 0; y = 0; z = 2000;
for(int i = 0; i < 14; i++){
y = (irr::f32)(rand() % 70 + 1) - 35;
StaticObject *Obsticle = new StaticObject(irr::core::vector3df(x, y, z), "Assets/Environment/Asteroid/Asteroid1.obj", "Assets/Environment/Asteroid/AsteroidTextureA.jpg", device->getSceneManager(), true);
Obsticle->moveAwayFromPlayer(true, Game::getCurrentPlayer()->getMovementSpeed());
z += (rand() % 500 + 500) + (player->getMovementSpeed() * 2.7f);
}
phase2Loaded = true;
}
示例8: SetOff_OnFlag
void SetOff_OnFlag( StaticObject& light, StaticObject::Lights::Flag2 flag )
{
//라이트 1 플래그 변화
bool IsLight = light.checkFlag( flag );
//라이트 off 상태면
if( IsLight )
light.resetFlag( flag ); //라이트 on
//라이트 on 상태면
else
light.setFlag( flag ); //라이트 off
}
示例9: getWrappingUnitDist
const double getWrappingUnitDist(const StaticObject& obj1, const StaticObject& obj2) {
pair<double,double> pos1 = obj1.getUnitPos();
pair<double,double> pos2 = obj2.getUnitPos();
double x = std::abs(pos1.first - pos2.first);
if(x > .5)
x = 1 - x;
double y = std::abs(pos1.second - pos2.second);
if(y > .5)
y = 1 - y;
return std::sqrt(x*x + y*y);
}
示例10: sizeof
void violetland::HUD::getButtonArea(AREA area, SDL_Rect* screenRect)
{
screenRect->x = screenRect->y = screenRect->w = screenRect->h = 0;
StaticObject* pObj = NULL;
switch (area)
{
case AREA_CHAR:
pObj = m_char;
break;
case AREA_RELOAD:
pObj = m_reload;
break;
case AREA_GRENADE:
pObj = m_grenade;
break;
case AREA_SHOOT:
pObj = m_shoot;
break;
case AREA_WASD:
pObj = m_wasd;
break;
default:
memset(screenRect, 0, sizeof(screenRect));
return;
}
float left = pObj->getLeft();
float right = pObj->getRight();
float top = pObj->getTop();
float bottom = pObj->getBottom();
screenRect->x = (int)(left);
screenRect->y = (int)(top);
screenRect->w = (int)(right - left);
screenRect->h = (int)(bottom - top);
if (area == AREA_WASD || area == AREA_SHOOT)
{
int indent = m_videoManager->RegularText->getIndent();
screenRect->x -= indent;
screenRect->y -= indent;
screenRect->w += indent * 2;
screenRect->h += indent * 2;
}
}
示例11: getWrappingDistSq
const unsigned getWrappingDistSq(const StaticObject& obj1, const StaticObject& obj2) {
pair<double,double> pos1 = obj1.getUnitPos();
pair<double,double> pos2 = obj2.getUnitPos();
double x = std::abs(pos1.first - pos2.first);
if(x > .5)
x = 1 - x;
double y = std::abs(pos1.second - pos2.second);
if(y > .5)
y = 1 - y;
x *= UNIVERSE_WIDTH * UNIVERSE_TOTAL_SCALE;
y *= UNIVERSE_HEIGHT * UNIVERSE_TOTAL_SCALE;
return static_cast<unsigned>(x*x + y*y);
}
示例12: fopen
int SearObject::load(const std::string &filename) {
bool big_endian = false;
FILE *fp = fopen(filename.c_str(), "rb");
if (fp == 0) {
fprintf(stderr, "[SearObject] Error opening %s for reading\n", filename.c_str());
return 1;
}
SearObjectHeader soh;
if (fread(&soh, sizeof(SearObjectHeader), 1, fp) != 1) {
// Error reading header
fprintf(stderr, "[SearObject] Error reading SearObject header in %s\n", filename.c_str());
fclose(fp);
return 1;
}
// Check Magic
if (strncmp(soh.magic, "SEARSTAT", 8)) {
fprintf(stderr, "[SearObject] Bad magic - unknown file format.\n");
fclose(fp);
return 1;
}
// Check Endianess
// Does this check actually work? Or should we convert into a chars and
// compare char order instead?
if (soh.byte_order == 0x00FF) {
big_endian = true;
printf("[SearObject] Swapping byte order\n");
swap_bytes_uint32_t(soh.num_meshes);
}
// Check Version
if (soh.version != 1) {
fprintf(stderr, "[SearObject] SearObject Version %d is unsupported. Version %d expected.\n", soh.version, 1);
fclose(fp);
return 1;
}
SearObjectMesh som;
TextureID tex_id = NO_TEXTURE_ID;
TextureID tex_mask_id = NO_TEXTURE_ID;
uint32_t *uptr;
float *fptr;
int c,x,y;
for (uint32_t i = 0; i < soh.num_meshes; ++i) {
if (fread(&som, sizeof(SearObjectMesh), 1, fp) != 1) {
fprintf(stderr, "[SearObject] Error reading SearObject Mesh in %s\n", filename.c_str());
fclose(fp);
return 1;
}
if (big_endian) {
swap_bytes_uint32_t(som.num_vertices);
swap_bytes_uint32_t(som.num_faces);
for (x = 0; x < 4; ++x) {
for (y = 0; y < 4; ++y) {
swap_bytes_float(som.mesh_transform[x][y]);
swap_bytes_float(som.texture_transform[x][y]);
}
}
for (x = 0; x < 4; ++x) {
swap_bytes_float(som.ambient[x]);
swap_bytes_float(som.diffuse[x]);
swap_bytes_float(som.specular[x]);
swap_bytes_float(som.emissive[x]);
}
swap_bytes_float(som.shininess);
}
StaticObject* so = new StaticObject();
so->init();
so->setNumPoints(som.num_vertices);
so->setNumFaces(som.num_faces);
// Does this use all 256 chars, or only up to 256?
som.texture_map[255] = '\0'; // Make sure the string is null-terminated
std::string tex_name(som.texture_map);
// See if config file has a mapping
m_config.clean(tex_name);
if (m_config.findItem(tex_name, KEY_texture_map_0)) {
tex_name = (std::string)m_config.getItem(tex_name, KEY_texture_map_0);
}
// Get texture ids
tex_id = RenderSystem::getInstance().requestTexture(tex_name);
tex_mask_id = RenderSystem::getInstance().requestTexture(tex_name, true);
so->setTexture(0, tex_id, tex_mask_id);
// Set transform matrices
so->getMatrix().setMatrix(som.mesh_transform);
so->getTexMatrix().setMatrix(som.texture_transform);
// Set Materials
so->setAmbient(som.ambient);
//.........这里部分代码省略.........
示例13: main
int main()
{
Player geko("Geko", glm::vec3(10.0, 10.0, 10.0));
// Start Konifguration - Window, Context, Camera and Callbacks //
glfwInit();
Window testWindow(500, 50, 800, 600, "testWindow");
glfwMakeContextCurrent(testWindow.getWindow());
cam.setKeySpeed(2.0);
cam.setNearFar(0.01, 100);
//Callback for Camera and Player
glfwSetKeyCallback(testWindow.getWindow(), key_callback);
glewInit();
// Shader and Renderer Initialization //
//Shader for Objects
VertexShader vs(loadShaderSource(SHADERS_PATH + std::string("/Vertex-Shaders/TextureShader3D.vert")));
FragmentShader fs(loadShaderSource(SHADERS_PATH + std::string("/Fragment-Shaders/TextureShader3D.frag")));
ShaderProgram shader(vs, fs);
//Shader for a Skybox
VertexShader vsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.vert")));
FragmentShader fsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.frag")));
ShaderProgram shaderSkybox(vsSkybox, fsSkybox);
//Renderer with context
OpenGL3Context context;
Renderer renderer(context);
//Level and Scene
Level testLevel("testLevel");
Scene testScene("testScene");
testLevel.addScene(&testScene);
testLevel.changeScene("testScene");
//Add Camera to scenegraph
testScene.getScenegraph()->addCamera(&cam);
testScene.getScenegraph()->getCamera("PlayerViewCam");
testScene.getScenegraph()->setActiveCamera("PlayerViewCam");
//Set all InputMaps and set one InputMap active
iH.setAllInputMaps(*(testScene.getScenegraph()->getActiveCamera()));
iH.changeActiveInputMap("Object");
iH.getActiveInputMap()->update(geko);
// ==============================================================
// == Object (ant, afraid) ======================================
// ==============================================================
Teapot teaAnt;
Texture texCV((char*)RESOURCES_PATH "/cv_logo.bmp");
//AntMesh antMesh;
//Node aiNodeFlick("Flick");
//aiNodeFlick.addGeometry(&teaAnt);
//aiNodeFlick.addTexture(&texCV);
//testScene.getScenegraph()->getRootNode()->addChildrenNode(&aiNodeFlick);
//AI ant_Flick;
//ant_Flick.setAntAfraid();
//aiNodeFlick.ssetObject(&ant_Flick);
// ==============================================================
// == Object (ant, aggressiv) ===================================
// ==============================================================
AntMesh antMesh;
//Node aiNodeFlack("Flack");
//aiNodeFlack.addGeometry(&teaAnt);
//aiNodeFlack.addGeometry(&antMesh);
//aiNodeFlack.addTexture(&texCV);
//testScene.getScenegraph()->getRootNode()->addChildrenNode(&aiNodeFlack);
//AI ant_Flack;
//ant_Flack.setAntAggressiv();
//aiNodeFlack.setObject(&ant_Flack);
// ==============================================================
// == Object (Tree) =============================================
// ==============================================================
Texture texBrick((char*)RESOURCES_PATH "/brick.bmp");
//TreeMesh treeMesh;
Teapot teaTree;
TreeMesh treeMesh;
Node treeNode("CookieTree");
StaticObject tree;
tree.setTree();
treeNode.setObject(&tree);
treeNode.addTexture(&texCV);
treeNode.addGeometry(&treeMesh);
glm::vec3 posFood(10.0, 0.0, -5.0);
//.........这里部分代码省略.........
示例14: main
//===================================================================//
//==================Main Method=====================================//
//==================================================================//
int main()
{
//===================================================================//
//==================Things you need to start with====================//
//==================================================================//
glfwInit();
Window testWindow(500, 50, 800, 600, "Demo");
glfwMakeContextCurrent(testWindow.getWindow());
// Callback
glfwSetKeyCallback(testWindow.getWindow(), key_callback);
cam.setKeySpeed(2.0);
cam.setNearFar(0.01, 100);
glewInit();
OpenGL3Context context;
//renderer = new Renderer(context);
Renderer renderer(context);
//===================================================================//
//==================Shaders for your program========================//
//==================================================================//
VertexShader vs(loadShaderSource(SHADERS_PATH + std::string("/Vertex-Shaders/TextureShader3D.vert")));
FragmentShader fs(loadShaderSource(SHADERS_PATH + std::string("/Fragment-Shaders/TextureShader3D.frag")));
ShaderProgram shader(vs, fs);
VertexShader vsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.vert")));
FragmentShader fsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.frag")));
ShaderProgram shaderGBuffer(vsGBuffer, fsGBuffer);
VertexShader vsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.vert")));
FragmentShader fsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.frag")));
ShaderProgram shaderSFQ(vsSfq, fsSfq);
VertexShader vsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.vert")));
FragmentShader fsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.frag")));
ShaderProgram shaderSkybox(vsSkybox, fsSkybox);
FBO fboGBuffer(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false);
SoundFileHandler sfh = SoundFileHandler(1000);
Rect screenFillingQuad;
screenFillingQuad.loadBufferData();
//===================================================================//
//==================Object declarations - Geometry, Texture, Node=== //
//==========================Object: Terrain===========================//
StaticObject terrainObject;
terrainObject.setClassType(ClassType::TERRAIN);
Texture terrainTex((char*)RESOURCES_PATH "/Grass2.jpg");
Terrain terrain2((char*)RESOURCES_PATH "/heightmap.jpg", 0.0f, 0.0f);
Node terrainNode2("Terrain");
terrainNode2.addGeometry(&terrain2);
terrainNode2.addTexture(&terrainTex);
terrainNode2.setObject(&terrainObject);
//===================================================================//
//==================Object declarations - Geometry, Texture, Node=== //
//==========================Object: Player===========================//
Texture texCV((char*)RESOURCES_PATH "/cv_logo.bmp");
GekoMesh gekoMesh;
geko.setExp(0.0);
geko.setLevelThreshold(100.0);
geko.setLevel(0);
Node playerNode("Player");
playerNode.addGeometry(&gekoMesh);
playerNode.setObject(&geko);
playerNode.addTexture(&texCV);
sfh.generateSource(glm::vec3(geko.getPosition()), RESOURCES_PATH "/Sound/Rascheln.wav");
geko.setSoundHandler(&sfh);
geko.setSourceName(MOVESOUND, "SpielerFootsteps", RESOURCES_PATH "/Sound/Rascheln.wav");
//geko.setSourceName(BACKGROUNDMUSIC, "Hintergrund", RESOURCES_PATH "/Sound/jingle2.wav");
geko.setSourceName(FIGHTSOUND, "Kampfsound", RESOURCES_PATH "/Sound/punch.wav");
geko.setSourceName(EATSOUND, "Essen", RESOURCES_PATH "/Sound/Munching.wav");
geko.setSourceName(QUESTSOUND, "Quest", RESOURCES_PATH "/Sound/jingle.wav");
geko.setSourceName(ITEMSOUND, "Item", RESOURCES_PATH "/Sound/itempickup.wav");
geko.setSourceName(FIRESOUND, "Fire", RESOURCES_PATH "/Sound/Feuer_kurz.wav");
sfh.disableLooping("Essen");
sfh.disableLooping("Quest");
sfh.disableLooping("Item");
geko.setPosition(glm::vec4(terrain2.getResolutionX() / 2.0f, 10.0f, terrain2.getResolutionY() / 2.0f, 1.0));
//sfh.generateSource("Feuer",posFood, RESOURCES_PATH "/Sound/Feuer kurz.wav");
//.........这里部分代码省略.........
示例15: StaticObject
void violet::HUD::drawInventory(Player* player) {
int topBasePoint = m_videoManager->RegularText->getIndent()
+ (m_videoManager->RegularText->getHeight()) * 4;
VideoMode screen = m_videoManager->getVideoMode();
const int barLeft = screen.Width / 25;
const int barLen = screen.Width / 15;
const int barHeight = m_videoManager->RegularText->getHeight() / 10;
GLfloat bcolor[] = { 1.0f, 1.0f, 1.0f, 0.0f };
GLfloat fcolor1[] = { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat fcolor2[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const float baseScale = m_videoManager->Scale * 0.2;
const int dataLeft = barLeft + 25 * m_videoManager->Scale;
// TODO: cache weapon image inside this class
StaticObject* wpnImg = new StaticObject(barLeft,
m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight(),
128, 128,
player->getWeapon()->getDroppedTex(), false);
wpnImg->Scale = baseScale;
glDisable(GL_TEXTURE_2D);
wpnImg->RMask = wpnImg->GMask = wpnImg->BMask = 1.0f;
wpnImg->draw(false, false);
glEnable(GL_TEXTURE_2D);
wpnImg->RMask = wpnImg->GMask = wpnImg->BMask = 0;
wpnImg->draw(false, false);
delete wpnImg;
std::ostringstream oss;
oss << player->getWeapon()->Ammo << '/' << player->getWeapon()->AmmoClipSize;
m_videoManager->RegularText->draw(oss.str(), dataLeft,
m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight(),
TextManager::LEFT, TextManager::MIDDLE);
m_inventoryImg[0]->draw(false, false, barLeft,
m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 2,
0.0f, baseScale);
oss.str("");
oss << player->Grenades;
m_videoManager->RegularText->draw(oss.str(), dataLeft,
m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 2,
TextManager::LEFT, TextManager::MIDDLE);
m_inventoryImg[1]->draw(false, false, barLeft,
m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 3,
0.0f, baseScale);
oss.str("");
oss << player->Teleports;
m_videoManager->RegularText->draw(oss.str(), dataLeft,
m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 3,
TextManager::LEFT, TextManager::MIDDLE);
int bonusN = 0;
for (int i = PLAYER_BONUS_FIRST; i < PLAYER_BONUS_COUNT; i++) {
if (player->bonusTimes[i] > 0) {
const int y = topBasePoint + bonusN * 132 * baseScale;
m_bonusImg[(PlayerBonusType) i]->draw(false, false, barLeft, y, 0,
baseScale);
drawBar(barLeft + 25 * m_videoManager->Scale, y, barLen, barHeight,
player->bonusTimes[i] / 15000.0f, bcolor, fcolor1, fcolor2);
bonusN++;
}
}
}