Problems with Texture

Started by Uija, July 24, 2005, 01:28:10 PM

Previous topic - Next topic

Uija

I did the following:

tex = TextureManager.getInstance();
Texture grass = new Texture( "grass2.png");
tex.addTexture( "grass", grass);

terra = Loader.loadASC( "terra02.asc", 1, false);
terra.setTexture( "grass");


The result can be found here
I have tried different sized of textures and got no result. Has that something to do with the U and V Data in the ASC file? I still have not found any informations about the fileformat, so I am learning it by try and error ;)

Perhaps anyone of you knows this and can tell me how to fix it ;)[/url][/code]

Uija

I think I got it fixed by setting U and V greater 0 ;)

Hm, I fixed the weird pixelerror, but I got no clue how to show the texture correctly. can anyone post some informations about the U and V Part of the ASC file?

EgonOlsen

u and v are a textures x and y with 0,0 being the upper left corner and 1,1 being the lower right. To map the upper right triangle of a quad with it's corresponding "triangle" of the texture for example, one would use (0,0), (1,0),(1,1)...and (0,0),(0,1),(1,1) for the lower left triangle.

Uija

When I create Terrains with those (most points are descriped 3 times than), I get an error from the loader. File seems to be to big. So I only use 1 Texture for the terrain, write no U and V and look how to create terrains with 3ds ;)

EgonOlsen

ASC is an old 3DS variant and 3DS is limited to 2^16 vertices per object. If you are using more, this may cause trouble. Are you?

Edit: You don't have to use the conversion step to ASC/3DS/whatever as you can create the triangles directly from your PNG and add them to the object "by hand" using addTriangle in Obejct3D.

Uija

Hmm, I should try that. thanks for the idea ;)

Uija

Works great!
Just the OcTrees take forever and the "createTriangleStrips" you are using in the FPS example.
What exactly does it? and is it important for Terrains? ;)

EgonOlsen

Quote from: "Uija"Works great!
Just the OcTrees take forever and the "createTriangleStrips" you are using in the FPS example.
What exactly does it? and is it important for Terrains? ;)
Creating an octree takes it's time...it's already quite optimized. Creating triangle strips isn't...but it may be usefull on the terrain depending on how you are creating it. Google for "triangle strips" to see what they actually are and build your terrain accordingly. jPCT will recognize it and so there should be no need to call createTriangleStrips anymore.