lonestar

0x10c-inspired space game based on the DCPU-16
git clone git://squid-tech.com/lonestar.git
Log | Files | Refs | README

commit b44b2ff6d790745198176c0ec2ed8655763cb525
parent b416757a32cc34158b07f02e54d1447add5a74ca
Author: Josh Moore <jxm5210@rit.edu>
Date:   Mon, 25 Nov 2019 01:16:54 -0500

Add basic floor/ceiling mesh rendering

Diffstat:
Msrc/LoneStar/Assets/Scenes/MainScene.unity | 30++++++++++++++++++++++++++++++
Msrc/LoneStar/Assets/Scenes/SampleScene.unity | 477+++++++------------------------------------------------------------------------
Msrc/LoneStar/Assets/Scripts/ShipLoader.cs | 175++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 245 insertions(+), 437 deletions(-)

diff --git a/src/LoneStar/Assets/Scenes/MainScene.unity b/src/LoneStar/Assets/Scenes/MainScene.unity @@ -120,6 +120,36 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &241763761 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 241763762} + m_Layer: 0 + m_Name: Ships + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &241763762 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 241763761} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.0409715, y: 1.2508826, z: 4.7763257} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &311442697 GameObject: m_ObjectHideFlags: 0 diff --git a/src/LoneStar/Assets/Scenes/SampleScene.unity b/src/LoneStar/Assets/Scenes/SampleScene.unity @@ -120,6 +120,36 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &40919614 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 40919615} + m_Layer: 0 + m_Name: Ships + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &40919615 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 40919614} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.0409715, y: 1.2508826, z: 4.7763257} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &47079374 GameObject: m_ObjectHideFlags: 0 @@ -253,7 +283,7 @@ MeshRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 181700529} - m_Enabled: 1 + m_Enabled: 0 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -346,7 +376,7 @@ MeshRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 211990291} - m_Enabled: 1 + m_Enabled: 0 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -434,7 +464,7 @@ Transform: - {fileID: 47079378} - {fileID: 610458616} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &300783090 PrefabInstance: @@ -451,7 +481,7 @@ PrefabInstance: - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} propertyPath: m_LocalPosition.x - value: -2.29 + value: 4.291 objectReference: {fileID: 0} - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} @@ -461,7 +491,7 @@ PrefabInstance: - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} propertyPath: m_LocalPosition.z - value: -3.6 + value: 2.507 objectReference: {fileID: 0} - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} @@ -471,7 +501,7 @@ PrefabInstance: - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} propertyPath: m_LocalRotation.y - value: 0.96217084 + value: 0.7075214 objectReference: {fileID: 0} - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} @@ -481,7 +511,7 @@ PrefabInstance: - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} propertyPath: m_LocalRotation.w - value: 0.2724469 + value: 0.7066919 objectReference: {fileID: 0} - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} @@ -496,7 +526,7 @@ PrefabInstance: - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} propertyPath: m_LocalEulerAnglesHint.y - value: 148.38 + value: 90.067 objectReference: {fileID: 0} - target: {fileID: 8925315248029930773, guid: c6af8def8713a464cb6ec77a39685d39, type: 3} @@ -550,7 +580,7 @@ MeshRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 480843791} - m_Enabled: 1 + m_Enabled: 0 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -603,100 +633,6 @@ Transform: m_Father: {fileID: 223974227} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 90, y: 90, z: 0} ---- !u!1001 &525625050 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 7157367172244747160, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Name - value: LightDevice (4) - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.x - value: -3.019 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.y - value: 0.74 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.z - value: -3.9353232 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_RootOrder - value: 7 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747165, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_SceneId - value: 1030593115 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.b - value: 0.18140125 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.r - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.g - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Enabled - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 6a3ee7b8517f9294885e92176b21e219, type: 3} --- !u!1 &610458614 GameObject: m_ObjectHideFlags: 0 @@ -904,80 +840,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &1063856807 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 7157367172244747160, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Name - value: LightDevice (3) - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.x - value: 3.015 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.y - value: 0.74 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.z - value: -3.9353232 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747165, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_SceneId - value: 266228895 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 6a3ee7b8517f9294885e92176b21e219, type: 3} --- !u!1 &1139446815 GameObject: m_ObjectHideFlags: 0 @@ -1018,7 +880,7 @@ MeshRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1139446815} - m_Enabled: 1 + m_Enabled: 0 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -1111,7 +973,7 @@ MeshRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1377869416} - m_Enabled: 1 + m_Enabled: 0 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -1164,260 +1026,3 @@ Transform: m_Father: {fileID: 223974227} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 90, y: -90, z: 0} ---- !u!1001 &1494425958 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 7157367172244747160, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Name - value: LightDevice (2) - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.x - value: -1.02 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.y - value: 0.74 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.z - value: -3.9353232 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_RootOrder - value: 5 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747165, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_SceneId - value: 4286942692 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.b - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.g - value: 0.13504837 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Enabled - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 6a3ee7b8517f9294885e92176b21e219, type: 3} ---- !u!1001 &1619602463 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 7157367172244747160, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Name - value: LightDevice (1) - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.x - value: 0.997 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.y - value: 0.74 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalPosition.z - value: -3.9353232 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_RootOrder - value: 4 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747167, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367172244747165, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_SceneId - value: 998800392 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.b - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.r - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Color.g - value: 0.120030165 - objectReference: {fileID: 0} - - target: {fileID: 7157367173229024532, guid: 6a3ee7b8517f9294885e92176b21e219, - type: 3} - propertyPath: m_Enabled - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 6a3ee7b8517f9294885e92176b21e219, type: 3} ---- !u!1001 &7189657357361928555 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 7189657357049239291, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_Name - value: DCPU16 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalPosition.x - value: 1.54 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalPosition.y - value: 1.46 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalPosition.z - value: -2.16 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239289, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7189657357049239290, guid: ec3bbb40653f32a4c928ba39529462c0, - type: 3} - propertyPath: m_SceneId - value: 2172062785 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: ec3bbb40653f32a4c928ba39529462c0, type: 3} diff --git a/src/LoneStar/Assets/Scripts/ShipLoader.cs b/src/LoneStar/Assets/Scripts/ShipLoader.cs @@ -24,6 +24,76 @@ public class ShipLoader this.shipname = name; } + // get all 8 point neighbors + Vector3[] getNeighbors(Vector3 point) + { + Vector3[] result = new Vector3[] + { + point + new Vector3(-SHIP_SCALE, 0, -SHIP_SCALE), + point + new Vector3(0, 0, -SHIP_SCALE), + point + new Vector3(SHIP_SCALE, 0, -SHIP_SCALE), + point + new Vector3(SHIP_SCALE, 0, 0), + point + new Vector3(SHIP_SCALE, 0, SHIP_SCALE), + point + new Vector3(0, 0, SHIP_SCALE), + point + new Vector3(-SHIP_SCALE, 0, SHIP_SCALE), + point + new Vector3(-SHIP_SCALE, 0, 0) + }; + + return result; + } + + // calculate all of the triangles for a mesh + //\TODO figure out missing triangles bug + //\TODO draw triangles for the underside as well + int[] computeTriangles(Vector3[] points) + { + int[] triangles = new int[points.Length * 6]; + int ti = 0; + + bool skipY = false; + bool skipX = false; + + for (int y = 0; y < 24; y++) + { + for (int x = 0; x < 32; x++) + { + Vector3 pos = new Vector3(x * SHIP_SCALE, 0, y * SHIP_SCALE); + + if (Array.IndexOf(points, pos) > -1) + { + Vector3[] posNeighbors = getNeighbors(pos); + + for (int i = 0; i < posNeighbors.Length; i++) + { + int a = Array.IndexOf(points, posNeighbors[i]); + int b = Array.IndexOf(points, posNeighbors[(i + 1) % posNeighbors.Length]); + int c = Array.IndexOf(points, pos); + + if (a > -1 && b > -1) + { + triangles[ti] = c; + triangles[ti + 1] = b; + triangles[ti + 2] = a; + + ti += 3; + skipX = true; + skipY = true; + } + } + } + + if (skipX) x++; + skipX = false; + } + + if (skipY) y++; + skipY = false; + } + + UnityEngine.Debug.Log((ti / 6).ToString()); + return triangles; + } + // Load ship XML from a file, assemble the ship, then place the player inside their ship //\TODO server-side this, so the player sends their XML and the server handles it public void loadShip(GameObject ships, PlayerController player) @@ -95,8 +165,111 @@ public class ShipLoader wallObject.transform.parent = shipObject.transform; } + // generate a list of vertices corresponding to the floor/ceiling mesh + // based on the scan-line polyfill algorithm + List<Vector3> generatedVerts = new List<Vector3>(); + bool addingPoints = false; + for (int y = 0; y < 24; y++) + for (int x = 0; x < 32; x++) + { + Vector3 pos = new Vector3(x * SHIP_SCALE, 0, y * SHIP_SCALE); + Vector3 next = pos + new Vector3(SHIP_SCALE, 0, 0); + + if (!addingPoints) + { + // check for transition ON + if (hullPoints.Contains(next)) + { + addingPoints = true; + x++; + generatedVerts.Add(next); + } + } + else if (addingPoints && hullPoints.Contains(pos)) + { + generatedVerts.Add(pos); + // check for transition OFF + if (!hullPoints.Contains(next)) + { + addingPoints = false; + } + } + else if (addingPoints) + { + // ON state - just add the point + generatedVerts.Add(pos); + } + } + + // copy generated mesh grid to Vector3[] array + // this is our mesh vertices + Vector3[] gridPoints = new Vector3[generatedVerts.Count]; + for (int i = 0; i < gridPoints.Length; i++) + { + gridPoints[i] = generatedVerts[i % generatedVerts.Count]; + } + + // calculate mesh triangles + int[] triangles = computeTriangles(gridPoints); + + GameObject floorObject = new GameObject(); + floorObject.name = "Floor"; + Mesh floorMesh = new Mesh(); + + UnityEngine.Debug.Log(String.Format("{0} {1}", gridPoints.Length, triangles.Length / 6)); + + float minX = 50000; + float minY = 50000; + float maxX = 0; + float maxY = 0; + + // find the mesh bounds + foreach (Vector3 p in gridPoints) + { + if (p.x < minX) minX = p.x; + else if (p.x > maxX) maxX = p.x; + + if (p.y < minY) minY = p.y; + else if (p.y > maxY) maxY = p.y; + } + + Vector2[] uv = new Vector2[gridPoints.Length]; + + for (int i = 0; i < gridPoints.Length; i++) + { + uv[i] = new Vector2((gridPoints[i].x - minX) / (maxX - minX), + (gridPoints[i].z - minY) / (maxY - minY)); + } + + + + floorMesh.vertices = gridPoints; + floorMesh.triangles = triangles; + floorMesh.uv = uv; + + floorMesh.RecalculateNormals(); + + // mesh components + floorObject.AddComponent<MeshFilter>(); + floorObject.GetComponent<MeshFilter>().mesh = floorMesh; + + floorObject.AddComponent<MeshRenderer>(); + floorObject.GetComponent<MeshRenderer>().material = HULL_DEFAULT.GetComponent<Renderer>().sharedMaterial; + + floorObject.AddComponent<MeshCollider>(); + + // copy to ceiling + GameObject ceilingObject = UnityEngine.Object.Instantiate(floorObject); + ceilingObject.name = "Ceiling"; + + floorObject.transform.position = new Vector3(0, -SHIP_SCALE / 2, 0); + floorObject.transform.parent = shipObject.transform; + ceilingObject.transform.position = new Vector3(0, SHIP_SCALE / 2, 0); + ceilingObject.transform.parent = shipObject.transform; + + // parent the ship to the Ships object - shipObject.transform.position = new Vector3(0, 0, 0); + shipObject.transform.position = new Vector3(0, 0.1f, 0); shipObject.transform.parent = ships.transform; } }