void DrawEERIEInter(EERIE_3DOBJ * eobj, const TransformInfo & t, Entity * io, bool forceDraw, float invisibility ) { ARX_PROFILE_FUNC(); if(!eobj) return; // Avoids To treat an object that isn't Visible if(!forceDraw && io && io != entities.player() && !Cedric_IO_Visible(t.pos)) return; DrawEERIEInter_ModelTransform(eobj, t); if(io) { io->bbox3D = UpdateBbox3d(eobj); } DrawEERIEInter_ViewProjectTransform(eobj); if(io) { io->bbox2D = UpdateBbox2d(*eobj); } if(!forceDraw && ARX_SCENE_PORTAL_ClipIO(io, t.pos)) return; DrawEERIEInter_Render(eobj, t, io, invisibility); }
void ARX_INTERFACE_ManageOpenedBook_Finish() { Vec3f pos = Vec3f(0.f, 0.f, 2100.f); Anglef angle = Anglef::ZERO; EERIE_LIGHT * light = lightHandleGet(torchLightHandle); EERIE_LIGHT tl = *light; light->pos = Vec3f(500.f, -1960.f, 1590.f); light->exist = 1; light->rgb = Color3f(0.6f, 0.7f, 0.9f); light->intensity = 1.8f; light->fallstart=4520.f; light->fallend = light->fallstart + 600.f; RecalcLight(light); EERIE_CAMERA * oldcam = ACTIVECAM; PDL[0] = light; TOTPDL=1; Vec2i tmpPos = Vec2i_ZERO; for(size_t i = 0; i < RUNE_COUNT; i++) { if(!gui::necklace.runes[i]) continue; EERIE_3DOBJ * rune = gui::necklace.runes[i]; bookcam.center.x = (382 + tmpPos.x * 45 + BOOKDEC.x) * g_sizeRatio.x; bookcam.center.y = (100 + tmpPos.y * 64 + BOOKDEC.y) * g_sizeRatio.y; SetActiveCamera(&bookcam); PrepareCamera(&bookcam, g_size); // First draw the lace angle.setPitch(0.f); if(player.hasRune((Rune)i)) { TransformInfo t1(pos, glm::toQuat(toRotationMatrix(angle))); DrawEERIEInter(gui::necklace.lacet, t1, NULL); if(rune->angle.getPitch() != 0.f) { if(rune->angle.getPitch() > 300.f) rune->angle.setPitch(300.f); angle.setPitch(std::sin(arxtime.get_updated() * (1.0f / 200)) * rune->angle.getPitch() * (1.0f / 40)); } rune->angle.setPitch(rune->angle.getPitch() - framedelay * 0.2f); if(rune->angle.getPitch() < 0.f) rune->angle.setPitch(0.f); GRenderer->SetRenderState(Renderer::DepthWrite, true); GRenderer->SetRenderState(Renderer::AlphaBlending, false); // Now draw the rune TransformInfo t2(pos, glm::toQuat(toRotationMatrix(angle))); DrawEERIEInter(rune, t2, NULL); EERIE_2D_BBOX runeBox; UpdateBbox2d(*rune, runeBox); PopAllTriangleList(); tmpPos.x++; if(tmpPos.x > 4) { tmpPos.x = 0; tmpPos.y++; } const Rect runeMouseTestRect( runeBox.min.x, runeBox.min.y, runeBox.max.x, runeBox.max.y ); // Checks for Mouse floating over a rune... if(runeMouseTestRect.contains(Vec2i(DANAEMouse))) { long r=0; for(size_t j = 0; j < rune->facelist.size(); j++) { float n = PtIn2DPolyProj(rune, &rune->facelist[j], (float)DANAEMouse.x, (float)DANAEMouse.y); if(n!=0.f) { r=1; break; } } if(r) { GRenderer->SetRenderState(Renderer::AlphaBlending, true); GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne); TransformInfo t(pos, glm::toQuat(toRotationMatrix(angle))); DrawEERIEInter(rune, t, NULL); rune->angle.setPitch(rune->angle.getPitch() + framedelay*2.f); PopAllTriangleList(); GRenderer->SetRenderState(Renderer::AlphaBlending, false); SpecialCursor=CURSOR_INTERACTION_ON; if(eeMouseDown1()) if((size_t)LastRune != i) { PlayerBookDrawRune((Rune)i); } LastRune=i; } } } } GRenderer->SetCulling(Renderer::CullCCW); LastRune=-1; *light = tl; SetActiveCamera(oldcam); PrepareCamera(oldcam, g_size); }
void ARX_INTERFACE_ManageOpenedBook_Finish(const Vec2f & mousePos, Rectf rect, float scale) { RenderState baseState = render3D().depthTest(false).fog(false); Vec3f pos = Vec3f(0.f, 0.f, 2100.f); EERIE_LIGHT * light = lightHandleGet(torchLightHandle); EERIE_LIGHT tl = *light; light->pos = Vec3f(500.f, -1960.f, 1590.f); light->m_exists = true; light->rgb = Color3f(0.6f, 0.7f, 0.9f); light->intensity = 1.8f; light->fallstart = 4520.f; light->fallend = light->fallstart + 600.f; RecalcLight(light); Camera * oldcam = g_camera; g_culledDynamicLights[0] = light; g_culledDynamicLightsCount = 1; Vec2i tmpPos(0); GRenderer->SetAntialiasing(true); float wave = timeWaveSin(g_platformTime.frameStart(), PlatformDurationMsf(1256.6370614f)); float ptDelta = toMs(g_platformTime.lastFrameDuration()); Camera bookcam; bookcam.angle = Anglef(); bookcam.m_pos = Vec3f(0.f); bookcam.focal = 500.f; bookcam.cdepth = 2200.f; for(size_t i = 0; i < RUNE_COUNT; i++) { if(!gui::necklace.runes[i]) continue; EERIE_3DOBJ * rune = gui::necklace.runes[i]; Vec2i projectionCenter = Vec2i(rect.topLeft() + (Vec2f(285, 36) + Vec2f(tmpPos) * Vec2f(45, 64)) * scale); PrepareCamera(&bookcam, Rect(rect), projectionCenter); if(player.hasRune((Rune)i)) { Anglef angle; if(rune->angle.getYaw() != 0.f) { if(rune->angle.getYaw() > 300.f) { rune->angle.setYaw(300.f); } angle.setYaw(wave * rune->angle.getYaw() * (1.0f / 40)); } rune->angle.setYaw(rune->angle.getYaw() - ptDelta * 0.2f); if(rune->angle.getYaw() < 0.f) rune->angle.setYaw(0.f); // Now draw the rune TransformInfo t2(pos, glm::quat_cast(toRotationMatrix(angle))); DrawEERIEInter(rune, t2, NULL, false, 0.f); Rectf runeBox = UpdateBbox2d(*rune).toRect(); PopAllTriangleListOpaque(baseState); tmpPos.x++; if(tmpPos.x > 4) { tmpPos.x = 0; tmpPos.y++; } // TODO this is a workaround for vertexClipPositions being relative to viewport Vec2f mousePosInViewport = mousePos - rect.topLeft(); // Checks for Mouse floating over a rune... if(runeBox.contains(mousePosInViewport)) { bool r = false; for(size_t j = 0; j < rune->facelist.size(); j++) { float n = PtIn2DPolyProj(rune->vertexClipPositions, &rune->facelist[j], mousePosInViewport.x, mousePosInViewport.y); if(n != 0.f) { r = true; break; } } if(r) { TransformInfo t(pos, glm::quat_cast(toRotationMatrix(angle))); DrawEERIEInter(rune, t, NULL, false, 0.f); rune->angle.setYaw(rune->angle.getYaw() + ptDelta * 2.f); PopAllTriangleListOpaque(baseState.blendAdditive()); cursorSetInteraction(); if(eeMouseDown1()) { PlayerBookDrawRune((Rune)i); } } } TransformInfo t1(pos, quat_identity()); DrawEERIEInter(gui::necklace.lacet, t1, NULL, false, 0.f); PopAllTriangleListOpaque(baseState); } } *light = tl; PrepareCamera(oldcam, g_size); GRenderer->SetAntialiasing(false); }