forked from liuhaochuan79/node_recast
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
137 lines (106 loc) · 3.57 KB
/
index.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* @Author: pop
* @Date: 2016-05-15 15:25:15
* @Last Modified by: pop
* @Last Modified time: 2016-05-16 18:27:47
*/
'use strict';
function Recast() {
this.addon = require('bindings')('addon');
this.buildContext = new this.addon.BuildContext();
this.inputGeom = new this.addon.InputGeom();
this.sample_TempObstacles = new this.addon.Sample_TempObstacles();
//设置上下文
this.sample_TempObstacles.setContext(this.buildContext);
//设置输入网格
this.sample_TempObstacles.setInputGeom(this.inputGeom);
}
Recast.prototype.setCellSize = function(val) {
this.sample_TempObstacles.setCellSize(val);
};
Recast.prototype.setCellHeight = function(val) {
this.sample_TempObstacles.setCellHeight(val);
};
Recast.prototype.setAgentHeight = function(val) {
this.sample_TempObstacles.setAgentHeight(val);
};
Recast.prototype.setAgentRadius = function(val) {
this.sample_TempObstacles.setAgentRadius(val);
};
Recast.prototype.setAgentMaxClimb = function(val) {
this.sample_TempObstacles.setAgentMaxClimb(val);
};
Recast.prototype.setAgentMaxSlope = function(val) {
this.sample_TempObstacles.setAgentMaxSlope(val);
};
Recast.prototype.setRegionMinSize = function(val) {
this.sample_TempObstacles.setRegionMinSize(val);
};
Recast.prototype.setRegionMergeSize = function(val) {
this.sample_TempObstacles.setRegionMergeSize(val);
};
Recast.prototype.setEdgeMaxLen = function(val) {
this.sample_TempObstacles.setEdgeMaxLen(val);
};
Recast.prototype.setEdgeMaxError = function(val) {
this.sample_TempObstacles.setEdgeMaxError(val);
};
Recast.prototype.setVertsPerPoly = function(val) {
this.sample_TempObstacles.setVertsPerPoly(val);
};
Recast.prototype.setDetailSampleDist = function(val) {
this.sample_TempObstacles.setDetailSampleDist(val);
};
Recast.prototype.setDetailSampleMaxError = function(val) {
this.sample_TempObstacles.setDetailSampleMaxError(val);
};
Recast.prototype.setPartitionType = function(val) {
this.sample_TempObstacles.setPartitionType(val);
};
Recast.prototype.setDefault = function() {
//设置参数
this.setCellSize(0.1);
this.setCellHeight(0.2);
this.setAgentHeight(2.0);
//直径如果设置太大,会截断狭窄的地形
//this.setAgentRadius(0.6);
this.setAgentRadius(0.0);
this.setAgentMaxClimb(0.9);
this.setAgentMaxSlope(45.0);
this.setRegionMinSize(8);
this.setRegionMergeSize(20.0);
this.setEdgeMaxLen(12.0);
this.setEdgeMaxError(1.3);
this.setVertsPerPoly(6);
this.setDetailSampleDist(6.0);
this.setDetailSampleMaxError(1.0);
this.setPartitionType(0);
};
Recast.prototype.load = function(fileName) {
return this.inputGeom.load(this.buildContext, fileName);
};
Recast.prototype.build = function() {
return this.sample_TempObstacles.build();
};
Recast.prototype.addTempObstacle = function(x,y,z,radius,height) {
return this.sample_TempObstacles.addTempObstacle(x,y,z,radius,height);
};
Recast.prototype.removeTempObstacle = function(ref) {
return this.sample_TempObstacles.removeTempObstacle(ref);
};
Recast.prototype.clearAllTempObstacles = function() {
return this.sample_TempObstacles.clearAllTempObstacles();
};
Recast.prototype.update = function(dt) {
this.sample_TempObstacles.update(dt);
};
Recast.prototype.findNearestPoint = function(x,y,z,rx,ry,rz) {
return this.sample_TempObstacles.findNearestPoint(x,y,z,rx,ry,rz);
};
Recast.prototype.findRandomPoint = function() {
return this.sample_TempObstacles.findRandomPoint();
};
Recast.prototype.findPath = function(x1,y1,z1,x2,y2,z2,maxPath) {
return this.sample_TempObstacles.findPath(x1,y1,z1,x2,y2,z2,maxPath);
};
module.exports = Recast;