Finding a "child' entity in a mesh.
Blitz3D Forums/Blitz3D Beginners Area/Finding a "child' entity in a mesh.
| ||
I'm trying to add character costumization in my game and I need to learn how to do one thing. This example is kinda a bad anology for character costumization, but it explains my problem better. Let's say I have a large terrain, and in the terrain is a river mesh. I want to somehow take the river mesh alone and add a water texture on it and make the texture scroll to look like an actual running river The reason that I want to learn this is so I can change the texture on my characters clothing, but for each pair of clothing indivisualy (You can change and choose the texture of your shirt, pants, sleeves etc...) Sorry if my anology was confusing, but how can I achieve this? |
| ||
Take a look at the docs, look for FindChild and GetChild. That should help you :) |
| ||
SLotman I took a look at it and it was very vaige. Could someone explain it? |
| ||
However you try this, You'd need some way of identifying the different child meshes, so that you know whuich one you're actually referring to. EntityName may be useful for this. Something Very simple: NakedMesh (Parent) EntityName Childw,"Shirt" EntityName Childx,"Trousers" EntityName Childy,"Hat" EntityName Childz,"Boots" So when you come to iterate through the children: For n=1 To CountChildren(NakedMesh) CurrentChild=GetChild(NakedMesh,n) Clothing$=EntityName(CurrentChild) Select (Clothing$) Case "Shirt": ;// CurrentChild is "Shirt" Case "Trousers": ;// CurrentChild is "Trousers" Case "Hat": ;// CurrentChild is "Hat" Case "Boots": ;// CurrentChild is "Boots" Default: ;//CurrentChild is not clothing End Select Next |
| ||
Malice To be completely and uttely honest, I'm still having trouble understanding it. The first top example makes absolutly no sense, since it has too many parimeters, and for the bottom example, I still don't see how I can take a case and treat it as a seperate entity and texture it. I hope I dont sound whiny or bit*hy, since you are helping me, but could you explain whats going on in the code better please? |
| ||
So, I'm assuming that you have one mesh for your character, and you're just wanting to change the colors, so to speak, of the outfit that the character is wearing, right? The reason why I ask is because I'm not sure if I follow your scenario. If the character is just a single mesh, there are some ways separating the clothing from the character, but if your character is made up of multiple meshes (e.g. you load your character, and then later load the boots, and then the shirt, and so on...), then you can just manipulate the individual meshes by loading different textures and applying them to the clothing. You probably already knew that, so I guess my question is: what exactly is it you're trying to do? Are the character and the outfits loaded in a package, or are they loaded separately? |
| ||
Hey TaGames, sorry, perhaps I misjudged your level of knowledge with regards to Blitz3D. Are you loading the character Mesh as a whole? I had assumed you had a separate mesh for ther character body and then the children meshes to represent the clothing worn. If the entire character & clothing is actually all one Mesh, then perhaps it's possible to distinguish between the clothing by making diffrerent surfaces. Each surface then, can be PAINTED wioth a different Brush (i.e. given its own texture) |
| ||
It's easy: when you create your model, in your 3D app you name the different parts. For example, the polygons that make up the pants, you name it "pants". Then, on b3d, you load the model with mesh=loadanimmesh(file) - this is important, loadmesh won't work. Finally, you use pants = FindChild(mesh, "pants") and you'll have an entity that you can paint, texture and everything like any other one. |
| ||
Malice Actually, thats what I forgot to mention. The mesh is just one peice whole, and I want to find and pick out peices of it, such as the torso, so I can apply different textures to it. Does an animated mesh make any difference? |