67 #ifndef _graphicsproceduralboxuvmodifier_cpp
68 #define _graphicsproceduralboxuvmodifier_cpp
70 #include "Graphics/Procedural/Mesh/boxuvmodifier.h"
79 BoxHalfExtents(1.0,1.0,1.0),
80 BoxPosition(0.0,0.0,0.0),
102 Vector3 VertNorm = VertIt->Normal;
105 for(
UInt8 AxisIndex = 0 ; AxisIndex < 6 ; ++AxisIndex )
107 if( Directions[AxisIndex].DotProduct(VertNorm) > MaxAxis ) {
108 MaxAxis = Directions[AxisIndex].
DotProduct(VertNorm);
109 PrincipalAxis = AxisIndex;
114 if( PrincipalAxis % 3 == 1 ) {
123 VertIt->UV = UVCoord;
126 switch( PrincipalAxis )
128 case 1: VertIt->UV =
Vector2( ( UVCoord.X + 2 ) / 4, ( UVCoord.Y + 1 ) / 3 );
break;
129 case 2: VertIt->UV =
Vector2( ( UVCoord.X + 1 ) / 4, UVCoord.Y / 3 );
break;
130 case 3: VertIt->UV =
Vector2( ( UVCoord.X + 3 ) / 4, ( UVCoord.Y + 1 ) / 3 );
break;
131 case 4: VertIt->UV =
Vector2( UVCoord.X / 4, ( UVCoord.Y + 1 ) / 3 );
break;
132 case 5: VertIt->UV =
Vector2( ( UVCoord.X + 1 ) / 4, ( UVCoord.Y + 2 ) / 3 );
break;
133 case 6: VertIt->UV =
Vector2( ( UVCoord.X + 1 ) / 4, ( UVCoord.Y + 1 ) / 3 );
break;
136 VertIt->UV =
Vector2( ( UVCoord.X + PrincipalAxis % 3 ) / 3, ( UVCoord.Y + PrincipalAxis / 3 ) / 2 );
143 {
return "BoxUVModifier"; }
There is only one texture to use for each face of the cube.
virtual void Modify(TriangleBuffer &Buffer)
Alters the generated pixels in a TriangleBuffer.
Vector3 CrossProduct(const Vector3 &Vec) const
This is used to calculate the crossproduct of this and another vector.
virtual String GetName() const
Gets the name of this modifier.
A modifier that will generate UV coordinates as they would need to be on a box model.
BoxUVModifier & SetBoxPosition(const Vector3 &Position)
Sets the center position of the Box to project UV's onto.
VertexContainer::iterator VertexIterator
Iterator type for Vertex instances in a VertexContainer.
Real X
Coordinate on the X vector.
Real Z
Coordinate on the Z vector.
virtual ~BoxUVModifier()
Class destructor.
A convenience buffer that stores vertices and indices of a mesh to be generated.
int Integer
A datatype used to represent any integer close to.
uint8_t UInt8
An 8-bit unsigned integer.
VertexContainer & GetVertices()
Gets a modifiable reference to Vertices.
Each face of the cube is packed into a 3x2 texture atlas.
float Real
A Datatype used to represent a real floating point number.
Each face of the cube is packed into a 4x3 texture atlas and is arranged into a cross shape...
MappingType
An enum describing how the quads for the cube are expected to be laid out on the texture.
BoxUVModifier & SetBoxHalfSize(const Vector3 &HalfSize)
Sets the half-size of the Box to project UV's onto.
This is used to represent a point on a 2 dimentional area, such as a screen.
static Vector3 Unit_Y()
Gets a vector representing the Y unit of a Vector3.
MappingType Mapping
How the quads for the cube are expected to be laid out on the texture.
BoxUVModifier()
Blank constructor.
Real Y
Coordinate on the Y vector.
static Vector3 Neg_Unit_X()
Gets a vector representing the negative X unit of a Vector3.
void SetValues(const Real &X, const Real &Y, const Real &Z)
Manually sets all the members of this vector3.
static Vector3 Unit_X()
Gets a vector representing the X unit of a Vector3.
Real DotProduct(const Vector3 &Vec) const
This is used to calculate the dotproduct of this and another vector.
static Vector3 Unit_Z()
Gets a vector representing the Z unit of a Vector3.
This is used to represent a point in space, or a vector through space.
Vector3 BoxPosition
The central position of the box.
The bulk of the engine components go in this namspace.
Boole IsZeroLength() const
Checks to see if the length of this vector is zero.
Vector3 BoxHalfExtents
The half-size of the box on each dimension.
static Vector3 Neg_Unit_Z()
Gets a vector representing the negative Z unit of a Vector3.
std::string String
A datatype used to a series of characters.
BoxUVModifier & SetMappingType(const MappingType Type)
Sets the UV mapping mode to be expected to be used with the mesh.
static Vector3 Neg_Unit_Y()
Gets a vector representing the negative Y unit of a Vector3.