Jump to content
  • 0

Add a proper way to draw in both 2d and 3d


Rinart73

Suggestion

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

Link to comment
Share on other sites

3 answers to this suggestion

Recommended Posts

  • 0

There can be a ton of projects, I don't have a whole concept of mine yet, but I can name reasons to have this functions in game:

 

There a lot of suggestions, lots of things that people want but devs will not make just because they have their roadmap and certain suggestions will require a lot of time. Or when a suggestion doesn't fit the game concept that devs have.

Also mods help to keep interest for the game even after second, third.. time you won.

 

So, I think that devs should expand Scripting API not just when they add a new thing like an Alliances, but generally allow modders to do more things, not just drawing, that I mentioned here.

 

This is a sandbox with modding support. Basicaly this means, that Devs should do basic things and modders should expand the game. Look at Minecraft: Vanilla: mine diamonds, kill the dragon. Look at Minecraft mods: whoa! Look at Skyrim, the game that is still alive only because huge expansions that modders made (not because of some Special Edition).

 

-

Originally I wanted to display some effects on the ship, as a part of some space discovery mod. Exposions and other effects needed to be constantly created and draw too much attention to them.

So for the space corrosion effect I wanted to draw a few overlaying textures on some blocks.

 

Then I discovered that drawDebugSphere doesn't work. And this annoyed me, because it's hard to test system upgrade radius without seeing it.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...