Skip to content

Commit

Permalink
Update View
Browse files Browse the repository at this point in the history
  • Loading branch information
duzexu committed Nov 24, 2017
1 parent cf39c73 commit 7d31adb
Show file tree
Hide file tree
Showing 89 changed files with 2,183 additions and 335 deletions.
137 changes: 115 additions & 22 deletions ARuler.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ARuler/ARuler-Bridging-Header.h
Expand Up @@ -3,3 +3,6 @@
//

#import "PlaneDetector.h"
#import <LeanCloudFeedback/LeanCloudFeedback.h>
#import <AVOSCloud/AVOSCloud.h>

7 changes: 7 additions & 0 deletions ARuler/AppDelegate.swift
Expand Up @@ -16,6 +16,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
AVOSCloud.setApplicationId("h28H91FlwcGb4KhOPOalHMwq-gzGzoHsz", clientKey: "BLzUch4hhXt1rpr1EpD5XtSh")
AVOSCloud.setAllLogsEnabled(false)

UIBarButtonItem.appearance().setTitleTextAttributes([.foregroundColor:UIColor.clear], for: .normal)
UIBarButtonItem.appearance().setTitleTextAttributes([.foregroundColor:UIColor.clear], for: .highlighted)
UIBarButtonItem.appearance().tintColor = UIColor.themeColor

return true
}

