GithubHelp home page GithubHelp logo

thumbworks / augmentedsolarsystem Goto Github PK

View Code? Open in Web Editor NEW
70.0 7.0 25.0 254.98 MB

An Augmented reality experience to explore planets in our Solar System

Swift 94.85% C 0.01% Ruby 5.14%
arkit solar planet augmented-reality scenekit ios ios-app ios11

augmentedsolarsystem's People

Contributors

rodericj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

augmentedsolarsystem's Issues

Better arrow hiding logic

Seems like I should be able to detect the direction of the arrow. Perhaps it's position relative to the camera. Otherwise determining if the SCNnode is inside of the camera frustum.

Detect when inside a node

When the sun scales it can become easy to lose one's place if inside of the sun. An indicator that we are inside of a node would make this much more explicit and indicate what the user can do at this point

Show the system on a table, scale to ARPlane size

A suggestion from Delong. He said he wanted to show the planets on a table so he could see them all. I should be able to determine the shortest dimension of the plane, then set Pluto's orbit to that, then calculate the size down from there.

Allow for scaling of time

Sometimes earth spins too quickly. It'd be nice if we could make this slow down to either real time or something else

enhancement - planet tilts according to season / date

https://github.com/johndpope/SwiftGlobe/blob/master/SwiftGlobe/SwiftGlobe.swift#L167

screen shot 2017-11-18 at 9 34 51 am

let kTiltOfEarthsAxisInDegrees = 23.5
let kTiltOfEarthsAxisInRadians = (23.5 * Double.pi) / 180.0

let kSkyboxSize = CGFloat(1000.0)
let kTiltOfEclipticFromGalacticPlaneDegrees = 60.2
let kTiltOfEclipticFromGalacticPlaneRadians = (60.2 * Double.pi) / 180.0


        // tilt it on it's axis (23.5 degrees), varied by the actual day of the year
        // (note that children nodes are correctly tilted with the parents coordinate space)
        let calendar = Calendar(identifier: .gregorian)
        let dayOfYear = Double( calendar.ordinality(of: .day, in: .year, for: Date())! )
        let daysSinceWinterSolstice = remainder(dayOfYear + 10.0, kDaysInAYear)
        let daysSinceWinterSolsticeInRadians = daysSinceWinterSolstice * 2.0 * Double.pi / kDaysInAYear
        let tiltXRadians = -cos( daysSinceWinterSolsticeInRadians) * kTiltOfEarthsAxisInRadians
        //
        seasonalTilt.eulerAngles = SCNVector3(x: tiltXRadians, y: 0.0, z: 0)
        scene.rootNode.addChildNode(seasonalTilt)

Add all of the moons

A little bit of issue with the initial tries on this. Should be able to use SwiftAA.

Update Icon

In some of the latest betas I'm seeing the app icon seems to not be large enough. Should be simple to fix

Enhancement - Geocentric Horizon view / CelestialSphere of universe based off user location + date

I've spent some days digging through this - with this image - hopefully it will make sense.
https://youtu.be/9XHoVF2G0j8?t=653

http://astro.unl.edu/classaction/animations/coordsmotion/celestialhorizon.html

screen shot 2017-11-16 at 20 36 41

I think I'm looking to find a camera angle for scenekit which would create a horizon view to universe
I want to make the point of view geocentric.
the horizon which is currently the heliocentric plane - I want to tilt to the declination of earth's orbit - with every planet above the horizon above the scenekit floor / everything below the earth beneath. the universe plane would still spin as it does. (I'm not looking to create star walk - how the view is represented is perfect. )

Not sure how hard this is - I found this function that maybe able to be repurposed.
given a users location / instead of finding the moon - perhaps we can derive a camera angle in scenekit. the point of view - would be geocentric - as the user sees the planets above.

func findMoon(date: NSDate, longitude: Double, latitude: Double) -> (Double,Double,Double)
https://github.com/johndpope/Moon/blob/ui-heading-display/Moon/FindMoonService.swift

