473,543 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2D height map to 3D model?

Hi Folks,

I'm looking to write a Python script that will take a 2D BMP (or
height map) and translate it into a 3D model in OBJ format.

Something of a challenge for me but if it were easy life would be
boring :)

Does anyone know if such a script already exists?
Or any pointers would be appreciated.

Thanks,

PhilC
Jul 18 '05 #1
3 4217
Hi Phil - You don't seem to be getting much in the way of replies so I
thought I would put my 2 cents in ...

PhilC <pc****@philc.n et> wrote in message news:<sk******* *************** **********@4ax. com>...
Hi Folks,

I'm looking to write a Python script that will take a 2D BMP (or
height map) and translate it into a 3D model in OBJ format.

I think you're saying that your input data would be a 2-dimensional
array each element of which would indicate an height above sea level
for that X,Y coordinate (the more I read your original question the
more I doubt my assumption but here goes anyway).

Firstly if you can mangle your data into some format which would be
acceptable as format I suspect that this ...

http://thuban.intevation.org/

.... might do that job.

Assuming that you can't do the mangling (I know I couldn't) have you
seen this ...

http://mayavi.sourceforge.net/

.... and as an instance of the output you might get, this ...

http://mayavi.sourceforge.net/docs/g....html#VIZ-DATA

Another option I came across was this ...

http://www.johnny-lin.com/py_pkgs/Ia...l.html#contour

.... I suspect however that you wanted some output that looked, however
roughly, like an aerial photograph - would be interested to know. I
live in a hilly, rather attractive city and have long wondered about
the possibility of being able to build a model of the land in
software.

Sorry this isn't more help. Maybe you could expand on your needs a
little ?

regards

Richard Shea.

Something of a challenge for me but if it were easy life would be
boring :)

Does anyone know if such a script already exists?
Or any pointers would be appreciated.

Thanks,

PhilC

Jul 18 '05 #2
Thanks Richard,

I was actually thinking of faces but an aerial photograph would be
similar. I'll check through those links and see if they help.

Again my appreciation for your reply.

PhilC

Jul 18 '05 #3
Didn't see the original question, but going from the subject, you want
to generate a 3D mesh from a height field (such as seen in an image).
The algorithm for doing that is fairly straightforward :

rectangles = []
for m in range(dim1-1):
for n in range(dim2-1):
vertices = []
vertices.append ( (m,n,heights[m,n]))
vertices.append ( (m+1,n,heights[m+1,n]))
vertices.append ( (m+1,n+1,height s[m+1,n+1]))
vertices.append ( (m,n+1,heights[m,n+1]))
rectangles.appe nd( vertices )

However, that dramatically increases the size of your geometry in memory
(you're storing 12 doubles for almost every data-point). It's easier to
use a format where you define vertices and a separate topology (via
indices into the vertices). Same basic approach works there, you just
have to add m+(n*dim1) to get the index for a corner of the quad. There
you're storing only 3 doubles for each vertex.

If you have a format that allows for triangle/quadrilateral strips, you
can make the rendering far more efficient using them. There you render
(m,n), (m+1,n), (m+1,n+1), (m,n+1), (m+1,n+2), (m,n+2), (m+1,n+3),...
That reduces the size of your index-set as well, but most of the speedup
is going to come from having fewer primitive operations.

Good luck,
Mike

PhilC wrote:
Thanks Richard,

I was actually thinking of faces but an aerial photograph would be
similar. I'll check through those links and see if they help.

Again my appreciation for your reply.

PhilC


--
_______________ _______________ _______________ ___
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
21504
by: delerious | last post by:
I need to determine an element's width and height in pixels (not including padding, border, and margin) in Javascript. The element will not have width or height styles specified. In Mozilla, I know I can use document.defaultView.getComputedStyle() to do this. IE does not support document.defaultView.getComputedStyle(). It supports...
17
7239
by: Torbjørn Pettersen | last post by:
I've got a table where I want some of the cells to use a background image. The cells have variable height, so I am using an image with a rather small height to fill up the background of the cells, thus making I look like one high image in there. When validating it, I get this error: there is no attribute "BACKGROUND" The validators also...
6
2246
by: Robert Lapes | last post by:
I'm just getting into using CSS and I'm having a problem getting Opera to display a Navigation Bar in the same way as IE6. Can someone please point me in the right direction? The site I'm working on can be seen at http://www.budbury.co.uk/itel/index.htm In Opera 6.05 the Nav Bar image floats behind the content division that follows the...
6
8305
by: Stanimir Stamenkov | last post by:
May be a FAQ but I haven't found a suitable solution yet. The general (presentational) structure of a document I'm describing is: Header ------- Content ------- Footer I want to make the "Content" part to fill the available height of
12
6710
by: Stanimir Stamenkov | last post by:
Here are two cases regarding inline-level elements' line-height, padding and background, which I doesn't understand: <div style="background: black; color: white; line-height: 1.5"> <span>Abc</span> <span style="background: white; color: black; line-height: 3">Abc</span> <span>Abc</span> </div>
3
4286
by: Raghavendra | last post by:
Hi All, Here is my code. ------------------------------------------- <div style="height:100%"> <BODY> sample text spanning about 30 lines </BODY> </div> <table><tr><td>footer</td></tr></table>
3
5519
by: TheXenocide | last post by:
Hello, First and foremost I'll describe a bit about my problem: I'm trying to make a site layout using ASP.NET 2.0 in Visual Studio .NET 2005 Beta 2. The site is a table based layout that is supposed to consume the entire viewing area (oldschool HTML was <table width="100%" height="100%">). This is not as easy as it sounds using the...
6
6010
by: jslaybaugh | last post by:
I'm working on an ASP.NET 2.0 application and am having trouble with a very simple table layout. Using ASP.NET 2.0 it defaults to XHTML 1.0 Transitional and I am trying to comply. However, I cannot seem to get my table to render properly, so I pulled out all the server controls and just made a very simple HTML only page and am having the...
2
3985
by: laszlokenez | last post by:
Tested in IE7 and FF2. I have 2 frames, 2 similar tables in them, similar CSS. (I have 1px cellpadding, and 1px border aroud the cells. From one frame I read the offsetHeight of a cell (getElementById), and set the height of the corresponding cell in the other frame. Here: ...
0
7411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5888
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5282
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3394
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3394
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1824
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
643
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.