Expand Down
Binary file removed ARuler/Assets.xcassets/Slice.imageset/Slice@2x.png
Binary file not shown.
Binary file removed ARuler/Assets.xcassets/Slice.imageset/Slice@3x.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ARuler/Assets.xcassets/trash.imageset/trash@2x.png
Binary file not shown.
Binary file removed ARuler/Assets.xcassets/trash.imageset/trash@3x.png
Binary file not shown.
941 changes: 858 additions & 83 deletions ARuler/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions ARuler/Info.plist
Expand Up @@ -17,17 +17,29 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>4</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>wxp</string>
<string>alipay</string>
<string>weixin</string>
<string>wechat</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>This application will use the camera for Augmented Reality.</string>
<string>ARuler需要使用您的摄像头以启动测量</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>ARuler需要访问您的相册</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>ARuler需要访问您的相册</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arkit</string>
<string>armv7</string>
</array>
<key>UIStatusBarHidden</key>
Expand Down
File renamed without changes.
25 changes: 17 additions & 8 deletions ARuler/LineNode.swift → ARuler/Node/LineNode.swift
Expand Up @@ -15,10 +15,11 @@ class LineNode: NSObject {
var endNode: SCNNode!
var lineNode: SCNNode?
var textNode: SCNNode!
var textWrapNode: SCNNode!

let sceneView: ARSCNView?

init(startPos: SCNVector3, sceneV: ARSCNView) {
init(startPos: SCNVector3, sceneV: ARSCNView, cameraNode:SCNNode) {
sceneView = sceneV

let dot = SCNSphere(radius:1)
Expand All @@ -44,6 +45,13 @@ class LineNode: NSObject {
text.firstMaterial?.isDoubleSided = true
textNode = SCNNode(geometry: text)
textNode.scale = SCNVector3(1/500.0, 1/500.0, 1/500.0)
textNode.eulerAngles = SCNVector3Make(0, .pi, 0)

textWrapNode = SCNNode()
textWrapNode.addChildNode(textNode)
let constraint = SCNLookAtConstraint(target: cameraNode)
constraint.isGimbalLockEnabled = true
textWrapNode.constraints = [constraint]
}

required init?(coder aDecoder: NSCoder) {
Expand All @@ -69,9 +77,10 @@ class LineNode: NSObject {
let length = posEnd.distanceFromPos(pos: startNode.position)
text.string = String(format: "%.2fcm", length*Float.LengthUnit.CentiMeter.rate.0)
textNode.setPivot()
textNode.position = middle
if textNode.parent == nil {
sceneView?.scene.rootNode.addChildNode(textNode)
textWrapNode.position = middle

if textWrapNode.parent == nil {
sceneView?.scene.rootNode.addChildNode(textWrapNode)
}

lineNode?.removeFromParentNode()
Expand All @@ -85,7 +94,7 @@ class LineNode: NSObject {
startNode.removeFromParentNode()
endNode.removeFromParentNode()
lineNode?.removeFromParentNode()
textNode.removeFromParentNode()
textWrapNode.removeFromParentNode()
}

// MARK: - Private
Expand All @@ -95,10 +104,10 @@ class LineNode: NSObject {
let positionData = NSData(bytes: positions, length: MemoryLayout<Float32>.size*positions.count)
let indices: [Int32] = [0, 1]
let indexData = NSData(bytes: indices, length: MemoryLayout<Int32>.size * indices.count)

let source = SCNGeometrySource(data: positionData as Data, semantic: SCNGeometrySource.Semantic.vertex, vectorCount: indices.count, usesFloatComponents: true, componentsPerVector: 3, bytesPerComponent: MemoryLayout<Float32>.size, dataOffset: 0, dataStride: MemoryLayout<Float32>.size * 3)
let element = SCNGeometryElement(data: indexData as Data, primitiveType: SCNGeometryPrimitiveType.line, primitiveCount: indices.count, bytesPerIndex: MemoryLayout<Int32>.size)

let line = SCNGeometry(sources: [source], elements: [element])
return SCNNode(geometry: line)
}
Expand Down Expand Up @@ -131,7 +140,7 @@ class LineNode: NSObject {
default:
angle = yaw
}
textNode.runAction(SCNAction.rotateTo(x: 0, y: CGFloat(angle), z: 0, duration: 0))
//textNode.runAction(SCNAction.rotateTo(x: 0, y: CGFloat(angle), z: 0, duration: 0))
}

// move to average of recent positions to avoid jitter
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions ARuler/Resource/Assets.xcassets/help.imageset/Contents.json
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "help@3x-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "help@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
25 changes: 25 additions & 0 deletions ARuler/Resource/Assets.xcassets/setting.imageset/Contents.json
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "setting@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "setting@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Expand Up @@ -18,5 +18,8 @@
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
File renamed without changes
File renamed without changes.
Binary file added ARuler/Resource/wx.jpg
Binary file added ARuler/Resource/zfb.jpg
File renamed without changes.
2 changes: 1 addition & 1 deletion ARuler/PlaneDetector.h → ARuler/Utils/PlaneDetector.h
Expand Up @@ -2,7 +2,7 @@
// PlaneDetector.h
// ARuler
//
// Created by 杜 泽旭 on 2017/7/31.
// Created by duzexu on 2017/7/31.
// Copyright © 2017年 duzexu. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion ARuler/PlaneDetector.mm → ARuler/Utils/PlaneDetector.mm
Expand Up @@ -2,7 +2,7 @@
// PlaneDetector.m
// ARuler
//
// Created by 杜 泽旭 on 2017/7/31.
// Created by duzexu on 2017/7/31.
// Copyright © 2017年 duzexu. All rights reserved.
//

Expand Down
41 changes: 41 additions & 0 deletions ARuler/Utils/UIColorExt.swift
@@ -0,0 +1,41 @@
//
// UIColorExt.swift
// ARuler
//
// Created by duzexu on 2017/9/21.
// Copyright © 2017年 duzexu. All rights reserved.
//

import Foundation

extension UIColor {
class var textColor: UIColor {
get {
return UIColor(red: 88/255.0, green: 88/255.0, blue: 88/255.0, alpha: 1)
}
}

class var headerTextColor: UIColor {
get {
return UIColor(red: 167/255.0, green: 180/255.0, blue: 190/255.0, alpha: 1)
}
}

class var themeColor: UIColor {
get {
return UIColor(red: 59/255.0, green: 122/255.0, blue: 219/255.0, alpha: 1)
}
}

class var alertColor: UIColor {
get {
return UIColor(red: 223/255.0, green: 53/255.0, blue: 46/255.0, alpha: 1)
}
}

class var fineColor: UIColor {
get {
return UIColor(red: 149/255.0, green: 210/255.0, blue: 107/255.0, alpha: 1)
}
}
}

0 comments on commit 7d31adb

Please sign in to comment.