void AABBMesh::setBoxes( const QList<QgsAABB> &bboxes )
{
  QList<QVector3D> vertices;
  Q_FOREACH ( const QgsAABB &bbox, bboxes )
    vertices << bbox.verticesForLines();
  mLineMeshGeo->setVertices( vertices );
  setVertexCount( mLineMeshGeo->vertexCount() );
}
Exemplo n.º 2
0
TexturedGeometry::TexturedGeometry()
    : Geometry()
    , nb_tex(0)
{
    setVertexCount(4);
    a = QVector<Attribute>()
            << Attribute(TypeFloat, 2, 0)
            << Attribute(TypeFloat, 2, 2*sizeof(float))
               ;
    setTextureCount(1);
}
Exemplo n.º 3
0
    // Constructor(s) ################################################
    //################################################################
    Object3D(char* objName, char* fileName, UINT32 vertexCount, float modelSize, bool active = true,
             glm::mat4 scaleMatrix       = glm::mat4(),
             glm::mat4 translationMatrix = glm::mat4(),
             glm::mat4 rotationalMatrix  = glm::mat4()){

        setObjName(objName);
        setFileName(fileName);
        setVertexCount(vertexCount);
        setModelSize(modelSize);
        setActive(active);

        //Unless default function parameters are overwritten,
        //we will write identity matrices to the matrices
        setRotationMatrix(rotationalMatrix);
        setScaleMatrix(scaleMatrix);
        setTranslationMatrix(translationMatrix);

    }
