Giter VIP home page Giter VIP logo

Comments (16)

Allui avatar Allui commented on July 30, 2024 1

little trick, and we have one button :D

-(void) glkView:(GLKView *)view drawInRect:(CGRect)rect {
    [panoramaView draw];
    GLKVector3 position = GLKVector3Make(0.0000001, -0.04, 0.1);
    CGPoint  buttonLocation = [panoramaView screenLocationFromVector:position];
    CGPoint p = [panoramaView imagePixelAtScreenLocation:buttonLocation];

    if (round(p.x) != 512) return;

    if (buttonLocation.x == buttonLocation.x) {
        [button setFrame:CGRectMake(buttonLocation.x, buttonLocation.y, 40, 40)];
    }
}

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

by "object" do you mean UIKit element or OpenGL geometry? or something else?

from panorama.

UlyssesRocha avatar UlyssesRocha commented on July 30, 2024

Ideally an UIKit element (I am not familiar with OpenGL ), in my scenario I want to add a .PNG image of a satellite object at a "real world position" , I am not sure what kind of object I will need.

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

right.. so, the problem isn't solved for UIKit elements. you saw from issue 19 that you can update the element's x,y position using that getScreenLocation... function? but that the object doesn't rotate with the scene.

what's missing is some kind of function that's like rotationValue for Screen Location.

were you trying to solve the rotation problem? or thinking of a different approach?

from panorama.

UlyssesRocha avatar UlyssesRocha commented on July 30, 2024

You mean rotation by the itself rotation?
http://i.stack.imgur.com/yt3D4.png

Or in the 3d environment?
In my case, I only need to set the "spacial position", so I only need to set the "2d" position. ( I only have the azimuth and altitude of the object)

I am not sure what I need to do to achieve this behaviour (again, I am not familiar with OpenGL).

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

again, this is not a good solution. UIKit integration isn't seamless at this point. step 1 is this function:

-(CGPoint) screenLocationFromVector:(GLKVector3)vector;

you have the altitude and azimuth, convert that to a vector, and then set your UIKit element's position to the CGPoint returned.

but you'll notice that your UIKit element doesn't rotate if you rotate your screen around the Z axis (the normal through the screen). doing this would be step 2

is this the direction you are aiming for?

from panorama.

UlyssesRocha avatar UlyssesRocha commented on July 30, 2024

:/ I need the Z axis to give the user the "point to a satellite" feature.

This step 2 to get the Z axis is too complicated using UIKit?
What you recommend to be done, use an OpenGL object? Can you give some directions?

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

i'm not good enough at 3D math to anticipate wether or not step2 would be an easy problem to solve. it might be easy..
the best approach might be a combination of the two.
doing it in opengl will be visually seamless but loses the uikit touch interaction paradigms. you have to build your own touch detection -(BOOL) touchInRect:(CGRect)rect; would help you get started but using a (clear) uikit element for touch detection might make for the best behavior you're seeking.

from panorama.

UlyssesRocha avatar UlyssesRocha commented on July 30, 2024

So I should start setting the UIKit element and setting its position to
-(CGPoint) screenLocationFromVector:(GLKVector3)vector;
And then work to correct the position in the Z axis?

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

the position won't be incorrect.

you should do what you're suggesting. you'll see what i'm talking about. it's only the rotation of the object that will be incorrect. the position should be fine.

from panorama.

UlyssesRocha avatar UlyssesRocha commented on July 30, 2024

Ty very much for the support, I will try to implement it.
To add the object, I should use addSubView? do I have to worry about keep updating the position of the object, or it will be done automatically?

from panorama.

UlyssesRocha avatar UlyssesRocha commented on July 30, 2024

Probably there is a smarter way of doing this, buuuut it kind of worked.

At initOpenGL

   button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    GLKVector3 satelite = GLKVector3Make(0, 0, 1);

    CGPoint location = [self screenLocationFromVector:satelite];
    [button setFrame:CGRectMake(location.x, location.y, 100, 100)];
    [button setBackgroundColor:[UIColor blackColor]];

    [self addSubview:button];

At updateLook

    GLKVector3 position = GLKVector3Make(0.0000001, -0.04, 0.1);
    buttonLocation = [self screenLocationFromVector:position];

    if (buttonLocation.x == buttonLocation.x){
        [button setFrame:CGRectMake(buttonLocation.x, buttonLocation.y, 40, 40)];
    }

The result,

There is another question, Why it kind of create 2 objects...? there is some way of solving this?

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

oh great! i think you uncovered a bug in screenLocationFromVector: it appears to be returning its antipode as well

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

what you did is fine but i would alloc UIKit things inside of ViewController instead of PanoramaView, place the button updating code in -(void) glkView:(GLKView *)view drawInRect:(CGRect)rect if it's possible that way

from panorama.

mattiosdev avatar mattiosdev commented on July 30, 2024

@Allui
Can you add your code here?

from panorama.

marcelosalloum avatar marcelosalloum commented on July 30, 2024

Hey @Allui, @UlyssesRocha, did any of you manage to show only one button over there? I am not sure how to do it but I guess the screenLocationFromVector method might have more than one solution. Am I right?

from panorama.

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.