mirror of
https://github.com/workinghard/Cube4Fun.git
synced 2025-12-14 04:42:09 +00:00
a
This commit is contained in:
@@ -12,9 +12,15 @@ import Cocoa
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@IBOutlet weak var window: NSWindow!
|
||||
@IBOutlet weak var windowToolbox: NSWindow!
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
// Insert code here to initialize your application
|
||||
}
|
||||
|
||||
func applicationShouldTerminate(sender: NSApplication) -> NSApplicationTerminateReply {
|
||||
CubeNetworkObj.closeConnection()
|
||||
return NSApplicationTerminateReply.TerminateNow
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6233" systemVersion="14A329f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1514" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6233"/>
|
||||
<plugIn identifier="com.apple.SceneKitIBPlugin" version="6233"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
|
||||
<plugIn identifier="com.apple.SceneKitIBPlugin" version="6751"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
@@ -647,18 +647,18 @@
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<window title="SceneKit Mac Template" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
|
||||
<window title="3D Cube" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="640" height="480"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
|
||||
<rect key="contentRect" x="335" y="390" width="764" height="530"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
|
||||
<view key="contentView" id="372">
|
||||
<rect key="frame" x="0.0" y="0.0" width="640" height="480"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="764" height="530"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<sceneView autoenablesDefaultLighting="YES" translatesAutoresizingMaskIntoConstraints="NO" id="536" customClass="GameView" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="640" height="480"/>
|
||||
<sceneView autoenablesDefaultLighting="YES" translatesAutoresizingMaskIntoConstraints="NO" id="536" customClass="GameView" customModule="Cube4Fun" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="764" height="530"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</sceneView>
|
||||
</subviews>
|
||||
@@ -669,15 +669,15 @@
|
||||
<constraint firstItem="536" firstAttribute="trailing" secondItem="372" secondAttribute="trailing" id="544"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<point key="canvasLocation" x="385" y="452"/>
|
||||
<point key="canvasLocation" x="447" y="477"/>
|
||||
</window>
|
||||
<customObject id="494" customClass="AppDelegate" customModuleProvider="target">
|
||||
<customObject id="494" customClass="AppDelegate" customModule="Cube4Fun" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="window" destination="371" id="532"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="420" customClass="NSFontManager"/>
|
||||
<viewController id="z44-Lp-cgU" customClass="GameViewController" customModuleProvider="target">
|
||||
<viewController id="z44-Lp-cgU" customClass="GameViewController" customModule="Cube4Fun" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="gameView" destination="536" id="No3-Ct-Xwn"/>
|
||||
<outlet property="view" destination="372" id="bTQ-MN-Ejh"/>
|
||||
|
||||
5
Cube4Fun/Cube4Fun-Bridging-Header.h
Normal file
5
Cube4Fun/Cube4Fun-Bridging-Header.h
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import "ObjCtoCPlusPlus.h"
|
||||
244
Cube4Fun/CubeNetwork.cpp
Normal file
244
Cube4Fun/CubeNetwork.cpp
Normal file
@@ -0,0 +1,244 @@
|
||||
//
|
||||
// CubeNetwork.cpp
|
||||
// Cube4Fun
|
||||
//
|
||||
// Created by Nik on 28.03.15.
|
||||
// Copyright (c) 2015 DerNik. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "Poco/Net/SocketAddress.h"
|
||||
#include "Poco/Net/DialogSocket.h"
|
||||
#include "Poco/Net/NetException.h"
|
||||
#include <stdlib.h> /* srand, rand */
|
||||
#include <time.h> /* time */
|
||||
#include <chrono>
|
||||
|
||||
#include "CubeNetwork.h"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif // win32
|
||||
|
||||
using Poco::Net::DialogSocket;
|
||||
using Poco::Net::SocketAddress;
|
||||
|
||||
|
||||
unsigned char buffer3D[64];
|
||||
unsigned char receiveBuffer[32];
|
||||
int bytesReceived;
|
||||
int i,x;
|
||||
unsigned char color;
|
||||
DialogSocket ds;
|
||||
int frameChange = 0;
|
||||
|
||||
void sleepcp(int milliseconds) // cross-platform sleep function
|
||||
{
|
||||
#ifdef WIN32
|
||||
Sleep(milliseconds);
|
||||
#else
|
||||
usleep(milliseconds * 1000);
|
||||
#endif // win32
|
||||
}
|
||||
|
||||
bool frame1[3][64] = { {1,0,0,1,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
1,0,0,1},
|
||||
{0,0,0,0,
|
||||
0,0,0,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0,
|
||||
0,0,0,0},
|
||||
{0,0,0,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0, //0,1,1,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
1,0,0,1,
|
||||
0,0,0,0}};
|
||||
|
||||
|
||||
void fillBufferWithMsg() {
|
||||
buffer3D[0] = 'G';
|
||||
buffer3D[1] = 'E';
|
||||
buffer3D[2] = 'T';
|
||||
buffer3D[3] = ' ';
|
||||
buffer3D[4] = '/';
|
||||
buffer3D[5] = '?';
|
||||
buffer3D[6] = 'S';
|
||||
buffer3D[7] = 's';
|
||||
buffer3D[8] = ' ';
|
||||
|
||||
}
|
||||
|
||||
void testFrame() {
|
||||
// for (color=128;color<130;color++) {
|
||||
// Create testframe
|
||||
for (x=0;x<64;x++) {
|
||||
buffer3D[x] = color; // Red frame
|
||||
}
|
||||
if ( color > 128 ) {
|
||||
buffer3D[0]=255;
|
||||
buffer3D[3]=255;
|
||||
buffer3D[12]=255;
|
||||
buffer3D[15]=255;
|
||||
|
||||
buffer3D[48]=255;
|
||||
buffer3D[51]=255;
|
||||
buffer3D[60]=255;
|
||||
buffer3D[63]=255;
|
||||
}else{
|
||||
buffer3D[0]=254;
|
||||
buffer3D[3]=254;
|
||||
buffer3D[12]=254;
|
||||
buffer3D[15]=254;
|
||||
|
||||
buffer3D[48]=254;
|
||||
buffer3D[51]=254;
|
||||
buffer3D[60]=254;
|
||||
buffer3D[63]=254;
|
||||
}
|
||||
ds.sendBytes(buffer3D, 64);
|
||||
// sleepcp(50); // 20 FPS
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testStream2() {
|
||||
int frameChange = 0;
|
||||
while (true) {
|
||||
unsigned char color = rand() % 254;
|
||||
for (i=0;i<64;i++) {
|
||||
if ( frame1[frameChange][i] == 1 ) {
|
||||
buffer3D[i] = color; // Rot
|
||||
}else{
|
||||
buffer3D[i] = 255; // Aus
|
||||
}
|
||||
}
|
||||
ds.sendBytes(buffer3D, 64);
|
||||
sleepcp(1000); // 20 FPS
|
||||
if ( frameChange < 2 ) {
|
||||
frameChange++;
|
||||
}else{
|
||||
frameChange=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void CubeNetwork::updateFrame() {
|
||||
unsigned char color = rand() % 254;
|
||||
for (i=0;i<64;i++) {
|
||||
if ( frame1[frameChange][i] == 1 ) {
|
||||
buffer3D[i] = color; // Rot
|
||||
}else{
|
||||
buffer3D[i] = 255; // Aus
|
||||
}
|
||||
}
|
||||
ds.sendBytes(buffer3D, 64);
|
||||
if ( frameChange < 2 ) {
|
||||
frameChange++;
|
||||
}else{
|
||||
frameChange=0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void CubeNetwork::updateFrame(const unsigned char * frameSequence, unsigned int frameCount) {
|
||||
// check for empty pointer
|
||||
if ( frameSequence != NULL ) {
|
||||
for (int frame = 0; frame<frameCount;frame++) {
|
||||
for (i=0;i<64;i++) {
|
||||
// Fill buffer
|
||||
buffer3D[i] = frameSequence[i+(frame*64)];
|
||||
}
|
||||
// Send the frame
|
||||
ds.sendBytes(buffer3D, 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CubeNetwork::openConnection() {
|
||||
try {
|
||||
ds.connect(SocketAddress("192.168.1.79", 8081));
|
||||
fillBufferWithMsg();
|
||||
ds.sendBytes(buffer3D, 9);
|
||||
}catch (const Poco::Net::NetException & e){
|
||||
std::cerr << e.displayText() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CubeNetwork::closeConnection() {
|
||||
try {
|
||||
buffer3D[0] = 's';
|
||||
buffer3D[1] = 'S';
|
||||
ds.sendBytes(buffer3D, 2); // End the stream mode
|
||||
}catch (const Poco::Net::NetException & e){
|
||||
std::cerr << e.displayText() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CubeNetwork::initObjects() {
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
try {
|
||||
ds.connect(SocketAddress("192.168.1.79", 8081));
|
||||
|
||||
fillBufferWithMsg();
|
||||
ds.sendBytes(buffer3D, 9);
|
||||
|
||||
|
||||
//testStream2();
|
||||
testFrame();
|
||||
|
||||
buffer3D[0] = 's';
|
||||
buffer3D[1] = 'S';
|
||||
ds.sendBytes(buffer3D, 2); // End the stream mode
|
||||
|
||||
}catch (const Poco::Net::NetException & e){
|
||||
std::cerr << e.displayText() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "It works" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
//void Performance_CPlusPlus::sortArray(unsigned int num_elements)
|
||||
23
Cube4Fun/CubeNetwork.h
Normal file
23
Cube4Fun/CubeNetwork.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// CubeNetwork.h
|
||||
// Cube4Fun
|
||||
//
|
||||
// Created by Nik on 28.03.15.
|
||||
// Copyright (c) 2015 DerNik. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __Cube4Fun__CubeNetwork__
|
||||
#define __Cube4Fun__CubeNetwork__
|
||||
|
||||
class CubeNetwork
|
||||
{
|
||||
public:
|
||||
|
||||
static void initObjects();
|
||||
static void updateFrame(const unsigned char * frameSequence = NULL, unsigned int frameCount = 0);
|
||||
static void openConnection();
|
||||
static void closeConnection();
|
||||
|
||||
};
|
||||
|
||||
#endif /* defined(__Cube4Fun__CubeNetwork__) */
|
||||
@@ -19,6 +19,9 @@ class GameView: SCNView {
|
||||
lastMousePos = theEvent.locationInWindow
|
||||
/* Called when a mouse click occurs */
|
||||
|
||||
var ledPressed: Int = 0;
|
||||
var ledColorOn = false;
|
||||
|
||||
// check what nodes are clicked
|
||||
let p = self.convertPoint(theEvent.locationInWindow, fromView: nil)
|
||||
if let hitResults = self.hitTest(p, options: nil) {
|
||||
@@ -36,7 +39,19 @@ class GameView: SCNView {
|
||||
if let geom = node.geometry {
|
||||
if let name:NSString = geom.name {
|
||||
let myGeometry:SCNText = self.scene!.rootNode.childNodeWithName("myDescr", recursively: true)?.geometry as SCNText
|
||||
// Show touched led
|
||||
myGeometry.string = name
|
||||
// Check for previously color
|
||||
let prevColor = geom.firstMaterial?.diffuse.contents as NSColor
|
||||
if prevColor != NSColor.grayColor() {
|
||||
geom.firstMaterial?.diffuse.contents = NSColor.grayColor()
|
||||
ledColorOn = false
|
||||
}else{
|
||||
geom.firstMaterial?.diffuse.contents = NSColor(calibratedHue: (10/255), saturation: 1.0, brightness: 1.0, alpha: 1.0)
|
||||
ledColorOn = true
|
||||
}
|
||||
ledPressed = Int(name.intValue)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +107,16 @@ class GameView: SCNView {
|
||||
material.emission.contents = NSColor.whiteColor()
|
||||
|
||||
SCNTransaction.commit()
|
||||
|
||||
// Update the LED frame
|
||||
var myByte: [Byte]
|
||||
if ledColorOn {
|
||||
myByte = [10]
|
||||
}else{
|
||||
myByte = [255] // Off
|
||||
}
|
||||
myFrames.replaceBytesInRange(NSMakeRange(ledPressed, 1), withBytes: myByte)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,8 +157,6 @@ class GameView: SCNView {
|
||||
|
||||
override func keyDown(theEvent: NSEvent) {
|
||||
|
||||
//let myCamera:SCNNode = self.scene!.rootNode.childNodeWithName("Camera", recursively: true)!
|
||||
|
||||
switch (theEvent.keyCode) {
|
||||
case 123:
|
||||
self.rotateCamera(0.0, y: -0.1)
|
||||
@@ -144,15 +167,29 @@ class GameView: SCNView {
|
||||
//self.rotateByAngle(-1.0);
|
||||
//right
|
||||
break;
|
||||
case 15:
|
||||
// Reset the cube
|
||||
case 15: // r - Key
|
||||
// Reset the cube position
|
||||
self.rotateCamera(0.0, y: -startAngle)
|
||||
break;
|
||||
case 17: // t - Key
|
||||
// Reset the frame color on the Cube
|
||||
myFrames.replaceBytesInRange(NSMakeRange(myFrameCount-1, 64), withBytes: emptyFrame)
|
||||
|
||||
// Reset the frame color in 3D
|
||||
if let rootNode = self.scene?.rootNode {
|
||||
if let cubeNode = rootNode.childNodeWithName("cubeNode", recursively: true) {
|
||||
for myLED in cubeNode.childNodes {
|
||||
//myLED.firstMaterial?.diffuse.contents = NSColor.grayColor()
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
super.keyDown(theEvent)
|
||||
}
|
||||
|
||||
println(theEvent.keyCode);
|
||||
|
||||
|
||||
//super.keyDown(theEvent)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,53 @@
|
||||
import SceneKit
|
||||
import QuartzCore
|
||||
|
||||
var myFrameCount: UInt32 = 0;
|
||||
var myFrames: NSMutableData = NSMutableData()
|
||||
|
||||
|
||||
let emptyFrame: [Byte] = [
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255,
|
||||
255,255,255,255]
|
||||
|
||||
class GameViewController: NSViewController {
|
||||
|
||||
@IBOutlet weak var gameView: GameView!
|
||||
|
||||
|
||||
func sendFrame() {
|
||||
//let string = UnsafePointer<UInt8>(myFrames.bytes)
|
||||
CubeNetworkObj.updateFrame(UnsafePointer<UInt8>(myFrames.bytes), count: myFrameCount)
|
||||
}
|
||||
|
||||
override func awakeFromNib(){
|
||||
|
||||
//NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(5), invocation: CubeNetworkObj.initObjects(), repeats: true)
|
||||
// CubeNetworkObj.initObjects();
|
||||
|
||||
// Init first frame
|
||||
myFrames = NSMutableData(bytes: emptyFrame, length: 64)
|
||||
myFrameCount = 1
|
||||
// Open connection to the LED cube
|
||||
CubeNetworkObj.openConnection()
|
||||
|
||||
NSTimer.scheduledTimerWithTimeInterval(0.2, target: self, selector: Selector("sendFrame"), userInfo: nil, repeats: true)
|
||||
|
||||
|
||||
|
||||
// create a new scene
|
||||
//let scene = SCNScene(named: "art.scnassets/ship.dae")!
|
||||
let scene = PrimitivesScene();
|
||||
@@ -22,7 +64,7 @@ class GameViewController: NSViewController {
|
||||
// create and add a camera to the scene
|
||||
let camera = SCNCamera()
|
||||
camera.usesOrthographicProjection = true
|
||||
camera.orthographicScale = 11
|
||||
camera.orthographicScale = 15
|
||||
camera.zNear = 0
|
||||
camera.zFar = 100
|
||||
let cameraNode = SCNNode()
|
||||
@@ -86,6 +128,7 @@ class GameViewController: NSViewController {
|
||||
ship.addAnimation(animation, forKey: nil)
|
||||
*/
|
||||
|
||||
|
||||
// set the scene to the view
|
||||
self.gameView!.scene = scene
|
||||
|
||||
|
||||
16
Cube4Fun/ObjCtoCPlusPlus.h
Executable file
16
Cube4Fun/ObjCtoCPlusPlus.h
Executable file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// ObjCtoCPlusPlus.h
|
||||
// Performance_Console
|
||||
//
|
||||
// Created by Gian Luigi Romita on 12/06/14.
|
||||
// Copyright (c) 2014 Gian Luigi Romita. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface CubeNetworkObj : NSObject
|
||||
+ (void) updateFrame: (const unsigned char *) frameSequence count: (UInt32) frameCount;
|
||||
+ (void) initObjects;
|
||||
+ (void) openConnection;
|
||||
+ (void) closeConnection;
|
||||
@end
|
||||
26
Cube4Fun/ObjCtoCPlusPlus.mm
Executable file
26
Cube4Fun/ObjCtoCPlusPlus.mm
Executable file
@@ -0,0 +1,26 @@
|
||||
#import "ObjCtoCPlusPlus.h"
|
||||
|
||||
#import "CubeNetwork.h"
|
||||
|
||||
|
||||
@implementation CubeNetworkObj
|
||||
|
||||
+ (void) initObjects
|
||||
{
|
||||
CubeNetwork::initObjects();
|
||||
}
|
||||
+ (void) updateFrame: (const unsigned char *) frameSequence count: (UInt32) frameCount
|
||||
{
|
||||
CubeNetwork::updateFrame(frameSequence, frameCount);
|
||||
}
|
||||
+ (void) openConnection
|
||||
{
|
||||
CubeNetwork::openConnection();
|
||||
}
|
||||
+ (void) closeConnection
|
||||
{
|
||||
CubeNetwork::closeConnection();
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -22,11 +22,18 @@ class PrimitivesScene: SCNScene {
|
||||
let xCount = 4
|
||||
var myIndex = 0
|
||||
|
||||
let spaceBetweenLEDs:CGFloat = 4.0
|
||||
let edgePosX:CGFloat = CGFloat(xCount-1) * spaceBetweenLEDs * -1 / 2
|
||||
let edgePosY:CGFloat = CGFloat(yCount-1) * spaceBetweenLEDs * -1 / 2
|
||||
let edgePosZ:CGFloat = CGFloat(zCount-1) * spaceBetweenLEDs * -1 / 2
|
||||
let boxSizeX:CGFloat = CGFloat(xCount-1) * spaceBetweenLEDs + 2 * radius
|
||||
let boxSizeZ:CGFloat = CGFloat(zCount-1) * spaceBetweenLEDs + 2 * radius
|
||||
let boxPosY:CGFloat = (CGFloat(yCount-1) * spaceBetweenLEDs / 2) + radius + 0.5
|
||||
|
||||
let text = SCNText(string: "Klick", extrusionDepth: 1)
|
||||
let textNode = SCNNode(geometry: text)
|
||||
textNode.name = "myDescr"
|
||||
textNode.position = SCNVector3(x:-12.0 , y: 6.0, z: 0.0)
|
||||
textNode.position = SCNVector3(x:-14.0 , y: 7.0, z: 0.0)
|
||||
textNode.scale = SCNVector3Make(0.1, 0.1, 0.1);
|
||||
|
||||
self.rootNode.addChildNode(textNode)
|
||||
@@ -35,46 +42,48 @@ class PrimitivesScene: SCNScene {
|
||||
let cubeNode = SCNNode()
|
||||
cubeNode.name = "cubeNode"
|
||||
|
||||
let box = SCNBox(width: 11.0, height: 1.0, length: 11.0, chamferRadius: 0.1)
|
||||
box.firstMaterial?.diffuse.contents = NSColor.blueColor()
|
||||
let box = SCNBox(width: boxSizeX, height: 1.0, length: boxSizeZ, chamferRadius: 0.1)
|
||||
box.firstMaterial?.diffuse.contents = NSColor.whiteColor()
|
||||
let boxNode = SCNNode(geometry: box)
|
||||
boxNode.name = "myBox"
|
||||
boxNode.position = SCNVector3(x:0.0 , y: -6.0, z: 0.0)
|
||||
boxNode.position = SCNVector3(x:0.0 , y: -boxPosY, z: 0.0)
|
||||
cubeNode.addChildNode(boxNode)
|
||||
|
||||
|
||||
var y:CGFloat = -4.5
|
||||
var y:CGFloat = edgePosY
|
||||
for row in 0..<yCount {
|
||||
var z:CGFloat = -4.5
|
||||
var z:CGFloat = edgePosZ
|
||||
for depth in 0..<zCount {
|
||||
var x:CGFloat = -4.5
|
||||
var x:CGFloat = edgePosX
|
||||
for column in 0..<xCount {
|
||||
|
||||
let sphereGeometry = SCNSphere(radius: radius)
|
||||
sphereGeometry.name = myIndex.description
|
||||
|
||||
sphereGeometry.firstMaterial?.diffuse.contents = NSColor.grayColor()
|
||||
/*
|
||||
if (row % 2 == 0) {
|
||||
sphereGeometry.firstMaterial?.diffuse.contents = NSColor.redColor()
|
||||
} else {
|
||||
sphereGeometry.firstMaterial?.diffuse.contents = NSColor.greenColor()
|
||||
}
|
||||
}*/
|
||||
|
||||
let sphereNode = SCNNode(geometry: sphereGeometry)
|
||||
sphereNode.position = SCNVector3(x: x, y: y, z: z)
|
||||
sphereNode.position = SCNVector3(x: y, y: x, z: z)
|
||||
|
||||
|
||||
cubeNode.addChildNode(sphereNode)
|
||||
|
||||
x += 3 * CGFloat(radius)
|
||||
x += spaceBetweenLEDs * CGFloat(radius)
|
||||
myIndex++
|
||||
|
||||
}
|
||||
z += 3 * CGFloat(radius)
|
||||
z += spaceBetweenLEDs * CGFloat(radius)
|
||||
}
|
||||
y += 3 * CGFloat(radius)
|
||||
y += spaceBetweenLEDs * CGFloat(radius)
|
||||
}
|
||||
|
||||
cubeNode.runAction(SCNAction.rotateByX(0, y: -0.3, z: 0, duration: 0.0))
|
||||
cubeNode.runAction(SCNAction.rotateByX(0, y: 0.6, z: 0, duration: 0.0))
|
||||
self.rootNode.addChildNode(cubeNode)
|
||||
|
||||
}
|
||||
|
||||
BIN
libPocoFoundationd.12.dylib
Executable file
BIN
libPocoFoundationd.12.dylib
Executable file
Binary file not shown.
BIN
libPocoNet.12.dylib
Executable file
BIN
libPocoNet.12.dylib
Executable file
Binary file not shown.
Reference in New Issue
Block a user