Пример #1
0
  correlation::parameters&
    correlation::parameters::copy(const parameters& other) {
# ifndef _LTI_MSC_6
    // MS Visual C++ 6 is not able to compile this...
    filter::parameters::copy(other);
# else
    // ...so we have to use this workaround.
    // Conditional on that, copy may not be virtual.
    filter::parameters& (filter::parameters::* p_copy)
      (const filter::parameters&) =
      filter::parameters::copy;
    (this->*p_copy)(other);
# endif

    delete kernel;
    kernel = 0;

    if (notNull(other.kernel)) {
      kernel = other.kernel->clone();
    }

    delete mask;
    mask = 0;

    if (notNull(other.mask)) {
      mask = dynamic_cast<channel8*>(other.mask->clone());
    }

    kernelAverage = other.kernelAverage;
    kernelSize = other.kernelSize;
    mode = other.mode;
    useMask = other.useMask;

    return *this;
  }
Пример #2
0
void Renderer::computeShadowing
   (RenderDevice*                       rd,
    const Array<shared_ptr<Surface>>&   allSurfaces, 
    const shared_ptr<GBuffer>&          gbuffer,
    const shared_ptr<Framebuffer>&      depthPeelFramebuffer,
    LightingEnvironment&                lightingEnvironment) {

    BEGIN_PROFILER_EVENT("Renderer::computeShadowing");
    // Compute shadows
    Surface::renderShadowMaps(rd, lightingEnvironment.lightArray, allSurfaces);

    if (! gbuffer->colorGuardBandThickness().isZero()) {
        rd->setGuardBandClip2D(gbuffer->colorGuardBandThickness());
    }        

    // Compute AO
    if (notNull(lightingEnvironment.ambientOcclusion)) {
        lightingEnvironment.ambientOcclusion->update
           (rd, 
            lightingEnvironment.ambientOcclusionSettings,
            gbuffer->camera(), gbuffer->texture(GBuffer::Field::DEPTH_AND_STENCIL), 
            notNull(depthPeelFramebuffer) ? depthPeelFramebuffer->texture(Framebuffer::DEPTH) : shared_ptr<Texture>(), 
            gbuffer->texture(GBuffer::Field::CS_NORMAL), 
            gbuffer->texture(GBuffer::Field::SS_POSITION_CHANGE), 
            gbuffer->depthGuardBandThickness() - gbuffer->colorGuardBandThickness());
    }
    END_PROFILER_EVENT();
}
Пример #3
0
shared_ptr<Texture> TemporalFilter::apply
   (RenderDevice* rd, 
    const Vector3&                  clipConstant,
    const Vector4&                  projConstant,
    const CFrame&                   currentCameraFrame,
    const CFrame&                   prevCameraFrame, 
    const shared_ptr<Texture>&      unfilteredValue, 
    const shared_ptr<Texture>&      depth, 
    const shared_ptr<Texture>&      ssVelocity, 
    const Vector2&                  guardBandSize,
    int                             numFilterComponents, 
    const Settings&                 settings) {

    if (settings.hysteresis == 0.0f) {
        return unfilteredValue;
    }

    alwaysAssertM((settings.hysteresis >= 0.0f) && (settings.hysteresis <= 1.0f), "TemporalFilter::Settings::hysteresis must be in [0.0, 1.0]");
    alwaysAssertM(notNull(unfilteredValue) && notNull(depth) && notNull(ssVelocity), "Sent null buffer to TemporalFilter::apply");
    alwaysAssertM((numFilterComponents >= 1) && (numFilterComponents <= 4), "numFilterComponents must be between 1 and 4");

    if (isNull(m_previousDepthBuffer) || 
        isNull(m_previousTexture) ||
        (m_previousDepthBuffer->vector2Bounds() != depth->vector2Bounds()) ||
        (m_previousTexture->vector2Bounds() != unfilteredValue->vector2Bounds())) {

        unfilteredValue->copyInto(m_previousTexture);
        depth->copyInto(m_previousDepthBuffer);
        m_resultFramebuffer = Framebuffer::create(Texture::createEmpty("TemporalFilter::m_resultFramebuffer", m_previousTexture->width(), m_previousTexture->height(), m_previousTexture->format()));
        Texture::copy(m_previousTexture, m_resultFramebuffer->texture(0));
        return m_resultFramebuffer->texture(0);
    }

    rd->push2D(m_resultFramebuffer); {
        Args args;
        args.setMacro("FILTER_COMPONENT_COUNT", numFilterComponents);
        ssVelocity->setShaderArgs(args, "ssVelocity_", Sampler::buffer());
        unfilteredValue->setShaderArgs(args, "unfilteredValue_", Sampler::buffer());
        depth->setShaderArgs(args, "depth_", Sampler::buffer());
        m_previousDepthBuffer->setShaderArgs(args, "previousDepth_", Sampler::video());
        m_previousTexture->setShaderArgs(args, "previousValue_", Sampler::video());

        args.setUniform("guardBandSize", guardBandSize);

        args.setUniform("cameraToWorld", currentCameraFrame);    
        args.setUniform("cameraToWorldPrevious", prevCameraFrame);
        
        args.setUniform("clipInfo", clipConstant);
        args.setUniform("projInfo", projConstant);

        settings.setArgs(args);
        args.setRect(rd->viewport());

        LAUNCH_SHADER("TemporalFilter_apply.*", args);
        m_resultFramebuffer->texture(0)->copyInto(m_previousTexture);

        depth->copyInto(m_previousDepthBuffer);
    } rd->pop2D();
     return m_resultFramebuffer->texture(0);
}
Пример #4
0
void Entity::init
   (const std::string&          name,
    Scene*                      scene,
    const CFrame&               frame,
    const shared_ptr<Track>&    track,
    bool                        canChange,
    bool                        shouldBeSaved) {

    m_name          = name;
    m_canChange     = canChange;
    m_shouldBeSaved = shouldBeSaved;
    m_track         = track;
    m_scene         = scene;

    if (notNull(track)) {
        m_previousFrame = m_frame = m_track->computeFrame(0);
    } else {
        m_frame = m_previousFrame = frame;
    }
    
    m_lastChangeTime = System::time();
    if (! m_canChange && notNull(m_track)) {
        debugAssertM(false, "Track specified for an Entity that cannot change.");
    }
}
Пример #5
0
void Object::onPose(SpriteSurface& surface) const {

    surface.spriteSheet = m_model->spriteSheet();
    surface.elevation   = elevation();
    surface.zOrder      = zOrder();
    surface.frame       = frame();

	const shared_ptr<Animation>& animation = m_model->animation(m_animationName);
    debugAssert(notNull(animation));

	const shared_ptr<Sprite>& sprite = animation->sprite(m_animationFrame);
    debugAssert(notNull(sprite));

    if (! animation->rotates()) {
        surface.frame.rotation = 0.0f;
    }

    // Offset of the upper-left corner from the 
    // frame's origin, in the frame's coordinate 
    // system.
	surface.texelOrigin		= sprite->originOffset();

    // Source texture coordinates
	surface.upperLeftTexel	= sprite->topLeft();

    // Source texture coordinates
	surface.texelSize		= sprite->size();
}
Пример #6
0
void ImageStats::init(int width, int height, int sampleBudget, int samplesPerIteration){

	for (int f = 0 ; f < FT_SIZE ; f++){
		if (!notNull(m_imageMean) || m_w != width || m_h != height)
			m_imageMean[f]	= Image3::createEmpty(width, height);
		if (!notNull(m_imageVar) || m_w != width || m_h != height)
			m_imageVar[f]	= Image3::createEmpty(width, height);
	}

	for (int f= 0 ; f < FT_SIZE ; f++){
		for (int c = 0 ; c < COLOR_CHS ; c++){ 
			if (m_dataMn[f][c] != nullptr) {
				for (int x = 0 ; x < m_w ; x++){
					delete m_dataMn[f][c][x];
					delete m_dataVr[f][c][x];
				}
				delete m_dataMn[f][c];
				delete m_dataVr[f][c];
			}
			m_dataMn[f][c] = new float*[width];
			m_dataVr[f][c] = new float*[width];
		}
	}

	m_samples		= new int*[width];
	m_samplesToGo	= new int*[width];
	for (int x = 0 ; x < width ; x++){
		for (int f = 0 ; f < FT_SIZE ; f++){
			m_dataMn[f][0][x] = new float[height];
			m_dataMn[f][1][x] = new float[height];
			m_dataMn[f][2][x] = new float[height];

			m_dataVr[f][0][x] = new float[height];
			m_dataVr[f][1][x] = new float[height];
			m_dataVr[f][2][x] = new float[height];
		}

		m_samples[x]		= new int[height];
		m_samplesToGo[x]	= new int[height];
		for (int y = 0 ; y < height ; y++){
			for (int f = 0 ; f < FT_SIZE ; f++){
				m_dataMn[f][0][x][y] = 0;
				m_dataMn[f][1][x][y] = 0;
				m_dataMn[f][2][x][y] = 0;

				m_dataVr[f][0][x][y] = 0;
				m_dataVr[f][1][x][y] = 0;
				m_dataVr[f][2][x][y] = 0;
			}

			m_samples[x][y] = 0;
			m_samplesToGo[x][y] = samplesPerIteration;
		}
	}
	m_w = width;
	m_h = height;
	m_sampleBudget = sampleBudget;
	m_samplesPerIteration = samplesPerIteration;
}
Пример #7
0
void Foam::cuttingPlane::calcCutCells
(
    const primitiveMesh& mesh,
    const scalarField& dotProducts,
    const labelUList& cellIdLabels
)
{
    const labelListList& cellEdges = mesh.cellEdges();
    const edgeList& edges = mesh.edges();

    label listSize = cellEdges.size();
    if (notNull(cellIdLabels))
    {
        listSize = cellIdLabels.size();
    }

    cutCells_.setSize(listSize);
    label cutcellI(0);

    // Find the cut cells by detecting any cell that uses points with
    // opposing dotProducts.
    for (label listI = 0; listI < listSize; ++listI)
    {
        label cellI = listI;

        if (notNull(cellIdLabels))
        {
            cellI = cellIdLabels[listI];
        }

        const labelList& cEdges = cellEdges[cellI];

        label nCutEdges = 0;

        forAll(cEdges, i)
        {
            const edge& e = edges[cEdges[i]];

            if
            (
                (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
             || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
            )
            {
                nCutEdges++;

                if (nCutEdges > 2)
                {
                    cutCells_[cutcellI++] = cellI;

                    break;
                }
            }
        }
    }

    // Set correct list size
    cutCells_.setSize(cutcellI);
}
Пример #8
0
int IconSet::getIndex(const String& s) const {
    const int* i = m_index.getPointer(s);
        
    if (notNull(i)) {
        return *i;
    } else {
        debugAssertM(notNull(i), format("Icon \"%s\" not found.", s.c_str()));
        return 0;
    }
}
Пример #9
0
void Foam::polyMesh::resetPrimitives
(
    const Xfer<pointField>& points,
    const Xfer<faceList>& faces,
    const Xfer<labelList>& owner,
    const Xfer<labelList>& neighbour,
    const labelList& patchSizes,
    const labelList& patchStarts,
    const bool validBoundary
)
{
    // Clear addressing. Keep geometric props and updateable props for mapping.
    clearAddressing(true);

    // Take over new primitive data.
    // Optimized to avoid overwriting data at all
    if (notNull(points))
    {
        points_.transfer(points());
        bounds_ = boundBox(points_, validBoundary);
    }

    if (notNull(faces))
    {
        faces_.transfer(faces());
    }

    if (notNull(owner))
    {
        owner_.transfer(owner());
    }

    if (notNull(neighbour))
    {
        neighbour_.transfer(neighbour());
    }


    // Reset patch sizes and starts
    forAll(boundary_, patchI)
    {
        boundary_[patchI] = polyPatch
        (
            boundary_[patchI],
            boundary_,
            patchI,
            patchSizes[patchI],
            patchStarts[patchI]
        );
    }
void Foam::MeshedSurfaceIOAllocator::resetFaces
(
    const Xfer<List<face>>& faces,
    const Xfer<surfZoneList>& zones
)
{
    if (notNull(faces))
    {
        faces_.transfer(faces());
    }

    if (notNull(zones))
    {
        zones_.transfer(zones());
    }
}
Пример #11
0
void App::updateSonicSculpture(int audioSampleOffset, int audioSampleCount) {
	float delta = 0.1f;
	float radius = sqrt(m_smoothedRootMeanSquare) * 1.0f;
	CFrame frame = activeCamera()->frame();
	// Offset a bit forward
	frame.translation += activeCamera()->frame().lookVector() * 0.2f;
	// Offset 3 inches down to the mouth opening
	frame.translation += activeCamera()->frame().upVector() * -0.0762f;
	if (m_appMode == AppMode::DEFAULT) {
		if (notNull(m_currentSonicSculpturePiece)) {
			if (m_currentSonicSculpturePiece->size() > 0) {
                m_sonicSculpturePieces.append(m_currentSonicSculpturePiece);
                m_lastInterestingEventTime = System::time();
			}
			m_currentSonicSculpturePiece = shared_ptr<SonicSculpturePiece>();
		}
	} else if (m_appMode == AppMode::MAKING_SCULPTURE) {
		if (isNull(m_currentSonicSculpturePiece)) {
            shared_ptr<UniversalMaterial> material = getSonicSculptureMaterial(m_sonicSculpturePieces.size());
			m_currentSonicSculpturePiece = SonicSculpturePiece::create(material);
		}
        m_lastInterestingEventTime = System::time();
		// TODO: eliminate some of the redundant copies
		Array<float> samples;
		samples.resize(audioSampleCount);
		for (int i = 0; i < audioSampleCount; ++i) {
			samples[i] = m_cpuRawAudioSnapshot[i + audioSampleOffset];
		}
		m_currentSonicSculpturePiece->insert(frame, radius, delta, samples);
	}
}
Пример #12
0
  /*
   * destroy XImage
   */
  void fastViewer::destroyImage() {
    if (notNull(display_info.shmimage)) {

      if (useShareMemory) {
        XShmDetach(display_info.display,&shminfo);
      }
      XDestroyImage(display_info.shmimage);
      display_info.shmimage = 0;

      if (useShareMemory) {
        // delete the shared memory block!
        shmid_ds shmStruct;

        shmStruct.shm_nattch = 0;
        shmdt(shminfo.shmaddr);
        if (shmctl(shminfo.shmid,IPC_RMID,&shmStruct) < 0) {
          std::string str;
          str = "fastViewer::shmctl failed:";
          str += std::strerror(errno);

          throw exception(str);
        }

        shminfo.shmid = -1;
      }
    }
  }
Пример #13
0
 /*
  * destructor
  */
 fastViewer::~fastViewer() {
   destroyWindow();
   if (notNull(display_info.display)) {
     XCloseDisplay(display_info.display);
     display_info.display = 0;
   }
 }
Пример #14
0
bool ArticulatedViewer::onEvent(const GEvent& e, App* app) {
    if ((e.type == GEventType::MOUSE_BUTTON_DOWN) && (e.button.button == 0) && ! app->userInput->keyDown(GKey::LCTRL)) {
        // Intersect all tri lists with the ray from the camera
        const Ray& ray = app->activeCamera()->worldRay(e.button.x, e.button.y, 
            app->renderDevice->viewport());

        m_selectedPart = NULL;
        m_selectedMesh = NULL;
        m_selectedTriangleIndex = -1;
        Model::HitInfo hitInfo;
        float distance = finf();
        const bool hit = m_model->intersect(ray, m_offset, ArticulatedModel::defaultPose(), distance, hitInfo);

        if (hit) {
//            shared_ptr<ArticulatedModel> model = dynamic_pointer_cast<ArticulatedModel>(hitInfo.model);
//            alwaysAssertM(notNull(model), "Not a model!");
            m_selectedMesh = m_model->mesh(hitInfo.meshID);
            m_selectedTriangleIndex = hitInfo.primitiveIndex;
        }

        if (notNull(m_selectedMesh)) {
            m_selectedPart = m_selectedMesh->logicalPart;
        }
        return hit;
    } else if ((e.type == GEventType::KEY_DOWN) && (e.key.keysym.sym == 'r')) {
        onInit(m_filename);
        return true;
    }

    return false;
}
Пример #15
0
Any Entity::toAny() const {
    Any a = m_sourceAny;
    debugAssert(! a.isNil());
    if (a.isNil()) {
        // Fallback for release mode failure
        return a;
    }

    if (m_movedSinceLoad) {
        a["frame"] = m_frame;
    }

    const shared_ptr<SplineTrack>& splineTrack = dynamic_pointer_cast<SplineTrack>(m_track);
    if (notNull(splineTrack) && splineTrack->changed()) {
        // Update the spline
        const PhysicsFrameSpline& spline = splineTrack->spline();
        if (spline.control.size() == 1) {
            // Write out in short form for the single control point
            const PhysicsFrame& p = spline.control[0];
            if (p.rotation == Quat()) {
                // No rotation
                a["track"] = p.translation;
            } else {
                // Full coordinate frame
                a["track"] = CFrame(p);
            }
        } else {
            // Write the full spline
            a["track"] = spline;
        }
    }

    a.setName("Entity");
    return a;
}
Пример #16
0
shared_ptr<UniversalMaterial> UniversalMaterial::create
(const shared_ptr<UniversalBSDF>&    bsdf,
 const Component3&                   emissive,
 const shared_ptr<BumpMap>&          bump,
 const Array<Component3>&            lightmaps,
 const shared_ptr<MapComponent<Image4> >& customMap,
 const Color4&                       customConstant,
 const std::string&                  customShaderPrefix) {
    alwaysAssertM(lightmaps.size() <= 1 || lightmaps.size() == 3, format("Tried to create material with %d directional lightmaps, must have 0, 1, or 3", lightmaps.size()));
    shared_ptr<UniversalMaterial> m = UniversalMaterial::createEmpty();

    if (notNull(bsdf)) {
        const shared_ptr<Texture>& texture = bsdf->lambertian().texture();
        if (texture) {
            m->m_name = texture->name();
        }
    }

    m->m_bsdf       = bsdf;
    m->m_emissive   = emissive;
    m->m_bump       = bump;

    m->m_numLightMapDirections = lightmaps.size();
    for (int i = 0; i < lightmaps.size(); ++i) {
        m->m_lightMap[i] = lightmaps[i];
    }

    m->m_customMap          = customMap;
    m->m_customConstant     = customConstant;
    m->m_customShaderPrefix = customShaderPrefix;

    m->computeDefines(m->m_macros);

    return m;
}
Пример #17
0
String OSWindow::clipboardText() {
    if (notNull(current())) {
        return current()->_clipboardText();
    } else {
        return "";
    }
}
Foam::distributedDirectFieldMapper::distributedDirectFieldMapper
(
    const labelUList& directAddressing,
    const mapDistributeBase& distMap,
    const label constructSize
)
:
    directAddressing_(directAddressing),
    hasUnmapped_(false)
{
    if (constructSize == -1)
    {
        distMap_ = distMap;
    }
    else
    {
        distMap_.constructSize() = constructSize;
        distMap_.subMap() = distMap.constructMap();
        distMap_.subHasFlip() = distMap.constructHasFlip();
        distMap_.constructMap() = distMap.subMap();
        distMap_.constructHasFlip() = distMap.subHasFlip();
    }

    if
    (
        notNull(directAddressing_)
     && directAddressing_.size()
     && min(directAddressing_) < 0
    )
    {
        hasUnmapped_ = true;
    }
}
Пример #19
0
Foam::surfMesh::surfMesh
(
    const IOobject& io,
    const Xfer<MeshedSurface<face> >& surf,
    const word& surfName
)
:
    surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
    Allocator
    (
        IOobject
        (
            "points",
            instance(),
            meshSubDir,
            *this,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        pointField(),
        IOobject
        (
            "faces",
            instance(),
            meshSubDir,
            *this,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        faceList(),
        IOobject
        (
            "surfZones",
            instance(),
            meshSubDir,
            *this,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        surfZoneList()
    ),
    MeshReference(this->storedIOFaces(), this->storedIOPoints())
{
    if (debug)
    {
        Info<<"IOobject: " << io.path() << nl
            <<" name: " << io.name()
            <<" instance: " << io.instance()
            <<" local: " << io.local()
            <<" dbDir: " << io.db().dbDir() << endl;
        Info<<"creating surfMesh at instance " << instance() << endl;
        Info<<"timeName: " << instance() << endl;
    }

    // We can also send Xfer<..>::null just to initialize without allocating
    if (notNull(surf))
    {
        transfer(surf());
    }
}
Пример #20
0
void XComboBox::sHandleNewIndex(int pIndex)
{
  if (DEBUG)
    qDebug("%s::sHandleNewIndex(%d)",objectName().toAscii().data(), pIndex);

  if ((pIndex >= 0) && (pIndex < _ids.count()) && (_ids.at(pIndex) != _lastId))
  {
    _lastId = _ids.at(pIndex);
    emit newID(_lastId);

    if (DEBUG)
      qDebug("%s::sHandleNewIndex() emitted %d",
             objectName().toAscii().data(), _lastId);

    if (allowNull())
    {
      emit valid((pIndex != 0));
      emit notNull((pIndex != 0));
    }
  }

  if (DEBUG)
    qDebug("%s::sHandleNewIndex() returning",
           objectName().toAscii().data());
}
Пример #21
0
void printList( struct node* l ) {
    struct node* tmp = l;
    while ( notNull(tmp) ) {
        printf("%d ",tmp -> x);
        tmp = tmp -> next;
    }
}
Radiance3 RayTracer::L_scatteredSpecularIndirect(const shared_ptr<Surfel>& surfel, const Vector3& wo, int bouncesLeft, Random& rnd) const{
    Radiance3 L(0,0,0);
    if (bouncesLeft > 0){
        G3D::UniversalSurfel::ImpulseArray impulses;

        //Downcast to universalSurfel to allow getting impulses
        const shared_ptr<UniversalSurfel>& u = dynamic_pointer_cast<UniversalSurfel>(surfel);
        debugAssertM(notNull(u), "Encountered a Surfel that was not a UniversalSurfel");
        
        //Find the impulses on the surface
        u->getImpulses(PathDirection::EYE_TO_SOURCE, wo, impulses);

        //For each impulses, recursively computed the radiance from that direction
        for (int i = 0; i < impulses.size(); ++i){
            Vector3 wi = impulses[i].direction;
            Color3 magnitude = impulses[i].magnitude;
            ++m_stats->indirectRays;
            L += L_i(surfel->position, wi, bouncesLeft - 1, rnd) * magnitude;
        }
        
        //If we enable path tracing, also cast a random ray from the surfel
        //Technically it is not SpecularIndirect. But as it is not used often, I'm going to leave it here
        if (m_settings.enablePathTracing){
            Vector3 wi = Vector3::hemiRandom(surfel->shadingNormal, rnd);
            L += L_i(surfel->position, wi, bouncesLeft - 1, rnd) * surfel->finiteScatteringDensity(wi,wo) * abs(wi.dot(surfel->shadingNormal));
        }
    }
    return L;
}
Пример #23
0
 // return the mask in use, or throw exception if none present
 const channel8& correlation::parameters::getMask() const {
   if (notNull(mask)) {
     return *mask;
   } else {
     throw invalidParametersException(getTypeName());
   }
 }
void ArticulatedModel::Part::transformGeometry(shared_ptr<ArticulatedModel> am, const Matrix4& xform) {
    // TODO: this is a linear search through the mesh array for every part, could be sped up
    // TODO: this transforms any geometry that is touch by a mesh in this part. This will have
    // unintended side effects when multiple parts have meshes that share geometry
    Set<ArticulatedModel::Geometry*> touchedGeometry;
    for (int i = 0; i < am->m_meshArray.size(); ++i) {
        Mesh* mesh = am->m_meshArray[i];
        alwaysAssertM(notNull(mesh->geometry), "Found a NULL mesh in transformGeometry");
        if ( mesh->logicalPart == this && ! touchedGeometry.contains(mesh->geometry)) {
            touchedGeometry.insert(mesh->geometry);
            CPUVertexArray::Vertex* vertex = mesh->geometry->cpuVertexArray.vertex.getCArray();
            const int N = mesh->geometry->cpuVertexArray.size();
            for (int i = 0; i < N; ++i) {
                vertex->position = xform.homoMul(vertex->position, 1.0f);
                vertex->tangent  = Vector4::nan();
                vertex->normal   = Vector3::nan();
                ++vertex;
            }
        }
  
    }
    for (int c = 0; c < m_children.size(); ++c) {
        m_children[c]->cframe.translation = 
            xform.homoMul(m_children[c]->cframe.translation, 1.0f);
    }
}
Пример #25
0
const shared_ptr<Entity> Scene::entity(const std::string& name) const {
    shared_ptr<Entity>* e = m_entityTable.getPointer(name);
    if (notNull(e)) {
        return *e;
    } else {
        return shared_ptr<Entity>();
    }
}
Пример #26
0
void XComboBox::populate(XSqlQuery &pQuery, int pSelected)
{
  int selected = 0;
  int counter  = 0;

//  Clear any old data
  clear();

  if (allowNull())
    counter++;

//  Load the combobox with the contents of the passed query, if any
  if (pQuery.first())
  {
    do
    {
      append(pQuery.value(0).toInt(), pQuery.value(1).toString(), pQuery.value(2).toString());

      if (pQuery.value(0).toInt() == pSelected)
        selected = counter;

      counter++;
    }
    while(pQuery.next());
  }

  setCurrentIndex(selected);
  if (_ids.count())
  {
    _lastId = _ids.at(selected);

    if (allowNull())
      emit notNull(TRUE);
  }
  else
  {
    _lastId = -1;

    if (allowNull())
      emit notNull(FALSE);
  }

  emit newID(_lastId);
  emit valid((_lastId != -1));
}
Пример #27
0
void AmbientOcclusion::PerViewBuffers::resizeBuffers(shared_ptr<Texture> depthTexture, const shared_ptr<Texture>& peeledDepthTexture) {
    bool rebind = false;
    const int width = depthTexture->width();
    const int height = depthTexture->height();
    const ImageFormat* csZFormat = cszBufferImageFormat(notNull(peeledDepthTexture));

    static int cszBufferIndex = 0;
    if (notNull(cszBuffer) && ((cszBuffer->width() != width) || (cszBuffer->height() != height))) {
        cszBuffer = shared_ptr<Texture>();
        cszBufferIndex = 0;
    }

    if (isNull(cszBuffer) || (csZFormat != cszBuffer->format())) {
    
        alwaysAssertM(ZBITS == 16 || ZBITS == 32, "Only ZBITS = 16 and 32 are supported.");

        debugAssert(width > 0 && height > 0);
        cszBuffer                   = Texture::createEmpty(format("G3D::AmbientOcclusion::cszBuffer%d", cszBufferIndex), width, height, csZFormat, Texture::DIM_2D, true);

        // The buffers have to be explicitly cleared or they won't allocate MIP maps on OS X
        cszBuffer->clear();
        for (int i = 0; i <= MAX_MIP_LEVEL; ++i) {
            cszFramebuffers.append(Framebuffer::create("cszFramebuffers[" + G3D::format("%d", i) + "]"));
        }
        rebind = true;
        ++cszBufferIndex;

    } else if ((cszBuffer->width() != width) || (cszBuffer->height() != height)) {
        // Resize
        cszBuffer->resize(width, height);
        rebind = true;
    }

    if (csZFormat != cszBuffer->format()) {
        cszBuffer = Texture::createEmpty(format("AmbientOcclusion::cszBuffer%d", cszBufferIndex), width, height, csZFormat, Texture::DIM_2D, true);
        ++cszBufferIndex;
        rebind = true;
    }

    if (rebind) {
        for (int i = 0; i <= MAX_MIP_LEVEL; ++i) {
            cszFramebuffers[i]->set(Framebuffer::COLOR0, cszBuffer, CubeFace::POS_X, i);
        }
    }
}
Пример #28
0
Rect2D Applet::renderBackground(RenderDevice* rd) const {
    if (notNull(m_background)) {
        const Rect2D& rect = rd->viewport().largestCenteredSubRect(float(m_background->width()), float(m_background->height()));
        Draw::rect2D(rect, rd, Color3::white(), m_background);
        return rect;
    } else {
        return rd->viewport();
    }
}
Пример #29
0
 virtual CFrame computeFrame(SimTime time) const override {
     shared_ptr<Entity> e = m_scene->entity(m_entityName);
     if (notNull(e)) {
         return e->frame();
     } else {
         // Maybe during initialization and the other entity does not yet exist
         return CFrame();
     }
 }
Пример #30
0
void VisibleEntity::simulatePose(SimTime absoluteTime, SimTime deltaTime) {
    switch (m_modelType) {
    case ARTICULATED_MODEL:
        if (isNaN(deltaTime) || (deltaTime > 0)) {
            m_artPreviousPose.frameTable = m_artPose.frameTable;
            m_artPreviousPose.uniformTable = m_artPose.uniformTable;
            if (notNull(m_artPose.uniformTable)) {
                m_artPose.uniformTable = shared_ptr<UniformTable>(new UniformTable(*m_artPreviousPose.uniformTable));
            }
        }

        if (m_artModel->usesSkeletalAnimation()) {
            Array<String> animationNames;
            m_artModel->getAnimationNames(animationNames);
            ArticulatedModel::Animation animation;
            m_artModel->getAnimation(animationNames[0], animation);
            animation.getCurrentPose(absoluteTime, m_artPose);
        } else {
            m_artPoseSpline.get(float(absoluteTime), m_artPose);
        }

        // Intentionally only compare cframeTables; materialTables don't change (usually)
        // and are more often non-empty, which could trigger a lot of computation here.
        if (m_artPreviousPose.frameTable != m_artPose.frameTable) {
            m_lastChangeTime = System::time();
        }
        break;

    case MD2_MODEL:
        {
            MD2Model::Pose::Action a;
            m_md2Pose.onSimulation(deltaTime, a);
            if (isNaN(deltaTime) || (deltaTime > 0)) {
                m_lastChangeTime = System::time();
            }
            break;
        }

    case MD3_MODEL:
        m_md3PoseSequence.getPose(float(absoluteTime), m_md3Pose);
        m_md3Model->simulatePose(m_md3Pose, deltaTime);
        if (isNaN(deltaTime) || (deltaTime > 0)) {
            m_lastChangeTime = System::time();
        }
        break;

    case HEIGHTFIELD_MODEL:
        break;

    case NONE:
        break;

    default:
        alwaysAssertM(false, "Tried to simulate a Visible Entity that was not one of the four supported model types.\n");
        break;
    }
}