void eae6320::Graphics::Render() { context.clear(); { context.StartScene(); { for (unsigned int i = 0; i < gameObjects.size(); i++) { //Set Shaders gameObjects[i]->material->effect->setEffects(context); gameObjects[i]->material->effect->setPositionOffset(context, gameObjects[i]->positionOffsetMatrix, Math::cMatrix_transformation::CreateWorldToViewTransform( gameObjects[i]->rotation, gameObjects[i]->position), gameObjects[i]->camObject); gameObjects[i]->material->effect->setUniform(context, gameObjects[i]->material->uniformData, gameObjects[i]->material->lengthOfUniform, gameObjects[i]->material->handleList); gameObjects[i]->material->setTexture(context); gameObjects[i]->mesh->DrawMesh(context); } debugMenu.menuOffset = 1/ eae6320::Time::GetSecondsElapsedThisFrame(); #ifdef _DEBUG //Enable Flycam if (eae6320::UserInput::IsKeyPressed('I')) { if (!hoveronK) { if (!isKSelected) { isKSelected = true; gameObjects[0]->camObject->isFlying = true; gameObjects[0]->flyCamObject->position = gameObjects[0]->camObject->position; } else { isKSelected = false; gameObjects[0]->camObject->isFlying = false; gameObjects[0]->camObject->position = gameObjects[0]->flyCamObject->position; //gameObjects[0]->camObject->position.x = gameObjects[0]->flyCamObject->position.x - 50.0f; ; } } hoveronK = true; } else { hoveronK = false; } //Enable menu if (eae6320::UserInput::IsKeyPressed('B')) { if (!hoverOnTilde) { if (!isTildeSelected) { isTildeSelected = true; isDebugMenuActive = true; } else { isTildeSelected = false; isDebugMenuActive = false; debugMenu.isMenuActive = false; } } hoverOnTilde = true; } else { hoverOnTilde = false; } //Draw sphere where the player is standing once the flycam is activated if (gameObjects[0]->camObject->isFlying) { DebugSphere *currentObject; currentObject = debugSpheres[0]; currentObject->m_center = gameObjects[0]->flyCamObject->position; currentObject->LoadDebugSphere(); currentObject->DrawSphere(); } if(isTildeSelected) RunDebugMenu(); #endif for (unsigned int i = 0; i < spriteObjects.size(); i++) { GameSprite *currentSprite; currentSprite = spriteObjects[i]; if (currentSprite && currentSprite->isInitialized()) currentSprite->Draw(0.0f); } for (unsigned int i = 0; i < debugBoxes.size(); i++) { DebugBox *currentObject; currentObject = debugBoxes[i]; currentObject->DrawBox(); } for (unsigned int i = 0; i < debugLines.size(); i++) { DebugLine *currentObject; currentObject = debugLines[i]; currentObject->DrawLine(); } for (unsigned int i = 0; i < debugSpheres.size(); i++) { DebugSphere *currentObject; currentObject = debugSpheres[i]; if ((debugMenu.checkBoxChecked && debugMenu.sliderSelected) || debugMenu.checkBoxChecked) { currentObject->DrawSphere(); } } } context.EndScene(); } context.displayRenderedBuffer(); }
void ShowInfoText() { DebugBox frameInfo = DebugBox(Vec2i(10, 10), "FrameInfo"); frameInfo.add("Platform time", prettyUs(toUs(g_platformTime.frameStart()))); frameInfo.add("Game time", prettyUs(toUs(g_gameTime.now()))); frameInfo.add("Prims", EERIEDrawnPolys); frameInfo.add("Particles", getParticleCount()); frameInfo.add("Sparks", ParticleSparkCount()); frameInfo.add("Polybooms", long(PolyBoomCount())); frameInfo.print(); DebugBox camBox = DebugBox(Vec2i(10, frameInfo.size().y + 5), "Camera"); camBox.add("Position", g_camera->m_pos); camBox.add("Rotation", g_camera->angle); camBox.add("Focal", g_camera->focal); camBox.print(); DebugBox playerBox = DebugBox(Vec2i(10, camBox.size().y + 5), "Player"); playerBox.add("Position", player.pos); playerBox.add("Rotation", player.angle); playerBox.add("Velocity", player.physics.velocity); EERIEPOLY * ep = CheckInPoly(player.pos); float truePolyY = -666.66f; if(ep) { float tempY = 0.f; if(GetTruePolyY(ep, player.pos, &tempY)) { truePolyY = tempY; } } ep = CheckInPoly(player.pos + Vec3f(0.f, -10.f, 0.f)); float slope = 0.f; if(ep) slope = ep->norm.y; long zap = IsAnyPolyThere(player.pos.x, player.pos.z); playerBox.add("Ground Slope", slope); playerBox.add("Ground truePolyY", truePolyY); playerBox.add("Ground POLY", zap); playerBox.add("Color", CURRENT_PLAYER_COLOR); playerBox.add("Stealth", GetPlayerStealth()); playerBox.add("Jump", player.jumplastposition); playerBox.add("OFFGRND", (!player.onfirmground ? "OFFGRND" : "")); playerBox.add("Life", player.lifePool); playerBox.add("Mana", player.manaPool); playerBox.add("Poisoned", player.poison); playerBox.add("Hunger", player.hunger); playerBox.add("Magic", static_cast<long>(player.doingmagic)); playerBox.print(); DebugBox miscBox = DebugBox(Vec2i(10, playerBox.size().y + 5), "Misc"); miscBox.add(arx_name + " version", arx_version); miscBox.add("Level", LastLoadedScene.string()); miscBox.add("Spell failed seq", LAST_FAILED_SEQUENCE); miscBox.add("Cinema", cinematicBorder.CINEMA_DECAL); miscBox.add("Mouse", Vec2i(DANAEMouse)); miscBox.add("Pathfind queue", EERIE_PATHFINDER_Get_Queued_Number()); miscBox.add("Pathfind status", EERIE_PATHFINDER_Is_Busy() ? "Working" : "Idled"); miscBox.print(); { struct ScriptDebugReport { std::string entityName; long events; long sends; ScriptDebugReport() : entityName("") , events(0) , sends(0) {} }; ScriptDebugReport maxEvents; Entity * io = ARX_SCRIPT_Get_IO_Max_Events(); if(io) { maxEvents.entityName = io->idString(); maxEvents.events = io->stat_count; } ScriptDebugReport maxSender; io = ARX_SCRIPT_Get_IO_Max_Events_Sent(); if(io) { maxSender.entityName = io->idString(); maxSender.sends = io->stat_sent; } DebugBox scriptBox = DebugBox(Vec2i(10, miscBox.size().y + 5), "Script"); scriptBox.add("Events", ScriptEvent::totalCount); scriptBox.add("Timers", ARX_SCRIPT_CountTimers()); scriptBox.add("Max events", maxEvents.entityName); scriptBox.add("Max events#", maxEvents.events); scriptBox.add("Max sender", maxSender.entityName); scriptBox.add("Max sender#", maxSender.sends); scriptBox.print(); } Entity * io = entities.get(LastSelectedIONum); if(io) { DebugBox entityBox = DebugBox(Vec2i(500, 10), "Entity " + io->idString()); entityBox.add("Pos", io->pos); entityBox.add("Angle", io->angle); entityBox.add("Room", static_cast<long>(io->room)); entityBox.add("Move", io->move); entityBox.add("Flags", flagNames(EntityFlagNames, io->ioflags)); entityBox.add("GFlags", flagNames(GameFlagNames, io->gameFlags)); entityBox.add("Show", entityVisilibityToString(io->show)); entityBox.print(); if(io->ioflags & IO_NPC) { IO_NPCDATA * npcData = io->_npcdata; DebugBox npcBox = DebugBox(Vec2i(500, entityBox.size().y + 5), "NPC"); npcBox.add("Life", npcData->lifePool); npcBox.add("Mana", npcData->manaPool); npcBox.add("Poisoned", npcData->poisonned); npcBox.add("ArmorClass", ARX_INTERACTIVE_GetArmorClass(io)); npcBox.add("Absorb", npcData->absorb); npcBox.add("Moveproblem", npcData->moveproblem); npcBox.add("Pathfind listpos", static_cast<long>(npcData->pathfind.listpos)); npcBox.add("Pathfind listnb", npcData->pathfind.listnb); npcBox.add("Pathfind targ", npcData->pathfind.truetarget.handleData()); npcBox.add("Behavior", flagNames(BehaviourFlagNames, npcData->behavior)); // TODO should those really be flags ? PathfindFlags pflag = io->_npcdata->pathfind.flags; std::string pflags; if(pflag & PATHFIND_ALWAYS) pflags += "ALWAYS "; if(pflag & PATHFIND_ONCE) pflags += "ONCE "; if(pflag & PATHFIND_NO_UPDATE) pflags += "NO_UPDATE "; npcBox.add("Pathfind flgs", pflags); npcBox.print(); } if(io->ioflags & (IO_FIX | IO_ITEM)) { DebugBox itemBox = DebugBox(Vec2i(500, entityBox.size().y + 5), "Item"); itemBox.add("Durability", io->durability); itemBox.add("Durability max", io->max_durability); itemBox.add("Poisonous", static_cast<long>(io->poisonous)); itemBox.add("Poisonous count", static_cast<long>(io->poisonous_count)); itemBox.print(); } long column2y = 400; for(size_t i = 0; i < MAX_ANIM_LAYERS; i++) { AnimLayer & layer = io->animlayer[i]; DebugBox animLayerBox = DebugBox(Vec2i(500, column2y), str(boost::format("Anim Layer %1%") % i)); animLayerBox.add("ctime", long(layer.ctime.t)); animLayerBox.add("flags", flagNames(AnimUseFlagNames, layer.flags)); animLayerBox.add("currentFrame", layer.currentFrame); if(layer.cur_anim) { animLayerBox.add("cur_anim", layer.cur_anim->path.string()); } else { animLayerBox.add("cur_anim", "none"); } animLayerBox.print(); column2y = animLayerBox.size().y + 5; } } ARX_SCRIPT_Init_Event_Stats(); }
void ShowInfoText() { DebugBox frameInfo = DebugBox(Vec2i(10, 10), "FrameInfo"); frameInfo.add("Prims", EERIEDrawnPolys); frameInfo.add("Particles", getParticleCount()); frameInfo.add("Polybooms", long(polyboom.size())); frameInfo.add("TIME", static_cast<long>(arxtime.now_ul() / 1000)); frameInfo.print(); DebugBox playerBox = DebugBox(Vec2i(10, frameInfo.size().y + 5), "Player"); playerBox.add("Position", player.pos); playerBox.add("AnchorPos", player.pos - Mscenepos); playerBox.add("Rotation", player.angle); playerBox.add("Velocity", player.physics.velocity); EERIEPOLY * ep = CheckInPoly(player.pos); float truePolyY = -666.66f; if(ep) { float tempY = 0.f; if(GetTruePolyY(ep, player.pos, &tempY)) { truePolyY = tempY; } } ep = CheckInPoly(player.pos + Vec3f(0.f, -10.f, 0.f)); float slope = 0.f; if(ep) slope = ep->norm.y; long zap = IsAnyPolyThere(player.pos.x,player.pos.z); playerBox.add("Ground Slope", slope); playerBox.add("Ground truePolyY", truePolyY); playerBox.add("Ground POLY", zap); playerBox.add("Color", CURRENT_PLAYER_COLOR); playerBox.add("Stealth", GetPlayerStealth()); playerBox.add("Jump", player.jumplastposition); playerBox.add("OFFGRND", (!player.onfirmground ? "OFFGRND" : "")); playerBox.add("Life", player.lifePool); playerBox.add("Mana", player.manaPool); playerBox.add("Poisoned", player.poison); playerBox.add("Hunger", player.hunger); playerBox.add("Magic", static_cast<long>(player.doingmagic)); playerBox.print(); DebugBox miscBox = DebugBox(Vec2i(10, playerBox.size().y + 5), "Misc"); miscBox.add("Arx version", arx_version); miscBox.add("Level", LastLoadedScene.string().c_str()); miscBox.add("Spell failed seq", LAST_FAILED_SEQUENCE.c_str()); miscBox.add("Camera focal", ACTIVECAM->focal); miscBox.add("Cinema", CINEMA_DECAL); miscBox.add("Mouse", Vec2i(DANAEMouse)); miscBox.add("Pathfind queue", EERIE_PATHFINDER_Get_Queued_Number()); miscBox.add("Pathfind status", (PATHFINDER_WORKING ? "Working" : "Idled")); miscBox.print(); { struct ScriptDebugReport { std::string entityName; long events; long sends; ScriptDebugReport() : entityName("") , events(0) , sends(0) {} }; ScriptDebugReport maxEvents; Entity * io = ARX_SCRIPT_Get_IO_Max_Events(); if(io) { maxEvents.entityName = io->idString(); maxEvents.events = io->stat_count; } ScriptDebugReport maxSender; io = ARX_SCRIPT_Get_IO_Max_Events_Sent(); if(io) { maxSender.entityName = io->idString(); maxSender.sends = io->stat_sent; } DebugBox scriptBox = DebugBox(Vec2i(10, miscBox.size().y + 5), "Script"); scriptBox.add("Events", ScriptEvent::totalCount); scriptBox.add("Timers", ARX_SCRIPT_CountTimers()); scriptBox.add("Max events", maxEvents.entityName); scriptBox.add("Max events#", maxEvents.events); scriptBox.add("Max sender", maxSender.entityName); scriptBox.add("Max sender#", maxSender.sends); scriptBox.print(); } if(ValidIONum(LastSelectedIONum)) { Entity * io = entities[LastSelectedIONum]; if(io) { DebugBox entityBox = DebugBox(Vec2i(500, 10), "Entity " + io->idString()); entityBox.add("Pos", io->pos); entityBox.add("Angle", io->angle); entityBox.add("Room", static_cast<long>(io->room)); entityBox.add("Move", io->move); entityBox.add("Flags", flagNames(EntityFlagNames, io->ioflags)); entityBox.add("Show", entityVisilibityToString(io->show)); entityBox.print(); if(io->ioflags & IO_NPC) { IO_NPCDATA * npcData = io->_npcdata; DebugBox npcBox = DebugBox(Vec2i(500, entityBox.size().y + 5), "NPC"); npcBox.add("Life", npcData->lifePool); npcBox.add("Mana", npcData->manaPool); npcBox.add("Poisoned", npcData->poisonned); npcBox.add("ArmorClass", ARX_INTERACTIVE_GetArmorClass(io)); npcBox.add("Absorb", npcData->absorb); npcBox.add("Moveproblem", npcData->moveproblem); npcBox.add("Pathfind listpos", static_cast<long>(npcData->pathfind.listpos)); npcBox.add("Pathfind listnb", npcData->pathfind.listnb); npcBox.add("Pathfind targ", npcData->pathfind.truetarget.handleData()); npcBox.add("Behavior", flagNames(BehaviourFlagNames, npcData->behavior)); // TODO should those really be flags ? PathfindFlags pflag = io->_npcdata->pathfind.flags; std::string pflags; if(pflag & PATHFIND_ALWAYS) pflags += "ALWAYS "; if(pflag & PATHFIND_ONCE) pflags += "ONCE "; if(pflag & PATHFIND_NO_UPDATE) pflags += "NO_UPDATE "; npcBox.add("Pathfind flgs", pflags); npcBox.print(); } if(io->ioflags & (IO_FIX | IO_ITEM)) { DebugBox itemBox = DebugBox(Vec2i(500, entityBox.size().y + 5), "Item"); itemBox.add("Durability", io->durability); itemBox.add("Durability max", io->max_durability); itemBox.add("Poisonous", static_cast<long>(io->poisonous)); itemBox.add("Poisonous count", static_cast<long>(io->poisonous_count)); itemBox.print(); } } } ARX_SCRIPT_Init_Event_Stats(); }