Enhancement - SceneKitExtension / map a lat / lng coordinate to scenekit earth planet of where user is

        let earthNode = PlanetoidGroupNode(planet: Planet.earth)
        earthNode.updatePlanetLocation(earthAA.position())

currently these lines map SwiftAA into the scenekit.
however, I don't believe there's any way to get scenekit camera to specific point of latitude / longitude.

this plist contains a bunch of cities with lat / lngs
https://github.com/op1000/EarthTravel/blob/master/EarthTravel/Resources/AllCititesToTravel_258.plist

        NSString* filePath = [[NSBundle mainBundle] pathForResource:@"AllCititesToTravel_258" ofType:@"plist"];
        NSDictionary* objectData = [NSDictionary dictionaryWithContentsOfFile:filePath];
        
        NSArray* arrayList = [objectData valueForKeyPath:@"list"];
        NSMutableArray* arrayCordinate = [[NSMutableArray alloc] init];
        for (NSDictionary* dicInfo in arrayList) {
            
            NSString* cityName = dicInfo[@"dest_name"];
            float lat = [dicInfo[@"lat"] floatValue];
            float lng = [dicInfo[@"lng"] floatValue];
            NSString* countryCode = [dicInfo objectForKey:@"country_code"];
            
            // drop some pins
            KGLEarthCoordinate *pin = [KGLEarthCoordinate coordinateWithLatitude:lat
                                                                    andLongitude:lng
                                                                andPinIdentifier:cityName
                                                                  andConturyCode:countryCode];
            [arrayCordinate addObject:pin];
        }
        [self dropPinsAtLocations:arrayCordinate];


