Single surface systems

Blitz3D Forums/Blitz3D Programming/Single surface systems

Lilprog(Posted 2004) [#1]
Sorry for being the newbie that asks alot of questions, alot of people suggested i use a single surface system for my crowds in my baseball game, and I hvent found much documentation on it, can anyone give a basic explanation of how it works?


sswift(Posted 2004) [#2]
Make a mesh.

Make a surface in the mesh.

Add polygons to that surface. For example, quads with a masked image on them that represents a member of the crowd.

At runtime, if desired, move selected vertices around to make the quads move about within the mesh, which makes the quads appear to move about within the world as if they are individual entities.

Optionally, clear and re-add triangles in mesh each frame after sorting them by distance. Only neccessary if using alpha mapping rather than masking, and not neccessary for a crowd that doesn't move at all if the camera stays in the field with the crowd surroudning it and you have ordered the polygons right in the first place. (Farthest from center of field first.)


Lilprog(Posted 2004) [#3]
Then you are duplicating the entity? or the mesh? Im just curious how you are multiplying this in order to get fast speeds. Im presuming that a textured quad renders faster than a sprite even though in theory they are the same thing?


Matty(Posted 2004) [#4]
You only have 1 entity and 1 mesh in a single surface system. Say you wanted 100 people in the crowd with each person represented by a quad. You would do the following:

Create a mesh.
Create a surface for the mesh with the appropriate brush which contains your picture of the person/people in the crowd.

For each person you want to make:
Add 4 vertices positioned so they form a rectangular shape, create triangles joining those 4 vertices so that they form a quad.

Keep adding vertices and making triangles until you have as many quads as you want.

They will all share the same surface and be part of the same mesh/entity.

This means though that you cannot use the normal positionentity/moventity commands as if you try and either move the entity or mesh you will move ALL the quads. You need some system of moving individual vertices around the world you create. Also, if you want to change the picture that is on the quad then you will need to alter the uv coordinates of the vertices that make up that quad so that a different region of your brush is displayed on that quad.


Rhyolite(Posted 2004) [#5]
I found looking at some of the single surface code in the archives very useful as an aid to understanding. Some of the 'particle systems' and '2D text in 3D' use single surface, but there are others too.

In case you are unaware, the more surfaces you have in your application, the slower it will run. So, without going to extremes, its always best to minimise your surfaces. Coding single surface is more difficult (at least initialy) and goes against what feels to be the 'natural' way of doing things!

Rhy Out


sswift(Posted 2004) [#6]
Also keep in mind that if you move any vertex that all vertices have to be updated on the video card. This limits the number of quads you can get away with using. I think I've seen some folks do somehting like 10K particles at once, each a quad, but that's more than you should use, I think the FPS was like 20 at that point.

And of course you can use additional surfaces or entities if you need different single suprface groups to use different apprance properties that you cannot achieve through vertex manipulation.