Planes, Meshes and Surfaces

Blitz3D Forums/Blitz3D Beginners Area/Planes, Meshes and Surfaces

KingLestat(Posted 2011) [#1]
Another newbie question for sure

To me these 3 seem the same, yet I am sure they each have their purpose; The help explains each but there is no explanation where each is needed and for what. Can somebody point me in the right direction?

Thanks


Yasha(Posted 2011) [#2]
They're actually quite separate:

A surface is (as close as B3D will let you get to) a DirectX structure. It is a list of vertices, the triangles formed by connecting vertices, and a few other things such as the texture applied and so on. This is a very low-level structure that maps closely to how the graphics layer actually stores 3D data (or at least how it used to back in 2001... technology's changed a bit). You shouldn't need to think about surfaces in detail unless you're doing a lot of low-level mesh manipulation, positioning vertices by hand in-program (say you'd done something advanced like write a particle engine or your own animation system). The surface is the basic building block of meshes, and a mesh can, if you need, be constructed from more than one. (You can't get at the surface info for non-mesh objects such as BSPs or MD2s or terrains.)

You do need to be dimly aware of surfaces' existence, however; because they're a basic unit used by the graphics layer, how many surfaces you have on screen will directly impact performance (basically, surfaces are uploaded to the graphics card in a single block; doesn't matter how many polygons you have but how many times it has to open the channel to send this block). This is why there is a distinct difference between functions like CopyEntity and CopyMesh.

Meshes are a Blitz abstraction that let you manipulate things in terms of the Entity system. As you know by now, entities have a Position, Rotation, Scale, Colour, Alpha and other such attributes. A mesh is more or less a pivot plus surfaces (don't try to construct them that way!) and other visually-relevant attributes such as colour; i.e. a Mesh is just a type of Entity that happens to have the 3D visual stuff attached to it.

A plane is something else entirely; it's an entity that dynamically constructs a surface behind the scenes (out of your reach) to give the illusion of an infinite 3D flat expanse. You can use it as a simple floor. To be honest, because it's so simple, its uses are limited in anything especially complex as you can't define edges or raised areas or holes in it.

Last edited 2011


KingLestat(Posted 2011) [#3]
er yes


KingLestat(Posted 2011) [#4]
thanks


Graythe(Posted 2011) [#5]
So, a plane may have some use as a floor, a mesh is a collection of vertices and at least one surface.


RemiD(Posted 2011) [#6]
I'm curious if one of you know the answer to this :

In Unity3d, if i modify the color of a mesh, this modifies the material, and thus creating another material. (another surface ?)

In blitz3d, if i use copyentity() to copy the mesh, and then i change the color of each mesh using entitycolor(), does this create others materials as well ?

Also is there a command to know how many surfaces are drawn each frame ?

Thanks,


Graythe(Posted 2011) [#7]
I believe that only the vertices are common to cloned entities. Using CopyEntity() will create will share vertices but not surfaces. Using CopyMesh() will create an independent entity.


Yasha(Posted 2011) [#8]
Using CopyEntity() will create will share vertices but not surfaces


No, this is wrong. Vertices are contained within a surface; as I said before, a surface is a vertex list, a triangle list and a brush. CopyEntity will create a new entity, but share any surfaces rather than giving it its own. Both CopyEntity and CopyMesh create a new entity, but the one created with CopyMesh has its own, independent, copy of the surface data. This is important in case you want to modify the mesh data in some way; if you'd used CopyEntity and then modified the copy, the original would be affected too.

In blitz3d, if i use copyentity() to copy the mesh, and then i change the color of each mesh using entitycolor(), does this create others materials as well ?


No. I'm guessing the closest match for a Unity "material" is the Blitz3D "brush". A brush combines several visual elements - texture, colour, shininess, alpha etc. - and can be used to apply them all at once.

Each entity and surface also has a brush "built-in" to it. When you apply any changes to an Entity, it only affects that entity's built-in brush: if you "paint" a surface or entity with a brush that you created or extracted (extraction creates a new copy of whatever you took it from) the values are just copied onto the built-in brush. Nothing new is created.

Last edited 2011


Graythe(Posted 2011) [#9]
if you'd used CopyEntity and then modified the copy, the original would be affected too.


Changing the colour does not affect the original.


Yasha(Posted 2011) [#10]
Changing the colour does not affect the original.


...because colour is an entity property, not a mesh property.


Graythe(Posted 2011) [#11]
Ah, thank you Yasha.