コード例 #1
0
static void replaceField(WordSimplification *simp)
{
    assert(simp->instrText != NULL);
    assert(simp->beginNode != NULL);
    assert(simp->endNode != NULL);

    if ((simp->beginNode->parent->tag == WORD_R) && (simp->endNode->parent->tag == WORD_R)) {
        DFNode *beginRun = simp->beginNode->parent;

        DFNode *simple = DFCreateElement(simp->beginNode->doc,WORD_FLDSIMPLE);
        DFSetAttribute(simple,WORD_INSTR,simp->instrText->data);
        DFInsertBefore(beginRun->parent,simple,beginRun);

        removeNodes(simp->beginNode,simp->endNode);
    }

    DFBufferRelease(simp->instrText);
    simp->instrText = NULL;
    simp->beginNode = NULL;
    simp->endNode = NULL;

    simp->haveFields = 1;
}
コード例 #2
0
ファイル: actor_path.cpp プロジェクト: hchen1014/scummvm
void Actor::setActorPath(ActorData *actor, const Point &fromPoint, const Point &toPoint) {
	Point nextPoint;
	int8 direction;

	_pathList[0] = toPoint;
	nextPoint = toPoint;

	_pathListIndex = 0;
	while (!(nextPoint == fromPoint)) {
		direction = getPathCell(nextPoint);
		if ((direction < 0) || (direction >= 8)) {
			error("Actor::setActorPath error direction 0x%X", direction);
		}
		nextPoint.x -= pathDirectionLUT2[direction][0];
		nextPoint.y -= pathDirectionLUT2[direction][1];
		++_pathListIndex;
		if (_pathListIndex >= _pathList.size()) {
			_pathList.push_back(nextPoint);
		} else {
			_pathList[_pathListIndex] = nextPoint;
		}

#ifdef ACTOR_DEBUG
		addDebugPoint(nextPoint, 0x8a);
#endif
	}

	pathToNode();
	removeNodes();
	nodeToPath();
	removePathPoints();

	for (uint i = 0; i < _pathNodeList.size(); i++) {
		actor->addWalkStepPoint(_pathNodeList[i].point);
	}
}
コード例 #3
0
ファイル: ivperf.cpp プロジェクト: Alexpux/IvTools
static float
timeRendering(Options &options,
	      const SbViewportRegion &vpr,
	      SoSeparator *&root)
//
//////////////////////////////////////////////////////////////
{
    SbTime 		timeDiff, startTime;
    int 		frameIndex;
    SoTransform		*sceneTransform;
    SoGLRenderAction 	ra(vpr);
    SoNodeList		noCacheList;
    SoSeparator 	*newRoot;

    // clear the window
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //
    // reset autocaching threshold before each experiment
    //   done by replacing every separator in the scene graph
    //   with a new one
    //
    newRoot = (SoSeparator *) replaceSeparators(root);
    newRoot->ref();
    newRoot->renderCaching = SoSeparator::OFF;

    // get a list of separators marked as being touched by the application
    newRoot->getByName(NO_CACHE_NAME, noCacheList);

    // find the transform node that spins the scene
    SoNodeList	xformList;
    newRoot->getByName(SCENE_XFORM_NAME, xformList);
    sceneTransform = (SoTransform *) xformList[0];

    if (options.noMaterials) {  // nuke material node
	removeNodes(newRoot, SoMaterial::getClassTypeId());
	removeNodes(newRoot, SoPackedColor::getClassTypeId());
	removeNodes(newRoot, SoBaseColor::getClassTypeId());
    }

    if (options.noXforms) {  // nuke transforms
	removeNodes(newRoot, SoTransformation::getClassTypeId());
    }

    if (options.noTextures || options.oneTexture) {  // override texture node

	removeNodes(newRoot, SoTexture2::getClassTypeId());

	if (options.oneTexture) {
	    // texture node with simple texture
	    static unsigned char img[] = {
		255, 255, 0, 0,
		255, 255, 0, 0,
		0, 0, 255, 255,
		0, 0, 255, 255
		};
	    SoTexture2 *overrideTex = new SoTexture2;	
	    overrideTex->image.setValue(SbVec2s(4, 4), 1, img);
	    newRoot->insertChild(overrideTex, 1);
	}
    }

    if (options.noFill) {  // draw as points
	SoDrawStyle *overrideFill = new SoDrawStyle;
	overrideFill->style.setValue(SoDrawStyle::POINTS);
	overrideFill->lineWidth.setIgnored(TRUE);
	overrideFill->linePattern.setIgnored(TRUE);
	overrideFill->setOverride(TRUE);
	newRoot->insertChild(overrideFill, 0);

	// cull backfaces so that extra points don't get drawn
	SoShapeHints *cullBackfaces = new SoShapeHints;
	cullBackfaces->shapeType = SoShapeHints::SOLID;
	cullBackfaces->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
	cullBackfaces->setOverride(TRUE);
	newRoot->insertChild(cullBackfaces, 0);
    }

    if (options.noVtxXforms) {  // draw invisible
	SoDrawStyle *overrideVtxXforms = new SoDrawStyle;
	overrideVtxXforms->style.setValue(SoDrawStyle::INVISIBLE);
	overrideVtxXforms->setOverride(TRUE);
	newRoot->insertChild(overrideVtxXforms, 0);
    }

    if (options.noLights) {  // set lighting model to base color
	SoLightModel *baseColor = new SoLightModel;
	baseColor->model = SoLightModel::BASE_COLOR;
	newRoot->insertChild(baseColor, 0);
    }
 
    for (frameIndex = 0; ; frameIndex++) {

	// wait till autocaching has kicked in then start timing
	if (frameIndex == NUM_FRAMES_AUTO_CACHING)
	    startTime = SbTime::getTimeOfDay();

	// stop timing and exit loop when requisite number of
	//    frames have been drawn
	if (frameIndex == options.numFrames + NUM_FRAMES_AUTO_CACHING) {
	    glFinish();
	    timeDiff = SbTime::getTimeOfDay() - startTime;
	    break;
	}
	    
	// if not frozen, update realTime and destroy labelled caches
	if (! options.freeze) { 

	    // update realTime 
	    SoSFTime *realTime = (SoSFTime *) SoDB::getGlobalField("realTime");
	    realTime->setValue(SbTime::getTimeOfDay());

	    // touch the separators marked NoCache 
	    for (int i=0; i<noCacheList.getLength(); i++)
		((SoSeparator *) noCacheList[i])->getChild(0)->touch();
	}

	// Rotate the scene
	sceneTransform->rotation.setValue(SbVec3f(1, 1, 1), 
                           frameIndex * 2 * M_PI / options.numFrames);

	if (! options.noClear)
	    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	ra.apply(newRoot);
    }

    // Get rid of newRoot
    newRoot->unref();

    return (timeDiff.getValue() / options.numFrames);
}