Beispiel #1
0
//-----------------------------------------------------------------------------------------
CDomeMesh::CDomeMesh(real dRadius, int iRings, int iSectors)
    : CMesh("Dome")
    , m_dRadius(dRadius)
    , m_iRings(iRings)
    , m_iSectors(iSectors)
{
    m_pBuffer = createSubMesh();
}
Beispiel #2
0
// Initialize the probe.
PetscErrorCode ProbeVolume::init(const MPI_Comm &comm,
                                 const YAML::Node &node,
                                 const type::Mesh &mesh)
{
    PetscErrorCode ierr;

    PetscFunctionBeginUser;

    ierr = ProbeBase::init(comm, node, mesh); CHKERRQ(ierr);

    // store information about the type of PETSc Viewer object to use
    std::string vtype_str = node["viewer"].as<std::string>("ascii");
    if (vtype_str == "ascii")
        viewerType = PETSCVIEWERASCII;
    else if (vtype_str == "hdf5")
        viewerType = PETSCVIEWERHDF5;
    // tolerance to define if a point belong to the sub-volume
    atol = node["atol"].as<PetscReal>(1e-6);
    // number of the time-steps over which we accumulate the data
    // data are added together and we write the time averaged data
    n_sum = node["n_sum"].as<PetscInt>(0);

    is = PETSC_NULL;
    dvec = PETSC_NULL;

    // store information about the sub-volume to monitor
    box = type::RealVec2D(3, type::RealVec1D(2, 0.0));
    for (auto item : node["box"])
    {
        type::Dir dir = type::str2dir[item.first.as<std::string>()];
        box[dir][0] = item.second[0].as<PetscReal>();
        box[dir][1] = item.second[1].as<PetscReal>();
    }

    nPtsDir.resize(3, 1);
    startIdxDir.resize(3, 0);

    // get information about the location of the sub-mesh
    ierr = getSubMeshInfo(mesh, box); CHKERRQ(ierr);
    // create gridline coordinates for the sub-mesh
    ierr = createSubMesh(mesh); CHKERRQ(ierr);
    // write the sub-mesh to file
    ierr = writeSubMesh(path); CHKERRQ(ierr);
    // create a PETSc Index Set object to easily grab a sub-vector
    ierr = createIS(mesh); CHKERRQ(ierr);

    // create a PETSc Viewer to output the data
    ierr = PetscViewerCreate(comm, &viewer); CHKERRQ(ierr);
    ierr = PetscViewerSetType(viewer, viewerType); CHKERRQ(ierr);
    // Note: we set the "append" mode as the output file already exists
    // (it was created when the sub-mesh was written into it)
    ierr = PetscViewerFileSetMode(viewer, FILE_MODE_APPEND); CHKERRQ(ierr);
    ierr = PetscViewerFileSetName(viewer, path.c_str()); CHKERRQ(ierr);

    PetscFunctionReturn(0);
}  // ProbeVolume::init
Beispiel #3
0
//-----------------------------------------------------------------------------------------
void CGrass::updateGeometry()
{
    if (m_pHeightMap)
    {
        m_pGrassBuffer = createSubMesh();
        m_pGrassBuffer->setPrimitiveType(ePrimitivePoint);

        CBuffer<QVector3D>& posBuffer = m_pGrassBuffer->positionsBuffer();
        CBuffer<IndiceType>& idBuffer = m_pGrassBuffer->indicesBuffer();
        CBuffer<QVector3D>& nBuffer = m_pGrassBuffer->normalsBuffer();

        int i = 0;

        for (real l = - m_pHeightMap->getLength() / 2.; l < m_pHeightMap->getLength() / 2.; l += dBladeStep)
        {
            for (real w = - m_pHeightMap->getWidth() / 2.; w < m_pHeightMap->getWidth() / 2.; w += dBladeStep)
            {
                real dL = l + Math::randDouble(-l/2., l/2.);
                real dW = w + Math::randDouble(-w/2., w/2.);

                QVector3D pos(dL, m_pHeightMap->getAltitude(dL, dW), dW);

                QVector3D normal = m_pHeightMap->getNormal(dL, dW);

                real iSlope = 1. - normal.y();
                if (pos.y() > 0.3 && iSlope < 0.05)
                {
                    posBuffer << pos;
                    idBuffer << i++;
                    nBuffer << normal;

                    /*
                    QMatrix4x4 T, R, S;
                    T.translate(Math::randNorm() * 0.03, 0., Math::randNorm() * 0.03);
                    R.rotate(Math::randDouble(0., 30.), 1., 0., 0.);
                    R.rotate(Math::randDouble(0., 360.), 0., 1., 0.);
                    R.rotate(Math::randDouble(0., 30.), 0., 0., 1.);
                    S.scale(Math::randNorm() + 0.5);

                    QMatrix4x4 transf = T * R * S;

                    for (int i = 0; i < 4; ++i)
                    {
                        QVector4D vColumn = transf.column(i);
                        *randMatColumnBuffer[i] << vColumn.x() << vColumn.y() << vColumn.z() << vColumn.w();
                    }*/
                }
            }
        }

        qDebug() << i - 1;
    }
}
Beispiel #4
0
void NIFMeshLoader::loadResource(Ogre::Resource *resource)
{
    Ogre::Mesh *mesh = dynamic_cast<Ogre::Mesh*>(resource);
    OgreAssert(mesh, "Attempting to load a mesh into a non-mesh resource!");

    Nif::NIFFile::ptr nif = Nif::NIFFile::create(mName);
    if(mShapeIndex >= nif->numRecords())
    {
        Ogre::SkeletonManager *skelMgr = Ogre::SkeletonManager::getSingletonPtr();
        if(!skelMgr->getByName(mName).isNull())
            mesh->setSkeletonName(mName);
        return;
    }

    const Nif::Record *record = nif->getRecord(mShapeIndex);
    createSubMesh(mesh, dynamic_cast<const Nif::NiTriShape*>(record));
}