Mesh Textureing problem

Blitz3D Forums/Blitz3D Beginners Area/Mesh Textureing problem

Mattizzle(Posted 2006) [#1]
I have made a fairly simple terrain in FreeWorld3D. I exported the terrain to ".obj" and exported a colapsed texture of all the texture layers to the same directory. I then imported the ".obj" terrain mesh into Blender. I then corrected the rotation that occurs (Gee wiz there really should be a standard for the Z axis being UP...my opinion anyway...^^), I used some modifiers to optimize the poly count (I got it down about 50% without any noticable change in shape "woo hoo!" :-P ) and then I exported the ".obj" to ".3ds".

So then to try my hand at viewing my first non-mess-around terrain in Blitz3D I wrote a simple program to move around and view the terrain. Here's my problem: using PaintBrush to texture the ".3ds" with a single 1024 x 1024 JPEG image, all that is seen on the mesh is a solid greenish hue. No, I haven't changed the brush's default properties at all (ie. BrushColor, BrushFX, ect.). I have tried ScaleTexture at anything between 1 and 1024.

Am I doing something wrong in Blender?
Am I forgeting something?
Is is even possible to do this?
Is there a better way?

Thanks in advance for any help,
Mattizzle


b32(Posted 2006) [#2]
Maybe the TexCoords/UV mapping is lost somehow ?


Mattizzle(Posted 2006) [#3]
Well since it's just a terrain in mesh form, I asumed it would just slap the texture on the top, all the way across. Do I need to actually UV map it in Blender? And if I had to do that, then I how would I be able to change the texture in real-time from blitz?


b32(Posted 2006) [#4]
If it is a mesh terrain, it needs texture coordinates. You can set them by using the VertexTexCoordinates command and read them using VertexU and VertexV. If all texcoordinates are zero, only the top-left pixel of the texture is used.
I think this is the easiest form of mapping a terrain. Only the X and Z are taken in account, the Y is ignored:



Mattizzle(Posted 2006) [#5]
Rats... It still only displays a single green color. When the same texture is applied to a "cube = CreateCube()" entity, it displays perfectly (without scaleing it) with the whole texture applied to each face of the cube. So... is it blenders fault?


b32(Posted 2006) [#6]
That is strange, maybe you could post the model ?


Mattizzle(Posted 2006) [#7]
Sure!

This is my band's website and I've just added a folder and uploaded the 3 files I'm using: www.thewyldturkees.com/game
For me, with FireFox, I just right clicked the links and selected "save link as" and then it downloaded the file.

Also, I just tried something, when I import the ".3ds" mesh back into to blender it gives me a "object 'Terrain_Mesh' not found" ... woa the file name is 'terra_mesh.3ds' ...how does it know to add "in" to "terra"... WEIRD!


b32(Posted 2006) [#8]
Ah, it was the function SetUVMap, it should have been CountVertices(surf) instead of CountVertices(mesh).
BTW, in your main loop, there is a 'collisions' command, it should be placed before the loop.



Mattizzle(Posted 2006) [#9]
You are a genius! The only problem now is getting it to scale and rotate to it's correct position... did you get it correct already?


b32(Posted 2006) [#10]
Thanks! To scale the texture correctly, the function's FOR..NEXT loop has to be split into two loops. Then you can use the first loop for determining the minimal and maximum VertexX and VertexZ.
Then, in a second loop, you can apply the TexCoords with this function:
uu# = (VertexX(surf, j) - min_x) / (max_x - min_x)
vv# = (VertexZ(surf, j) - min_z) / (max_z - min_z)
VertexTexCoords surf, i, uu, vv

And, I don't know, is it necessary to rotate the texture ? Then maybe you can rotate it in paint/photoshop.
However, I still think it is better to find out when the texture coordinates were lost during the conversion process. I don't expect a mesh terrain to be exported without uv mapping, so I think it is the conversion from .obj to .3ds in Blender. I never used Blender, but I think there must be a function related to uv coordinates. In 3ds max, don't remember which version, you had to enable 'generate uv coordinates' before creating any meshes. So I can imagine a similair function in Blender.
Maybe it is part of the export options ?


Stevie G(Posted 2006) [#11]
No need for the first loop. Use Meshwidth and MeshDepth.

MW# = Meshwidth( mesh )
MD# = Meshdepth( mesh )

... assuming the mesh is centered

uu# = ( Vertexx( surf, j ) + MW*.5 ) / MW
vv# = ( Vertexz( surf, j ) + MD * .5 ) / MD

... assuming it's not

uu# = Vertexx( surf, j ) / MW
vv# = Vertexz( surf, j ) / MD

Stevie


Mattizzle(Posted 2006) [#12]
Perhaps the texture coords are getting erased when i use Blender's "Decimate" modifier to optimize the poly count...


Mattizzle(Posted 2006) [#13]
Ok, the Decimate modifier in Blender does indeed kill the UVs so without decimating, Blender renders the texture on the imported ".obj" correctly. However, the ".3ds" export from blender can nolonger be read by Blitz for some reason... I guess this is now a Blender problem... any ideas?


b32(Posted 2006) [#14]
No idea, are there any export settings ? If nothing works, try re-installing the application.


Mustang(Posted 2006) [#15]
Umm... you do know that .3DS format is from stone-age and everyone who still uses it today is asking for trouble? :) I bet that you don't remember for example that .3DS supports only 8+3 characters in a filename, so "HugeCockpitPanel.jpg" is shortened to-- well, something "totally different" like Monty Python would say. Filename mismatch would explain why .OBJ works but .3DS doesn't if it's texture problem.


Mattizzle(Posted 2006) [#16]
What would you recomend as a file type to use in this case then?


b32(Posted 2006) [#17]
B3D is the recommended format for Blitz3D. There is also support for .X and .MD2


Mustang(Posted 2006) [#18]
.MD2 goes also to the same category as .3DS - ie it's old and crappy, don't use it for anything. .MD2 is a huge memory hog and because of the format specs for example vertices wobble noticeable... and it was never meant for >1K meshes anyway. And they are "good" for characters only, do not use them for terrains.

For your everyday basic meshes I'd use .B3D (first choice) or .X (notice that Blitz supports only DX7 .X, meaning no bones).