| 222 | }; |
| 223 | |
| 224 | SpacebattleExample::SpacebattleExample(ExampleShared& sharedData) : |
| 225 | ParticleDemo("Space battle", sharedData) |
| 226 | { |
| 227 | Ndk::InitializeComponent<LaserBeamComponent>("Lasrbeam"); |
| 228 | Ndk::InitializeComponent<SpaceshipComponent>("Spceship"); |
| 229 | Ndk::InitializeSystem<LaserBeamSystem>(); |
| 230 | Ndk::InitializeSystem<SpaceshipSystem>(); |
| 231 | |
| 232 | Nz::ModelParameters parameters; |
| 233 | parameters.mesh.optimizeIndexBuffers = false; |
| 234 | |
| 235 | Nz::Color grey(100, 100, 100); |
| 236 | |
| 237 | if (!m_turret.baseModel.LoadFromFile("resources/Turret/base.obj", parameters)) |
| 238 | NazaraWarning("Failed to load base.obj"); |
| 239 | |
| 240 | for (unsigned int i = 0; i < m_turret.baseModel.GetMaterialCount(); ++i) |
| 241 | m_turret.baseModel.GetMaterial(i)->SetDiffuseColor(grey); |
| 242 | |
| 243 | if (!m_turret.rotatingBaseModel.LoadFromFile("resources/Turret/rotating_base.obj", parameters)) |
| 244 | NazaraWarning("Failed to load rotating_base.obj"); |
| 245 | |
| 246 | for (unsigned int i = 0; i < m_turret.rotatingBaseModel.GetMaterialCount(); ++i) |
| 247 | m_turret.rotatingBaseModel.GetMaterial(i)->SetDiffuseColor(grey); |
| 248 | |
| 249 | if (!m_turret.cannonBaseModel.LoadFromFile("resources/Turret/cannon_base.obj", parameters)) |
| 250 | NazaraWarning("Failed to load cannon_base.obj"); |
| 251 | |
| 252 | for (unsigned int i = 0; i < m_turret.cannonBaseModel.GetMaterialCount(); ++i) |
| 253 | m_turret.cannonBaseModel.GetMaterial(i)->SetDiffuseColor(grey); |
| 254 | |
| 255 | parameters.mesh.texCoordScale.Set(40.f, 40.f); |
| 256 | parameters.mesh.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 180.f, 0.f)); |
| 257 | if (!m_turret.cannonModel.LoadFromFile("resources/Turret/cannon.obj", parameters)) |
| 258 | NazaraWarning("Failed to load cannon.obj"); |
| 259 | |
| 260 | // Since OBJ don't support normal maps.. |
| 261 | m_turret.cannonModel.GetMaterial(0)->SetNormalMap("resources/Turret/198_norm.jpg"); |
| 262 | |
| 263 | parameters.mesh.matrix.MakeIdentity(); |
| 264 | parameters.mesh.texCoordScale.Set(1.f, 1.f); |
| 265 | |
| 266 | parameters.mesh.center = true; |
| 267 | if (!m_spacestationModel.LoadFromFile("resources/SpaceStation/space_station.obj", parameters)) |
| 268 | NazaraWarning("Failed to load space_station.obj"); |
| 269 | |
| 270 | parameters.mesh.texCoordScale.Set(1.f, -1.f); |
| 271 | parameters.mesh.matrix.MakeRotation(Nz::EulerAnglesf(0.f, -90.f, 0.f)); |
| 272 | |
| 273 | if (!m_spaceshipModel.LoadFromFile("resources/space_frigate_6/space_frigate_6.obj", parameters)) |
| 274 | NazaraWarning("Failed to load space_frigate_6.obj"); |
| 275 | |
| 276 | // Since OBJ don't support normal maps.. |
| 277 | for (unsigned int i = 0; i < m_spaceshipModel.GetMaterialCount(); ++i) |
| 278 | { |
| 279 | m_spaceshipModel.GetMaterial(i)->SetEmissiveMap("resources/space_frigate_6/space_frigate_6_illumination.jpg"); |
| 280 | m_spaceshipModel.GetMaterial(i)->SetNormalMap("resources/space_frigate_6/space_frigate_6_normal.png"); |
| 281 | } |
nothing calls this directly
no test coverage detected