Exemplo n.º 4
0
void OctreeProjectedPolygon::merge(const OctreeProjectedPolygon& that) {

    // RIGHT/NEAR
    // LEFT/NEAR
    if (
        (getProjectionType() == that.getProjectionType()) &&
        (
            getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR) ||
            getProjectionType() == (PROJECTION_LEFT  | PROJECTION_NEAR)
        )
    ) {
        if (getVertex(1) == that.getVertex(0) && getVertex(4) == that.getVertex(5)) {
            //setVertex(0, this.getVertex(0)); // no change
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            //setVertex(5, this.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(0) == that.getVertex(1) && getVertex(5) == that.getVertex(4)) {
            setVertex(0, that.getVertex(0));
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, this.getVertex(3)); // no change
            //setVertex(4, that.getVertex(4)); // no change
            setVertex(5, that.getVertex(5));
            return; // done
        }
        if (getVertex(2) == that.getVertex(1) && getVertex(3) == that.getVertex(4)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, that.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(1) == that.getVertex(2) && getVertex(4) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, that.getVertex(3)); // no change
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            return; // done
        }
    }

    // NEAR/BOTTOM
    if (
        (getProjectionType() == that.getProjectionType()) &&
        (
            getProjectionType() == (PROJECTION_NEAR | PROJECTION_BOTTOM)
        )
    ) {
        if (getVertex(0) == that.getVertex(5) && getVertex(3) == that.getVertex(4)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, that.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(5) == that.getVertex(0) && getVertex(4) == that.getVertex(3)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, that.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, that.getVertex(3)); // no change
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            return; // done
        }
        if (getVertex(1) == that.getVertex(0) && getVertex(2) == that.getVertex(3)) {
            //setVertex(0, this.getVertex(0)); // no change
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            //setVertex(3, that.getVertex(3)); // no change
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, that.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(0) == that.getVertex(1) && getVertex(3) == that.getVertex(2)) {
            setVertex(0, that.getVertex(0));
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, that.getVertex(2)); // no change
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            return; // done
        }
    }

    // NEAR/TOP
    if (
        (getProjectionType() == that.getProjectionType()) &&
        (
            getProjectionType() == (PROJECTION_NEAR | PROJECTION_TOP)
        )
    ) {
        if (getVertex(0) == that.getVertex(5) && getVertex(1) == that.getVertex(2)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, that.getVertex(3)); // no change
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, that.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(5) == that.getVertex(0) && getVertex(2) == that.getVertex(1)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, that.getVertex(1)); // no change
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            return; // done
        }
        if (getVertex(4) == that.getVertex(5) && getVertex(3) == that.getVertex(2)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, that.getVertex(1)); // no change
            //setVertex(2, that.getVertex(2)); // no change
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            //setVertex(5, that.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(5) == that.getVertex(4) && getVertex(2) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            //setVertex(3, this.getVertex(3)); // no change
            //setVertex(4, that.getVertex(3)); // no change
            setVertex(5, that.getVertex(5));
            return; // done
        }
    }


    // RIGHT/NEAR & NEAR/RIGHT/TOP
    // LEFT/NEAR  & NEAR/LEFT/TOP
    if (
        ((getProjectionType()     == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_TOP)) &&
         (that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR)))
        ||
        ((getProjectionType()     == (PROJECTION_LEFT  | PROJECTION_NEAR | PROJECTION_TOP)) &&
         (that.getProjectionType() == (PROJECTION_LEFT  | PROJECTION_NEAR)))
    )
    {
        if (getVertex(5) == that.getVertex(0) && getVertex(3) == that.getVertex(2)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR));
            return; // done
        }
    }

    // RIGHT/NEAR & NEAR/RIGHT/TOP
    // LEFT/NEAR  & NEAR/LEFT/TOP
    if (
        ((that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_TOP)) &&
         (getProjectionType()       == (PROJECTION_RIGHT | PROJECTION_NEAR)))
        ||
        ((that.getProjectionType() == (PROJECTION_LEFT  | PROJECTION_NEAR | PROJECTION_TOP)) &&
         (getProjectionType()       == (PROJECTION_LEFT  | PROJECTION_NEAR)))

    )
    {
        if (getVertex(0) == that.getVertex(5) && getVertex(2) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            //setVertex(3, this.getVertex(3)); // no change
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, this.getVertex(5)); // no change
            //setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR)); // no change
            return; // done
        }
    }

    // RIGHT/NEAR & NEAR/RIGHT/BOTTOM
    // NEAR/LEFT & NEAR/LEFT/BOTTOM
    if (
        ((that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM)) &&
         (getProjectionType()       == (PROJECTION_RIGHT | PROJECTION_NEAR)))
        ||
        ((that.getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_BOTTOM)) &&
         (getProjectionType()       == (PROJECTION_LEFT | PROJECTION_NEAR)))

    )
    {
        if (getVertex(5) == that.getVertex(0) && getVertex(3) == that.getVertex(2)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            //setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR)); // no change
            return; // done
        }
    }
    // RIGHT/NEAR & NEAR/RIGHT/BOTTOM
    // NEAR/LEFT & NEAR/LEFT/BOTTOM
    if (
        ((getProjectionType()     == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM)) &&
         (that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR)))
        ||
        ((getProjectionType()     == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_BOTTOM)) &&
         (that.getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR)))
    )
    {
        if (getVertex(0) == that.getVertex(5) && getVertex(2) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            //setVertex(3, this.getVertex(3)); // no change
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, this.getVertex(5)); // no change
            setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR));
            return; // done
        }
    }


    // NEAR/TOP & NEAR
    if (
        (getProjectionType()      == (PROJECTION_NEAR                   )) &&
        (that.getProjectionType() == (PROJECTION_NEAR  | PROJECTION_TOP ))
    )
    {
        if (getVertex(0) == that.getVertex(5) && getVertex(1) == that.getVertex(2)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, this.getVertex(3)); // no change
            //setVertexCount(4); // no change
            //setProjectionType((PROJECTION_NEAR));  // no change
            return; // done
        }
    }

    // NEAR/TOP & NEAR
    if (
        (that.getProjectionType() == (PROJECTION_NEAR                   )) &&
        (getProjectionType()      == (PROJECTION_NEAR  | PROJECTION_TOP ))
    )
    {
        if (getVertex(5) == that.getVertex(0) && getVertex(2) == that.getVertex(1)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            setVertexCount(4);
            setProjectionType((PROJECTION_NEAR));
            return; // done
        }
    }

    // NEAR/BOTTOM & NEAR
    if (
        (getProjectionType()      == (PROJECTION_NEAR                      )) &&
        (that.getProjectionType() == (PROJECTION_NEAR  | PROJECTION_BOTTOM ))
    )
    {
        if (getVertex(2) == that.getVertex(3) && getVertex(3) == that.getVertex(0)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            setVertex(2, that.getVertex(4));
            setVertex(3, that.getVertex(5));
            //setVertexCount(4); // no change
            //setProjectionType((PROJECTION_NEAR));  // no change
        }
    }

    // NEAR/BOTTOM & NEAR
    if (
        (that.getProjectionType() == (PROJECTION_NEAR                      )) &&
        (getProjectionType()      == (PROJECTION_NEAR  | PROJECTION_BOTTOM ))
    )
    {
        if (getVertex(3) == that.getVertex(2) && getVertex(0) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            setVertex(2, getVertex(4));
            setVertex(3, getVertex(5));
            setVertexCount(4);
            setProjectionType((PROJECTION_NEAR));
            return; // done
        }
    }

    // NEAR/RIGHT & NEAR
    if (
        (getProjectionType()      == (PROJECTION_NEAR                      )) &&
        (that.getProjectionType() == (PROJECTION_NEAR  | PROJECTION_RIGHT ))
    )
    {
        if (getVertex(0) == that.getVertex(1) && getVertex(3) == that.getVertex(4)) {
            setVertex(0, that.getVertex(0));
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            setVertex(3, that.getVertex(5));
            //setVertexCount(4); // no change
            //setProjectionType((PROJECTION_NEAR));  // no change
        }
    }

    // NEAR/RIGHT & NEAR
    if (
        (that.getProjectionType() == (PROJECTION_NEAR                      )) &&
        (getProjectionType()      == (PROJECTION_NEAR  | PROJECTION_RIGHT ))
    )
    {
        if (getVertex(1) == that.getVertex(0) && getVertex(4) == that.getVertex(3)) {
            //setVertex(0, this.getVertex(0)); // no change
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            setVertex(3, getVertex(5));
            setVertexCount(4);
            setProjectionType((PROJECTION_NEAR));
            return; // done
        }
    }

    // NEAR/LEFT & NEAR
    if (
        (getProjectionType()      == (PROJECTION_NEAR                    )) &&
        (that.getProjectionType() == (PROJECTION_NEAR  | PROJECTION_LEFT ))
    )
    {
        if (getVertex(1) == that.getVertex(1) && getVertex(2) == that.getVertex(4)) {
            //setVertex(0, this.getVertex()); // no change
            setVertex(1, that.getVertex(2));
            setVertex(2, that.getVertex(3));
            //setVertex(3, this.getVertex(3)); // no change
            //setVertexCount(4); // no change
            //setProjectionType((PROJECTION_NEAR));  // no change
            return; // done
        }
    }

    // NEAR/LEFT & NEAR
    if (
        (that.getProjectionType() == (PROJECTION_NEAR                    )) &&
        (getProjectionType()      == (PROJECTION_NEAR  | PROJECTION_LEFT ))
    )
    {
        if (getVertex(1) == that.getVertex(0) && getVertex(4) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, getVertex(2));
            setVertex(2, getVertex(3));
            setVertex(3, that.getVertex(3));
            setVertexCount(4);
            setProjectionType((PROJECTION_NEAR));
            return; // done
        }
    }

    // NEAR/RIGHT/TOP & NEAR/TOP
    if (
        ((getProjectionType()     == (PROJECTION_TOP | PROJECTION_NEAR                     )) &&
         (that.getProjectionType() == (PROJECTION_TOP | PROJECTION_NEAR  | PROJECTION_RIGHT )))
    )
    {
        if (getVertex(0) == that.getVertex(1) && getVertex(4) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, this.getVertex(3)); // no change
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            return; // done
        }
    }

    // NEAR/RIGHT/TOP & NEAR/TOP
    if (
        ((that.getProjectionType() == (PROJECTION_TOP | PROJECTION_NEAR                     )) &&
         (getProjectionType()      == (PROJECTION_TOP | PROJECTION_NEAR  | PROJECTION_RIGHT )))
    )
    {
        if (getVertex(1) == that.getVertex(0) && getVertex(3) == that.getVertex(4)) {
            //setVertex(0, this.getVertex(0)); // no change
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, this.getVertex(5)); // no change
            setProjectionType((PROJECTION_TOP | PROJECTION_NEAR));
            return; // done
        }
    }


    // NEAR/RIGHT/BOTTOM & NEAR/BOTTOM
    if (
        ((getProjectionType()     == (PROJECTION_BOTTOM | PROJECTION_NEAR                     )) &&
         (that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR  | PROJECTION_RIGHT )))
    )
    {
        if (getVertex(1) == that.getVertex(2) && getVertex(5) == that.getVertex(4)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, this.getVertex(3)); // no change
            //setVertex(4, this.getVertex(4)); // no change
            setVertex(5, that.getVertex(5));
            return; // done
        }
    }

    // NEAR/RIGHT/BOTTOM & NEAR/BOTTOM
    if (
        ((that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR                     )) &&
         (getProjectionType()       == (PROJECTION_BOTTOM | PROJECTION_NEAR  | PROJECTION_RIGHT )))
    )
    {
        if (getVertex(2) == that.getVertex(1) && getVertex(4) == that.getVertex(5)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            //setVertex(5, this.getVertex(5)); // no change
            setProjectionType((PROJECTION_BOTTOM | PROJECTION_NEAR));
            return; // done
        }
    }

    // NEAR/LEFT/BOTTOM & NEAR/BOTTOM
    if (
        ((getProjectionType()     == (PROJECTION_BOTTOM | PROJECTION_NEAR                     )) &&
         (that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR  | PROJECTION_LEFT )))
    )
    {
        if (getVertex(2) == that.getVertex(0) && getVertex(4) == that.getVertex(4)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            setVertex(2, that.getVertex(1));
            setVertex(3, that.getVertex(2));
            setVertex(4, that.getVertex(3));
            //setVertex(5, this.getVertex(5)); // no change
            return; // done
        }
    }

    // NEAR/LEFT/BOTTOM & NEAR/BOTTOM
    if (
        ((that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR                     )) &&
         (getProjectionType()       == (PROJECTION_BOTTOM | PROJECTION_NEAR  | PROJECTION_LEFT )))
    )
    {
        if (getVertex(0) == that.getVertex(2) && getVertex(4) == that.getVertex(4)) {
            // we need to do this in an unusual order, because otherwise we'd overwrite our own values
            setVertex(4, getVertex(3));
            setVertex(3, getVertex(2));
            setVertex(2, getVertex(1));
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            setVertex(5, that.getVertex(5));
            setProjectionType((PROJECTION_BOTTOM | PROJECTION_NEAR));
            return; // done
        }
    }


    // RIGHT/NEAR/BOTTOM
    // RIGHT/NEAR/TOP
    // LEFT/NEAR/BOTTOM
    // LEFT/NEAR/TOP
    if (
        (getProjectionType() == that.getProjectionType()) &&
        (
            getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM ) ||
            getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_TOP    ) ||
            getProjectionType() == (PROJECTION_LEFT  | PROJECTION_NEAR | PROJECTION_BOTTOM ) ||
            getProjectionType() == (PROJECTION_LEFT  | PROJECTION_NEAR | PROJECTION_TOP    )
        )
    ) {
        if (getVertex(0) == that.getVertex(5) && getVertex(2) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            //setVertex(3, this.getVertex(3)); // no change
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, this.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(5) == that.getVertex(0) && getVertex(3) == that.getVertex(2)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            return; // done
        }
        if (getVertex(2) == that.getVertex(1) && getVertex(4) == that.getVertex(5)) {
            //setVertex(0, this.getVertex(0)); // no change
            //setVertex(1, this.getVertex(1)); // no change
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            setVertex(4, that.getVertex(4));
            //setVertex(5, this.getVertex(5)); // no change
            return; // done
        }
        if (getVertex(1) == that.getVertex(2) && getVertex(5) == that.getVertex(4)) {
            setVertex(0, that.getVertex(0));
            setVertex(1, that.getVertex(1));
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, this.getVertex(3)); // no change
            //setVertex(4, this.getVertex(4)); // no change
            setVertex(5, that.getVertex(5));
            return; // done
        }
        //   if this.([1],[3]) == that.([0],[4]) then create polygon: this.[0], that.[1], that.[2], that.[3], this.[4], this.[5]
        if (getVertex(1) == that.getVertex(0) && getVertex(3) == that.getVertex(4)) {
            //setVertex(0, this.getVertex(0)); // no change
            setVertex(1, that.getVertex(1));
            setVertex(2, that.getVertex(2));
            setVertex(3, that.getVertex(3));
            //setVertex(4, this.getVertex(4)); // no change
            //setVertex(5, this.getVertex(5)); // no change
            return; // done
        }
        //   if this.([0],[4]) == that.([1],[3]) then create polygon: that.[0], this.[1], this.[2], this.[3], that.[4], that.[5]
        if (getVertex(0) == that.getVertex(1) && getVertex(4) == that.getVertex(3)) {
            setVertex(0, that.getVertex(0));
            //setVertex(1, this.getVertex(1)); // no change
            //setVertex(2, this.getVertex(2)); // no change
            //setVertex(3, this.getVertex(3)); // no change
            setVertex(4, that.getVertex(4));
            setVertex(5, that.getVertex(5));
            return; // done
        }
    }

}
Exemplo n.º 5
0
Cube::Cube(ShaderProgram* shaderProgram)
	:GameObject(shaderProgram)
{
	setVertexCount(8);
	setIndexCount(36);
    activateAttribute(3);
	activateAttribute(4);
	setAttribute(0, 0, vec3(-0.5f, -0.5f, -0.5f));
	setAttribute(0, 1, vec3(0.5f, -0.5f, -0.5f));
	setAttribute(0, 2, vec3(0.5f, -0.5f, 0.5f));
	setAttribute(0, 3, vec3(-0.5f, -0.5f, 0.5f));
	setAttribute(0, 4, vec3(-0.5f, 0.5f, -0.5f));
	setAttribute(0, 5, vec3(0.5f, 0.5f, -0.5f));
	setAttribute(0, 6, vec3(0.5f, 0.5f, 0.5f));
	setAttribute(0, 7, vec3(-0.5f, 0.5f, 0.5f));
	setAttribute(1, 0, vec4(0.0f, 1.0f, 0.0f, 1.0f));
	setAttribute(1, 1, vec4(0.0f, 0.0f, 1.0f, 1.0f));
	setAttribute(1, 2, vec4(1.0f, 0.0f, 0.0f, 1.0f));
	setAttribute(1, 3, vec4(0.0f, 1.0f, 0.0f, 1.0f));
	setAttribute(1, 4, vec4(0.0f, 0.0f, 1.0f, 1.0f));
	setAttribute(1, 5, vec4(1.0f, 0.0f, 0.0f, 1.0f));
	setAttribute(1, 5, vec4(0.0f, 0.0f, 1.0f, 1.0f));
	setAttribute(1, 7, vec4(1.0f, 0.0f, 0.0f, 1.0f));

	setIndex(0, 0);
	setIndex(1, 1);
	setIndex(2, 2);
	setIndex(3, 2);
	setIndex(4, 3);
	setIndex(5, 0);

	setIndex(6, 1);
	setIndex(7, 5);
	setIndex(8, 2);
	setIndex(9, 2);
	setIndex(10, 5);
	setIndex(11, 6);

	setIndex(12, 6);
	setIndex(13, 5);
	setIndex(14, 4);
	setIndex(15, 7);
	setIndex(16, 6);
	setIndex(17, 4);

	setIndex(18, 3);
	setIndex(19, 7);
	setIndex(20, 4);
	setIndex(21, 0);
	setIndex(22, 3);
	setIndex(23, 4);

	setIndex(24, 6);
	setIndex(25, 7);
	setIndex(26, 3);
	setIndex(27, 2);
	setIndex(28, 6);
	setIndex(29, 3);

	setIndex(30, 0);
	setIndex(31, 5);
	setIndex(32, 1);
	setIndex(33, 5);
	setIndex(34, 0);
	setIndex(35, 4);
}
Exemplo n.º 6
0
bool
ScreenOrientedQuad::initialize (const Ctr::Region2f& screenLocation, bool background)
{    
    setPrimitiveType (Ctr::TriangleStrip);
    setPrimitiveCount (2);
    setVertexCount (4);

    _screenLocation = screenLocation;
    uint32_t width = 1;
    uint32_t height = 1;

    //create vertex streams and vertex declaration information
    std::vector<VertexElement>       vertexElements;
    vertexElements.push_back (VertexElement( 0, 0,  FLOAT4, METHOD_DEFAULT, POSITION, 0));
    vertexElements.push_back (VertexElement( 0, 16, FLOAT2, METHOD_DEFAULT, TEXCOORD, 0));
    vertexElements.push_back (VertexElement(0xFF,0, UNUSED,0,0,0));

    float lhx = _screenLocation.minExtent.x * width;
    float lhy = _screenLocation.minExtent.y * height;
    float screenWidth = _screenLocation.size().x * width;
    float screenHeight = _screenLocation.size().y * height;

    float z = 0;
    float w = 1;

    if (background)
    {
        z = 1;
        w = 1;
    }

    Vector4f vpos[] = {Vector4f(lhx, lhy, z, w), 
                       Vector4f(lhx, lhy + screenHeight, z, w), 
                       Vector4f(lhx+screenWidth, lhy, z, w), 
                       Vector4f(lhx+screenWidth, lhy + screenHeight, z, w) };    

    Vector2f tpos[] = {Vector2f(0, 1), Vector2f(0, 0), 
                           Vector2f(1, 1), Vector2f(1, 0) };    

    if (IVertexDeclaration* vertexDeclaration =
        Ctr::VertexDeclarationMgr::vertexDeclarationMgr()->createVertexDeclaration
        (&VertexDeclarationParameters(vertexElements)))
    {
        setVertexDeclaration (vertexDeclaration);
        _positionStream = new Ctr::VertexStream
            (Ctr::POSITION, 0, 4, 4, (float*)vpos);
        _texCoordStream = new Ctr::VertexStream
            (Ctr::TEXCOORD, 0, 2, 4, (float*)tpos);

        addStream (_positionStream);
        addStream (_texCoordStream);

        if (create())
        {
            return cache();
        }
    }
    else
    {
        safedelete (vertexDeclaration);
        return false;
    }

    return false;
}