Coder Social home page Coder Social logo

Comments (11)

valyard avatar valyard commented on July 1, 2024

Scale is multiplicative. This might be misleading but value of 1 is "no scale", 1.1 — 10% scaled up, 0.9 — 10% scaled down.

from touchscript.

avgritche avatar avgritche commented on July 1, 2024

That's the way i saw it, but the retreived value does not reflect the spacing between fingers..
I expected something like: "Current_FingerDistance / GestureStart_FingersDistance" that could be done in a slow & precise move (currently used to control the zoom of a camera).

from touchscript.

valyard avatar valyard commented on July 1, 2024

This is delta value. You should keep all the previous values to calculate current absolute scale.

currentScale *= delta;

It's not that simple with "start finger distance" as you pointed out because you can start with one fingers and end the gesture holding other ones.

from touchscript.

avgritche avatar avgritche commented on July 1, 2024

From Unity documentation : "Contains local delta scale when gesture is recognized. Value is between 0 and +infinity, where 1 is no scale, 0.5 is scaled in half, 2 scaled twice."

It sound like a value i could directly use ?
So it's not clear what you mean by storing each deltas.

The problem is that i don't get such values for it (debug.print)..
1.0 - or close on gesture recognition = no scale
0.8 - when fingers are totally close from others, + relativly linear move from "no scale" position = useable.
1.01 - when finger are as far as possible from center, + unuseable move from "no scale" position (from 1.0 to 1.12 then to 1.01) = unuseable.

ps : The rotation (the hardest one i guess) work as a charm.. i wont bother you with this one ;)

from touchscript.

valyard avatar valyard commented on July 1, 2024

No, this is delta value from previous frame.
It is like (distance between fingers this frame) / (distance between fingers last frame).

from touchscript.

avgritche avatar avgritche commented on July 1, 2024

My goal is not to argue, but to make it work in my project and help you improve you'r lib meanwhile.. so i need to describe the value as it is.
What i obtain from ScaleGesture.LocalDeltaScale is like : Current_FingerDistance / GestureStart_FingersDistance.
It may be different from what you intend/got, for a weird reason.. but that's bugs rules, and that's why i'm here.

from touchscript.

valyard avatar valyard commented on July 1, 2024

Sorry I lost track of what you actually want.
Do you want LocalDeltaScale to be equal to (current finger distance) / (start finger distance), right?
If so, it's not possible. LocalDeltaScale = (current finger distance) / (finger distance last frame).
So, once again, to get absolute scale value you need to store LocalDeltaScale each frame like this:

absoluteScale *= gesture.LocalDeltaScale;

absoluteScale variable will contain what you want.

from touchscript.

avgritche avatar avgritche commented on July 1, 2024

I've done the zoom & pan i needed directly using TouchManager.Touches.. and the rotation using your events.
So this discussion now only intend to bring feedback to you, as this lib is a nice gift that helped me a lot.

using ScaleGesture.LocalDeltaScale :

  • if put some fingers and scale then down a bit, i obtain 0.99 (nearly 1.0 - triggering) : it's ok.
  • if i scale then down at maximum, i obtain 0.8 (never 0.5), but the localdeltascale reflect my finger spacing : it's ok.
  • if i maintain the same position, i still obtain 0.8 (so it does not sound like a delta) : but it's still ok.

then

  • if i try to scale up.. i can go back from 0.8 to 1.0 with no problem.. but when scaling up, the values are non lineary linked to my fingers spacing, that's where my problem is. While i increase the finger spacing, it move from 1.0 to 1.1, then to 1.01.. i never can reach 1.5 or even 2.0.

In short : Scale down work nicely, scale up does not work.. for me.

ps : i'm french, so sorry if my english does not help understanding and/or does not reflect the friendly feeling.

from touchscript.

valyard avatar valyard commented on July 1, 2024

This doesn't sound like normal behavior. Do you have a test project you could send me to test?

from touchscript.

avgritche avatar avgritche commented on July 1, 2024

Preparing the sample made it clearer :
You where right from start, "absoluteScale *= gesture.LocalDeltaScale;" is perfect for this need.

So sorry for this long missunderstanding, and thanks for your patience..

Regards,
Alain.

from touchscript.

valyard avatar valyard commented on July 1, 2024

Good to know that you figured this out.

from touchscript.

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.