From dcb55fbf3a4cbaf06d307adbf6dfabe71a7917dc Mon Sep 17 00:00:00 2001 From: Sanjay Madhav Date: Thu, 19 Apr 2018 18:20:32 -0700 Subject: [PATCH 1/2] Explicitly set precompiled header setting in Visual Studio to "NotUsing" --- Chapter01/Game.vcxproj | 6 ++---- Chapter02/Game.vcxproj | 6 ++---- Chapter03/Game.vcxproj | 6 ++---- Chapter04/Game.vcxproj | 6 ++---- Chapter05/Game.vcxproj | 6 ++---- Chapter06/Game.vcxproj | 6 ++---- Chapter07/Game.vcxproj | 6 ++---- Chapter08/Game.vcxproj | 6 ++---- Chapter09/Game.vcxproj | 6 ++---- Chapter10/Game.vcxproj | 6 ++---- Chapter11/Game.vcxproj | 6 ++---- Chapter12/Game.vcxproj | 6 ++---- Chapter13/Game.vcxproj | 6 ++---- Chapter14/Game.vcxproj | 6 ++---- Exercises/4.2/Game.vcxproj | 6 ++---- 15 files changed, 30 insertions(+), 60 deletions(-) diff --git a/Chapter01/Game.vcxproj b/Chapter01/Game.vcxproj index 1f8e815e..e16204f8 100644 --- a/Chapter01/Game.vcxproj +++ b/Chapter01/Game.vcxproj @@ -55,8 +55,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -80,8 +79,7 @@ xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter02/Game.vcxproj b/Chapter02/Game.vcxproj index ff4157f9..35c39009 100644 --- a/Chapter02/Game.vcxproj +++ b/Chapter02/Game.vcxproj @@ -69,8 +69,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -94,8 +93,7 @@ xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter03/Game.vcxproj b/Chapter03/Game.vcxproj index f88503fe..fd6197c8 100644 --- a/Chapter03/Game.vcxproj +++ b/Chapter03/Game.vcxproj @@ -77,8 +77,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -102,8 +101,7 @@ xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter04/Game.vcxproj b/Chapter04/Game.vcxproj index 23567660..27b091d3 100644 --- a/Chapter04/Game.vcxproj +++ b/Chapter04/Game.vcxproj @@ -84,8 +84,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -109,8 +108,7 @@ xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter05/Game.vcxproj b/Chapter05/Game.vcxproj index 70015946..b0bd2f45 100644 --- a/Chapter05/Game.vcxproj +++ b/Chapter05/Game.vcxproj @@ -90,8 +90,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -115,8 +114,7 @@ xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter06/Game.vcxproj b/Chapter06/Game.vcxproj index 182b0c8f..ff861c40 100644 --- a/Chapter06/Game.vcxproj +++ b/Chapter06/Game.vcxproj @@ -91,8 +91,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -116,8 +115,7 @@ xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter07/Game.vcxproj b/Chapter07/Game.vcxproj index 64f0ac90..e14fa8e5 100644 --- a/Chapter07/Game.vcxproj +++ b/Chapter07/Game.vcxproj @@ -97,8 +97,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -125,8 +124,7 @@ xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studi Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter08/Game.vcxproj b/Chapter08/Game.vcxproj index af5adf12..5ab5ac24 100644 --- a/Chapter08/Game.vcxproj +++ b/Chapter08/Game.vcxproj @@ -92,8 +92,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -117,8 +116,7 @@ xcopy "$(ProjectDir)\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter09/Game.vcxproj b/Chapter09/Game.vcxproj index 1b09fd26..ed68601d 100644 --- a/Chapter09/Game.vcxproj +++ b/Chapter09/Game.vcxproj @@ -113,8 +113,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -141,8 +140,7 @@ xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studi Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter10/Game.vcxproj b/Chapter10/Game.vcxproj index cc34eddf..e0ee7f3f 100644 --- a/Chapter10/Game.vcxproj +++ b/Chapter10/Game.vcxproj @@ -111,8 +111,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -139,8 +138,7 @@ xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studi Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter11/Game.vcxproj b/Chapter11/Game.vcxproj index aac807a2..a49ef091 100644 --- a/Chapter11/Game.vcxproj +++ b/Chapter11/Game.vcxproj @@ -123,8 +123,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -151,8 +150,7 @@ xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studi Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter12/Game.vcxproj b/Chapter12/Game.vcxproj index 9c4641ae..5ddbc62f 100644 --- a/Chapter12/Game.vcxproj +++ b/Chapter12/Game.vcxproj @@ -132,8 +132,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -160,8 +159,7 @@ xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studi Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter13/Game.vcxproj b/Chapter13/Game.vcxproj index 43d2b661..aa3d84a1 100644 --- a/Chapter13/Game.vcxproj +++ b/Chapter13/Game.vcxproj @@ -143,8 +143,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -171,8 +170,7 @@ xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studi Level3 - - + NotUsing MaxSpeed true true diff --git a/Chapter14/Game.vcxproj b/Chapter14/Game.vcxproj index 2eae5c86..aef575d9 100644 --- a/Chapter14/Game.vcxproj +++ b/Chapter14/Game.vcxproj @@ -145,8 +145,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -173,8 +172,7 @@ xcopy "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studi Level3 - - + NotUsing MaxSpeed true true diff --git a/Exercises/4.2/Game.vcxproj b/Exercises/4.2/Game.vcxproj index 3c041589..506ca23a 100644 --- a/Exercises/4.2/Game.vcxproj +++ b/Exercises/4.2/Game.vcxproj @@ -71,8 +71,7 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) @@ -96,8 +95,7 @@ xcopy "$(ProjectDir)\..\..\external\GLEW\lib\win\x86\*.dll" "$(OutDir)" /i /s /y Level3 - - + NotUsing MaxSpeed true true From 6a27a8db0ca4cd0edd0d92d5b423738b8289f7c2 Mon Sep 17 00:00:00 2001 From: Sanjay Madhav Date: Mon, 24 Sep 2018 02:38:25 -0700 Subject: [PATCH 2/2] Added missing Blender export script --- Exporter/Blender/gpmesh_export.py | 122 ++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Exporter/Blender/gpmesh_export.py diff --git a/Exporter/Blender/gpmesh_export.py b/Exporter/Blender/gpmesh_export.py new file mode 100644 index 00000000..7a9cdf31 --- /dev/null +++ b/Exporter/Blender/gpmesh_export.py @@ -0,0 +1,122 @@ +import bpy + +def write_gpmesh(context, filepath, vertFormat): + # Get current object + obj = bpy.context.scene.objects.active + if obj.type == 'MESH': + mesh = obj.data + f = open(filepath, 'w', encoding='utf-8') + f.write("{\n") + f.write("\t\"version\":1,\n") + f.write("\t\"vertexformat\":\"" + vertFormat + "\",\n") + f.write("\t\"shader\":\"BasicMesh\",\n") + + # For now, only one texture + # figure out the file name... + texname = filepath.split("\\")[-1].split("/")[-1].split(".")[0] + # Make it a png + texname += ".png" + f.write("\t\"textures\":[\n") + f.write("\t\t\"" + texname + "\"\n") + f.write("\t],\n") + + # specular power + f.write("\t\"specularPower\":100,\n") + + # vertices + # We have to create our own storage for because uvs are stored separately + verts = [dict() for x in range(len(mesh.vertices))] + for v in mesh.vertices: + verts[v.index]["pos"] = v.co + verts[v.index]["norm"] = v.normal + + for l in mesh.loops: + verts[l.vertex_index]["uv"] = mesh.uv_layers.active.data[l.index].uv + + f.write("\t\"vertices\":[\n") + first = True + for v in verts: + if first: + f.write("\t\t[") + first = False + else: + f.write(",\n\t\t[") + f.write("%f,%f,%f," % (v["pos"].x, v["pos"].y, v["pos"].z)) + f.write("%f,%f,%f," % (v["norm"].x, v["norm"].y, v["norm"].z)) + f.write("%f,%f" % (v["uv"].x, v["uv"].y)) + f.write("]") + f.write("\n\t],\n") + + # indices + f.write("\t\"indices\":[\n") + first = True + for p in mesh.polygons: + if first: + f.write("\t\t") + first = False + else: + f.write(",\n\t\t") + f.write("[%d,%d,%d]" % (p.vertices[0], p.vertices[1], p.vertices[2])) + f.write("\n\t]\n") + + f.write("}\n") + f.close() + else: + raise ValueError("No mesh selected") + + return {'FINISHED'} + + +# ExportHelper is a helper class, defines filename and +# invoke() function which calls the file selector. +from bpy_extras.io_utils import ExportHelper +from bpy.props import StringProperty, BoolProperty, EnumProperty +from bpy.types import Operator + + +class ExportGPMesh(Operator, ExportHelper): + """Export to Game Programming in C++ mesh format""" + bl_idname = "export_test.gpmesh" # important since its how bpy.ops.import_test.some_data is constructed + bl_label = "Export Mesh" + + # ExportHelper mixin class uses this + filename_ext = ".gpmesh" + + filter_glob = StringProperty( + default="*.gpmesh", + options={'HIDDEN'}, + maxlen=255, # Max internal buffer length, longer would be clamped. + ) + + vertFormat = EnumProperty( + name="Vertex Format", + description="Choose the vertex format", + items=(('PosNormTex', "PosNormTex", "Position, normal, tex coord"), + ('PosTex', "PosTex", "Position, tex coord")), + default='PosNormTex', + ) + + def execute(self, context): + return write_gpmesh(context, self.filepath, self.vertFormat) + + +# Only needed if you want to add into a dynamic menu +def menu_func_export(self, context): + self.layout.operator(ExportGPMesh.bl_idname, text="GPMesh Exporter (.gpmesh)") + + +def register(): + bpy.utils.register_class(ExportGPMesh) + bpy.types.INFO_MT_file_export.append(menu_func_export) + + +def unregister(): + bpy.utils.unregister_class(ExportGPMesh) + bpy.types.INFO_MT_file_export.remove(menu_func_export) + + +if __name__ == "__main__": + register() + + # test call + bpy.ops.export_test.gpmesh('INVOKE_DEFAULT')