Working on filling gauges

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Working on filling gauges

Post by Ats »

Hi everyone,

Today I started working on some filling gauges, and simple things I was making in actionscript are quite hard for me to do with ZGameEditor, so I have some questions for you...

In this stripped down example, you can move the circle on the Y axis and the gauge moves up to the circle position. How would you do to know that you clicked the circle instead of moving it wherever you clicked on the screen?

Also right now, the circle moves to the mouse position with this very approximate expression:

Code: Select all

currentModel.Position.Y = App.MousePosition.Y*(app.cameraPosition.z-currentModel.Position.z)/2.5;
It works but it's not precise at all. Do you have a better technique to place an object under the mouse wathever the camera position?

Thanks for your help ;)
Attachments
gauge1.zgeproj
(2.05 KiB) Downloaded 399 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: Working on filling gauges

Post by Kjell »

Hi Ats,
Ats wrote:Today I started working on some filling gauges, and simple things I was making in actionscript are quite hard for me to do with ZGameEditor, so I have some questions for you...
Since you mention actionscript, i suspect you're referring to this situation in a 2D environment? Your example project uses a perspective camera and 3D meshes though ..

Anyway, there are three aspects which determine the implementation.

- What kind of camera ( perspective / ortho / custom ) will you be using and what kind of behavior ( rotation, zoom and such )?
- How does the plane over which the torus moves behave, is it constant .. or does it have some kind of correlation to the camera.
- How do you want to handle the picking. Should it be polygon based, a 3D-shape, or 2D?

K
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Yeah, switching from 2D to 3D is a bit hard... I'm learning :)

So the camera would be perspective and it can rotate. In fact, I'm testing to add an interactive interface inside a cockpit, much like Samus' ship in Metroid Prime 3: http://youtu.be/QAxeQ-wS7d4?t=4m38s (at 4'38")

The torus follows the Y axis of his gauge whathever the camera orientation.
For the picking, it should be the size of the torus. Maybe a box is better otherwise we should rotate the 2D hitbox ?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Ats,
Ats wrote:I'm testing to add an interactive interface inside a cockpit, much like Samus' ship in Metroid Prime 3
You want to do the picking the other way around. Instead of un-projecting a 2D coordinate and checking that against 3D objects, project the 3D objects and test that against the 2D cursor .. allot simpler / faster.
Ats wrote:The torus follows the Y axis of his gauge whathever the camera orientation.
This will be a little trickier ..

K
Last edited by Kjell on Sun Feb 17, 2013 12:03 am, edited 1 time in total.
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

That's awesome and exactly what I meant. So the cursors are 2D sprites that are always facing the camera?
What do you mean by "matrix data from the last frame"?

And by the way, thanks for your cursor.zgeproj, it's very usefull for me!
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Arts,
Ats wrote:That's awesome and exactly what I meant.
Alright, i'll get you a .zgeproj shortly.
Ats wrote:So the cursors are 2D sprites that are always facing the camera?
Yes, but i could have used 3D spheres as well. What's important is that i used a 2D circle as picking intersection "shape" for the orbs.
Ats wrote:What do you mean by "matrix data from the last frame"?
This is a ZGE related problem / limitation. Since the camera projection / view matrices are generated after OnUpdate, the only way to get the matrices you need is to calculate them by yourself.

K
Post Reply