-(void)dropPinsAtLocations:(NSArray *)pinArray
{
    // remove any existing pins
    for (SCNNode *node in _currentPins) {
        [node removeFromParentNode];
    }
    _currentPins = [NSMutableArray array];
    
    // create new pins
    for (KGLEarthCoordinate *coord in pinArray) {
        KGLPinNode *newPin = [KGLPinNode pinAtLatitude:coord.latitude
                                          andLongitude:coord.longitude
                                                 title:coord.pinIdentifier
                                           countryCode:coord.contryCode];
        if (coord.pinIdentifier) {
            newPin.identifier = coord.pinIdentifier;
        }
        [_shadedNode addChildNode:newPin];
        [_currentPins addObject:newPin];
    }
/*!
 * @discussion Convenience method for creating a pin, with internal nodes set up, at a specified location, assuming an Earth at the center of the scene with a radius of 50 units.
 * @param latitude The pin's latitude, in degrees.
 * @param longitude The pin's longitude, in degrees.
 * @return An instance of the KGLPinNode class.
 */

+ (KGLPinNode *)pinAtLatitude:(float)latitude
                 andLongitude:(float)longitude
                        title:(NSString*)title
                  countryCode:(NSString*)countryCode
{
    KGLPinNode *pin = [super node];

    if (pin) {
        pin.latitude = latitude;
        pin.longitude = longitude;
        pin.countryCode = countryCode;
    }
    
    pin.name = @"pinWrapper";

    SCNBox* pinScene = [SCNBox boxWithWidth:1.0 height:1.0 length:1.0*108.0/159.0 chamferRadius:0];

    //SCNPyramid* pinScene = [SCNPyramid pyramidWithWidth:1.0 height:1.0 length:1.0];
    SCNNode *pinNode = [SCNNode nodeWithGeometry:pinScene];
    NSString* strCountryImagePath = [NSString stringWithFormat: @"icon_%@", countryCode];
    {
        // ambient light
        SCNMaterial *greenMaterial              = [SCNMaterial material];
        greenMaterial.diffuse.contents          = [UIColor clearColor];
        greenMaterial.locksAmbientWithDiffuse   = YES;
        
        SCNMaterial *redMaterial                = [SCNMaterial material];
        redMaterial.diffuse.contents            = [UIColor clearColor];
        redMaterial.locksAmbientWithDiffuse     = YES;
        
        SCNMaterial *blueMaterial               = [SCNMaterial material];
        blueMaterial.diffuse.contents           = [UIColor clearColor];
        blueMaterial.locksAmbientWithDiffuse    = YES;
        
        SCNMaterial *yellowMaterial             = [SCNMaterial material];
        yellowMaterial.diffuse.contents         = [UIColor clearColor];
        yellowMaterial.locksAmbientWithDiffuse  = YES;
        
        SCNMaterial *purpleMaterial             = [SCNMaterial material];
        purpleMaterial.diffuse.contents         = strCountryImagePath; // 위를 쳐다보는 면
        purpleMaterial.locksAmbientWithDiffuse  = YES;
        
        SCNMaterial *magentaMaterial            = [SCNMaterial material];
        magentaMaterial.diffuse.contents        = [UIColor clearColor];
        magentaMaterial.locksAmbientWithDiffuse = YES;
        
        
        pinScene.materials =  @[greenMaterial,  redMaterial,    blueMaterial,
                           yellowMaterial, purpleMaterial, magentaMaterial];
    }
    
    // add the pin geometry to the pin node
    [pin addChildNode:pinNode];
    
    // pins are small, especially from directly above or zoomed out, so wrap a larger rectangular node around the pin
    // this will create a greater touch area
    SCNBox *touchBrick = [SCNBox boxWithWidth:5.0f height:7.5f length:5.0f chamferRadius:0];
    SCNNode *touchNode = [SCNNode nodeWithGeometry:touchBrick];
    touchNode.hidden = YES;
    touchNode.name = @"TouchPin";
    [pin addChildNode:touchNode];
    
    // position the pin
    // calculate the pin's position along the Y axis of the Earth, based on the given latitude
    float yPos = sinf(DEGREES_TO_RADIANS(latitude)) * 27.8f*ZOOME_RATIO;
    // calculate what the radius of the horizontal circle that cuts through the Earth is at the given Y position
    float localRadius = [KGLEarthCommonMath radiusOfCircleBisectingSphereOfRadius:27.8f*ZOOME_RATIO atHeight:yPos];
    // using the local radius, calculate the X and Z positions of the pin, based on the given longitude
    HorizontalCoords coords = [KGLEarthCommonMath horizontalCoordinatesAtDegrees:longitude ofSphereRadius:localRadius];
    pin.position = SCNVector3Make(-1 * coords.x, yPos, coords.z);
    
    // rotate the pin so it stands vertically at 90 degrees from the surface of the Earth
    // first, set the pin's euler angles such that it lies flat against the surface of the Earth, given the pin's location
    // the yaw angle positions the pin so it faces out from the surface of the Earth at its location
    float yawAngle = atan2f(-1 * coords.x, coords.z);
    // the pitch angle tilts the pin so it lies on the ground
    float pitchAngle = -1 * DEGREES_TO_RADIANS(latitude) - M_PI_2;
    pin.eulerAngles = SCNVector3Make(pitchAngle, yawAngle, 0);
    
    // now rotate the pin by 180 degrees vertically, so it stands up
    SCNMatrix4 latRotation = SCNMatrix4MakeRotation(DEGREES_TO_RADIANS(180),1, 0, 0);
    pin.transform = SCNMatrix4Mult(latRotation, pin.transform);
    
    //==============================
    // label
    //==============================
    SCNText *text = [SCNText textWithString:title extrusionDepth:0.1];
    
    SCNMaterial *magentaMaterial = [SCNMaterial material];
    magentaMaterial.diffuse.contents = [UtilManager colorWithHexString:@"ec4f30"];
    magentaMaterial.locksAmbientWithDiffuse = YES;
    text.materials = @[magentaMaterial];
    
    SCNNode *textNode = [SCNNode nodeWithGeometry:text];
    textNode.position = SCNVector3Make(-1+M_PI_2, 0, 0);
    textNode.transform = SCNMatrix4Mult(SCNMatrix4MakeScale(0.05, 0.05, 0.05), textNode.transform);
    [pin addChildNode:textNode];
        
    return pin;
}
}

Add option to see proportional size and distance

The scale of the Solar System is the interesting part of this whole experiment. Let's add an option to show the proper scale of things. Since some planets would be obnoxiously small, may need to add some labels and hints as to where things are if they are too small.

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.