Page 1 of 1
Working on filling gauges
Posted: Fri Feb 15, 2013 2:15 am
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

Re: Working on filling gauges
Posted: Fri Feb 15, 2013 1:00 pm
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
Posted: Fri Feb 15, 2013 4:35 pm
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 ?
Posted: Fri Feb 15, 2013 4:45 pm
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
Posted: Fri Feb 15, 2013 9:31 pm
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!
Posted: Fri Feb 15, 2013 9:39 pm
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