reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

The ofPlanePrimitive allows you to create an UV plane. Can be used for example as simple canvas for projecting simple texture . More...

#include <of3dPrimitives.h>

Inheritance diagram for ofPlanePrimitive:
of3dPrimitive ofNode

Public Member Functions

 ofPlanePrimitive ()
 
 ofPlanePrimitive (float width, float height, int columns, int rows, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP)
 
 ~ofPlanePrimitive ()
 
void set (float width, float height, int columns, int rows, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP)
 
void set (float width, float height)
 
void resizeToTexture (ofTexture &inTexture, float scale=1.f)
 
void setWidth (float width)
 
void setHeight (float height)
 
void setColumns (int columns)
 
void setRows (int rows)
 
void setResolution (int columns, int rows)
 
void setMode (ofPrimitiveMode mode)
 
int getNumColumns () const
 
int getNumRows () const
 
glm::vec2 getResolution () const
 
float getWidth () const
 
float getHeight () const
 
- Public Member Functions inherited from of3dPrimitive
 of3dPrimitive ()
 
virtual ~of3dPrimitive ()
 
 of3dPrimitive (const ofMesh &mesh)
 
 of3dPrimitive (const of3dPrimitive &mom)
 
of3dPrimitiveoperator= (const of3dPrimitive &mom)
 
void mapTexCoords (float u1, float v1, float u2, float v2)
 
void mapTexCoordsFromTexture (const ofTexture &inTexture)
 
ofMeshgetMeshPtr ()
 
ofMeshgetMesh ()
 
const ofMeshgetMeshPtr () const
 
const ofMeshgetMesh () const
 
glm::vec4 * getTexCoordsPtr ()
 
glm::vec4 & getTexCoords ()
 
const glm::vec4 * getTexCoordsPtr () const
 
const glm::vec4 & getTexCoords () const
 
bool hasScaling () const
 
bool hasNormalsEnabled () const
 
void enableNormals ()
 
void enableTextures ()
 
void enableColors ()
 
void disableNormals ()
 
void disableTextures ()
 
void disableColors ()
 
void drawVertices () const
 
void drawWireframe () const
 
void drawFaces () const
 
void draw (ofPolyRenderMode renderType) const
 
void draw () const
 Draw the node as a white cube with xyz axes.
 
void drawNormals (float length, bool bFaceNormals=false) const
 
void drawAxes (float a_size) const
 
void setUseVbo (bool useVbo)
 
bool isUsingVbo () const
 
virtual void draw () const
 Draw the node as a white cube with xyz axes.
 
- Public Member Functions inherited from ofNode
void setParent (ofNode &parent, bool bMaintainGlobalTransform=false)
 Set parent for the node. The node will inherit transformations from parent.
 
void clearParent (bool bMaintainGlobalTransform=false)
 Remove parent node linking.
 
ofNodegetParent () const
 Get the parent node of this node.
 
glm::vec3 getPosition () const
 Get node's local position as a 3D vector.
 
float getX () const
 Get node's local x position.
 
float getY () const
 Get node's local y position.
 
float getZ () const
 Get node's local z position.
 
glm::vec3 getXAxis () const
 Get the node's local x axis as 3d vector.
 
glm::vec3 getYAxis () const
 Get the node's local y axis as 3d vector.
 
glm::vec3 getZAxis () const
 Get the node's local z axis as 3d vector.
 
glm::vec3 getSideDir () const
 Get direction of node's side aka local x axis, as 3d vector.
 
glm::vec3 getLookAtDir () const
 Get direction the node looks at aka local -z axis, as 3d vector.
 
glm::vec3 getUpDir () const
 Get direction of node's top aka local y axis, as 3d vector.
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getPitch() const)
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getHeading() const)
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getRoll() const)
 
float getPitchDeg () const
 Get pitch of node, aka the rotation along local x axis.
 
float getHeadingDeg () const
 Get heading of node, aka the rotation along local y axis.
 
float getRollDeg () const
 Get roll of node, aka the rotation along local z axis.
 
float getPitchRad () const
 Get pitch of node, aka the rotation along local x axis.
 
float getHeadingRad () const
 Get heading of node, aka the rotation along local y axis.
 
float getRollRad () const
 Get roll of node, aka the rotation along local z axis.
 
glm::quat getOrientationQuat () const
 Get the local orientation of the node as a quaternion.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", glm::vec3 getOrientationEuler() const)
 
glm::vec3 getOrientationEulerDeg () const
 Get local orientation of node in degrees around x, y, and z axes.
 
glm::vec3 getOrientationEulerRad () const
 Get local orientation of node in degrees around x, y, and z axes.
 
glm::vec3 getScale () const
 Get local scale of node in xyz axes where 1 is default.
 
const glm::mat4 & getLocalTransformMatrix () const
 Get node's local transformations (position, orientation, scale).
 
glm::mat4 getGlobalTransformMatrix () const
 Get node's global transformations (position, orientation, scale).
 
glm::vec3 getGlobalPosition () const
 Get node's global position as a 3D vector.
 
glm::quat getGlobalOrientation () const
 Get the global orientation of the node as a quaternion.
 
