Giter VIP home page Giter VIP logo

Comments (8)

zhuozhuo avatar zhuozhuo commented on July 30, 2024

I want add some objects such as buttons or view.

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

got a solution-
it looks like GLKView Opaque property needs to be NO for this to happen. I'm going to push this small change up to master.

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

my hierarchy looks like this:
GLKViewController
-GLKView (PanoramaView)
--UIKIT Objects (UIButton, UIView)

add all your elements as subviews to PanoramaView and it should work fine

here's my ViewController.m code:
@interface ViewController (){
PanoramaView *panoramaView;
}
@EnD

@implementation ViewController

  • (void)viewDidLoad{
    [super viewDidLoad];
    panoramaView = [[PanoramaView alloc] init];
    [panoramaView setImage:@"park_2048.jpg"];
    [panoramaView setOrientToDevice:YES];
    [panoramaView setTouchToPan:NO];
    [panoramaView setPinchToZoom:YES];
    [panoramaView setShowTouches:NO];
    [self setView:panoramaView];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button setFrame:CGRectMake(10, 10, 100, 100)];
    [button setBackgroundColor:[UIColor blackColor]];
    [panoramaView addSubview:button];
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    }

-(void) buttonAction{
NSLog(@"hit");
}

-(void) glkView:(GLKView *)view drawInRect:(CGRect)rect{
[panoramaView draw];
}

@EnD

from panorama.

zhuozhuo avatar zhuozhuo commented on July 30, 2024

Thank you for your answer。But I want to let button follow panoramaView rotation movement.

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

oh, i would build an object in openGL, putting it where this comment is:
//TODO: add any objects here to make them a part of the virtual reality
that way it distorts properly and feels like it's integrated.

if you just want a UIKit object tracking a point (it wouldn't rotate for example), then you want to convert a unit vector to a screen point. i have a function
-(GLKVector3) vectorFromScreenLocation:(CGPoint)screenTouch inAttitude:(GLKMatrix4)matrix;
and what you'd want is the inverse of that. which might be useful to have. i don't have time free time at the moment, but if you want to take care of it I'll merge it. Or I can look into it at a later time.

from panorama.

autresphere avatar autresphere commented on July 30, 2024

Hi,
Any news about this screenLocationFromVector method?
Thanks in advance.

from panorama.

autresphere avatar autresphere commented on July 30, 2024

Here is some code that returns the location on screen from a 3D point:

- (BOOL)computeScreenLocation:(CGPoint*)location fromVector:(GLKVector3)vector inAttitude:(GLKMatrix4)matrix
{
    GLKVector4 screenVector;
    GLKVector4 vector4;

    if(location == NULL)
        return NO;

    matrix = GLKMatrix4Multiply(_projectionMatrix, matrix);
    vector4 = GLKVector4Make(vector.x, vector.y, vector.z, 1);
    screenVector = GLKMatrix4MultiplyVector4(matrix, vector4);

    location->x = (screenVector.x/screenVector.w/2.0 + 0.5) * self.frame.size.width;
    location->y = (0.5-screenVector.y/screenVector.w/2) * self.frame.size.height;

    return (screenVector.z >= 0);
}

This method returns wether the point is before or behind the screen.
It does work in portrait but would need some additional code to take care of all orientations.
I will create a PR if I find some time.

from panorama.

mayakraft avatar mayakraft commented on July 30, 2024

it actually works fine with orientations, it alerted me to another issue- orientation handling is being over-complicated, fixing it now.

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.