Exemplo n.º 1
0
Player::Player(sf::Texture &img, int w, int h, int speed) : Sprite(img, sf::Vector2i(0,0), SOUTH, w, h, speed) {
    life = 4;
    
    no.loadFromFile(resourcePath() + "no.wav");
    hit.loadFromFile(resourcePath() + "hit.wav");
    kiss.loadFromFile(resourcePath() + "kiss.wav");
    heart.loadFromFile(resourcePath() + "heart.png");
    
    CreateAnimations(3);
}
bool ModelLoader::Load( ID3D11Device* device, const std::string& filename, Vertex::VERTEX_TYPE type, Model& outModel, Skeleton* outSkeleton, AnimationController* outAnimationController ) {
	this->device = device;
	// reset extents
	minX = minY = minZ = FLT_MAX;
	maxX = maxY = maxZ = FLT_MIN;
	Assimp::Importer importer;
	Assimp::DefaultLogger::get()->info( "***********    Importing: "+filename+"    ***********" );
	scene = importer.ReadFile( filename,
		aiProcess_CalcTangentSpace|
		aiProcess_ImproveCacheLocality|
		aiProcess_MakeLeftHanded|
		aiProcess_FlipWindingOrder|
		aiProcess_Triangulate|
		aiProcess_JoinIdenticalVertices|
		aiProcess_SortByPType|
		aiProcess_FlipUVs|
		aiProcess_ValidateDataStructure|
		aiProcess_FindInvalidData
		);
	if( !scene ) {
		Assimp::DefaultLogger::get()->error( importer.GetErrorString() );
		return false;
	}
	if( !scene->HasMeshes() ) {
		Assimp::DefaultLogger::get()->error( "File contains no mesh" );
		return false;
	}
	CreateIndexBuffer();
	CreateVertexBuffer( type );

	if( scene->HasAnimations() ) {
		this->skeleton = outSkeleton;
		this->animationController = outAnimationController;
		// if the model has animations then the caller must pass in a skeleton and a animation controller
		assert( outSkeleton!=nullptr );
		assert( outAnimationController!=nullptr );
		CreateSkeleton();
		CreateBoneHierarchy();
		CreateAnimations();
	}

	outModel.SetIB( ib, indexCount );
	outModel.SetVB( vb );
	switch( type ) {
	case Vertex::BASIC_32:
	{
		outModel.SetVertexStride( sizeof( Vertex::Basic32 ) );
		break;
	}
	case Vertex::POS_NORMAL_TEX_TAN:
	{
		outModel.SetVertexStride( sizeof( Vertex::PosNormalTexTan ) );
		break;
	}
	case Vertex::POS_NORMAL_TEX_TAN_SKINNED:
	{
		outModel.SetVertexStride( sizeof( Vertex::PosNormalTexTanSkinned ) );
		break;
	}
	default:
		assert( false ); // this should never happen
	}
	return true;
}
Exemplo n.º 3
0
// load animations, start sound
void Projectile::Setup()
{
	tint.r=128;
	tint.g=128;
	tint.b=128;
	tint.a=255;

	ieDword time = core->GetGame()->Ticks;
	timeStartStep = time;

	if(ExtFlags&PEF_TEXT) {
		Actor *act = area->GetActorByGlobalID(Caster);
		if(act) {
			displaymsg->DisplayStringName(StrRef, DMC_LIGHTGREY, act,0);
		}
	}

	//falling = vertical
	//incoming = right side
	//both = left side
	if(ExtFlags&(PEF_FALLING|PEF_INCOMING) ) {
		if (ExtFlags&PEF_INCOMING) {
			if (ExtFlags&PEF_FALLING) {
				Pos.x=Destination.x-200;
			} else {
				Pos.x=Destination.x+200;
			}
		}
		else {
			Pos.x=Destination.x;
		}
		Pos.y=Destination.y-200;
		NextTarget(Destination);
	}

	if(ExtFlags&PEF_WALL) {
		SetupWall();
	}

	//cone area of effect always disables the travel flag
	//but also makes the caster immune to the effect
	if (Extension) {
		if (Extension->AFlags&PAF_CONE) {
			NewOrientation = Orientation = GetOrient(Destination, Pos);
			Destination=Pos;
			ExtFlags|=PEF_NO_TRAVEL;
		}

		//this flag says the first explosion is delayed
		//(works for delaying triggers too)
		//getting the explosion count here, so an absent caster won't cut short
		//on the explosion count
		if(Extension->AFlags&PAF_DELAY) {
			extension_delay=Extension->Delay;
		} else {
			extension_delay=0;
		}
		extension_explosioncount=CalculateExplosionCount();
	}

	//set any static tint
	if(ExtFlags&PEF_TINT) {
		Color tmpColor[PALSIZE];

		core->GetPalette( Gradients[0], PALSIZE, tmpColor );
		StaticTint(tmpColor[PALSIZE/2]);
	}

	CreateAnimations(travel, BAMRes1, Seq1);

	if (TFlags&PTF_SHADOW) {
		CreateAnimations(shadow, BAMRes2, Seq2);
	}

	if (TFlags&PTF_SMOKE) {
		GetSmokeAnim();
	}

	//there is no travel phase, create the projectile right at the target
	if (ExtFlags&PEF_NO_TRAVEL) {
		Pos = Destination;

		//the travel projectile should linger after explosion
		if(ExtFlags&PEF_POP) {
			//the explosion consists of a pop in/hold/pop out of the travel projectile (dimension door)
			if(travel[0] && shadow[0]) {
				extension_delay = travel[0]->GetFrameCount()*2+shadow[0]->GetFrameCount();
				//SetDelay( travel[0]->GetFrameCount()*2+shadow[0]->GetFrameCount());
				travel[0]->Flags|=A_ANI_PLAYONCE;
				shadow[0]->Flags|=A_ANI_PLAYONCE;
			}
		} else {
			if(travel[0]) {
				extension_delay = travel[0]->GetFrameCount();
				travel[0]->Flags|=A_ANI_PLAYONCE;
				//SetDelay(travel[0]->GetFrameCount() );
			}
		}
	}

	if (TFlags&PTF_COLOUR) {
		SetupPalette(travel, palette, Gradients);
	} else {
		gamedata->FreePalette(palette, PaletteRes);
		palette=gamedata->GetPalette(PaletteRes);
	}

	if (TFlags&PTF_LIGHT) {
		light = core->GetVideoDriver()->CreateLight(LightX, LightZ);
	}
	if (TFlags&PTF_BLEND) {
		SetBlend(TFlags&PTF_BRIGHTEN);
	}
	if (SFlags&PSF_FLYING) {
		ZPos = FLY_HEIGHT;
	}
	phase = P_TRAVEL;
	travel_handle = core->GetAudioDrv()->Play(SoundRes1, Pos.x, Pos.y, (SFlags & PSF_LOOPING ? GEM_SND_LOOPING : 0));

	//create more projectiles
	if(ExtFlags&PEF_ITERATION) {
		CreateIteration();
	}
}