Basically now we have a way to draw 2D UI: text, rect, border and turret/fighter tooltips.
Drawing debug sphere/box/line is either broken or unintuitive, because I din't see anybody who got this working.
I suggest to implement 2 ways of drawing things:
First one is usual drawSomething (line, circle for 2D UI context; sphere, box, plain (flat 2d surface) for 3D context). Yes, it is expensive to draw things from Lua but it doesn't mean that we shouldn't have this possibility.
Second one is more performance-friendly and has some slight similarities with how SVG image format works in HTML (and how game UI currently works too).
So, instead of:
local color = ColorARGB(0.5, 0.35, 0.35, 0.35)
function draw()
drawSphere(Entity().position, 10, color)
end
We will create a DrawSphere as an object. We can:
Hide or show it whenever we want to (toggle its drawing)
Adjust its position, rotation
Link it to the entity: position only or position + rotation
This way there will be no drawback from Lua calling draw function every frame. C++ will handle all drawing, while just getting commands like "show", "hide", "move", "destroy".
local mySphere
local sphereTimer
function init()
local entity = Entity()
mySphere = DrawSphere()
mySphere.lockToEntity = entity
mySphere.lockToEntityOrientation = true
mySphere.entityOrientation = entity.orientation
mySphere.color = ColorARGB(0.5, 0.35, 0.35, 0.35)
mySphere.translation = dvec3(10, 15, 10)
end
function someEvent() -- maybe button was pressed or damage taken
mySphere.show()
sphereTimer = 30
end
function updateClient(timeStep)
if sphereTimer > 0 then
sphereTimer = sphereTimer - timeStep
if sphereTimer <= 0 then
mySphere.hide()
end
end
end
Suggestion
Rinart73
Basically now we have a way to draw 2D UI: text, rect, border and turret/fighter tooltips.
Drawing debug sphere/box/line is either broken or unintuitive, because I din't see anybody who got this working.
I suggest to implement 2 ways of drawing things:
First one is usual drawSomething (line, circle for 2D UI context; sphere, box, plain (flat 2d surface) for 3D context). Yes, it is expensive to draw things from Lua but it doesn't mean that we shouldn't have this possibility.
Second one is more performance-friendly and has some slight similarities with how SVG image format works in HTML (and how game UI currently works too).
So, instead of:
We will create a DrawSphere as an object. We can:
This way there will be no drawback from Lua calling draw function every frame. C++ will handle all drawing, while just getting commands like "show", "hide", "move", "destroy".
Link to comment
Share on other sites
3 answers to this suggestion
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now