/// <summary> /// /// </summary> /// <param name="textureDictionary">all the different textures the ship uses, most used are Default, Left and Right</param> /// <param name="position">position of the ship</param> /// <param name="turrets">turrets on the ship</param> /// <param name="healthMax">max health</param> /// <param name="energyMax">max energy</param> /// <param name="energyRegen">energy regen per frame</param> /// <param name="turnRate">how fast the ship turns</param> public Ship(IReadOnlyDictionary <string, Texture2D> textureDictionary, Vector2 position, Dictionary <string, List <ITurret> > turrets, float healthMax, float energyMax, float energyRegen, float turnRate, float speed, TractorBeam tractorBeam, int upgradeCount) : base(textureDictionary["Default"], position) { foreach (var t in turrets) { Turrets.Add(t.Key, t.Value); } foreach (var entry in textureDictionary) { TextureDictionary.Add(entry.Key, entry.Value); } Upgrades = new Upgrade[upgradeCount]; TractorBeam = tractorBeam; HealthMax = healthMax; BaseHealth = healthMax; Health = healthMax; BaseEnergy = energyMax; EnergyMax = energyMax; Energy = energyMax; BaseEnergyRegen = energyRegen; EnergyRegen = energyRegen; TurnRate = turnRate; Speed = speed; BackwardsSpeed = 1 / 5f * speed; StrafeSpeed = 3 / 5f * speed; }
private static Material ConvertMaterialAndTextures(Ai.Material aiMaterial, ModelPackConverterOptions options, string baseDirectoryPath, TextureDictionary textureDictionary) { // Convert all textures TextureInfo diffuseTexture = null; if (aiMaterial.HasTextureDiffuse) { diffuseTexture = ConvertTexture(aiMaterial.TextureDiffuse, baseDirectoryPath); } TextureInfo lightmapTexture = null; if (aiMaterial.HasTextureLightMap) { lightmapTexture = ConvertTexture(aiMaterial.TextureLightMap, baseDirectoryPath); } TextureInfo displacementTexture = null; if (aiMaterial.HasTextureDisplacement) { displacementTexture = ConvertTexture(aiMaterial.TextureDisplacement, baseDirectoryPath); } TextureInfo opacityTexture = null; if (aiMaterial.HasTextureOpacity) { opacityTexture = ConvertTexture(aiMaterial.TextureOpacity, baseDirectoryPath); } TextureInfo normalTexture = null; if (aiMaterial.HasTextureNormal) { normalTexture = ConvertTexture(aiMaterial.TextureNormal, baseDirectoryPath); } TextureInfo heightTexture = null; if (aiMaterial.HasTextureHeight) { heightTexture = ConvertTexture(aiMaterial.TextureHeight, baseDirectoryPath); } TextureInfo emissiveTexture = null; if (aiMaterial.HasTextureEmissive) { emissiveTexture = ConvertTexture(aiMaterial.TextureEmissive, baseDirectoryPath); } TextureInfo ambientTexture = null; if (aiMaterial.HasTextureAmbient) { ambientTexture = ConvertTexture(aiMaterial.TextureAmbient, baseDirectoryPath); } TextureInfo specularTexture = null; if (aiMaterial.HasTextureSpecular) { specularTexture = ConvertTexture(aiMaterial.TextureSpecular, baseDirectoryPath); } TextureInfo reflectionTexture = null; if (aiMaterial.HasTextureReflection) { reflectionTexture = ConvertTexture(aiMaterial.TextureReflection, baseDirectoryPath); } // Convert material Material material = null; string materialName = AssimpConverterCommon.UnescapeName(aiMaterial.Name); switch (options.MaterialPreset) { case MaterialPreset.FieldTerrain: { if (diffuseTexture != null) { textureDictionary.Add(diffuseTexture.Texture); material = MaterialFactory.CreateFieldTerrainMaterial(materialName, diffuseTexture.Name, HasAlpha(diffuseTexture.PixelFormat)); } } break; case MaterialPreset.FieldTerrainVertexColors: { if (diffuseTexture != null) { textureDictionary.Add(diffuseTexture.Texture); material = MaterialFactory.CreateFieldTerrainVertexColorsMaterial(materialName, diffuseTexture.Name, HasAlpha(diffuseTexture.PixelFormat)); } } break; case MaterialPreset.FieldTerrainCastShadow: { if (diffuseTexture != null) { textureDictionary.Add(diffuseTexture.Texture); material = MaterialFactory.CreateFieldTerrainCastShadowMaterial(materialName, diffuseTexture.Name, HasAlpha(diffuseTexture.PixelFormat)); } } break; case MaterialPreset.CharacterSkinP5: case MaterialPreset.CharacterSkinFB: { if (diffuseTexture != null) { textureDictionary.Add(diffuseTexture.Texture); string shadowTextureName = diffuseTexture.Name; if (ambientTexture != null) { textureDictionary.Add(ambientTexture.Texture); shadowTextureName = ambientTexture.Name; } // TODO: transparency var hasTransparency = HasAlpha(diffuseTexture.PixelFormat); if (options.MaterialPreset == MaterialPreset.CharacterSkinP5) { material = MaterialFactory.CreateCharacterSkinP5Material(materialName, diffuseTexture.Name, shadowTextureName, hasTransparency); } else { material = MaterialFactory.CreateCharacterSkinFBMaterial(materialName, diffuseTexture.Name, shadowTextureName, hasTransparency); } } } break; case MaterialPreset.PersonaSkinP5: { if (diffuseTexture != null) { textureDictionary.Add(diffuseTexture.Texture); string shadowTextureName = diffuseTexture.Name; string specularTextureName = diffuseTexture.Name; if (ambientTexture != null) { textureDictionary.Add(ambientTexture.Texture); shadowTextureName = ambientTexture.Name; } if (specularTexture != null) { textureDictionary.Add(specularTexture.Texture); specularTextureName = specularTexture.Name; } material = MaterialFactory.CreatePersonaSkinP5Material(materialName, diffuseTexture.Name, specularTextureName, shadowTextureName); } } break; case MaterialPreset.CharacterClothP4D: { if (diffuseTexture != null) { textureDictionary.Add(diffuseTexture.Texture); material = MaterialFactory.CreateCharacterClothP4DMaterial(materialName, diffuseTexture.Name, HasAlpha(diffuseTexture.PixelFormat)); } } break; case MaterialPreset.CharacterSkinP3DP5D: { if (diffuseTexture != null) { textureDictionary.Add(diffuseTexture.Texture); material = MaterialFactory.CreateCharacterSkinP3DP5DMaterial(materialName, diffuseTexture.Name, HasAlpha(diffuseTexture.PixelFormat)); } } break; } // Create dummy material if none was created if (material == null) { material = new Material(materialName); } return(material); }