Ejemplo n.º 1
0
void doPlayerWalkAnimation(Animation *anim)
{	
	drawAnimation(anim, player.x, player.y);
	doAnimation(anim);
		
	int direction = input.yaw;
		
	if(direction == NORTH)
	{
		player.y -= PLAYER_SPEED;
	}
	else if(direction == SOUTH)
	{
		player.y += PLAYER_SPEED;
	}
	else if(direction == EAST)
	{
		player.x += PLAYER_SPEED;
	}
	else
	{
		player.x -= PLAYER_SPEED;
	}
	
	game.walkAnimationCount++;

	if(game.walkAnimationCount == 4)
	{
		game.walkAnimationCount = 0;
	}
}
void DroidObjectImplementation::rechargeFromDroid(){

	// Reset power to max
	power = MAX_POWER;

	showFlyText("npc_reaction/flytext","recharged", 0, 153, 0);  // "*Recharged*"
	doAnimation("power_up");
	return;

}
Ejemplo n.º 3
0
void perform(HWND hDlg, HWND hList, HWND hEditList,Plane::PlaneDirection direction
			 //,CountPlanesFunc cpf,LandOrLiftPlanesFunc lolpf,
			 )
{
	Plane * plane = gestor->criarAviaoPara(direction);
	ListBox_AddString(hList,plane->GetName());
	//_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10);
	loadIntoBufferPlanesCount(direction);
	
	Edit_SetText(hEditList,buffer);
	
	plane = executeLandOrListFunction(direction);
	
	EnterCriticalSection(&csDelFromLB);
	ListBox_DeleteString(hList,ListBox_FindStringExact(hList,0,plane->GetName()));
	LeaveCriticalSection(&csDelFromLB);

	//_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10);
	loadIntoBufferPlanesCount(direction);
	Edit_SetText(hEditList,buffer);

	if(!(plane->terminateQuickly()))
	{
		INT * animationEditTexts = getAnimationEditText(plane->_idLane);
		if(plane->GetDirection()==Plane::LAND)
		{
			for (int i=0; i < 26; ++i) {
				doAnimation(plane,hDlg,animationEditTexts[i]);
			}
		}
		else if(plane->GetDirection()==Plane::LIFTOFF)
		{
			for(int i = 25; i>=0;--i)
			{
				doAnimation(plane,hDlg,animationEditTexts[i]);
			}
		}
		gestor->libertarPista(plane);
	}
}
void DroidObjectImplementation::handleLowPower(){

	// Send fly text
	showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
	doAnimation("power_down");

	// Stop following
	setOblivious();

	// Deactivate all modules
	for( int i=0; i<modules.size(); i++){
		BaseDroidModuleComponent* module = modules.get(i);
		module->deactivate();
	}

	return;
}
int DroidObjectImplementation::rechargeFromBattery(CreatureObject* player){

	// Find droid battery in player inventory
	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
	if (inventory == NULL){
		player->sendSystemMessage("Player inventory not found");
		return 0;
	}

	ManagedReference<SceneObject*> batterySceno = NULL;
	for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
		ManagedReference<SceneObject*> sceno = inventory->getContainerObject(i);
		if( sceno->getObjectTemplate()->getFullTemplateString() == "object/tangible/droid_battery/battery.iff" ){
			batterySceno = sceno;
		}
	}

	// Battery not found
	if( batterySceno == NULL ){
		showFlyText("npc_reaction/flytext","nobattery", 204, 0, 0); // "You don't have a power storage device."
		return 0;
	}

	// Battery found
	ManagedReference<TangibleObject*> batteryTano = cast<TangibleObject*>(batterySceno.get());
	if( batteryTano == NULL ){
		player->sendSystemMessage("Error with droid battery object");
		return 0;
	}

	// Reset power to max
	power = MAX_POWER;

	// Consume battery
	Locker locker(batteryTano);

	batteryTano->decreaseUseCount();

	showFlyText("npc_reaction/flytext","recharged", 0, 153, 0);  // "*Recharged*"
	doAnimation("power_up");
	return 0;

}
Ejemplo n.º 6
0
void TextureObject::draw(OpenglESProgram* openglESProgram, double sElapsed) {
	if (textureID == TextureManager::NO_TEXTURE) {
		setTextureID(TextureManager::getTextureID(picture));
	}

	doAnimation(sElapsed);

	glUseProgram(openglESProgram->getProgram());

	glVertexAttribPointer(openglESProgram->getVertexLocation(), POINT_DIMENSION, GL_FLOAT, GL_FALSE, STRIDE, attribute);
	glVertexAttribPointer(openglESProgram->getTextureCoordinatesLocation(), UV_DIMENSION, GL_FLOAT, GL_FALSE, STRIDE, attribute + POINT_DIMENSION);

	glEnableVertexAttribArray(openglESProgram->getVertexLocation());
	glEnableVertexAttribArray(openglESProgram->getTextureCoordinatesLocation());

	glUniform4fv(openglESProgram->getColorLocation(), 1, color);
	glUniform1f(openglESProgram->getAlphaLocation(), alpha);

	glUniform4fv(openglESProgram->getInVec4Location(), 1, inVec4);
	glUniform4fv(openglESProgram->getShowVec4Location(), 1, showVec4);

	glm::mat4 complexMatrix = transMatrix * rotateMatrix * scaleMatrix;
	glUniformMatrix4fv(openglESProgram->getChangeMatrixLocation(), 1, GL_FALSE, &complexMatrix[0][0]);

	glm::mat4 finalMatrix = openglESProgram->getmMVPMatrix() * complexMatrix;
	glUniformMatrix4fv(openglESProgram->getMatrixLocation(), 1, GL_FALSE, &finalMatrix[0][0]);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, textureID);
	glUniform1f(openglESProgram->getTextureUnitLocation(), 0);

	glDrawArrays(GL_TRIANGLE_STRIP, 0, pointNum);

	glDisableVertexAttribArray(openglESProgram->getVertexLocation());
	glDisableVertexAttribArray(openglESProgram->getTextureCoordinatesLocation());
}
Ejemplo n.º 7
0
fluidControlWidget::fluidControlWidget(QWidget *parent)
	: QWidget(parent)
{

	mySimulation = NULL;

	animationTimer = new QTimer(this);
	connect( animationTimer, SIGNAL(timeout()), this, SLOT(doAnimation()) ); 

	//setUp Gui

	QPushButton * but_resetFlux = new QPushButton("Reset Flux!");
	connect(but_resetFlux, SIGNAL(released()), this, SLOT(resetToCollectedFlux()));
	//QPushButton * butt_defForce = new QPushButton("Define Force!");
	//connect(butt_defForce, SIGNAL(released()), this, SLOT(setForceFlux()));
	//QPushButton * butt = new QPushButton("Flux 2 Vorticity 2 Flux!");
	//connect(butt, SIGNAL(released()), this, SLOT(flux2vort2flux()));

	QPushButton * butt_simStep = new QPushButton("Do 1 Timestep");
	connect(butt_simStep, SIGNAL(released()), this, SLOT(singleSimulationStep()));
	QPushButton * butt_startSim = new QPushButton("Start/Stop Simulation");
	connect(butt_startSim , SIGNAL(released()), this, SLOT(startSim()));


	QPushButton * but_borderconstr = new QPushButton("Define Border Constraints");//"Debug (harmonic flow)!");
	connect(but_borderconstr , SIGNAL(released()), this, SLOT(debugSome()));

	QPushButton * debug2 = new QPushButton("Debug (pathtracing/vorts)!");
	connect(debug2 , SIGNAL(released()), this, SLOT(debugSome2()));

	stepSliderLabel = new QLabel("Timestep Size ()");
	viscosityLabel = new QLabel("Viscosity [0,10]");
	forceAgeLabel = new QLabel("ForceAge (nr Iteratons): ");
	forceStrengthLabel = new QLabel("Force Strength (): ");


	stepSlider = new QSlider(Qt::Horizontal, this);
	stepSlider->setMinimum(0);
	stepSlider->setMaximum(1000);
	stepSlider->setTickPosition(QSlider::TicksAbove);
	stepSlider->setValue(0);
	connect(stepSlider,SIGNAL(sliderReleased()), this, SLOT(updateTimeStep()));


	viscositySlider = new QSlider(Qt::Horizontal, this);
	viscositySlider->setMinimum(0);
	viscositySlider->setMaximum(200);
	viscositySlider->setTickPosition(QSlider::TicksAbove);
	viscositySlider->setValue(0);
	connect(viscositySlider,SIGNAL(sliderReleased()), this, SLOT(updateViscosity()));


	forceAgeSlider = new QSlider(Qt::Horizontal, this);
	forceAgeSlider->setMinimum(0);
	forceAgeSlider->setMaximum(100);
	forceAgeSlider->setTickPosition(QSlider::TicksAbove);
	forceAgeSlider->setValue(5);
	connect(forceAgeSlider,SIGNAL(sliderReleased()), this, SLOT(forceAgeChanged()));
	forceAgeChanged();

	forceStrengthSlider = new QSlider(Qt::Horizontal, this);
	forceStrengthSlider->setMinimum(0);
	forceStrengthSlider->setMaximum(480);
	forceStrengthSlider->setTickPosition(QSlider::TicksAbove);
	forceStrengthSlider->setValue(80);
	connect(forceStrengthSlider,SIGNAL(sliderReleased()), this, SLOT(forceStrengthChanged()));
	forceStrengthChanged();


//	viscosityAndTimestep = new QLabel("");
//	updateViscTimeLabel();
	animationLabel = new QLabel("");

	vectorInput = new QLineEdit();
	vectorInput->setText("");
	//vectorInput->setInputMask("#09.00 #09.00 #09.00");
	connect(vectorInput,SIGNAL(textChanged( const QString& )), this, SLOT(borderDirInput(const QString & )));

	//////////////////////////////////////////////////////////////////////////
	//display settings
	//////////////////////////////////////////////////////////////////////////
	QCheckBox * showStreamLines;
	QCheckBox * doInterpolation;
	QCheckBox * showVortNotSpeed;
	QCheckBox * texLine;
	showStreamLines = new QCheckBox();
	showStreamLines->setChecked(false);
	connect(showStreamLines, SIGNAL(stateChanged(int)), this, SLOT(showStreamLn(int)));

	doInterpolation = new QCheckBox();
	doInterpolation->setChecked(true);
	connect(doInterpolation, SIGNAL(stateChanged(int)), this, SLOT(doInterpl(int)));

	showVortNotSpeed = new QCheckBox();
	showVortNotSpeed->setChecked(true);
	connect(showVortNotSpeed, SIGNAL(stateChanged(int)), this, SLOT(showVorticity(int)));

	texLine = new QCheckBox();
	texLine->setChecked(true);
	connect(texLine, SIGNAL(stateChanged(int)), this, SLOT(showTexLines(int)));

	QLabel * streamLinesInterpolationLable = new QLabel("Lines/Interpol/Linelength/Vort/Tex/Color");
	QSpinBox * lineLength = new QSpinBox(this);
	lineLength->setMinimum(1);
	lineLength->setMaximum(50);
	lineLength->setSingleStep(1);
	connect(lineLength, SIGNAL(valueChanged(int)), this, SLOT(streamLineLengthChanged(int)));

	QSpinBox * colorScale = new QSpinBox(this);
	colorScale->setMinimum(1);
	colorScale->setMaximum(100);
	colorScale->setSingleStep(1);
	colorScale->setValue(50);
	connect(colorScale, SIGNAL(valueChanged(int)), this, SLOT(colorScaleChanged(int)));



	QVBoxLayout * layout = new QVBoxLayout();

	layout->addWidget(animationLabel);
	layout->addWidget(vectorInput);
	layout->addWidget(but_borderconstr);
	//layout->addWidget(butt);
	//layout->addWidget(butt_defForce);
	layout->addWidget(butt_startSim);
	layout->addWidget(but_resetFlux);
	layout->addWidget(butt_simStep);

	layout->addWidget(stepSliderLabel);
	layout->addWidget(stepSlider);
	layout->addWidget(viscosityLabel);
	layout->addWidget(viscositySlider);
	layout->addWidget(forceAgeLabel);
	layout->addWidget(forceAgeSlider);
	layout->addWidget(forceStrengthLabel);
	layout->addWidget(forceStrengthSlider);
//	layout->addWidget(viscosityAndTimestep);



	layout->addWidget(streamLinesInterpolationLable);

	QHBoxLayout * hlayout = new QHBoxLayout();
	hlayout->addWidget(showStreamLines);
	hlayout->addWidget(doInterpolation);
	hlayout->addWidget(lineLength);
	hlayout->addWidget(showVortNotSpeed);
	hlayout->addWidget(texLine);
	hlayout->addWidget(colorScale);
	layout->addLayout(hlayout);

	layout->addWidget(debug2);


	QPushButton * dbg1 = new QPushButton("PathTr");
	connect(dbg1 , SIGNAL(released()), this, SLOT(pathtrace()));
	QPushButton * dbg2= new QPushButton("VortPart");
	connect(dbg2 , SIGNAL(released()), this, SLOT(showVorticityPart()));
	QHBoxLayout * hlayout2 = new QHBoxLayout();
	hlayout2->addWidget(dbg1);
	hlayout2->addWidget(dbg2);
	layout->addLayout(hlayout2);

	this->setLayout(layout);

	Model::getModel()->attach(this);


	this->selectedBorder = 0;
	for(int i = 0; i < Model::getModel()->getMeshInfo()->getBorder().size(); i++){
		borderConstrDirs.push_back(tuple3f());
	}

}
Ejemplo n.º 8
0
void Export::slotAccept()
{
    switch ( group -> selectedId() )
    {
        case 0:
	{
            QString fn = QFileDialog::getSaveFileName( "projects/output/", "PNG sequence ( *.png )", this );
            if ( !fn.isEmpty() )
	    {
        	if ( k_toon -> scenes() -> exportAnimation( fn, "PNG" ) > 0 )
        	    k_toon -> statusBar() -> message( tr( "Animation Exported Successfully" ), 2000 );
        	else
        	    k_toon -> statusBar() -> message( tr( "Could not Export Animation" ), 2000 );
	    }
	    break;
	}
        case 1:
	{
            QString fn = QFileDialog::getSaveFileName( "projects/output/", "Single PNG ( *.png )", this );
            if ( !fn.isEmpty() )
	    {
		QPixmap exp;
		fn = fn + ".png";
		exp.convertFromImage( k_toon -> renderCameraPreview() -> grabFrameBuffer() );
		if ( !exp.save( fn, "PNG" ) )
		     k_toon -> statusBar() -> message( tr( "Could not save the file: %1" ).arg( fn ), 2000 );
	    }
	    break;
	}
        case 2:
	{
            QString fn = QFileDialog::getSaveFileName( "projects/output/", "Macromedia Flash ( *.swf )", this );
            if ( !fn.isEmpty() )
	    {
	        int number_of_images = k_toon -> scenes() -> exportAnimation( fn, "JPEG" );
        	if ( number_of_images > 0 )
		{
		    int frame_rate = k_toon -> currentStatus() -> currentFrameRate();

		    SWFMovie *movie = doMovie( 360, 280 );
  		    movie -> setRate( ( float )frame_rate );
  		    QStringList images;

		    for ( int i = 1; i < number_of_images; i++ )
  		    {
     			QString iterator = QString::number( i );
     			iterator = iterator.rightJustify( 3, '0' );
     			images << QString( fn + iterator + ".jpg" );
  		    }

  		    SWFDisplayItem *frame = doAnimation( movie, images );
		    frame -> addColor( 255, 0, 0 );

  		    if ( movie -> save( ( char * )( fn + ".swf" ).latin1() ) < 0 )
        	        k_toon -> statusBar() -> message( tr( "Could not Export Animation" ), 2000 );
		    else
		        k_toon -> statusBar() -> message( tr( "Animation Exported Successfully" ), 2000 );

		    for ( int i = 1; i < number_of_images; i++ )
  		    {
     			QString iterator = QString::number( i );
     			iterator = iterator.rightJustify( 3, '0' );
     			QFile::remove( fn + iterator + ".jpg" );
  		    }
		}
        	else
        	    k_toon -> statusBar() -> message( tr( "Could not Export Animation" ), 2000 );
	    }
	    break;
	}
	case 3:
	{
            QString fn = QFileDialog::getSaveFileName( "projects/output/", "Scalable Vector Graphics ( *.svg )", this );
            if ( !fn.isEmpty() )
	    {
		QPixmap exp;
		fn = fn + ".svg";
		exp.convertFromImage( k_toon -> renderCameraPreview() -> grabFrameBuffer() );

		QPainter painter;
		QPicture picture;

		painter.begin( &picture );
		painter.drawPixmap( 0, 0, exp );
		painter.end();

		if ( picture.save( fn, "svg" ) )
		    k_toon -> statusBar() -> message( tr( "SVG Exported Successfully" ), 2000 );
		else
		    k_toon -> statusBar() -> message( tr( "Could not Export SVG" ), 2000 );
	    }
	    break;
	}
	default: break;
    }

    close( true );
}