texture problem

i have a probleme with texturing my map.
When i texture it my map use only the red square on this picture.

How can i so for it to use the entire texture ?
If you can help me ^^

yes i read it, without success^^
sorry for my english, i’ll try to be more clear. Here is my map :

The texture on this world map, provide from a 2048*2048 jpeg. But when panda texturing the map, he use only a bottom-left square of the texture image. He scale it and apply it to the whole map. If i load another map into my scene, place it near the first one and texture it with the same texture, panda will use another square (near the first one) of the texture image to texture the second map.
What i want is to panda to use the whole texture file for each map i load in the world.
The maps are untextured when i load them.
Thx for helping.
Hope its better explain ^^

Well… it’s still not quite clear. The screenshot looks good. What’s wrong there? Is it the ground? The plants? The trees? Ralph? Do you want your texture to be stretched to the object? Or tiled?
It might be useful for us if you talked in your native language, indeed. (French?) There might be someone here who understands it.

Have you read the entire Texturing section at the Manual?

yea i read it.
The texture problem is on the ground, he use just a part of a texture file and apply it to the whole map. And i want panda to use the entire texture file on the entire map
Consider that this is my texture file :

Texture.jpg :

[color=red]red : use by panda for texturing the ground
white : don’t use by panda for texturing the ground

The red square is the only part of the texture that panda use for texturing my entire ground. Just this red square is used for texturing the whole ground.
I want panda to use all the texture on my ground, the white part too.

En francais, panda applique une petite partie de ma texture (un carré en bas a gauche) qu’il étire sur toute la map, alors que je voudrais qu’il utilise toute la texure.

Hope to be more clear…

Okay, i think i get it now.
You have a large texture file and only part of it gets applied to the 3d model. Right?

I think you UV-mapped it wrong. What 3d program do you use? Blender? Or didn’t you use UV-mapping? How did you apply the texture to the object?

yes that’s it ^^
It’s a map made from a png image by a panda programs.
I applied the texture like that :

tex = loader.loadTexture(MYDIR+"/text3.JPG")		   # charge la texture de la map (PROVISOIRE)
		self.environ = loader.loadModel(MYDIR+"/Maps/Map3.png.bam")		   # charge la map (PROVISOIRE)
		self.environ.setHpr(0,0,0)			# regle l'orientation de la map (RPOVISOIRE)
		self.environ.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition)		   # applique la texture a la map (PROVISOIRE)

I tried a lot of different maners for applied the texture bu ti get always the same result… if you have a tips…

I think I found a possible problem. It is the following line:

self.environ.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition)

This line generates UV coordinates for your model. And it does it in the following way: every vertex of your mesh is assigned the world position coordinates of the vertex (x,y,z) as (u,v,w) texture coordinates.

So if your terrain starts at coordinates (x=0,y=0) and ends at coordinates (x=100,y=100) then the uv coordinates ar (u=0,v=0) for the start and (u=100,v=100) for the end. The lower left edge of the texture is (u=0,v=0) and the upper right edge of the texture is (u=1,v=1), so the whole texture is applied only to a very small part of the terrain mesh, where uv coordinates are in the range [0…1]. The texture is repeated 100 times in every direction.

The other way round, if your mesh is very small in world space, say (x=0,y=0) to (x=0.2,y=0.2), then what you have described would happen. Only part of the texture is applied, since uv coordinates are in the range [0…0.2].

For more information on automatic texture creation have a look at this manual page:

I don’t know how you create your model, but since you simply load it I assume you are using a modeler like Blender. Do you already create UV coordinates in this modeler? One way would be to create them ahead withing the range [0…1]. Another solution is described at the bottom of the above manual page, using setTexProjector.

Hope this helps

i dont think the problem come form here, i tried a lot of different manners for applying the texture, and its always the same thing.

My model wasn’t created with a modeler, it’s a panda programs who have transformed a png image into a 3D models., and then export it to .egg file.

what program was that?

i dont know, it has been posted on the forum, its a python program.
sounds like terrainodepath or something like that.

I found it
Here is the code i used for making egg files from png images.
If you can found some answers for me ^^

OK, I get it a little bit more now.

So, you have a grayscale heightfield PNG map, you converted it to EGG, then you applied the texture in Panda.
Please read enn0x’s post again. That MUST be the problem.

You can also try to use Panda’s HeightfieldTesselator class instead of the program on the forums.

Hmm… the terrain renderer is no longer available for download, but I found an (old) version on my disk.

Around line 90 to 100 in file “TerrainNodePath.py” is the following code:

        # Load the texture file for the mesh and apply it on the default 
        # TextureStage, the texture needs to be scaled to fit the mesh.
        texture = loader.loadTexture(textureFileName)
        xTexScale = (1.0/scaleValue)/self.heightMap.getXSize()
        yTexScale = (1.0/scaleValue)/self.heightMap.getYSize()

I would start debugging here. Perhaps you did modify the script? When I run the original code (using the original 257x257 heightmap) and print out xTexScale and yTexScale I get these values:

xTexScale = 3.89105058366e-005
yTexScale = 3.89105058366e-005

This is 0.1 * 1/257 !!!
Can it be that your 10% texture usage comes from this scale factor?

Anyway, the script generates UV coordinates, so using automatic UV generation seems unnecessary to me. Perhaps you can find out what the range of the UV coordinates in your model is? This would help with finding the error.


        xTexScale = (1.0/scaleValue)/self.heightMap.getXSize()
        yTexScale = (1.0/scaleValue)/self.heightMap.getYSize() 

I remember modify these lines of the code because there was a division by 0 error or something like that.
I gonna take a look at it.

I modify the 2 lines and its okj its works thanks you !
Hope to no get another divide by 0 error .
thx ^^