Surface order changing

Blitz3D Forums/Blitz3D Programming/Surface order changing

rgdyman(Posted 2011) [#1]
I have been using blitz3d for a while now. This is my first post.
I have been able to solve or simply find any questions I may of
had in the past by trial and error or finding the solution here
on the forums. This one has got me scratching my head for days
now and could really use some help.

What I have is a mesh with 4 surfaces. The idea is to choose a
surface using the mouse or a ComboBox. The ComboBox has
the name of the surface, ( Head,Body,Legs,Feet )

You select a surface and place a texture on that surface.
It's a simple "Build your own character" .

The system is fully functional. However, the "surfaces" will be in the
proper order only when I am running it from Blitz3D. When I run it
from a .exe the surfaces get all messed up.

The head is now the fee, the feet are now the body......

Is there something I maybe missing when I create the .exe?
Im very confused on this one. Any help would be a life saver,
Thanks in advance.


Yasha(Posted 2011) [#2]
Are you loading the mesh from a file? If so, I believe the loading order may not be guaranteed to stay the same (not sure where I got that idea, but I definitely remember it from somewhere).

Anyway, if you always know that the model will have four surfaces and that they will be one of those listed above, you could simply devise a test to tell which is which and swap them around to the correct variables for the combobox?

If it's important that they're in a particular oder on the mesh, you will have to rebuild the mesh using surface and vertex commands. There's no way to delete a surface once it's added, so you have to create a new mesh and copy them over in the right order instead.


rgdyman(Posted 2011) [#3]
Thanks for the reply.

I am loading form file, "Press the Load button and select the b3d mesh
you want." It loads in.

considering the textures will change constantly , seeking a texture name
to determine the surface wont work.

Using surface and vertex commands to rebuild things. Thats all new to me,.
Im not afraid of seeking the examples and\or forum tips along with some trial and error. ( Tend to learn a lot from that anyway) But, is that the
trail I should follow?

Basically, what Im asking is, In order to guarantee that the "Head" surface remains the "Head" surface for all eternity so when I select
"Head" in the combo box I will be retextureing the "Head"
I have to learn how to use surface and vertex commands to rebuild the
mesh?

All else fails, I could get the folder the tetuxre came from and see if its
"Head" , if so then carry on, if not, then place on the side, Or create a type . Field BodyPart() . field surface.

( the idea just came to me now about the type )
Then when Place Tetxure is pressed , sift the Type and find the proper surface.... Well I know to well how "Ideas" tend to crash and burn
with that old thought of " Hmmmm,, why that happen?"

Again, Thanks for the help and tips.
In advance, thanks for any further tips or a nice nudge in the right direction :)


Kryzon(Posted 2011) [#4]
You can also use the vertex count as a test to find out which surface you're dealing with (I wouldn't like to do this either, but it might be the only reliable way). If only surfaces had a 'Name' property.

You need to make sure each one has a different vertex count, even if you have to add dummy vertices in your modelling software just to make each one different.

Last edited 2011


Yasha(Posted 2011) [#5]
If the only thing that's changing is the texture, it may be worth ignoring the surfaces and just playing with the textures.

The way I would handle this is with a minor design change to use a "texture atlas" instead of multiple textures on multiple surfaces. Simply move the UVs for each current surface into one of the four corners, and make the whole model a single surface. Then give it a texture four times the size, with each of the four textures you want copied into one of the four quadrants of the large "atlas" texture.

You'd probably have to leave it untextured until it got into the program, then create the atlas from the required four smaller textures and apply it to the whole model. Each time you wanted to update a single area, instead of retexturing a surface, you'd just CopyRect the desired source texture to the relevant quadrant of the individual model's atlas (and it will update in real time without needing to EntityTexture again). You'd be able to rely on UV coordinates not to change at runtime, so you could set the selection that way.

... maybe.


rgdyman(Posted 2011) [#6]
hmm, vert count.

100=feet
200=body
600=Head

Interesting idea. Never thought of that.....The meshes are both default. So the vert count will never change.
Rather cool idea Kryzon, Seems fast and to the point. The main issue is
New Meshes. A child for instance. Diff mesh. same surface count.
But vert count is interesting. I'll run with that for now and see how she runs. Naturally, only using the one Male Mesh things will run perfect
for the fact verts have not changed. Hopefully a new idea using this
principle will help me along the way with new Meshes being used,
And YES, a "Name" for each surface be a life saver.


After many hours of aggravation , I finally came here and posted.

Thanks for the ideas, pointers.. Nice to have the help :)

EDIT: Yasha posted as I was slowly typing away....
Yasha, That I will have to read a few times and try things until I grasp it first hand. Seems confusing :P,.,probably isn't once I see it first hand,
but that was one confusing read lol.... But, its stuff like that that gets me to have something to search about. Confusing yes, but Informative.
Thanks! :)

Last edited 2011


Vorderman(Posted 2011) [#7]
Can you use the parts as objects instead of surfaces?

Break the mesh up into seperate objects and name then in whatever program you built it in, then export to B3D and load into Blitz as an AnimMesh, then locate the various objects using their names and the FindChild command.

You can then just manipulate the single surfaces on each of the different objects rather than 4 surfaces on 1 object.

Last edited 2011


Yasha(Posted 2011) [#8]
Sorry my suggestion wasn't clear. Maybe a diagram...



It requires doing a few things differently in the modeller: don't put a texture on the model there, and scale each of the surfaces' UVs to 1/4 of the texture map. Then move each one to their respective quarter of the map. Add them all to the same surface and export.

Once in B3D, make a new texture with CreateTexture that's the size of all four subtextures combined, and apply it to the model. Now all you need to do is copy the source texture you want for a given body part to the right quarter of the model's view texture, using CopyRect.

The important point being that since you moved the UVs for each body part yourself, you know for certain which quarter they're in, and you don't have to mess about with surfaces or brushes at all, which is good for efficiency (if efficiency is a concern).

For the record I actually think Vorderman's idea is better, but I just wanted to clear up the explanation.


rgdyman(Posted 2011) [#9]
Yasha, After reading your post a couple times it did come clear. The diagram summed it up, Thanks!.

I went ahead and tried the vert counting, Things ran perfect.
Naturally, using any other mesh will result in surface selection
changing if the verts do not match he coded counts.... Works
but a tad limiting.


I need to have my hand at the UV'ing method. Makes sense so its
one foot forward.

I did code in surface selection using the mouse. To my surprise,
I can select each surface . However, you cant "see" what selection
was made. I tried to set entityfx to 2 and have the vert color change to
red in hopes to highlight the surface chosen. The entire mesh turned red so it appears I simply goofed the entire code up...
Of course when I was typing this I had the felling the entire time that it
cant be this easy... :)

If MeshEN > 0 And surfacechosen > 0 
		
        EntityFX(MeshEN,2)
		
	verts=CountVertices surfacechosen
		
	For v = 1 To verts
		VertexColor surfacechosen,v,255,0,0
	Next 
EndIf 


Is there a way to toggle each surface coloring to highlight the selection?
Thanks , yet again :)

Last edited 2011


Warner(Posted 2011) [#10]
Try setting all vertices on the mesh:

Else, beside 'EntityFX' there is also 'BrushFX'. If each surface has its own brush attached (PaintSurface),
you can use BrushFX to toggle vertex colors mode for each individual surface.

Last edited 2011


rgdyman(Posted 2011) [#11]
Warner,

I cant believe just did what I hate most and did a copy/paste job,
But that little snip of code works perfect!

I cant thank you enough!

Now I can just highlight the surface selected. No need for the combo box
or any of that... This is GREAT!

Thanks to everyone that jumped in to help me out. I wish I would of came here a while back for trouble I have had. I think I will back the project up and have my hand at the other ideas anyway. Just to get a feel for the different ways I could of achieved this whole thing. Worst case I might learn a little something new , lol.

Thanks again everyone!
rgdyman