ogre_slice.cpp¶
src/ogre_slice.cpp implements the OgreSlice class and the two ToOgre() conversion helpers declared in ogre_slice.h.
Constants¶
kManualObjectPrefix = "ManualObjectSubmap"— prefix for manual object names.kSubmapSourceMaterialName = "cartographer_ros/Submap"— the source material defined bysubmap.material.kSubmapMaterialPrefix = "SubmapMaterial",kSubmapTexturePrefix = "SubmapTexture"— prefixes for per-slice cloned materials and textures.GetSliceIdentifier()builds a unique"<trajectory>-<submap>-<slice>"string used to name the material, texture, and manual object.
ToOgre helpers¶
ToOgre(Vector3d)copies x/y/z into anOgre::Vector3.ToOgre(Quaterniond)copies w/x/y/z into anOgre::Quaternion.
Constructor¶
Creates a child scene node under the submap node and a ManualObject named after the slice identifier. It clones the source cartographer_ros/Submap material per slice, and configures it: no shadow receiving, no lighting, no culling, a depth bias of (-1, 0) (pulls the slice toward the camera so it draws over other geometry), and depth writes disabled so submaps blend correctly.
Destructor¶
Removes the cloned material and texture from their OGRE managers, then destroys the slice scene node and the manual object.
Update¶
Given new SubmapTexture data:
Positions and orients the slice node from the slice pose.
Builds an RGB pixel buffer from the intensity/alpha channels (blue always 0), since OGRE
loadRawDatadoes not handle RG textures.Rebuilds the manual object as a textured triangle strip quad. The quad is sized from
resolution * width/height, with the width extending along-Yand the height along-X.Uploads the pixels with
loadRawDataas a 2DPF_BYTE_RGBtexture (removing any previous texture).Configures the pass with additive-ish scene blending (
SBF_ONE,SBF_ONE_MINUS_SOURCE_ALPHA) for the pre-multiplied alpha, binds the new texture unit, and disables texture filtering (nearest).
SetAlpha¶
Sets the u_alpha fragment-program constant on the material, driving opacity of the slice.
Visibility¶
SetVisibility stores the local flag; UpdateOgreNodeVisibility(submap_visibility) makes the node visible only when both the parent submap and this slice are visible.