Alienhead Posted February 7 Share Posted February 7 I'm looking for an example of a sprite rendering in front of the 3d world?  My attempts have failed 😦 Quote   Alienhead Components and Software  Link to comment Share on other sites More sharing options...
Alienhead Posted February 8 Author Share Posted February 8 Since I have yet to get a sprite to render in front of 3d objects I was going to use the UI system. But now I read this system is getting wiped in place of a new one? Is this verified? would I be better off to not use the UI system until 1.0 ?   Quote   Alienhead Components and Software  Link to comment Share on other sites More sharing options...
Dreikblack Posted February 8 Share Posted February 8 1 hour ago, Alienhead said: this system is getting wiped in place of a new one? I It's not. Just will be 3D camera instead of world and other things should stay like they are now afaik (and no SetRenderLayers will be needed for UI). Internally there will be bigger changes, but ideally it will affect only bugs (by fixing them indirectly) and not API beside CreateInterface ui = CreateInterface(camera, font, frameSize) 1 Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted February 8 Share Posted February 8 SetOrder, GUI and Sprite with ordering example local displays = GetDisplays() local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR) local world = CreateWorld() local framebuffer = CreateFramebuffer(window) local light = CreateBoxLight(world) light:SetRotation(45, 35, 0) light:SetRange(-10, 10) light:SetColor(2) local model = CreateBox(world) model:SetColor(0, 0, 1) local font = LoadFont("Fonts/arial.ttf") local ui = CreateInterface(world, font, framebuffer.size) ui:SetRenderLayers(2) ui.background:SetColor(0.0, 0.0, 0.0, 0.0) local sz = ui.background:ClientSize() local sz = ui.background:ClientSize() local button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui.background) local uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC) uiCamera:SetPosition(framebuffer.size.x * 0.5, framebuffer.size.y * 0.5, 0) uiCamera:SetRenderLayers(2) uiCamera:SetClearMode(CLEAR_DEPTH); --higher number than other cameras means drawing later than other camera, by default 0 and order defined by creation order uiCamera:SetOrder(1) --100 width, 10 height local sprite = CreateSprite(world, 100, 10) sprite:SetColor(1, 0, 0) --z/depth - to make appear behind GUI and correct order relativly other sprites sprite:SetPosition(sz.x / 2, sz.y / 2, 0.99901) --to display in 2D camera sprite:SetRenderLayers(2) local sprite2 = CreateSprite(world, 100, 10) sprite2:SetColor(0, 1, 0) --bigger depth means it will be behind first sprite sprite2:SetPosition(sz.x / 2 + 50, sz.y / 2, 0.99902) sprite2:SetRenderLayers(2) local camera = CreateCamera(world) camera:SetClearColor(0.125) camera:SetPosition(0, 0, -4) while not window:KeyDown(KEY_ESCAPE) do while (PeekEvent()) do local ev = WaitEvent() if (ev.id == EVENT_WINDOWCLOSE and ev.source == window) then return 0 else ui:ProcessEvent(ev) end end model:Turn(0, 1, 0) world:Update() world:Render(framebuffer) end 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.