mirror of
https://github.com/tappollo/Panorama.git
synced 2026-01-12 17:03:06 +08:00
fix for #51, getTextureSize returns CGSize instead of CGPoint
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
D543FEC91D8485FF00DA5ED4 /* spectrum.png in Resources */ = {isa = PBXBuildFile; fileRef = D543FEC81D8485FF00DA5ED4 /* spectrum.png */; };
|
||||
D55E8FB21828D2360076A9D7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D55E8F951828D2360076A9D7 /* AppDelegate.m */; };
|
||||
D55E8FB61828D2360076A9D7 /* equirectangular-projection-lines.png in Resources */ = {isa = PBXBuildFile; fileRef = D55E8F9C1828D2360076A9D7 /* equirectangular-projection-lines.png */; };
|
||||
D55E8FC01828D2360076A9D7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D55E8FA71828D2360076A9D7 /* main.m */; };
|
||||
@@ -47,6 +48,7 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
D543FEC81D8485FF00DA5ED4 /* spectrum.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spectrum.png; path = images/spectrum.png; sourceTree = "<group>"; };
|
||||
D55E8F941828D2360076A9D7 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
D55E8F951828D2360076A9D7 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
D55E8F9B1828D2360076A9D7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
@@ -139,6 +141,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D5EC7AB8183AFBC400F62609 /* park_2048.jpg */,
|
||||
D543FEC81D8485FF00DA5ED4 /* spectrum.png */,
|
||||
D55E8F9C1828D2360076A9D7 /* equirectangular-projection-lines.png */,
|
||||
D560B0B31D7F260500535DCF /* button-screen-double.png */,
|
||||
D560B0B41D7F260500535DCF /* button-screen-single.png */,
|
||||
@@ -299,6 +302,7 @@
|
||||
D5C8B44C18A8E58700051A88 /* Default-568h@2x.png in Resources */,
|
||||
D560B0B51D7F260500535DCF /* button-screen-double.png in Resources */,
|
||||
D55E8FE21828D3F50076A9D7 /* 60.png in Resources */,
|
||||
D543FEC91D8485FF00DA5ED4 /* spectrum.png in Resources */,
|
||||
D55E8FB61828D2360076A9D7 /* equirectangular-projection-lines.png in Resources */,
|
||||
D560B0B61D7F260500535DCF /* button-screen-single.png in Resources */,
|
||||
);
|
||||
|
||||
@@ -37,7 +37,7 @@ GLKQuaternion GLKQuaternionFromTwoVectors(GLKVector3 u, GLKVector3 v){
|
||||
-(id) init:(GLint)stacks slices:(GLint)slices radius:(GLfloat)radius textureFile:(NSString *)textureFile;
|
||||
-(void) swapTexture:(NSString*)textureFile;
|
||||
-(void) swapTextureWithImage:(UIImage*)image;
|
||||
-(CGPoint) getTextureSize;
|
||||
-(CGSize) getTextureSize;
|
||||
|
||||
@end
|
||||
|
||||
@@ -273,12 +273,13 @@ GLKQuaternion GLKQuaternionFromTwoVectors(GLKVector3 u, GLKVector3 v){
|
||||
return [self imagePixelFromVector:[self vectorFromScreenLocation:point inAttitude:_attitudeMatrix]];
|
||||
}
|
||||
-(CGPoint) imagePixelFromVector:(GLKVector3)vector{
|
||||
CGPoint pxl = CGPointMake((M_PI-atan2f(-vector.z, -vector.x))/(2*M_PI), acosf(vector.y)/M_PI);
|
||||
CGPoint tex = [sphere getTextureSize];
|
||||
CGPoint pxl = CGPointMake((atan2f(-vector.x, vector.z))/(2*M_PI), acosf(vector.y)/M_PI);
|
||||
if(pxl.x < 0.0) pxl.x += 1.0;
|
||||
CGSize tex = [sphere getTextureSize];
|
||||
// if no texture exists, returns between 0.0 - 1.0
|
||||
if(!(tex.x == 0.0f && tex.y == 0.0f)){
|
||||
pxl.x *= tex.x;
|
||||
pxl.y *= tex.y;
|
||||
if(!(tex.width == 0.0f && tex.height == 0.0f)){
|
||||
pxl.x *= tex.width;
|
||||
pxl.y *= tex.height;
|
||||
}
|
||||
return pxl;
|
||||
}
|
||||
@@ -587,12 +588,12 @@ GLKQuaternion GLKQuaternionFromTwoVectors(GLKVector3 u, GLKVector3 v){
|
||||
glDeleteTextures(1, &name);
|
||||
m_TextureInfo = [self loadTextureFromImage:image];
|
||||
}
|
||||
-(CGPoint)getTextureSize{
|
||||
-(CGSize)getTextureSize{
|
||||
if(m_TextureInfo){
|
||||
return CGPointMake(m_TextureInfo.width, m_TextureInfo.height);
|
||||
return CGSizeMake(m_TextureInfo.width, m_TextureInfo.height);
|
||||
}
|
||||
else{
|
||||
return CGPointZero;
|
||||
return CGSizeZero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
[super viewDidLoad];
|
||||
panoramaView = [[PanoramaView alloc] init];
|
||||
[panoramaView setImageWithName:@"park_2048.jpg"];
|
||||
// [panoramaView setImageWithName:@"spectrum.png"];
|
||||
[panoramaView setOrientToDevice:YES];
|
||||
[panoramaView setTouchToPan:NO];
|
||||
[panoramaView setPinchToZoom:YES];
|
||||
@@ -32,26 +33,28 @@
|
||||
[panoramaView draw];
|
||||
}
|
||||
|
||||
// everything below is to make the VR switching button.
|
||||
-(void) viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
CGFloat PAD = 15.0;
|
||||
UIButton *VRButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
|
||||
[VRButton setTransform:CGAffineTransformMakeRotation(M_PI*0.5)];
|
||||
[VRButton setCenter:CGPointMake(VRButton.frame.size.width*0.5 + PAD,
|
||||
self.view.bounds.size.height - VRButton.frame.size.height*0.5 - PAD)];
|
||||
[VRButton setImage:[UIImage imageNamed:@"button-screen-double"] forState:UIControlStateNormal];
|
||||
[VRButton setAlpha:0.5];
|
||||
[VRButton addTarget:self action:@selector(vrButtonHandler:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:VRButton];
|
||||
}
|
||||
-(void) vrButtonHandler:(UIButton*)sender{
|
||||
[panoramaView setVRMode:!panoramaView.VRMode];
|
||||
if(panoramaView.VRMode){
|
||||
[sender setImage:[UIImage imageNamed:@"button-screen-single"] forState:UIControlStateNormal];
|
||||
}else{
|
||||
[sender setImage:[UIImage imageNamed:@"button-screen-double"] forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
|
||||
// uncomment everything below to make a VR-Mode switching button
|
||||
|
||||
//-(void) viewWillAppear:(BOOL)animated{
|
||||
// [super viewWillAppear:animated];
|
||||
// CGFloat PAD = 15.0;
|
||||
// UIButton *VRButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
|
||||
// [VRButton setTransform:CGAffineTransformMakeRotation(M_PI*0.5)];
|
||||
// [VRButton setCenter:CGPointMake(VRButton.frame.size.width*0.5 + PAD,
|
||||
// self.view.bounds.size.height - VRButton.frame.size.height*0.5 - PAD)];
|
||||
// [VRButton setImage:[UIImage imageNamed:@"button-screen-double"] forState:UIControlStateNormal];
|
||||
// [VRButton setAlpha:0.5];
|
||||
// [VRButton addTarget:self action:@selector(vrButtonHandler:) forControlEvents:UIControlEventTouchUpInside];
|
||||
// [self.view addSubview:VRButton];
|
||||
//}
|
||||
//-(void) vrButtonHandler:(UIButton*)sender{
|
||||
// [panoramaView setVRMode:!panoramaView.VRMode];
|
||||
// if(panoramaView.VRMode){
|
||||
// [sender setImage:[UIImage imageNamed:@"button-screen-single"] forState:UIControlStateNormal];
|
||||
// }else{
|
||||
// [sender setImage:[UIImage imageNamed:@"button-screen-double"] forState:UIControlStateNormal];
|
||||
// }
|
||||
//}
|
||||
|
||||
@end
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
OpenGL, device-oriented, touch-interactive
|
||||
|
||||

|
||||

|
||||
|
||||
acceptable image sizes: (4096×2048), 2048×1024, 1024×512, 512×256, 256×128 ...
|
||||
|
||||
@@ -124,6 +124,8 @@ The program begins by facing the center column of the image, or azimuth 0°
|
||||
|
||||
# about equirectangular
|
||||
|
||||

|
||||
|
||||
equirectangular images mapped to the inside of a celestial sphere come out looking like the original scene, and the math is relatively simple [http://en.wikipedia.org/wiki/Equirectangular_projection](http://en.wikipedia.org/wiki/Equirectangular_projection)
|
||||
|
||||
# license
|
||||
|
||||
Reference in New Issue
Block a user