Comments (16)
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.
by "object" do you mean UIKit element or OpenGL geometry? or something else?
from panorama.
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.
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.
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.
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.
:/ 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.
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.
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.
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.
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.
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)];
}
There is another question, Why it kind of create 2 objects...? there is some way of solving this?
from panorama.
oh great! i think you uncovered a bug in screenLocationFromVector:
it appears to be returning its antipode as well
from panorama.
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.
@Allui
Can you add your code here?
from panorama.
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)
- Just detect touch Swift 3 HOT 1
- How do i get same woking of lockPanToHorizon with landscape mode in device HOT 3
- Set Image directly instead of name/path HOT 1
- adapting image orientation with device orientation HOT 2
- How can I set the current viewing direction to the center of the image? HOT 2
- How to Use the Panorama View for UIView? HOT 1
- Camera Features Support HOT 3
- setImage and setImageWithName not working when I try to set it from directory or bundle directory HOT 2
- Large Image not loading. HOT 2
- Tiny planet effect by zooming out HOT 1
- EXC_BAD_ACCESS on iOS 11 HOT 4
- how to set image size for scale 16:9 HOT 1
- Unable to build pod in swift project HOT 2
- Library for Android
- iOS black screen HOT 1
- Control Zooming
- Its not working on iOS
- Migrate to Swift and Metal?
- How to use pitch and yaw to place hotspots ?
- Port to Swift/Metal is available: dhoerl/Panorama
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panorama.