glm::vec3 getGlobalScale () const
 Get global scale of node in xyz axes where 1 is default.
 
void setPosition (float px, float py, float pz)
 Set the local position of the node using xyz coordinates.
 
void setPosition (const glm::vec3 &p)
 Set the local position of the node using a 3D vector of coordinates.
 
void setGlobalPosition (float px, float py, float pz)
 Set the global position of the node using xyz coordinates.
 
void setGlobalPosition (const glm::vec3 &p)
 Set the global position of the node using a 3D vector of coordinates.
 
void setOrientation (const glm::quat &q)
 Set local orientation with a quaternion.
 
void setOrientation (const glm::vec3 &eulerAngles)
 Set local orientation with xyz euler angles.
 
void setGlobalOrientation (const glm::quat &q)
 Set global orientation with a quaternion.
 
void setScale (float s)
 Set local uniform scale (x, y, and z are equally scaled).
 
void setScale (float sx, float sy, float sz)
 Set local scale for xyz axes individually.
 
void setScale (const glm::vec3 &s)
 Set local scale for xyz axes individually with a 3D vector.
 
void move (float x, float y, float z)
 Move node by relative amount with xyz coordinates.
 
void move (const glm::vec3 &offset)
 Move node by relative amount with xyz as ref to 3D vector.
 
void truck (float amount)
 Move node left+right relative to current position (in local x axis).
 
void boom (float amount)
 Move node up+down relative to current position (in local y axis).
 
void dolly (float amount)
 Move node backward+forward relative to current position (in local z axis).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void tilt(float degrees))
 
void tiltDeg (float degrees)
 Tilt up+down relative to current orientation (around local x axis).
 
void tiltRad (float radians)
 Tilt up+down relative to current orientation (around local x axis).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void pan(float degrees))
 
void panDeg (float degrees)
 Rotate left+right relative to current orientation (around local y axis).
 
void panRad (float radians)
 Rotate left+right relative to current orientation (around local y axis).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void roll(float degrees))
 
void rollDeg (float degrees)
 Roll left+right relative to current orientation (around local z axis).
 
void rollRad (float radians)
 Roll left+right relative to current orientation (around local z axis).
 
void rotate (const glm::quat &q)
 Rotate relative to current orientation by quaternion.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void rotate(float degrees, const glm::vec3 &v))
 
void rotateDeg (float degrees, const glm::vec3 &v)
 Rotate relative to current orientation around arbitrary axis.
 
void rotateRad (float radians, const glm::vec3 &v)
 Rotate relative to current orientation around arbitrary axis.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void rotate(float degrees, float vx, float vy, float vz))
 
void rotateDeg (float degrees, float vx, float vy, float vz)
 Rotate relative to current orientation around arbitrary axis.
 
void rotateRad (float radians, float vx, float vy, float vz)
 Rotate relative to current orientation around arbitrary axis.
 
void rotateAround (const glm::quat &q, const glm::vec3 &point)
 Rotate relative to current orientation by quaternion around point.
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void rotateAround(float degrees, const glm::vec3 &axis, const glm::vec3 &point))
 
void rotateAroundDeg (float degrees, const glm::vec3 &axis, const glm::vec3 &point)
 Rotate relative to current orientation around arbitrary axis around point.
 
void rotateAroundRad (float radians, const glm::vec3 &axis, const glm::vec3 &point)
 Rotate relative to current orientation around arbitrary axis around point.
 
void lookAt (const glm::vec3 &lookAtPosition)
 Orient node to look at point (-z axis pointing to global position).
 
void lookAt (const glm::vec3 &lookAtPosition, glm::vec3 upVector)
 Orient node to look at point (-z axis pointing to global position).
 
void lookAt (const ofNode &lookAtNode)
 Orient node to look at another node (-z axis pointing at other node).
 
void lookAt (const ofNode &lookAtNode, const glm::vec3 &upVector)
 Orient node to look at another node (-z axis pointing at other node).
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void orbit(float longitude, float latitude, float radius, const glm::vec3 &centerPoint=glm::vec3(0, 0, 0)))
 
 OF_DEPRECATED_MSG ("Use the Deg/Rad version.", void orbit(float longitude, float latitude, float radius, ofNode &centerNode))
 
void orbitDeg (float longitude, float latitude, float radius, const glm::vec3 &centerPoint=glm::vec3(0, 0, 0))
 Orbit node around a global position at a specific radius.
 
void orbitDeg (float longitude, float latitude, float radius, ofNode &centerNode)
 Orbit node around another node at a specific radius.
 
void orbitRad (float longitude, float latitude, float radius, const glm::vec3 &centerPoint=glm::vec3(0, 0, 0))
 Orbit node around a global position at a specific radius.
 
void orbitRad (float longitude, float latitude, float radius, ofNode &centerNode)
 Orbit node around another node at a specific radius.
 
void transformGL (ofBaseRenderer *renderer=nullptr) const
 Set opengl renderer's modelview matrix to this nodes transform.
 
void restoreTransformGL (ofBaseRenderer *renderer=nullptr) const
 Restore opengl renderer's previous modelview transform matrix.
 
