8000 add file · sunxvming/python-learn@4573bb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4573bb5

Browse files
committed
add file
1 parent 8ebef3a commit 4573bb5

File tree

5 files changed

+1087
-10
lines changed

5 files changed

+1087
-10
lines changed

convert_obj/GenScenePath.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#if UNITY_EDITOR
2+
using UnityEngine;
3+
using System.Collections.Generic;
4+
using UnityEngine.SceneManagement;
5+
using System.IO;
6+
7+
8+
public class GenScenePath : MonoBehaviour
9+
{
10+
public void CreatePoly() {
11+
var go = gameObject.GetComponent<MeshFilter>();
12+
var mesh = go.sharedMesh;
13+
var angle = go.transform.eulerAngles.x;
14+
var offTrans = go.transform.position;
15+
var trans = go.transform;
16+
var navpath = CreatScenePath.GenPolygon(mesh.vertices, mesh.triangles,go.transform.right, angle, offTrans, trans);
17+
//Log.Sys("--------------------",mesh.vertices.Length );
18+
19+
string name = SceneManager.GetActiveScene().name.ToLower() + gameObject.name;
20+
var bytes = navpath.GetBytes();
21+
string pointsPath = Application.dataPath + "/Scenes/points_" + name + ".txt";
22+
StreamWriter stream = new StreamWriter(pointsPath);
23+
for (int i = 0; i < bytes.Length; i++)
24+
{
25+
stream.WriteLine(bytes[i]);
26+
}
27+
stream.Flush();
28+
stream.Close();
29+
30+
var pf = new PathFinder(navpath);
31+
pf.SavePath(Application.dataPath + "/Resources/qpf/" + name + ".qpf");
32+
pf.SavePath("../server/qpf/" + name + ".qpf");
33+
pf.Dispose();
34+
Log.Sys("=========export path qpf done==========");
35+
}
36+
37+
public void CreatePoly1() {
38+
//UnityEngine.AI.NavMeshTriangulation tmpNavMeshTriangulation = UnityEngine.AI.NavMesh.CalculateTriangulation();
39+
40+
////�½��ļ�
41+
//string tmpPath = Application.dataPath + "/Scenes/" + SceneManager.GetActiveScene().name + ".obj";
42+
//StreamWriter tmpStreamWriter = new StreamWriter(tmpPath);
43+
44+
////����
45+
//for (int i = 0; i < tmpNavMeshTriangulation.vertices.Length; i++)
46+
//{
47+
// tmpStreamWriter.WriteLine("v " + tmpNavMeshTriangulation.vertices[i].x + " " + tmpNavMeshTriangulation.vertices[i].y + " " + tmpNavMeshTriangulation.vertices[i].z);
48+
//}
49+
50+
//tmpStreamWriter.WriteLine("g pPlane1");
51+
52+
////����
53+
//for (int i = 0; i < tmpNavMeshTriangulation.indices.Length;)
54+
//{
55+
// tmpStreamWriter.WriteLine("f " + (tmpNavMeshTriangulation.indices[i] + 1) + " " + (tmpNavMeshTriangulation.indices[i + 1] + 1) + " " + (tmpNavMeshTriangulation.indices[i + 2] + 1));
56+
// i = i + 3;
57+
//}
58+
59+
//tmpStreamWriter.Flush();
60+
//tmpStreamWriter.Close();
61+
62+
//var navpath = CreatScenePath.GenPolygon(tmpNavMeshTriangulation.vertices, tmpNavMeshTriangulation.indices,Vector3.zero,0);
63+
//string name = SceneManager.GetActiveScene().name.ToLower() + gameObject.name;
64+
//var bytes = navpath.GetBytes();
65+
//string pointsPath = Application.dataPath + "/Scenes/points_" + name + ".txt";
66+
//StreamWriter stream = new StreamWriter(pointsPath);
67+
//for (int i = 0; i < bytes.Length; i++)
68+
//{
69+
// stream.WriteLine(bytes[i]);
70+
//}
71+
//stream.Flush();
72+
//stream.Close();
73+
//var pf = new PathFinder(navpath);
74+
//pf.SavePath(Application.dataPath + "/Resources/qpf/" + name + ".qpf");
75+
//pf.SavePath("../server/qpf/" + name + ".qpf");
76+
//pf.Dispose();
77+
//Log.Sys("=========export path qpf done==========");
78+
}
79+
}
80+
#endif

convert_obj/GenScenePathEditor.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
using UnityEditor;
4+
5+
[CustomEditor(typeof(GenScenePath))]
6+
public class GenScenePathEditor : Editor
7+
{
8+
9+
public override void OnInspectorGUI()
10+
{
11+
GenScenePath pre = (GenScenePath)target;
12+
13+
if (GUILayout.Button("Create Path"))
14+
{
15+
pre.CreatePoly();
16+
}
17+
18+
}
19+
}

0 commit comments

Comments
 (0)
0