Billboard)
The bulletin board in Ogre is simply a quadrilateral in the scenario, but its orientation is related to the camera. Usually the billboard rotates along the camera's view to align with the camera's line of sight. Place the billboard anywhere in the scene and it will be directed to the camera. For efficiency, the patch board is aligned with the camera's line of sight, rather than the vector from the patch board to the camera. In most cases, there is no obvious difference between the two. If you want to use the last alignment form, you can also do it, but the performance will be reduced.
Billboard set)
The bulletin board cannot exist independently, and they cannot render themselves. They must belong to a bulletin board set. A board set can be considered as a group of boards.
All the boards in the billboard set have the same size and use the same material. The same size and texture increase the computing and rendering efficiency. You can change the size of a bulletin board separately in a bulletin board set, but this will cause performance degradation.
Assume that a board set is an operational unit. Either they are not rendered or all are rendered. In other words, they use the same
You can also remove individual sets, but it is best not to do so. This is also out of efficiency considerations. In the case that a wide range of application dashboards are used to simulate grass, many of the billboards in the panel may fall beyond the perspective, in this case, you may think of a separate elimination method, but this will inevitably affect the performance. A better way is to use multiple notification boards instead of removing them from a large one. The dashboard in the dashboard set is located relative to the scene node from the dashboard set attached. Since the boards in the billboard set use the same material, they are rendered in the same batch.
Billboard Creation
The dashboard can be described by the offset and size (width and height) of the center of the dashboard set. Its direction is its function to the camera vector. By default, a point board is created. This Board is always completely Ground-to-camera and vertical. The default position of the source on the deployment board is its center. You can change the source position within the range of nine specifications. The second type of panel is the oriented panel, which can be rotated along the respective Y axis or along the common axis (usually the Y axis. The third is the perpendicular panel, which is perpendicular to the direction vector (the vector between the Panel and the camera. This vector can be a shared vector (usually the Z axis) or its own Z axis. This type of Board also requires an upper-direction secondary positioning.
The point board has some advantages over other types of boards. Generally, ogre generates a quad (four vertices, each
Vertices have positions and texture coordinates), and the generated ry is sent to the GPU for rendering. For the point board, you can abolish three of them, let the GPU select, and decide how to render the texture Attributes Based on points. There are some restrictions on hardware point rendering: only supported
Point board, which is limited to the class with the center as the origin. The size and appearance are defined in the material. They are not in the billboard set and are limited in size.
Is not as big as the software. It does not support individual board rotation and size change, but can be rotated on the Texture unit.
Board pool
When creating a deployment board, you must notify the number of deployment boards in the deployment board set. The bulletin board is placed in the active and free lists respectively, which makes positioning very fast. When the number of boards created exceeds the size of the pool, the size of the pool is doubled. It is best to determine the size of the pool in advance to avoid unreasonable increase in the size of the pool during use.
Patch board texture coordinates
Supports non-full-range texture coordinate allocation. For example, if you have a texture, it contains several sub-textures. Each texture contains
English letters. At this time, you want to create several bulletin boards with different letters displayed on each bulletin board. Of course, they all come from the same texture.
You can create an array containing texture coordinates and then provide the array to the billboard set. When you create a dashboard using the dashboard,
You can give this board an index for the array storing texture coordinates. The image and Code are as follows:
// Create a new billboard set with a pool of 4 billboards
BillboardSet * bbset = sceneMgr-> createBillboardSet ("BBSet", 4 );
// Create a texture coordinate array to address the texture
FloatRect texCoordArray [] = {
FloatRect (0.0, 0.0, 0.5, 0.5), // address the ""
FloatRect (0.5, 0.0, 1.0, 0.5), // address the "B"
FloatRect (0.0, 0.5, 0.5, 1.0), // address the "C"
FloatRect (0.5, 0.5, 1.0, 1.0), // address the "D"
};
// Provide this array to the billboard set
Bbset-> setTextureCoords (texCoordArray, 4 );
// Now create a billboard to display the "D"; this
// Is the fourth entry in the array, index = 3
Billboard * bb = bbset-> createBillboard (Vector3 (0, 0, 0 ));
Bb-> setTexcoordIndex (3 );
You can also assign values to texture coordinates directly.
FloatRect coords (0.5, 0.5, 1.0, 1.0 );
Bb-> setTexcoordRect (coords );
The material script used by the bulletin board and everything in the normal material script can be included, and the patch board and dot texture can be used as unique.
Commands and parameters.
Ribbon Trails)
A board chain is a group of boards associated with the front and back (you can think of the organizational structure of the chicken in the game "The e ). Ogre
A ribbon-trail reference class is provided, which uses the billboard chain to chase Nodes in the scenario and leave a tail. The billboard chain can be divided into multiple sections, so it can simulate the effect of the lamp. The disadvantage of the billboard chain is that it must be updated manually. You can add an item at the end of each section of the billboard chain. Each section has the maximum length. If the length exceeds that, the tail item is removed and re-used as the node header.
Ribbon trail has similar behaviors. The removal of items from the tail end increases as the header, and the color fades from start to end. The image and Code are as follows:
Void setupTrailLights (void)
{
NameValuePairList pairList;
PairList ["numberOfChains"] = "2 ";
PairList ["maxElements"] = "80 ";
RibbonTrail * trail = static_cast <RibbonTrail *> (
MSceneMgr-> createMovableObject ("1", "RibbonTrail", & pairList ));
Trail-> setMaterialName ("Examples/LightRibbonTrail ");
Trail-> setTrailLength (400 );
MSceneMgr-> getRootSceneNode ()->
CreateChildSceneNode ()-> attachObject (trail );
// Create nodes for trail to follow
SceneNode * animNode = mSceneMgr-> getRootSceneNode ()->
CreateChildSceneNode ();
AnimNode-> setPosition (50, 30, 0 );
Animation * anim = mSceneMgr-> createAnimation ("an1", 14 );
Anim-> setInterpolationMode (Animation: IM_SPLINE );
NodeAnimationTrack * track = anim-> createNodeTrack (1, animNode );
TransformKeyFrame * kf = track-> createNodeKeyFrame (0 );
Kf-> setTranslate (Vector3 (50, 30, 0 ));
Kf = track-> createNodeKeyFrame (2 );
Kf-> setTranslate (Vector3 (100,-30, 0 ));
Kf = track-> createNodeKeyFrame (4 );
Kf-> setTranslate (Vector3 (120,-100,150 ));
Kf = track-> createNodeKeyFrame (6 );
Kf-> setTranslate (Vector3 (30,-100, 50 ));
Kf = track-> createNodeKeyFrame (8 );
Kf-> setTranslate (Vector3 (-50, 30,-50 ));
Kf = track-> createNodeKeyFrame (10 );
Kf-> setTranslate (Vector3 (-150,-20,-100 ));
Kf = track-> createNodeKeyFrame (12 );
Kf-> setTranslate (Vector3 (-50,-30, 0 ));
Kf = track-> createNodeKeyFrame (14 );
Kf-> setTranslate (Vector3 (50, 30, 0 ));
AnimationState * animState = mSceneMgr-> createAnimationState ("an1 ");
AnimState-> setEnabled (true );
MAnimStateList. push_back (animState );
Trail-> setInitialColour (0, 1.0, 0.8, 0 );
Trail-> setColourChange (0, 0.5, 0.5, 0.5, 0.5 );
Trail-> setInitialWidth (0, 5 );
Trail-> addNode (animNode );
// Add light
Light * l2 = mSceneMgr-> createLight ("l2 ");
L2-> setDiffuseColour (trail-> getInitialColour (0 ));
AnimNode-> attachObject (l2 );
// Add billboard
BillboardSet * bbs = mSceneMgr-> createBillboardSet ("bb", 1 );
Bbs-> createBillboard (Vector3: ZERO, trail-> getInitialColour (0 ));
Bbs-> setMaterialName ("Examples/Flare ");
AnimNode-> attachObject (bbs );
}
First, RibbonTrail creates two chains, each containing up to 80 elements and its tail is 400 world units long. A node animNoade is created. An animation is created for this node so that the node can change its position in the scene according to the key frame design. Then, a RibbonTrail is connected to this node, so RibbonTrail can be moved with animNode. A lamp is created and connected to this node. The lamp also moves along with the node, so the monster's head may change in light and shade. At last, a billboard is used to represent the created lamp, because the lamp is invisible in the scene. Because the lamp is mounted to the animNode node, the bulletin board bbs is also mounted to the same node. Of course, do not forget to use the animation state to push the animation.