Problem with loading heightmap

Yeah your right about that… Haha not really sure why I put that there when really I just thinking maybe putting the whole file path would help out. Could probably be something else like you guys were saying before

I’m running into the same issue on Win7x64. Haven’t tried Debian yet. I’m running 1.7.2. This is the only version I have installed, no previous versions have ever been installed.

The image I see is a grey background and a white square in the middle. Strange to say the least.

Well, have you considered that that white square is your untextured, unlit, unscaled terrain?

Have been fighting this issue for 5 hours now :smiley:
On windows, need to convert paths to unix style.


     from panda3d.core import ExecutionEnvironment
     import pathlib
     import os

     # Get $MAIN_DIR from config file.
     base = os.path.dirname(ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR"))

     # Textures is a folder I have created on my machine, not related to panda3d itself
     img = base + os.sep + 'Textures' + os.sep + 'a.png'
     img = pathlib.PurePosixPath(pathlib.Path(img))
     self.terrain.setHeightfield(img)

As an addendum to that, I believe that you can also simply keep your file-paths in Unix-format, and then use Panda’s Filename object to convert them to the format used by the current operating system. Something like this:

# In your "import" statements:
from panda3d.core import Filename

# Elsewhere...
myFilePath = "myFolder/data/aFile.txt"
filename = Filename(myFilePath)
with open(filename.toOsSpecific(), "r") as f:
    # Read from the file...

I think you talked about something completely different here ^^" , since we do not want to use path format used by windows because panda3d uses unix path format.

Ah, you’re right–sorry, I’m tired today! ^^;

That said, I think that you can do much of what you’re doing with Filename, too–for example, it has the “fromOsSpecific” static-method, which allows you to convert a filename from the format of the current OS to Panda’s format.

Something like this:

base = ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR")
filename = Filename(base + "/Textures/a.png")
self.terrain.setHeightfield(filename)

(I’m not sure of what format “getEnvironmentVariable” returns its directory in–that is, whether it always uses Panda’s format, or the format of the current OS. If the latter, you would presumably want to run “base” through “Filename.fromOsSpecific”, too.)

Bingo ! Works perfectly !

Thanks :smiley:

My pleasure–I’m glad if I helped! :slight_smile: