Different textures on different faces?

Blitz3D Forums/Blitz3D Beginners Area/Different textures on different faces?

AJirenius(Posted 2006) [#1]
I've set up my *.3ds object with different materialID's on different faces that allows me to put one texture on some polygons (faces) and another texture on the other polygons.

Now I don't find a way to apply several textures like this on one mesh in Blitz3D.. Is there a way?

Thanks for help


Dreamora(Posted 2006) [#2]
FindSurface and Brush commands should help you there.


Yeshu777(Posted 2006) [#3]
Yes.

Have a look at CreateBrush and PaintSurface commands in the docs.

Let me know if you need sampler code to get you going.


Rook Zimbabwe(Posted 2006) [#4]
This is slightly off subject but if you were creating your own models in a 3d modeling program you culd also assign textures to each face in many of them and just make sure that the texture files are included with the model... This is a simplification of what you would probably want to do if you were writing a game though,,,


AJirenius(Posted 2006) [#5]
Rook:
Thats what Ive done. I've assigned textures (via Material ID's) to different faces but using 3dsMAX6 I export the file as a 3ds the texture doesnt follow the mesh and there is no way Blitz can recognize the Materials ID's. Should I export the mesh in another format or must I go through the whole meshsurface and paint them manually in Blitz3d?

Thanks for all help though at least I have one solution if there is no better way


Dreamora(Posted 2006) [#6]
You are most likely doing Error 1 on 3DS:

3DS has Dos 8.3 naming convention -> 8 letters for name, 3 for expansion

If that isn't the problem, then you forgot to move the textures in the same folder as the 3DS or forgot to bake / fix the UVW modifier before exporting which means that the texture coordinates were never exported at all.

And material IDs have no relevance outside 3DS Max. Within BM they are only surfaces to be painted by brushes no mather what format they come from.


AJirenius(Posted 2006) [#7]
Dreamora: I don't think you understood the problem.

The 3ds file is exported correctly. Naming is correct (less than 9 chars) and if I try to open the 3ds file in a new scene the texture coordinates and the textures is working correctly.

The thing is that Im using several textures on the mesh and 3ds does contain the information about which faces are using which texture so in other engines Ive been able to open the mesh correctly using several textures on one mesh.
When I open the 3ds mesh in Blitz3D I just apply one texture on the mesh using: Entitytexture Mesh,Texture
But I just wondered if there is a fast way to apply all the textures correctly on the mesh I created without having to trace every surface and paint them again (cause it really means plenty of work).

Still thank you all for the great community support and hope you/I can find a nice (and fast) solution for this.

Edit: Say that I cannot do anything other than split my mesh up again into different surfaces (as Blitz doesnt recognize those 3ds data already) How do I do this. I can create a surface yes but how do I choose which triangles should becontained by the specific surface. I believe AddVertices and AddTriangle just adds new elements to the surface/mesh and not chooses the ones already there?

Please help a total newbie :D


AJirenius(Posted 2006) [#8]
Ok, Im stupid

You tried to tell me and I just didnt listen
As I said the MaterialID data is contained in the *.3ds and the UVW is correctly exported as well with all the coordinates AND the texture data.

I just had to place the textures in the same folder and not messing with the Entitytexture Mesh,Texture as that only screwed up the old texturedata somehow

So problem solved! Thank you!


Dreamora(Posted 2006) [#9]
If you textured your 3DS correctly, you don't need to use entitytexture as the texture is already present on the object.
If it isn't then it is either exported incorrectly or the texture is not in the same directory as the mesh. (try loadanimmesh to make sure it isn't some strange behavior from a different thing)

If it isn't on it and you want to manually texture it, you must use the paintbrush approach to texture each surface manually (entitytexture does not do that, it textures the whole mesh).

So it sounds more like you are not understanding your problem correctly at the moment if you think you need to use entity texture to texture a pretextured object :-)

On the AddVertex thing: You can't change the surface of a vertex. And it is not needed anyway. Any change on a surface means full reupload of the whole surface to graphic card anyway.
If you want to see whats within a surface, you can use CountTriangles and TriangleVertex and the VerteX / Y / Z commands


b32(Posted 2006) [#10]
As mentioned, maybe it is possible to change the textures using this:
brush = LoadBrush("filename.jpg")
surf = GetSurface(mesh, 1) ; <- 1..CountSurfaces(mesh)
PaintSurface brush, surf

instead of EntityTexture?


AJirenius(Posted 2006) [#11]
bram32: As the mesh is loaded as only 1 surface at start, wouldnt that just make another surface covering the whole mesh?

Think of it like this. eg. I've done a soldier that I want to have shining armour on. Now after I've loaded it, how do I select the polygons on the body that are supposed to be the shining armour and then can apply a brush with reflection on it.

My problem is however solved but I would like to know if that's possible within Blitz3D.

(Even if I have exported the 3ds with different texture on it and it works now it still says that I have only one surface by the way.)


b32(Posted 2006) [#12]
Erm, yes you are right. When a mesh has only one surface, it will only paint the entire surface this way. Do I understand correctly that there are multiple textures on the mesh but they are all applied to the same surface ?
Then you could try and use the index parameter of EntityTexture: ie. EntityTexture mesh, tex, 0, 1
The 4th number is the texture layer. It can be in the range 0-7.


AJirenius(Posted 2006) [#13]
No. They are to be applied on different polygons (surfaces). The "reflection texture" are only to be applied on the certain "armour" polygons. Thats why I need to divide the mesh into several surfaces so I can apply the brush on just some special polygons.
Now this is probably pretty easy if you want to apply 6 different textures on one cube (1 on each side) but what about complex meshes like the knight in shining armour.

As I said, the UVW-data including WHICH texture to be applied where is included in the 3ds-format but can I use that data in Blitz3d???


Dreamora(Posted 2006) [#14]
UVW has nothing to do with which texture is on which polygon

UVW data apply to multi texturing (multiple textures on the same surface).

And 3DS does not support multi UV as X does not. Only B3D supports it and only 2UV Sets.


Perhaps we restart the thread and you clearly specify what you have and what you want to achieve as you mix all different things about 3D meshes, surfaces etc


b32(Posted 2006) [#15]
(edit)Yes, that is a good idea(/edit)
org:
There is a VertexW command, to complete the VertexU and VertexV command. I think it should be possible to use the data in the file. And it would make sense trying that before writing a program with which you can paint to triangles.
You say the model loads correctly now, right ? So both the textures applied to the model are showing in the right place ? If that is the case, blitz must have loaded the data somehow. And there is only one surface ? Maybe the exporter merged the two textures into one bigger texture ? Or the model has multiple texture layers applied to it ?
I'm conviced that there is a solution for this. Maybe you could post a .3ds testing model ?
If you think it is the .3ds format that causes the trouble: in 3dsmax, you could export .x files using the panda exporter and i believe the b3d pipeline to export .b3d files.