Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support both touch and motion #2

Open
vitrinh282 opened this issue Jul 24, 2017 · 35 comments
Open

Support both touch and motion #2

vitrinh282 opened this issue Jul 24, 2017 · 35 comments

Comments

@vitrinh282
Copy link

do you have support touch and motion in same sphere5

@szt243660543
Copy link
Owner

setting [self.library setTouchEvent:YES], this funciton support touch screen to select object.

@vitrinh282
Copy link
Author

ah i mean that "[self.SZTLibrary interactiveMode:SZTModeInteractiveMotionWithTouch];"
but i just see move left right, not touch to move top and bottom , right ?

@szt243660543
Copy link
Owner

oh, I misunderstood. this sdk is not touch to move top and bottom, beause I don't think it's useful.

@vitrinh282
Copy link
Author

that's ok, Just wanna to easy to see around , anyway thank for support me :)

@vitrinh282
Copy link
Author

and what is formula to calculate position of hotspot that i add in VR ImageView base on point (X,Y ) of Image (Width,height)

@szt243660543
Copy link
Owner

you can see demo SZT_TouchDemo.

[image setObjectSize:200.0 Height:100.0];
// This method is used to set the width and height of the image. If this method is not declared, it read image default size.

[image setPosition:5.0 Y:0.0 Z:-20.0];
// beacuse the initial position of the camera is at vec(0,0,0), the vector direction is vec(0,0, -1), so the coordinates must be in the front.

@szt243660543
Copy link
Owner

I'm not sure what you want to know.

@vitrinh282
Copy link
Author

vrbackbround
here what i mean

@szt243660543
Copy link
Owner

The camera is facing in the direction of vec(0,0,-1)。

@vitrinh282
Copy link
Author

i still don't see, i mean how you calculate X, Y, Z from x,y above

@szt243660543
Copy link
Owner

The coordinates are only relevant to the location of the camera, irrespective of the background ball, and the SDK default background ball radius is 150.I default that the camera is facing in the direction (0,0, -1), you can try to change the coordinates of the map to see the effect.

@vitrinh282
Copy link
Author

no , i mean if i want put image somewhere in VRview LIKE on table or on chair, wall , and i just know position (x,y) and width , height of panorama image , so how do you know X, Y, Z to setposition for putting image exactly on table, chair, wall.....

@szt243660543
Copy link
Owner

szt243660543 commented Jul 25, 2017

If you want to be related to the background ball, then you have to use latitude and longitude to calculate the coordinates so that you can find the exact location.
wechatimg2

@vitrinh282
Copy link
Author

sorry but i try to change value of X,Y,Z to find formula, but i'm still not found. What's relative degree in your picture to help me get formula has relative on background ball.

@szt243660543
Copy link
Owner

You can understand that, your position is at the center of the ball vec(0,0,0), and VEC (0,0, -10) is in front of you,vec (-10,0,0) is on your left, vec (10,0,0) is on your right, and so on..

@szt243660543
Copy link
Owner

You can also use the script directly. I've done the latitude and longitude conversion. You just need to tell me the longitude latitude and the depth value. I can fix it for you.

how to use script: you can see Script specification:http://www.vrkongfu.com/doc/doc_en.html

@vitrinh282
Copy link
Author

vitrinh282 commented Jul 25, 2017

vrbackbround
my side , I have point in image Panorama , with position (x,y) and size of image panorama (width,height).
So o want to put image (hotspot) at that point. with all data x, y ,width, height , how do you convert to X, Y, Z to setposition at that point same this image .
detail x =385, y=405 , width =2048, height = 1024 same on this

@vitrinh282
Copy link
Author

Can you find it ?

@szt243660543
Copy link
Owner

How did you get the x = 385,y = 405?

@vitrinh282
Copy link
Author

i Use paint on window

@szt243660543
Copy link
Owner

szt243660543 commented Jul 27, 2017

Use the following method, it can help you to latitude and longitude into coordinates.

  • (GLKVector3)CalculateSphereSurfacePointWithLat:(float)lat Lon:(float)lon Depth:(float)depth
    {
    GLKVector3 X_Z;
    // 经
    X_Z.x = depth * sin(GLKMathDegreesToRadians(lon));
    X_Z.y = 0;
    X_Z.z = depth * - cos(GLKMathDegreesToRadians(lon));

    GLKVector3 Y_Z;
    // 纬
    Y_Z.x = 0;
    Y_Z.y = depth * sin(GLKMathDegreesToRadians(lat));
    Y_Z.z = depth * - cos(GLKMathDegreesToRadians(lat));

    if (lat == 0.0) {
    Y_Z = GLKVector3Make(0.0, 0.0, 0.0);
    }

    if (lon == 0.0) {
    X_Z = GLKVector3Make(0.0, 0.0, 0.0);
    }

    GLKVector3 dir = [MathC vector3Normalization:GLKVector3Add(X_Z, Y_Z)];
    if (lat == 0.0 && lon == 0.0) {
    dir = GLKVector3Make(0.0, 0.0, -1.0);
    }
    GLKVector3 point = GLKVector3MultiplyScalar(dir, depth);

    return point;
    }

// 规格化

  • (GLKVector3)vector3Normalization:(GLKVector3)vec3
    {
    float sqr = sqrt(vec3.xvec3.x + vec3.yvec3.y + vec3.z*vec3.z);
    float tempx = vec3.x/sqr;
    float tempy = vec3.y/sqr;
    float tempz = vec3.z/sqr;

    return GLKVector3Make(tempx, tempy, tempz);
    }

@szt243660543
Copy link
Owner

image

The latitude and longitude information is similar to the world map map. From left to right longitude is -180 to 180, from bottom to top latitude is -90 to 90.

@vitrinh282
Copy link
Author

what concer between setPosition(X,Y,Z) and latitude, longtude ? how do i calculate ? I don't understand
I just put image in point example above ? then how do you get position

@vitrinh282
Copy link
Author

i tried with your method but result x,y ,z is big ,it was wrong when i setposition

@szt243660543
Copy link
Owner

What is the depth value of your incoming?

@vitrinh282
Copy link
Author

150

@szt243660543
Copy link
Owner

szt243660543 commented Aug 1, 2017

the depth value need in 0 ~ 150,try 25. What is the latitude and longitude value?

@vitrinh282
Copy link
Author

float lon = 360.0f * (float)x / ((float)image.size.width*(float)image.scale) -180.0f;
float lat = 90.0f - (180.0f * (float)y / ((float)image.size.height*(float)image.scale));

base on you description, i calculate long and lat follow formula above , but not right

@szt243660543
Copy link
Owner

Independent of the width of the background image, you can get the coordinates you want with just passing the values I provide.

@szt243660543
Copy link
Owner

Because the background map is already attached to the ball, no matter how large your image is, it is attached to a ball with a radius of 150.

@vitrinh282
Copy link
Author

vitrinh282 commented Aug 1, 2017

i used your background image , image size in formula , its background

@vitrinh282
Copy link
Author

do you develop from project md360player, that i want same on android, ios not support add plugin, so i need another solution , that's your project, so could you me .

@szt243660543
Copy link
Owner

This is not developed on md360player.so it is different from each other.

@vitrinh282
Copy link
Author

ok , i got how to calculate position
about rotateto when i just add radianX image will rote up down,
radianY will rotate left right
but if I add two in same image will be wrong, you can try with your rotate demo change radianY 0 to 50

@vitrinh282
Copy link
Author

And has a problem when i use Displaymode Normal, Screen will be same flashfly when phone is lock or pause state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants