SoXipPlot2Columns::SoXipPlot2Columns() { SO_KIT_CONSTRUCTOR( SoXipPlot2Columns ); SO_KIT_ADD_CATALOG_ENTRY( mMainSeparator, SoSeparator, FALSE, this, \x0, TRUE ); SO_KIT_ADD_CATALOG_ENTRY( mVertices, SoCoordinate3, FALSE, mMainSeparator, \x0, FALSE ); SO_KIT_ADD_CATALOG_ENTRY( mFaceSeparator, SoSeparator, FALSE, mMainSeparator, \x0, FALSE ); SO_KIT_ADD_CATALOG_ENTRY( mFaceMaterial, SoMaterial, FALSE, mFaceSeparator, \x0, FALSE ); SO_KIT_ADD_CATALOG_ENTRY( mFaces, SoFaceSet, FALSE, mFaceSeparator, \x0, FALSE ); SO_KIT_ADD_CATALOG_ENTRY( mBorderSeparator, SoSeparator, FALSE, mMainSeparator, \x0, FALSE ); SO_KIT_ADD_CATALOG_ENTRY( mBorderColor, SoBaseColor, FALSE, mBorderSeparator, \x0, FALSE ); SO_KIT_ADD_CATALOG_ENTRY( mBorderStyle, SoDrawStyle, FALSE, mBorderSeparator, \x0, FALSE ); SO_KIT_ADD_CATALOG_ENTRY( mBorderLines, SoLineSet, FALSE, mBorderSeparator, \x0, FALSE ); SO_NODE_ADD_FIELD( label, ("Columns") ); SO_NODE_ADD_FIELD( data, (0) ); data.setNum(0); SO_NODE_ADD_FIELD( faceColor, (0.2, 0.2, 0.2) ); SO_NODE_ADD_FIELD( faceTransparency, (0) ); SO_NODE_ADD_FIELD( borderColor, (0, 0, 0) ); SO_NODE_ADD_FIELD( borderWidth, (1) ); SO_KIT_INIT_INSTANCE(); setVertices(); mDataSensor = new SoFieldSensor( dataSensorCB, this ); mDataSensor->attach( &data ); setUpConnections( TRUE, TRUE ); }
void Geometry::addVertices(const std::vector<Eigen::Vector3f>& vertices) { if (!m_hasDataVertices) { setVertices(vertices); return; } m_vbo.add(vertices); }
//============================================================================== void cTriangleArray::compress() { // get number of allocated triangles unsigned int numTriangles = getNumTriangles(); // remove non allocated triangles unsigned j=-1; for (int i=0; i<numTriangles; i++) { if (getAllocated(i)) { j++; if (i!=j) { unsigned int index0 = getVertexIndex0(i); unsigned int index1 = getVertexIndex1(i); unsigned int index2 = getVertexIndex2(i); m_allocated[j] = true; setVertices(j, index0, index1, index2); } } } // resize arrays unsigned size = j+1; m_allocated.resize(size); m_indices.resize(3*size); }
bool SkyBuildingRoof::init(Layer *gameScene_, b2World *gameWorld_, Point pos, int groundY) { gLayer = gameScene_; gWorld = gameWorld_; startPos = pos; groundYpos = groundY; cocos2d::Texture2D::TexParams params = {GL_NEAREST, GL_NEAREST, GL_REPEAT, GL_REPEAT}; Texture2D* viewTexture = Director::getInstance()->getTextureCache()->addImage("testbuilding_view.png"); viewTexture->setTexParameters(params); viewTextureSize = Size(viewTexture->getPixelsWide(), viewTexture->getPixelsHigh()); Texture2D* terrainTexture = Director::getInstance()->getTextureCache()->addImage("terrain.png"); terrainTexture->setTexParameters(params); Vector2dVector empty; terrain = PRFilledPolygon::filledPolygonWithPointsAndTexture(empty, terrainTexture); lowerFrontView = PRFilledPolygon::filledPolygonWithPointsAndTexture(empty, viewTexture); gLayer->addChild(terrain,2); gLayer->addChild(lowerFrontView, 60); setVertices(pos); return true; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int EdgeGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { herr_t err = 0; SharedVertexList::Pointer vertices = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedVertexList>(DREAM3D::Geometry::SharedVertexList, parentId, preflight, err); SharedEdgeList::Pointer edges = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedEdgeList>(DREAM3D::Geometry::SharedEdgeList, parentId, preflight, err); if (edges.get() == NULL || vertices.get() == NULL) { return -1; } size_t numEdges = edges->getNumberOfTuples(); size_t numVerts = vertices->getNumberOfTuples(); FloatArrayType::Pointer edgeCentroids = GeometryHelpers::GeomIO::ReadListFromHDF5<FloatArrayType>(DREAM3D::StringConstants::EdgeCentroids, parentId, preflight, err); if (err < 0 && err != -2) { return -1; } ElementDynamicList::Pointer edgeNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::EdgeNeighbors, parentId, numEdges, preflight, err); if (err < 0 && err != -2) { return -1; } ElementDynamicList::Pointer edgesContainingVert = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::EdgesContainingVert, parentId, numVerts, preflight, err); if (err < 0 && err != -2) { return -1; } setVertices(vertices); setEdges(edges); setElementCentroids(edgeCentroids); setElementNeighbors(edgeNeighbors); setElementsContainingVert(edgesContainingVert); return 1; }
void QChain::cutCircle(Circle circle) { if (m_vertices.size() == 0) return; circle.setCenter(circle.pos()); QPainterPath cr; cr.addEllipse(circle.x - circle.r, circle.y - circle.r, 2 * circle.r, 2 * circle.r); QPolygonF polygon; for (QPointF p : m_vertices) polygon.append(p); QPainterPath chain; chain.addPolygon(polygon); if (!chain.intersects(cr)) return; chain = chain.subtracted(cr); for (const QPolygonF &poly : chain.toSubpathPolygons()) { std::vector<Vector2d> pts(poly.begin(), poly.end() - 1); if (std::fabs(Geometry::area(pts.begin(), pts.end())) > 5.f) { auto chain = std::make_unique<QChain>(world()); chain->setVertices(std::vector<QPointF>(pts.begin(), pts.end())); chain->initializeLater(world()); world()->itemSet()->addBody(std::move(chain)); } } m_vertices.clear(); destroyLater(); }
void MShape::read(const QDomElement& obj) { // Read basic data. Serializable::read(obj); // Read vertices. QDomElement verticesObj = obj.firstChildElement("vertices"); QDomNode vertexNode = verticesObj.firstChild(); QVector<QPointF> vertices; while (!vertexNode.isNull()) { const QDomElement& vertexElem = vertexNode.toElement(); qreal x = vertexElem.attribute("x").toDouble(); qreal y = vertexElem.attribute("y").toDouble(); vertices.append(QPointF(x, y)); vertexNode = vertexNode.nextSibling(); } // Set the vertices. setVertices(vertices); // Rebuild. build(); }
Heightmap::Heightmap(int columns, int rows) { setColumns(columns); setRows(rows); vector<vec3> vertices; vector<unsigned int> indices; vector<vec2> texcoords; for(int z = 0; z <= rows; z++) { for(int x = 0; x <= columns; x++) { vertices.push_back(vec3(x*(1.0f/columns), 0, z*(1.0f/rows))); texcoords.push_back(vec2(x*0.5f, z*0.5f)); } } for(int row = 0; row < rows; row++) { for(int column = 0; column < columns; column++) { indices.push_back(column + row * (columns + 1)); indices.push_back(column + (row + 1) * (columns + 1)); indices.push_back(column + 1 + row * (columns + 1)); indices.push_back(column + 1 + row * (columns + 1)); indices.push_back(column + (row + 1) * (columns + 1)); indices.push_back(column + 1 + (row + 1) * (columns + 1)); } } setVertices(vertices); setIndices(indices); setTexcoords(texcoords); material.setSpecularReflectance(0.05f); material.setShininess(1.0f); material.setAmbientReflectance(0.5f); init(); calculateNormals(); }
ShapeEntity::ShapeEntity(const sf::Vector2f& velocity, const sf::Vector2f& acceleration, const sf::Vector2f& maxVelocity, const sf::Vector2f& accValues, const Vertices& vertices) :Entity(velocity,acceleration,maxVelocity,accValues), shape_(), bounds_(){ if (vertices.size()>0) setVertices(vertices); }
void BezierShape::createCurve() { const size_t num = std::max(20, (int)(Math::getDistance(points[0], points[3]) / 10)); float dt = 1.0f / (num - 1); std::vector<Vector> vertices(num); for (size_t i = 0; i < num; ++i) vertices[i] = pointOnCubicBezier(i * dt); setVertices(vertices); }
void PolygonLine :: cropPolygon(const double &iArcPosStart, const double &iArcPosEnd) { std::vector<FloatArray> points; giveSubPolygon(points, iArcPosStart, iArcPosEnd); setVertices(points); const double tol2 = 1.0e-18; removeDuplicatePoints(tol2); }
FXGLCircleSource() : FXGLVertices(0,0,0, VERTICES_LINES|VERTICES_LOOPLINES|VERTICES_NODEPTHTEST), vertices(0) { static const FXuint no=128; FXERRHM(vertices=new FXVec3f[no]); for(FXuint n=0; n<no; n++) vertices[n]=FXVec3f(sin((float)PI*2/no*n), cos((float)PI*2/no*n), 0); setVertices(vertices, no); setLineSize(0.1f); setColor(FXGLColor(0,0,0)); }
// ********************************************************* void CPrimRender::setVertices(const std::vector<NLMISC::CVector2f> &vertices) { //H_AUTO(R2_CPrimRender_setVertices) std::vector<CVector> vertices3D(vertices.size()); for(uint k = 0; k < vertices.size(); ++k) { vertices3D[k] = vertices[k]; } setVertices(vertices3D); }
void Mesh::init(const QVector<QPointF>& points, int nColumns, int nRows) { Q_ASSERT(nColumns >= 2 && nRows >= 2); Q_ASSERT(points.size() == nColumns * nRows); _nColumns = nColumns; _nRows = nRows; setVertices(points); build(); }
bool QChain::read(const QJsonObject &obj) { std::vector<QPointF> pts; QJsonArray array = obj["vertices"].toArray(); for (int i = 0; i < array.size(); i++) pts.push_back(Utility::Json::toPoint(array[i].toObject())); setVertices(pts); texture().setSource(obj["textureSource"].toString()); texture().setTextureScale( QVector2D(Utility::Json::toPoint(obj["textureScale"].toObject()))); return true; }
void ofApp::update(){ gn1.addFrame( 0.01 ); gn1.update(); gn2.addFrame( 0.021 ); gn2.update(); setVertices(); //setIndices(); //setColors(); }
void SkyBuildingRoof::update(float dt, Point pos) { if (!dead) { setVertices(pos); // setGroundBuildings(pos); } else { if ((pos.x - lastPos.x) > MonsterOffset) { afterDeath = true; } } }
Plane* Plane::init(LPDIRECT3DDEVICE9 device) { CUSTOMVERTEX vtx[] = { CUSTOMVERTEX(D3DXVECTOR3(-1, 0, 1), D3DXVECTOR3(0, 1, 0), 0x00ffffff, D3DXVECTOR2(0, 0)), CUSTOMVERTEX(D3DXVECTOR3( 1, 0, 1), D3DXVECTOR3(0, 1, 0), 0x00ffffff, D3DXVECTOR2(1, 0)), CUSTOMVERTEX(D3DXVECTOR3(-1, 0, -1), D3DXVECTOR3(0, 1, 0), 0xffffffff, D3DXVECTOR2(0, 1)), CUSTOMVERTEX(D3DXVECTOR3( 1, 0, -1), D3DXVECTOR3(0, 1, 0), 0xffffffff, D3DXVECTOR2(1, 1)), }; setVertices(vtx, 4); LPD3DXBUFFER code; LPD3DXBUFFER error; D3DXCompileShaderFromFile("shader.hlsl", NULL, NULL, "vertexShaderTexture", "vs_2_0", 0, &code, &error, &_vs_constant_table); if(error) { OutputDebugString((LPCSTR)error->GetBufferPointer()); vbuf->Release(); error->Release(); return 0; } device->CreateVertexShader((DWORD*)code->GetBufferPointer(), &_vs); code->Release(); D3DXCompileShaderFromFile("shader.hlsl", NULL, NULL, "pixelShaderTexture", "ps_2_0", 0, &code, &error, &_ps_constant_table); if(error) { OutputDebugString((LPCSTR)error->GetBufferPointer()); vbuf->Release(); _vs_constant_table->Release(); _vs->Release(); error->Release(); return 0; } device->CreatePixelShader((DWORD*)code->GetBufferPointer(), &_ps); code->Release(); D3DXCreateTextureFromFile(device, "textures/ground.png", &texture); angle = (D3DX_PI / 180.0f * 2); //D3DXMATRIX rot; //D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(1, 0, 0), (D3DX_PI / 180.0f * -90)); //world *= rot; return this; }
void DrawableStatsAttachment::operator -=(DrawableStatsAttachment *arg) { setVertices (getVertices() - arg->getVertices()); setPoints (getPoints() - arg->getPoints()); setLines (getLines() - arg->getLines()); setTriangles (getTriangles() - arg->getTriangles()); setPatches (getPatches () - arg->getPatches ()); setProcessedAttributeBytes(getProcessedAttributeBytes() - arg->getProcessedAttributeBytes()); setStoredAttributeBytes (getStoredAttributeBytes() - arg->getStoredAttributeBytes()); setValid(true); }
void AddChain::finished() { SubAction::finished(); auto chain = std::make_unique<QChain>(world()); chain->setVertices(m_pts); chain->texture().setSource(":/resources/rock.png"); chain->texture().setTextureScale(QVector2D(0.05, 0.05)); chain->initialize(world()); m_state |= DirtyState::Finished; update(); world()->itemSet()->addBody(std::move(chain)); }
void GLSubBuffer::setBatchVertices(int batchIndex, dsize elementCount, void *data) { DENG2_ASSERT(d->batchIndexOffset >= 0); dsize const elementSize = d->format.first->stride; duint8 *elems = reinterpret_cast<duint8 *>(data); for (dsize i = 0; i < elementCount; ++i) { *reinterpret_cast<float *>(elems + d->batchIndexOffset + i * elementSize) = float(batchIndex); } setVertices(elementCount, data); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int VertexGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { herr_t err = 0; SharedVertexList::Pointer vertices = SharedVertexList::NullPointer(); vertices = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedVertexList>(DREAM3D::Geometry::SharedVertexList, parentId, preflight, err); if (vertices.get() == NULL) { return -1; } setVertices(vertices); return 1; }
STDMETHODIMP CVisComplexObj::put_vertices(VARIANT newVal) { double *data; HRESULT result = VariantToDoubleArray(&data, &newVal); logToFile((f, "putVertices: %d\n", result)); if (result) return E_INVALIDARG; if (data != NULL) { if (GetDim(data) != 2) return E_INVALIDARG; if (GetLength(data, 0) != 2 && GetLength(data, 0) != 3) return E_INVALIDARG; } setVertices(data); FreeDoubleArray(scrVertices); scrVertices = CopyDoubleArrayStruct(getVertices()); updateScrVertices(); return S_OK; }
void ModelMD2::prepareFrame() { #ifdef DEBUG static bool isFirst = true; if (isFirst) { printf("Call ModelMD2::prepareFrame()...\n"); isFirst = false; } #endif if (m_actionIdx == -1) return; float *uvs = (float *) malloc(m_header.numTriangles * 6 * sizeof(float)); float *vertices = (float *) malloc(m_header.numTriangles * 9 * sizeof(float)); float *normals = (float *) malloc(m_header.numTriangles * 9 * sizeof(float)); int i, j, uvIdx = 0, vertexIdx = 0, normalIdx = 0; md2_frame_t *f = &m_frames[m_frameIdx]; for (i = 0; i < m_header.numTriangles; i++) { md2_triangle_t *t = &m_triangles[i]; for (j = 0; j < 3; j++) { //set uvs uvs[uvIdx++] = (float) m_texCoords[t->textureIndices[j]].s / (float) m_header.skinWidth; uvs[uvIdx++] = 1.0f - (float) m_texCoords[t->textureIndices[j]].t / (float) m_header.skinHeight; //set vertices & normals vertices[vertexIdx++] = f->vertices[t->vertexIndices[j]].vertex[0]; vertices[vertexIdx++] = f->vertices[t->vertexIndices[j]].vertex[1]; vertices[vertexIdx++] = f->vertices[t->vertexIndices[j]].vertex[2]; normals[normalIdx++] = f->vertices[t->vertexIndices[j]].normal[0]; normals[normalIdx++] = f->vertices[t->vertexIndices[j]].normal[2]; normals[normalIdx++] = f->vertices[t->vertexIndices[j]].normal[1]; } } setVertices(vertices, m_header.numTriangles * 9 * sizeof(float)); setNormals(normals, m_header.numTriangles * 9 * sizeof(float)); setUvs(uvs, m_header.numTriangles * 6 * sizeof(float)); FREEANDNULL(vertices); FREEANDNULL(normals); FREEANDNULL(uvs); m_frameIdx++; if (m_frameIdx > m_actions[m_actionIdx].max_idx) m_frameIdx = m_isLooped ? m_actions[m_actionIdx].min_idx : m_actions[m_actionIdx].max_idx; }
Block::Block(int column, int row, int colorValue) { this->colorValue = colorValue; this->column = column; this->row = row; setVertices(); indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 1; indices[4] = 2; indices[5] = 3; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); glGenBuffers(1, &EBO); setVAO(); }
void DrawableStatsAttachment::reset(void) { // Don't change it unless it's valid. // Needed to protect intermediate results if(!getValid()) return; setVertices (0); setPoints (0); setLines (0); setTriangles (0); setPatches (0); setProcessedAttributeBytes(0); setStoredAttributeBytes (0); setValid(false); }
// Initialise Mesh, Shaders & Textures. bool Setup() { setVertices(); //Create all the shaders shaders.addShader(PGShader("Particle", "particle.vert", "particle.frag")); shaders.addShader(PGShader("Sky", "sky.vert", "sky.frag")); shaders.addShader(PGShader("Clouds", "clouds.vert", "clouds.frag")); //Load all textures LoadTexture("Fireworks", "fire.tga"); LoadTexture("Water", "ice.tga"); LoadTexture("Sky", "night_sky.tga"); LoadTexture("Clouds", "clouds.tga"); return true; }
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// //::::::::::::::::::::::Room CLASS METHODS::::::::::::::::::::::::::::// Room::Room(float newX, float newY, float newZ, float width=20.0f, float depth=30.0f, float height=20.0f, float r=0.0f, float g=1.0f, float b=0.0f, float r2=0.0f, float g2=0.0f, float b2=0.0f) { Shape::set(newX, newY, newZ, width, depth, height, r, g, b,r2,g2,b2); //floor walls[0] = new Cube(x,y,z, w,d,1.0f, red,green,blue, red2,green2,blue2); //front walls[1] = new Cube(x,y-(d/2)+0.5f,z+(h/2)+0.5f, w-1.0f,1.0f,h, red+redShift,green+greenShift,blue+blueShift, red2+redShift,green2+greenShift,blue2+blueShift); //back walls[2] = new Cube(x,y+(d/2)-0.5f,z+(h/2)+0.5f, w-1.0f,1.0f,h, red,green,blue, red2,green2,blue2); //left walls[3] = new Cube(x-(w/2)+0.5f,y,z+(h/2)+0.5f, 1.0f,d-1.0f,h, red+redShift,green+greenShift,blue+blueShift, red2+redShift,green2+greenShift,blue2+blueShift); //right walls[4] = new Cube(x+(w/2)-0.5f,y,z+(h/2)+0.5f, 1.0f,d-1.0f,h, red,green,blue, red2,green2,blue2); //ceiling walls[5] = new Cube(x,y,z+h+1.0f, w,d,1.0f, red+redShift,green+greenShift,blue+blueShift, red2+redShift,green2+greenShift,blue2+blueShift); setVertices(); }
/** Method to scale the positions in the mesh. Normals will be kept as is. This is a potentially slow operation, use with care. * It will also create a temporary float[] which will be garbage collected. * * @param scaleX scale on x * @param scaleY scale on y * @param scaleZ scale on z */ void Mesh::scale (float scaleX, float scaleY, float scaleZ) { //TODO: VertexAttribute posAttr(-1, 0, ""); getVertexAttribute(VertexAttributes::Position, posAttr); int offset = posAttr.offset / 4; int numComponents = posAttr.numComponents; int numVertices = getNumVertices(); int vertexSize = getVertexSize() / 4; float* vertices = new float[numVertices * vertexSize]; memcpy(vertices, m_vertices->getBuffer(), sizeof(float) * numVertices * vertexSize); int idx = offset; switch (numComponents) { case 1: for (int i = 0; i < numVertices; i++) { vertices[idx] *= scaleX; idx += vertexSize; } break; case 2: for (int i = 0; i < numVertices; i++) { vertices[idx] *= scaleX; vertices[idx + 1] *= scaleY; idx += vertexSize; } break; case 3: for (int i = 0; i < numVertices; i++) { vertices[idx] *= scaleX; vertices[idx + 1] *= scaleY; vertices[idx + 2] *= scaleZ; idx += vertexSize; } break; } setVertices(vertices, numVertices * vertexSize); delete [] vertices; }
int TriangleMeshData::setDataProperty(int property, void const* value, int numElements) { if (property == NUM_VERTICES) { return setNumVertices(*((unsigned int const*) value)); } else if (property == NUM_INDICES) { return setNumIndices(*((unsigned int const*) value)); } else if (property == X_COORDINATES) { setDataX((double const*) value, numElements); } else if (property == Y_COORDINATES) { setDataY((double const*) value, numElements); } else if (property == Z_COORDINATES) { setDataZ((double const*) value, numElements); } else if (property == COORDINATES) { setVertices((double const*) value, numElements); } else if (property == INDICES) { setIndices((unsigned int const*) value, numElements); } else if (property == VALUES) { setValues((double const*) value, numElements); } else { return Data3D::setDataProperty(property, value, numElements); } return 1; }