public void Read(NetInfo gameNet, string _mode) { this.mode = _mode; if (gameNet == null) { return; } nodeMeshes = new CSMesh[gameNet.m_nodes.Length]; segmentMeshes = new CSMesh[gameNet.m_segments.Length]; for (int i = 0; i < nodeMeshes.Length; i++) { nodeMeshes[i] = new CSMesh { index = i, name = gameNet.m_nodes[i].m_mesh.name, shader = gameNet.m_nodes[i].m_material.shader.name, }; for (int d = 0; d < 3; d++) { nodeMeshes[i].color[d] = gameNet.m_nodes[i].m_material.color[d]; } } for (int i = 0; i < segmentMeshes.Length; i++) { segmentMeshes[i] = new CSMesh { index = i, name = gameNet.m_segments[i].m_mesh.name, shader = gameNet.m_segments[i].m_material.shader.name, }; for (int d = 0; d < 3; d++) { segmentMeshes[i].color[d] = gameNet.m_segments[i].m_material.color[d]; } } }
public void Read(NetInfo gameNet, string _mode) { this.mode = _mode; if (gameNet == null) { return; } nodeMeshes = new CSMesh[gameNet.m_nodes.Length]; segmentMeshes = new CSMesh[gameNet.m_segments.Length]; Debug.Log("gamenetName" + gameNet.name); var netname = ExtraUtils.FormatNetworkName(); //get elevation? Debug.Log("mode " + mode); if (_mode == "Basic") { _mode = ""; } else { _mode = " " + _mode; } for (int i = 0; i < nodeMeshes.Length; i++) { nodeMeshes[i] = new CSMesh(); nodeMeshes[i].index = i; if (i != 0) { nodeMeshes[i].name = netname + "_mesh" + (i + 1) + _mode; nodeMeshes[i].texture = netname + "_mesh" + (i + 1) + _mode; } else { nodeMeshes[i].name = netname + _mode; nodeMeshes[i].texture = netname + _mode; } Debug.Log("nodemesh1"); nodeMeshes[i].name = nodeMeshes[i].name + "_node"; nodeMeshes[i].texture = nodeMeshes[i].texture + "_node"; nodeMeshes[i].shader = gameNet.m_nodes[i].m_material.shader.name; for (int d = 0; d < 3; d++) { nodeMeshes[i].color[d] = gameNet.m_nodes[i].m_material.color[d]; } Debug.Log("nodemesh2"); } Debug.Log("segmesh1"); for (int i = 0; i < segmentMeshes.Length; i++) { segmentMeshes[i] = new CSMesh(); Debug.Log("segmesh2"); segmentMeshes[i].index = i; if (i != 0) { segmentMeshes[i].name = netname + "_mesh" + (i + 1) + _mode; segmentMeshes[i].texture = netname + "_mesh" + (i + 1) + _mode; Debug.Log("segmesh3"); } else { segmentMeshes[i].name = netname + _mode; segmentMeshes[i].texture = netname + _mode; } //Debug.Log("segmesh4"); segmentMeshes[i].shader = gameNet.m_segments[i].m_material.shader.name; for (int d = 0; d < 3; d++) { segmentMeshes[i].color[d] = gameNet.m_segments[i].m_material.color[d]; } } //hack for dumped slope and tunnel meshes - removes first entry in list Debug.Log("_mode: " + _mode); if (_mode == " Slope" || _mode == " Tunnel") { CSMesh[] tempnodeMeshes = nodeMeshes; CSMesh[] tempsegmentMeshes = segmentMeshes; nodeMeshes = new CSMesh[gameNet.m_nodes.Length - 1]; for (int i = 0; i < nodeMeshes.Length; i++) { nodeMeshes[i] = tempnodeMeshes[i + 1]; } segmentMeshes = new CSMesh[gameNet.m_segments.Length - 1]; for (int i = 0; i < segmentMeshes.Length; i++) { segmentMeshes[i] = tempsegmentMeshes[i + 1]; } } }
/***************** Class Definitions *****************/ /***************** Class Functions *****************/ void Start() { m_meshFilter = gameObject.AddComponent <MeshFilter>(); m_unityMesh = m_meshFilter.mesh; m_meshRenderer = gameObject.AddComponent <MeshRenderer>(); m_objectTransform = gameObject.GetComponent <Transform>(); m_csMesh = new CSMesh(); m_csImportedFBXScene = new CSImportedFBXScene(); // C++ handler which is unmanaged memory (we need to delete) m_cppImportedFBXScene = CPPDLLCreateFBXHandler(); //int result = CSLoadFBXFile("C:\\Users\\Brandon\\Desktop\\GameEngineBF\\EngineBJF\\FBXLibraryHandler\\SciFiCharacter\\NewSciFiCharacter.fbx"); DateTime m_timeBefore = DateTime.Now; int result = CSLoadFBXFile("C:\\Users\\Brandon\\Desktop\\GameEngineBF\\EngineBJF\\FBXLibraryHandler\\CyberPunksWeapons\\Glossy\\SM_Pistol.fbx"); DateTime m_timeAfter = DateTime.Now; TimeSpan m_duration = m_timeAfter - m_timeBefore; if (m_duration.Seconds > 0) { print("The mesh was loaded in: " + m_duration.Seconds + " s"); } else { print("The mesh was loaded in: " + m_duration.Milliseconds + " ms"); } if (1 == result) { // If the file loaded a mesh successfully, let's fill out the mesh component of this game object. FillOutGameObjectMesh(); if (m_csMesh.m_allVerticesUVs != null) { DateTime m_timeBefore2 = DateTime.Now; //int result2 = CSLoadMaterialFromFBXFile("C:\\Users\\Brandon\\Desktop\\GameEngineBF\\EngineBJF\\FBXLibraryHandler\\SciFiCharacter\\NewSciFiCharacter.fbx"); int result2 = CSLoadMaterialFromFBXFile("C:\\Users\\Brandon\\Desktop\\GameEngineBF\\EngineBJF\\FBXLibraryHandler\\CyberPunksWeapons\\Glossy\\SM_Pistol.fbx"); DateTime m_timeAfter2 = DateTime.Now; TimeSpan m_duration2 = m_timeAfter2 - m_timeBefore2; if (m_duration.Seconds > 0) { print("The material was loaded in: " + m_duration2.Seconds + " s"); } else { print("The material was loaded in: " + m_duration2.Milliseconds + " ms"); } } } // If the file did not load, lets check if there is a specific error message we can display to the user. switch (result) { case 0: print("File path did not load"); break; case -1: print("File did not contain mesh data"); break; default: break; } //m_objectTransform.Translate(new Vector3(0.0f, -10.0f)); // For testing //m_objectTransform.localScale = new Vector3(0.1f, 0.1f, 0.1f); // For testing float scaleAmount = 0.5f; m_objectTransform.Translate(new Vector3(0.0f, 0.0f)); // For testing m_objectTransform.localScale = new Vector3(scaleAmount, scaleAmount, scaleAmount); // For testing m_objectTransform.Rotate(new Vector3(0.0f, 1.0f, 0.0f), 90.0f); }