This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: Custom Brushes  (Read 918 times)

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Custom Brushes
« on: June 05, 2012, 10:59:33 am »
There had been some requests for custom brushes, being squares, random or dependent on terrain height / slope.

Well, that might be possible and come in the future.



What is needed for this? LUA.

Code: [Select]
function brush_random (_, _, _, _, _, _)
  return math.random()
end

function brush_square (_, _, _, _, pos_x, pos_y)
  local radius = size_x
  local inner_radius = 0.8
  local outer_radius = 0.2
  if pos_x > 0.2 and pos_y > 0.2 and
     pos_x < 0.8 and pos_y < 0.8 then
    return 1.0
  end
  return 0.0
end

function brush_circle ( center_x, center_y
                      , size_x, _
                      , pos_x, pos_y
                      )
  local radius = size_x
  local inner_radius = 0.8
  local outer_radius = 0.2
  local dist = distance ( center_x, center_y
                        , size_x, size_x
                        , pos_x, pos_y
                        )
  if dist > radius then
    return 0.0
  end
  if dist < inner_radius then
    return 1.0
  end
  return (1.0 - (dist - inner_radius) / outer_radius)
end

It is now required to think of a good API for the brushes to be able to make height dependent ones and register them nicely with noggit with supplying parameters like hardness or the range for random brushes etc.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Elinora

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 187
    • View Profile
Re: Custom Brushes
« Reply #1 on: June 05, 2012, 11:39:44 am »
I.

Am.


In.

Love..



This is really as important to me to get, as the 3D painting tool was.. Caaaaaaaaan't wait.

« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Currently studying Game Design at Copenhagen University. I also have a big project going on, sadly I have no portfolio of it (yet).