Coder Social home page Coder Social logo

ViewMatrix about geonbit.ui HOT 3 CLOSED

ronenness avatar ronenness commented on May 27, 2024
ViewMatrix

from geonbit.ui.

Comments (3)

RonenNess avatar RonenNess commented on May 27, 2024

Hi @Toemsel,

Thank you for the suggestion.

What effect are you trying to achieve with transformations? If you need scaling you should use UserInterface.Active.GlobalScale. Scaling with matrix won't be "anchors aware", eg if you scale up entities will start going off screen, while using UserInterface.Active.GlobalScale scale in a smart way that keeps everything in borders.

Using transformations can help you achieve one of the following effects: rotate around X axis (rotation z and y won't work) and translation.

I added transformations support, but it wasn't as simple as it sound because the transformation should also affect cursor position to detect clicks etc. Merely exporting the spritebatch transformation matrix would result in bad clicking detection.

Anyway here's the commit, in dev branch:

685c04f

  • few other commits after it.

You use it like this:

UserInterface.Active.RenderTargetTransformMatrix = someMatrix;.

Few more things you need to be aware of when using this:

  1. You have to use render targets for it to work (see this https://github.com/RonenNess/GeonBit.UI#using-render-targets)
  2. You need to decide if you want the cursor to be affected by transformations or not. eg. is cursor will be rendered in normal space, or transformed. You can change the behavior with UserInterface.Active.IncludeCursorInRenderTarget.

I don't know when next nuget version be so if you want this feature now you should fetch dev branch and build locally.

Let me know if you need any additional help.
Cheers!

from geonbit.ui.

Toemsel avatar Toemsel commented on May 27, 2024

Wow, fast answer and fix! πŸ‘

I do not try to scale nor transform the GUI in any way. While working with a 3D camera, the GUI does not adapt to the global world camera. (How should it) In a normal case that wouldn't be required, but I attach GUI elements (buttons) on world objects, which aren't in the ViewPort. Thus, transforming the ViewMatrix also should apply to the GUI. (In my special case). Therefore, I thought about a Transformation Matrix in your library.

Thanks for the fast fix! That did the trick

from geonbit.ui.

RonenNess avatar RonenNess commented on May 27, 2024

To combine the UI in 3d space you can also use render targets and instead of drawing the render target using sprites batch use it as a texture on a 3d object.

Although this will require manipulating the cursor position in a more tricky way currently not supported.

Anyway glad the fix helped, have fun :)

from geonbit.ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.