Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
7abc578e
Commit
7abc578e
authored
Jan 16, 2020
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
Suzanne fixed
parent
9665ac42
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/mesh/height map
+0
-104
0 additions, 104 deletions
modules/mesh/height map
with
0 additions
and
104 deletions
modules/mesh/height map
+
0
−
104
View file @
7abc578e
...
@@ -469,8 +469,6 @@ function map_worker() {
...
@@ -469,8 +469,6 @@ function map_worker() {
//
//
if (y2 != y1) {
if (y2 != y1) {
for (var y = y1; y <= y2; ++y) {
for (var y = y1; y <= y2; ++y) {
if (y < 0) continue
if (y > (h - 1)) break
x12 = Math.floor(0.5+x1+(y-y1)*(x2-x1)/(y2-y1))
x12 = Math.floor(0.5+x1+(y-y1)*(x2-x1)/(y2-y1))
z12 = z1+(y-y1)*(z2-z1)/(y2-y1)
z12 = z1+(y-y1)*(z2-z1)/(y2-y1)
x02 = Math.floor(0.5+x0+(y-y0)*(x2-x0)/(y2-y0))
x02 = Math.floor(0.5+x0+(y-y0)*(x2-x0)/(y2-y0))
...
@@ -482,7 +480,6 @@ function map_worker() {
...
@@ -482,7 +480,6 @@ function map_worker() {
var x = x12 - dir
var x = x12 - dir
while (x != x02) {
while (x != x02) {
x += dir
x += dir
if ((x < 0) || (x > (h-1))) continue
var z = z12+slope*(x-x12)
var z = z12+slope*(x-x12)
if (z > map[(h-1-y)*w+x]) {
if (z > map[(h-1-y)*w+x]) {
map[(h-1-y)*w+x] = z
map[(h-1-y)*w+x] = z
...
@@ -496,8 +493,6 @@ function map_worker() {
...
@@ -496,8 +493,6 @@ function map_worker() {
}
}
if (y1 != y0) {
if (y1 != y0) {
for (var y = y0; y <= y1; ++y) {
for (var y = y0; y <= y1; ++y) {
if (y < 0) continue
if (y > (h-1)) break
x01 = Math.floor(0.5+x0+(y-y0)*(x1-x0)/(y1-y0))
x01 = Math.floor(0.5+x0+(y-y0)*(x1-x0)/(y1-y0))
z01 = z0+(y-y0)*(z1-z0)/(y1-y0)
z01 = z0+(y-y0)*(z1-z0)/(y1-y0)
x02 = Math.floor(0.5+x0+(y-y0)*(x2-x0)/(y2-y0))
x02 = Math.floor(0.5+x0+(y-y0)*(x2-x0)/(y2-y0))
...
@@ -509,7 +504,6 @@ function map_worker() {
...
@@ -509,7 +504,6 @@ function map_worker() {
var x = x01 - dir
var x = x01 - dir
while (x != x02) {
while (x != x02) {
x += dir
x += dir
if ((x < 0) || (x > (w-1))) continue
var z = z01+slope*(x-x01)
var z = z01+slope*(x-x01)
if (z > map[(h-1-y)*w+x]) {
if (z > map[(h-1-y)*w+x]) {
map[(h-1-y)*w+x] = z
map[(h-1-y)*w+x] = z
...
@@ -522,104 +516,6 @@ function map_worker() {
...
@@ -522,104 +516,6 @@ function map_worker() {
}
}
}
}
}
}
/*
//
// find triangles crossing the map
//
var segs = []
offset = 80+4
for (var t = 0; t < triangles; ++t) {
offset += 3*4
x0 = view.getFloat32(offset,endian)
offset += 4
y0 = view.getFloat32(offset,endian)
offset += 4
z0 = view.getFloat32(offset,endian)
offset += 4
x1 = view.getFloat32(offset,endian)
offset += 4
y1 = view.getFloat32(offset,endian)
offset += 4
z1 = view.getFloat32(offset,endian)
offset += 4
x2 = view.getFloat32(offset,endian)
offset += 4
y2 = view.getFloat32(offset,endian)
offset += 4
z2 = view.getFloat32(offset,endian)
offset += 4
//
// assemble vertices
//
offset += 2
var v = [[x0,y0,z0],[x1,y1,z1],[x2,y2,z2]]
//
// sort z
//
v.sort(function(a,b) {
if (a[2] < b[2])
return -1
else if (a[2] > b[2])
return 1
else
return 0
})
//
// check for crossings
//
if ((v[0][2] < (zmax-depth)) && (v[2][2] > (zmax-depth))) {
//
// crossing found, check for side and save
//
if (v[1][2] < (zmax-depth)) {
var x0 = v[2][0]+(v[0][0]-v[2][0])
*(v[2][2]-(zmax-depth))/(v[2][2]-v[0][2])
var y0 = v[2][1]+(v[0][1]-v[2][1])
*(v[2][2]-(zmax-depth))/(v[2][2]-v[0][2])
var x1 = v[2][0]+(v[1][0]-v[2][0])
*(v[2][2]-(zmax-depth))/(v[2][2]-v[1][2])
var y1 = v[2][1]+(v[1][1]-v[2][1])
*(v[2][2]-(zmax-depth))/(v[2][2]-v[1][2])
}
else if (v[1][2] >= (zmax-depth)) {
var x0 = v[2][0]+(v[0][0]-v[2][0])
*(v[2][2]-(zmax-depth))/(v[2][2]-v[0][2])
var y0 = v[2][1]+(v[0][1]-v[2][1])
*(v[2][2]-(zmax-depth))/(v[2][2]-v[0][2])
var x1 = v[1][0]+(v[0][0]-v[1][0])
*(v[1][2]-(zmax-depth))/(v[1][2]-v[0][2])
var y1 = v[1][1]+(v[0][1]-v[1][1])
*(v[1][2]-(zmax-depth))/(v[1][2]-v[0][2])
}
if (y0 < y1)
segs.push({x0:x0,y0:y0,x1:x1,y1:y1})
else
segs.push({x0:x1,y0:y1,x1:x0,y1:y0})
}
}
//
// fill interior
//
for (var row = 0; row < h; ++row) {
var y = ymin+(ymax-ymin)*row/(h-1)
rowsegs = segs.filter(p => ((p.y0 <= y) && (p.y1 >= y)))
var xs = rowsegs.map(p =>
(p.x0+(p.x1-p.x0)*(y-p.y0)/(p.y1-p.y0)))
xs.sort((a,b) => (a-b))
for (var col = 0; col < w; ++col) {
var x = xmin+(xmax-xmin)*col/(w-1)
var index = xs.findIndex((p) => (p >= x))
if (index == -1)
var i = 0
else
var i = 255*(index%2)
buf[(h-1-row)*w*4+col*4+0] = i
buf[(h-1-row)*w*4+col*4+1] = i
buf[(h-1-row)*w*4+col*4+2] = i
buf[(h-1-row)*w*4+col*4+3] = 255
}
}
*/
//
//
// output the map
// output the map
//
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment