Skip to content

Commit

Permalink
add AppiIcons
Browse files Browse the repository at this point in the history
  • Loading branch information
mhamilt committed Mar 16, 2021
1 parent b7b80dd commit 5fcbbe3
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Swift-Metal-Plate/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class AppDelegate: NSObject, NSApplicationDelegate
{
if let window = NSApplication.shared.mainWindow
{
window.setContentSize(NSSize(width: 600, height: 600))
window.minSize = NSSize(width: 600, height: 600)
window.setContentSize(NSSize(width: 650, height: 650))
window.minSize = NSSize(width: 650, height: 650)
}
}

Expand Down
30 changes: 20 additions & 10 deletions Swift-Metal-Plate/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,63 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"idiom" : "mac",
"filename" : "plate-icon-16.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"idiom" : "mac",
"filename" : "plate-icon-33.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "plate-icon-32.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "plate-icon-64.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"idiom" : "mac",
"filename" : "plate-icon-128.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"idiom" : "mac",
"filename" : "plate-icon-257.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"idiom" : "mac",
"filename" : "plate-icon-256.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"idiom" : "mac",
"filename" : "plate-icon-513.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"idiom" : "mac",
"filename" : "plate-icon-512.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"idiom" : "mac",
"filename" : "plate-icon-1024.png",
"scale" : "2x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions Swift-Metal-Plate/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -674,7 +675,7 @@
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Hello_Metal" customModuleProvider="target"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Swift_Metal_Plate" customModuleProvider="target"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
Expand All @@ -685,7 +686,7 @@
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
Expand All @@ -704,7 +705,7 @@
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="Hello_Metal" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="Swift_Metal_Plate" customModuleProvider="target" sceneMemberID="viewController">
<customView key="view" id="7mM-0T-phg" userLabel="MTKView" customClass="MTKView">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
7 changes: 7 additions & 0 deletions Swift-Metal-Plate/FD-Plate/FDPlate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,13 @@ float* FDPlate::getCurrentState()
return u.get();
}

void FDPlate::clearStates()
{
std::fill(u.get(), u.get()+getGridSize(), 0.0);
std::fill(u1.get(), u1.get()+getGridSize(), 0.0);
std::fill(u2.get(), u2.get()+getGridSize(), 0.0);
}

float FDPlate::getOutput()
{
return (this->*outputFunction)();
Expand Down
2 changes: 2 additions & 0 deletions Swift-Metal-Plate/FD-Plate/FDPlate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class FDPlate
@return a float point to the current grid state of size Nx * Ny
*/
float* getCurrentState();
/// set all grid state values to 0
void clearStates();

//==========================================================================
/**
Expand Down
14 changes: 9 additions & 5 deletions Swift-Metal-Plate/FD-Plate/FDPlateCBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ void *makePlate()
{
const double sampleRate = 44.1e3;
FDPlate::PlateParameters plateParams;
plateParams.t60 = 0.03;
plateParams.thickness = 0.001;
plateParams.t60 = 0.3;
plateParams.thickness = 0.0009;
plateParams.tone = .5;
plateParams.lengthX = 1.59;
plateParams.lengthY = 1.59;
plateParams.lengthX = 2.59;
plateParams.lengthY = 2.59;
plateParams.bcType = FDPlate::BoundaryCondition::simplySupported;

FDPlate* plate = new FDPlate(sampleRate, plateParams);
Expand Down Expand Up @@ -53,7 +53,11 @@ void addForce(void* globalPlate, float force, float xCoord, float yCoord)
FDPlate& plate = *static_cast<FDPlate*>(globalPlate);
plate.addForce(force, xCoord, yCoord);
}

void clearStates(void* globalPlate)
{
FDPlate& plate = *static_cast<FDPlate*>(globalPlate);
plate.clearStates();
}
void destructPlate(void* globalPlate)
{
if(static_cast<FDPlate*>(globalPlate))
Expand Down
2 changes: 1 addition & 1 deletion Swift-Metal-Plate/FD-Plate/FDPlateCBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ float* getCurrentState (void* globalPlate);
void updateScheme (void* globalPlate);
void addForce (void* globalPlate, float force, float xCoord, float yCoord);
void destructPlate (void* globalPlate);

void clearStates (void* globalPlate);
void bridgetest();
#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion Swift-Metal-Plate/MetalSrc/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct Model
setPlateVertices()
self.vertices = (self.plateVertexData as! [Vertex])
self.indices = self.plateInidices
self.count = try self.indices?.count
self.count = self.indices?.count
}

/// Convert the vertices to an MTLBuffer on the GPU
Expand Down
4 changes: 2 additions & 2 deletions Swift-Metal-Plate/MetalSrc/Renderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ extension Renderer: MTKViewDelegate
updateScheme(plate)
// updateScheme(plate)
// updateScheme(plate)
for i in 0...5
for _ in 0...5
{
updateScheme(plate)
}
Expand All @@ -137,7 +137,7 @@ extension Renderer: MTKViewDelegate
renderEncoder.setVertexBuffer(stateBuffer, offset: 0, index: 3)
//----------------------------------------------------------------------
// Styling
renderEncoder.setTriangleFillMode(uniforms.wireframe ? .lines : .fill)
renderEncoder.setTriangleFillMode(.fill)
renderEncoder.drawIndexedPrimitives(type: .triangle,
indexCount: model!.count,
indexType: .uint16,
Expand Down
23 changes: 15 additions & 8 deletions Swift-Metal-Plate/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,50 @@ import MetalKit
class ViewController: NSViewController
{
@IBOutlet weak var mtkView: MTKView!

var renderer: Renderer!

override func viewDidLoad()
{
super.viewDidLoad()

guard let defaultDevice = MTLCreateSystemDefaultDevice() else {
fatalError("Could not create default Metal device")
}
mtkView.device = defaultDevice

mtkView.clearColor = MTLClearColor(red: 0.0, green: 0.0, blue: 0.2, alpha: 1.0)

guard let tmpRenderer = Renderer(mtkView: self.mtkView) else {
fatalError("Could not initialise Renderer class")
}
renderer = tmpRenderer
mtkView.delegate = renderer
renderer.setModel()

let scale = 2.2 as Float
let scale = 2.15 as Float

let translation: SIMD3<Float> = [0.0, 0.0, 0.0]
let rx: float_t = 0.0
let ry: float_t = 0.0
let rz: float_t = 0.0

renderer.uniforms.modelMatrix = float4x4.createTransformationMatrix(translation: translation,
rx: rx, ry: ry, rz: rz,
scale: scale)
}

override func mouseDown(with event: NSEvent)
{
super.mouseDown(with: event)
addForce(renderer.plate, 1000.0, Float(event.locationInWindow.y)/600.0, Float(event.locationInWindow.x)/600.0)
super.mouseDown(with: event)
let width:Float = Float(self.view.window!.frame.width)

addForce(renderer.plate, 1000.0, Float(event.locationInWindow.y)/width, Float(event.locationInWindow.x)/width)
}

override func rightMouseDown(with event: NSEvent)
{
clearStates(renderer.plate);
}
}

0 comments on commit 5fcbbe3

Please sign in to comment.