Hi! Can I apply textures to an object only? Mesh ones do'nt show!


Quickie chaps! Been texturing stuff, had problems. I’m getting au fait with Blenders material system. Seems when I make a a material and have the OB button pressed not the ME button pressed any textures I apply to models can be extraced from a script in python. However, if I assign a set of vertices to a mesh group and apply a texture, it does render in the render view but I can never get access to the uv data in python. It always says the face has no texture data.

It is a very weird problem. If I do something like:

cube = bpy.data.objects[“Cube”]
mesh = cube.getData(mesh=1)
for f in mesh.faces: print f.uv

Then sometimes it will show data. On the occasions where it does show data if I go in through a similar fashion:

cube = bpy.data.meshes[“Cube”]
mesh = cube.getData(mesh=1)
for f in mesh.faces: print f.uv

It won’t show any data?? Can someone try and explain to me what’s going on here? How is an object different to a mesh? And why does it show on some occasions and not others? This is the most bizarre material system I have ever used in my life.

Any ideas? Thanks.

This problem was solved when I used a UV map. UV data shows up fine now in python. I think I need to find the cause of this though, because it’s not much help to anyone else searching through here in the future to just see that I solved it and that was that. I’ll try and find out what the key difference is/was and report it back.

Can’t help much with the rest, but from my experience, Object and Mesh are two different types of datablock. An Object need not be a Mesh, but Objects that are polygon meshes have the Mesh datablock as part of their Object datablock – in other words, there is a hierarchy of sorts, with some kinds of datablock being linked to other types in order to create the full range of an Object’s characteristics. Object is kind of at the “top” of that hierarchy – actually it’s also a lot like a network of linkages, but in most cases Object is linked to rather than from. Hope that’s not too confusing.

This means that Objects can be Lamps, Armatures, Empties (a special case, though), Cameras, and lots of other “things” in Blender. Object-level transforms are those that take place in the Global world space – primarily Translation, Rotation and Scale. Other transforms (like the Lens property of a Camera) are not Object-level but instead are manipulated within a particular kind of datablock – Objects can be linked to a Camera datablock that has all the defining parameters of a camera, the ones you see in the Camera panel.

Materials are a datablock that afaik is linked to the Mesh datablock, not the Object – switch the Mesh datablock that’s linked to an Object and it not only changes the vertices, edges and faces, but also all the Materials assigned to them. Textures are part of the Materials datablock, so they would also be linked to the Mesh datablock.

Linked datablocks form the underlying structures of most everything in Blender – Actions, IPO curve sets, NLA strips, Lamps, the whole shebang is a potpourri of linked datablocks. This is extremely flexible in that an Object can change its characteristics very quickly based on assigning new links to different datablocks.

There are limitations on making & switching links of course – for example I don’t think you can change a Mesh Object into a Camera Object – and certain datablocks are linkable only to certain types of Objects (e.g., can’t give a Camera a Mesh property), but that’s pretty much just common sense.

Anyone with more in-depth savvy on this subject, please jump in!

That’s really, really good information. Thank you so much. I will have to read through that and properly digest it as soon as I can. Right now I’m locked in a death struggle (not really) with sorting a mesh file into a by-material layout so I can render faces per texture in DX9 so I don’t have to load and reload textures multiple times when going through a mutli-material mesh. Also converting it to binary so it goes very fast. All well and good but it isn’t leaving much time for anything else! I’ll read through your great post as soon as I can ;o)