GetSurface trouble!!

Blitz3D Forums/Blitz3D Programming/GetSurface trouble!!

PsychicParrot(Posted 2004) [#1]
Hellooo! :D

I seem to be having Getsurface problems ... it's like this:

I have a model with two materials/brushes called Material01 and Material02. I change the texture of Material02 with:

o11=GetSurface(p\model,1)
x11=GetSurfaceBrush(o11)
BrushTexture(x11,face)

PaintSurface o11,x11
FreeBrush x11
FreeTexture face

But sometimes, this textures Material01 instead! Not content with that, it seems to vary between machines too!

I'm guessing then, that the getsurface doesn't actually work in any particular heirarchy so I guess I need to check the name of the texture to make sure that it's the right one instead .. BUT .. TextureName returns a filepath, doesn't it? Does that mean I have to parse it to get just the filename of the texture (without the path)?? If so, is this the only way to texture individual materials/brushes??

It's all a bit nasty, if you ask me!

Oops .. forgot to mention this is on an animmesh loaded b3d model :)

Thanks in advance for any help.


TeraBit(Posted 2004) [#2]
I think that surfaces are loaded in an arbitrary order. As you say, the best way is to check the name.

Function fname$(wha$)
    For t=Len(wha$) To 1 Step -1
        If Mid$(wha$,t,1)="\" Then
            Return Right$(wha$,Len(wha$)-t)
        EndIf
    Next
    Return wha$
End Function


That'll return the filename only.


PsychicParrot(Posted 2004) [#3]
Thanks, Lee .. kind of a kludge, but if it works ... hey who am I to argue? ;)


AntonyWells(Posted 2004) [#4]
-Edit- Ah, you got it working. Right. Move along, nothing to see here.

Surfaces are reserved to a parent mesh.

Use loadMesh instead of loadanim mesh and they're certain to all be within one mesh.

Blitz's surface/texture feedback is pretty limited, in that it returns you copies(Except for surfaces), so actually editing them won't do much.

But if you're directing applying something to a surface, it'll work.

Remember it goes from 0 to surfaceCount-1, not 1 to surface Count.

i.e

for j=0 to countSurfaces(myEntity)-1
next

dunno if that's any help...


PsychicParrot(Posted 2004) [#5]
Thanks, Otacon .. we have a kludge, but I just kind of wished it was different thats all ;)

I didn't know that it was from 0 to surfaceCount-1, though, since in the Blitz help for GetSurface it reads:

"Index should be in the range 1...CountSurfaces( mesh ), inclusive."

Is that a mistake, then? Urks!

:D


simonh(Posted 2004) [#6]
Vertices and triangles are indexed from 0 to CountVertices/Triangles()-1, surfaces from 1 to CountSurfaces()


AntonyWells(Posted 2004) [#7]
Simon's clearly lying.

(Checks docs)

Simon's clearly a time traveling punk.

But he's right, I was thinking of vivid..


PsychicParrot(Posted 2004) [#8]
Thanks people for clearing that for me :)