void resetTransform ()
 Reset this node's transformations, position, rotation and scale.
 
virtual void customDraw (const ofBaseRenderer *renderer) const
 If you extend ofNode and wish to change the way it draws, extend this.
 
virtual void customDraw ()
 If you extend ofNode and wish to change the way it draws, extend this.
 

Protected Attributes

float width
 
float height
 
glm::vec2 resolution
 
- Protected Attributes inherited from of3dPrimitive
glm::vec4 texCoords
 
bool usingVbo
 
std::shared_ptr< ofMeshmesh
 
ofMesh normalsMesh
 
- Protected Attributes inherited from ofNode
ofNodeparent = nullptr
 

Additional Inherited Members

- Protected Member Functions inherited from of3dPrimitive
void normalizeAndApplySavedTexCoords ()
 
std::vector< ofIndexTypegetIndices (int startIndex, int endIndex) const
 
- Protected Member Functions inherited from ofNode
void createMatrix ()
 
void updateAxis ()
 
virtual void onPositionChanged ()
 Classes extending ofNode can override this method to get notified when the position changed.
 
virtual void onOrientationChanged ()
 Classes extending ofNode can override this methods to get notified when the orientation changed.
 
virtual void onScaleChanged ()
 Classes extending ofNode can override this methods to get notified when the scale changed.
 

Detailed Description

The ofPlanePrimitive allows you to create an UV plane. Can be used for example as simple canvas for projecting simple texture .

Like all primitives it allows you to set the size, in this case height and width, draw it, set positions, etc, as a simple example:

void setup()
{
// resolution 640x480...
plane.set(640, 480);
plane.setPosition(320, 240, 0);
plane.setResolution(2, 2);
}
void draw()
{
plane.drawWireframe();
}
void draw() const
Draw the node as a white cube with xyz axes.
Definition of3dPrimitives.cpp:211
void drawWireframe() const
Definition of3dPrimitives.cpp:196
void setPosition(float px, float py, float pz)
Set the local position of the node using xyz coordinates.
Definition ofNode.cpp:172
The ofPlanePrimitive allows you to create an UV plane. Can be used for example as simple canvas for p...
Definition of3dPrimitives.h:120
void set(float width, float height, int columns, int rows, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP)
Definition of3dPrimitives.cpp:304
void setResolution(int columns, int rows)
Definition of3dPrimitives.cpp:351

As you can see, plane is constructed from two triangles. To draw a texture over any primitive, simply bind the ofTexture instance and then draw your primitive:

texture.getTextureReference().bind();
// now draw filled...
plane.draw();
void draw(ofPolyRenderMode renderType) const
Definition of3dPrimitives.cpp:206

The plane primitive also allows you to simply pass an ofTexture to the plane and generate the texture coordinates from that texture so that the ofTexture fills the plane when it's drawn. This saves you the hassle of creating all the texture coordinates for each vertex, which is nice.

Constructor & Destructor Documentation

◆ ofPlanePrimitive() [1/2]

ofPlanePrimitive::ofPlanePrimitive ( )

◆ ofPlanePrimitive() [2/2]

ofPlanePrimitive::ofPlanePrimitive ( float  width,
float  height,
int  columns,
int  rows,
ofPrimitiveMode  mode = OF_PRIMITIVE_TRIANGLE_STRIP 
)

◆ ~ofPlanePrimitive()

ofPlanePrimitive::~ofPlanePrimitive ( )

Member Function Documentation

◆ getHeight()

float ofPlanePrimitive::getHeight ( ) const

◆ getNumColumns()

int ofPlanePrimitive::getNumColumns ( ) const

◆ getNumRows()

int ofPlanePrimitive::getNumRows ( ) const

◆ getResolution()

glm::vec2 ofPlanePrimitive::getResolution ( ) const

◆ getWidth()

float ofPlanePrimitive::getWidth ( ) const

◆ resizeToTexture()

void ofPlanePrimitive::resizeToTexture ( ofTexture inTexture,
float  scale = 1.f 
)

◆ set() [1/2]

void ofPlanePrimitive::set ( float  width,
float  height 
)

◆ set() [2/2]

void ofPlanePrimitive::set ( float  width,
float  height,
int  columns,
int  rows,
ofPrimitiveMode  mode = OF_PRIMITIVE_TRIANGLE_STRIP 
)

◆ setColumns()

void ofPlanePrimitive::setColumns ( int  columns)

◆ setHeight()

void ofPlanePrimitive::setHeight ( float  height)

◆ setMode()

void ofPlanePrimitive::setMode ( ofPrimitiveMode  mode)

◆ setResolution()

void ofPlanePrimitive::setResolution ( int  columns,
int  rows 
)

◆ setRows()

void ofPlanePrimitive::setRows ( int  rows)

◆ setWidth()

void ofPlanePrimitive::setWidth ( float  width)

Member Data Documentation

◆ height

float ofPlanePrimitive::height
protected

◆ resolution

glm::vec2 ofPlanePrimitive::resolution
protected

◆ width

float ofPlanePrimitive::width
protected

The documentation for this class was generated from the following files: