terrain

OpenGL - How to calculate normals in a terrain height grid?

冷暖自知 提交于 2019-12-17 17:31:13
问题 My approach is to calculate two tangent vectors parallel to axis X and Y respectively. Then calculate the cross product to find the normal vector. The tangent vector is given by the line that crosses the middle point on the two nearest segments as is shown in the following picture. I was wondering whether there is a more direct calculation, or less expensive in terms of CPU cycles. 回答1: You can actually calculate it without a cross product, by using the "finite difference method" (or at least

Mapping slope of an area and returning percent above and below a threshold in R

拟墨画扇 提交于 2019-12-13 20:10:40
问题 I am trying to figure our the proportion of an area that has a slope of 0, +/- 5 degrees. Another way of saying it is anything above 5 degrees and below 5 degrees are bad. I am trying to find the actual number, and a graphic. To achieve this I turned to R and using the Raster package. Let's use a generic country, in this case, the Philippines {list.of.packages <- c("sp","raster","rasterVis","maptools","rgeos") new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,

Cesium path onto terrain: line connecting 2 points goes under the terrain

≡放荡痞女 提交于 2019-12-12 18:06:28
问题 I have a path moving over time. I use Cesium.sampleTerrain to get positions elevation and drape them on the terrain. The problem is that, even if all points are on the terrain, the line connecting 2 points sometimes goes under the terrain. How can I do to drape also connecting lines on the terrain? Here is my code: var promise = Cesium.sampleTerrain(terrainProvider, 14, positions); Cesium.when(promise, function(updatedPositions) { var cartesianPositions = Cesium.Ellipsoid.WGS84

Javascript 3d Terrain Without Three.js

谁说我不能喝 提交于 2019-12-12 05:19:02
问题 I have searched around but I can't find anything like what I'm trying to do that doesn't use Three.js in some way (I can't use Three.js because my computer is too old to support Webgl). Here's what I've got so far: HTML: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="terrain.js"></script> <title>Terrain</title> </head> <body> <canvas id="canvas" height="400" width="400"></canvas> </body> </html> Javascript: var canvas, ctx, row1 = [], row2 = [], intensity = 15, width = 20,

How to make a 2d map with perlin noise python

落爺英雄遲暮 提交于 2019-12-11 06:28:10
问题 I have been experimenting on making a random map for a top down RPG I am making in Python. (and Pyglet) So far I have been making island by starting at 0,0 and going in a random direction 500 times (x+=32 or y -=32 sort of thing) However this doesn't look like a real image very much so I had a look at the Perlin Noise approach. How would I get a randomly generated map out of this :/ (preferably an island) and is it better than the random direction method? 回答1: a perlin map can be generated

OpenGl VBO technicalities in C++

痴心易碎 提交于 2019-12-10 14:59:47
问题 I'm a little confused as to the proper usage of VBOs in an OpenGL program. I want to create a terrain paging algorithm, using a map called from a 4096x4096 greyscale heightmap as the "whole" map. From what I've read, each vertex stored in the VBO will take up 64 bytes. The problem I have is that most sources state that a single VBO should be between 1-4mb in size, and less VBOs is better. Yet according to my calculations, storing each vertex would take a total of about a gigabyte of data!

Flat Terrain Generation in Java

江枫思渺然 提交于 2019-12-08 08:50:54
问题 I am currently working on a 2D survival game and I want to generate my own custom terrain problem is, I don't know how! I wanted to make it similar to Minicraft (not minecraft) where it is random flat terrain but i have no clue how to do so. I tried making sense of Notch's actual code but it all seems like gibberish. If anyone could link me to a tutorial or at least explain how to do it please do. 回答1: This example implements Icon and uses TexturePaint to synthesize ground tiles. 来源: https:/

How to draw a circle on 3D terrain in XNA?

こ雲淡風輕ζ 提交于 2019-12-08 05:46:14
问题 So I've been looking across the web to find an answer to this question, but I seem to be missing something. I've got a little project going that dynamically creates 3D terrain in XNA 4.0, but I want be able to draw a circle (or any other shape for that matter, but let's first go with a circle) on the terrain. Now I've read some things about 'projective texturing' but I'll admit I'm at a complete loss when it comes to shader-language. The idea is that I can (dynamically) create a basic shape,

Issue with Terrain Collision using Three.js

一笑奈何 提交于 2019-12-08 03:49:07
问题 I have created a terrain via a heightmap in Three.js and am using mrdoob's misc_controls_pointerlock for collision and movement. However, when I do objects.push(terrainobj); the performance goes down to about 3fps (from around 60) and there is no collision with the terrain. The collision is achieved via rays. How can I get around this? 回答1: If it's just a heightmap you could avoid using ray and do the collision checking right in the bitmap (using canvas and imagedata). You just need to

Terrain/Mountain algorithm not working as intended

拜拜、爱过 提交于 2019-12-07 11:43:37
问题 I want to create a terrain with a mountain on it, using a very basic principle, shown by this height mapping: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 1 2 3 2 1 0 0 0 0 0 1 2 3 4 3 2 1 0 0 0 0 0 1 2 3 2 1 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 It starts at a random point with height = 4 , and then gradually decreases it amonst the neighbours. The recursive idea is simple, I start a