-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQ3Types.swift
50 lines (43 loc) · 1.29 KB
/
Q3Types.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Q3Types.swift
// Quake 3 BSP Renderer
//
// Created by Thomas Brunoli on 13/01/2016.
// Copyright © 2016 Thomas Brunoli. All rights reserved.
//
import Foundation
import simd
struct Q3Vertex {
var position: float4 = float4(0, 0, 0, 0)
var normal: float4 = float4(0, 0, 0, 0)
var color: float4 = float4(0, 0, 0, 0)
var textureCoord: float2 = float2(0, 0)
var lightmapCoord: float2 = float2(0, 0)
}
func +(left: Q3Vertex, right: Q3Vertex) -> Q3Vertex {
return Q3Vertex(
position: left.position + right.position,
normal: left.normal + right.normal,
color: left.color + right.color,
textureCoord: left.textureCoord + right.textureCoord,
lightmapCoord: left.lightmapCoord + right.lightmapCoord
)
}
func *(left: Q3Vertex, right: Float) -> Q3Vertex {
return Q3Vertex(
position: left.position * right,
normal: left.normal * right,
color: left.color * right,
textureCoord: left.textureCoord * right,
lightmapCoord: left.lightmapCoord * right
)
}
typealias Q3Lightmap = Array<(UInt8, UInt8, UInt8, UInt8)>
enum Q3FaceType: Int {
case Polygon = 1, Patch = 2, Mesh = 3, Billboard = 4
}
struct Q3Face {
let textureName: String
let lightmapIndex: Int
let vertexIndices: Array<UInt32>
}