b3d surface indexing...

Blitz3D Forums/Blitz3D Programming/b3d surface indexing...

PetBom(Posted 2004) [#1]
Hi

I have a problem with the surface indexing of .b3d objects.

The problem is this:
Imagine a .b3d cube consisting of 6 surfaces. On each of this sides i want to paint a specific bitmap texture. (using PaintSurface) I create a brush and paint the specific surfaces using an index (1-6) and that works fine. But now I also create another object in the scene (any object light, camera, primitive, pivot, it dosent't matter). The result of creating this new object is that the surface indexes of the .b3d cube is all screwed up, i.e the surface that used to have index 4 now has index 6, index 1 is now index 5 and so on...

Has anyone else encountered this? And is there a way around it? (I guess "don't use .b3d files" is one answer but not the one I'm looking for.)

If anyone is interested I can send sample code highlighting the problem (I won't paste it here since you need the bitmaps to see the effect)

Anyone?

Oh yes! I running Blitz3D ver. 1.85

//PetBom


jfk EO-11110(Posted 2004) [#2]
So you load a cube .B3D with 6 surfaces? Couldn't you assign the textures in the modeler app? And if you need to chanche the textures at runtime, you can use the new functions to determine the texture path of a surface. Read this thread about this issue:
http://www.blitzbasic.com/Community/posts.php?topic=29716

btw. as far as I know blitz will not modify the order of the surfaces if the mesh is once loaded, it's only the case that it will be a diffrent order each time you load it, which was a problem until we had the new commands I mentioned (gettexturename etc., see link)


PetBom(Posted 2004) [#3]
I do assign textures in the modelling app (I actually used Maplet to devise my little test) but I need to tweak them in runtime so I need to be able to access the surfaces. But thank's for the answer. Part of asking the question was to make sure that I'm not going insane :). And using your comment and the referered issue, I feel quite certain that I am, in fact, rather sane... You will get different indexes on each load of the object! (Actually you will get the same indexes from the same object on each load, unless you add any other objects. When poking about with the little test i wrote i also noticed that when you compile an .exe you get totally different indexes from the same object)

What I guess I'll do is (as you suggested) assign tempate textures in the modellling app that I will only use to these to identify the surfaces in runtaime and reasign them in code. Should do the trick.

Thanks!

Or mabye someone got another workaround?


jfk EO-11110(Posted 2004) [#4]
If you would load the cube with LoadAnimMesh, all 6 sides would be children and they all could have their own entity name. But it's a bad idea to use AnimMesh only for the sake of this. Unfortunatly Surfaces do not have names (correct me if I'm wrong with this!!!), so when you load them with LoadMesh it isn't that simple. Maybe you could use a non-texture Material in the Modeler and identify the sides by their brush color, however, it's a bit tricky.


PetBom(Posted 2004) [#5]
I actually solved it by using placehoder materials (32x32 bitmaps named surf01.bmp, surf02.bmb...) in the modeller. I load the .b3d file using LoadMesh(). I then loop through all surfaces using GetSurfaceBrush() and then TexttureName(GetBrushTexture()). The returned string (the path to the template texture) is then stripped of all but the numbers, which I can use as and 'index'. Tada! Problem solved.

The actual looping process takes a copuple of milliseconds. But since I only need to do this once, to create TextureBuffers()that I can tweak in realtime, it is not a problem

//PetBom


(tu) sinu(Posted 2004) [#6]
surface index assignment is random!


jfk EO-11110(Posted 2004) [#7]
indeed, sinu, that's actually what we have been talking about.

BT PetBom - you need to free the Brushes CREATED with GetBrush() and the Textures CREATED with GetTexture() because these commands create a recourse-eating copy of the original.


PetBom(Posted 2004) [#8]
jfk - Yep! I know. I free them right after use. I actually copy the texture created to an array of texturebuffers before freeing it. That way I can access each surface texture anytime I like. Note that I do not this looping and looking for textures more than once. I then use my array to tweak the textures

sinu - I sort of figured that out... :) (Se above)

//PetBom