Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Grid similar to that found in editors  (Read 1330 times)

0 Members and 1 Guest are viewing this topic.

mentor

  • Newbie
  • *
  • Posts: 31
    • View Profile
Grid similar to that found in editors
« on: August 27, 2014, 06:42:42 pm »
Hi,

I'm writing a program and I was wondering how to make a grid just like that which can be found in all sort of editors (UDK, UE4, 3d modelling apps). A grid which responds to mouse - which can be moved by dragging a mouse and can be scaled when we move mouse wheel. Any ideas how to do that?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Grid similar to that found in editors
« Reply #1 on: August 27, 2014, 06:48:33 pm »
Calculate where the grid should be drawn and draw it.
React to mouse events to detect clicks, drags etc.
Based on mouse events detect if the user drags the grid and recalculate how it should be drawn.
Based on events detect if the user wants to zoom and recalculate zoom factors and where to draw the grid.
Etc etc etc.

You basically just need to figure out what you want your grid to do, react to events to determine what action the user is performing, update your internal representation of the world (your grid) and then draw your internal representation.
Just like you'd approach most programming tasks; figure out all the individual steps involved and then implement them all one by one.

mentor

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Grid similar to that found in editors
« Reply #2 on: August 27, 2014, 07:05:49 pm »
OK, thanks! I will try that out :)