Base class for texturizers to be used with a MeshModelInstance.
#include <Rendering/SceneComponents/Models/texturizer.h>
◆ Wrapping
Enumerator |
---|
ClampToEdge | |
ClampToBorder | |
Repeat | |
MirroredRepeat | |
◆ Texturizer() [1/2]
Constructs a texturizer with the blend mode set to Decal and wrapping on.
◆ Texturizer() [2/2]
◆ ~Texturizer()
◆ canSerialize()
bool canSerialize |
( |
| ) |
const |
|
overridevirtual |
◆ clone()
- Returns
- A clone of this object.
- Note
- Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.
Implements Clonable.
Implemented in Texture2D, Texture3D, and NoTexture.
◆ getCacheId()
QString getCacheId |
( |
| ) |
const |
- Returns
- A string which characterizes the parameters which affect the output of this object. It should be unique for each possible combination of the inputs. A common format is to append strings in the form ":key=value" to assist debugging, but any string that is unique for a given set of parameters is acceptable.
- Note
- The default implementation uses the serialization function save() to generate an appropriate string. Subclasses can override this function to provide a more efficient string if they so wish, since the default implementation is likely to be relatively expensive.
◆ getDimensions()
virtual unsigned getDimensions |
( |
| ) |
const |
|
pure virtual |
- Returns
- The number of dimensions this texturizer supports. This should always be 1, 2 or 3, although it is conceivable that a texturizer might have 4 dimensions (but really that would be a modification of 3 dimensions with the 4th dimension being associated with the w component). A value of zero can also be returned as a special case to denote a texturizer which does not apply a texture at all.
Implemented in Texture2D, Texture3D, and NoTexture.
◆ getEnabled()
bool getEnabled |
( |
| ) |
const |
- Returns
- whether or not the texturizer is enabled.
◆ getInterpolate()
bool getInterpolate |
( |
| ) |
const |
- Returns
- True if the texture image should be interpolated when it does not map exactly pixel for pixel onto an object.
- See also
- setInterpolate()
◆ getNumDimensionsEnabled()
unsigned getNumDimensionsEnabled |
( |
| ) |
const |
|
inline |
- Returns
- Convenience method to get dimensions conditionally if Texturizer is enabled
◆ getNumImages()
virtual unsigned getNumImages |
( |
| ) |
const |
|
pure virtual |
- Returns
- The number of images this texturizer holds. Some texturizers provide only one image, whereas others provide a set of images and the image to use for any given element is found by calling getTextureImage(). The getNumImages() function can be used by model processors to work out how many images they will need to handle during processing.
Implemented in Texture2D, Texture3D, and NoTexture.
◆ getNumImagesEnabled()
unsigned getNumImagesEnabled |
( |
| ) |
const |
|
inline |
- Returns
- Convenience method to get getNumImages conditionally if Texturizer is enabled
◆ getTextureCoords()
- Parameters
-
node | The node we want the texture co-ordinate of |
- Precondition
- setTexturedModel must have already been called with the MeshModelInterface that the supplied node belongs to.
- Returns
- The texture co-ordinates for the specified node. While the result returned is a 3D vector corresponding to the (s,t,r) texture co-ordinates, for lower dimensional textures simply ignore the latter components (eg 2D textures ignore the r component). For consistency, lower dimensional texturizers must set components they don't use to zero.
- See also
- getTextureImage(), setTexturedModel()
Implemented in NoTexture, Texture2D, and Texture3D.
◆ getTextureImage()
- Parameters
-
index | The index of the texture image to retrieve. It must be a non-negative number less than the result of getNumImages(). |
- Returns
- The texture image corresponding to the specified index.
Implemented in Texture2D, Texture3D, and NoTexture.
◆ getWrapping()
- Returns
- True if the texture image should be wrapped when texture co-ordinates fall outside the range [0,1].
- See also
- setWrapping()
◆ load()
- Parameters
-
item | Supplies the state to be loaded into this object. |
This function will load the state of this object from item. For many object types, this is most easily implemented in terms of the object's input operator (>>).
It would be reasonable for subclass implementations to assume that the data provided in item is in the same form as would have been saved from a call to save.
- Returns
- If the state of the object could not be loaded, the function returns false. A return value of true implies that the object state was successfully loaded. If canSerialize() returns false, this function must do nothing except return false as well.
Implements Serialize.
◆ operator=()
◆ save()
- Parameters
-
item | Where to save the state of this object. |
This function will serialise the object by saving it to item. For most object types, this is most easily implemented in terms of the object's output operator (<<).
It is allowable for an object to only serialize part of itself. This would be useful if the data it represents has a set of defaults and only those values different to the defaults need to be serialized. Such an implementation then needs to be careful how it handles the complimentary load member function.
- Returns
- If an object could not be serialised or if the underlying object type does not support serialisation, this function should return false. A return value of true implies that the object was successfully saved to item. If canSerialize() returns false, this function must do nothing except return false as well.
Implements Serialize.
◆ setEnabled()
void setEnabled |
( |
bool |
b | ) |
|
- Parameters
-
b | whether or not to enable the texturizer. |
◆ setInterpolate()
void setInterpolate |
( |
bool |
b | ) |
|
- Parameters
-
b | Specifies whether to use some form of interpolation when a target pixel doesn't map exactly to a pixel in the texture image. |
When mapping a texture onto an object, the object is unlikely to be a perfect pixel for pixel match to the size of the texture image. When this occurs, renderers can choose to simply choose the closest texture pixel or it can perform some kind of interpolation between pixels to create an "averaged" pixel color for that point on the object. If b is true, this averaging is permitted, but if false then the renderer must always choose the closest texture pixel and perform no averaging. Having averaging enabled can give a smoother blend from one pixel to another and may be more appropriate when the texture image has to be stretched or shrunk by a large amount, but it is slower and will generally lead to a fuzzier image, particularly when the texture image has to be magnified to a size bigger than its resolution.
The default setting for this is false.
- See also
- getInterpolate()
◆ setTexturedModel()
- Parameters
-
model | The model about to be textured. |
glyphing | If true, the texture image selection by getTextureImage() should be based on node states instead of element states, since the the glyph that will be textured reflects the node states and no model elements are normally present or shown. |
Subclasses can reimplement this function to save internal data about the model that will be used for subsequent calls to getTextureCoords() and getTextureImage(). Clients are free to call this function at any time, so the subclass must keep this in mind, although it will usually only be called by a model appearance processor just before it uses the texturizer to process the specified model or before it outputs a glyph.
- Returns
- True if successful or false if there was an error when trying to use the specified model. If the texturizer will not be able to return valid texture co-ordinates (eg texture co-ordinate node states are missing in the model), this function should return false.
Reimplemented in NoTexture, Texture2D, and Texture3D.
◆ setWrapping()
- Parameters
-
wrap | If set to true, then for texture co-ordinates outside the range [0,1], the texture image will be wrapped to the opposite side as necessary. If set to false, then values outside this range are clamped to the closest end of the range. |
- See also
- getWrapping()