54 using std::make_unique;
56 using std::unique_ptr;
109 engine = unique_ptr<Engine>(Engine::createOffScreenInstance(512, 512,
true,
true,
true));
111 engine->setShadowMapLightEyeDistanceScale(0.1f);
112 engine->setSceneColor(
Color4(39.0f / 255.0f, 39.0f / 255.0f, 39.0f / 255.0f, 1.0f));
113 audio = Audio::getInstance();
136 this->prototype = unique_ptr<Prototype>(
prototype);
168 engine->removeEntity(
"model");
169 engine->removeEntity(
"attachment1");
175 auto currentModelObject =
dynamic_cast<Object*
>(
engine->getEntity(
"model"));
176 if (currentModelObject !=
nullptr) {
178 ModelUtilities::computeModelStatistics(currentModelObject->getModel(), &modelStatistics);
228 engine->removeEntity(
"model");
229 engine->removeEntity(
"attachment1");
232 struct AnimationSetupStruct {
234 string overlayFromNodeId;
238 map<string, AnimationSetupStruct> originalAnimationSetups;
239 for (
const auto& [animationSetupId, animationSetup]:
prototype->getModel()->getAnimationSetups()) {
240 originalAnimationSetups[animationSetup->getId()] = {
241 .loop = animationSetup->isLoop(),
242 .overlayFromNodeId = animationSetup->getOverlayFromNodeId(),
243 .speed = animationSetup->getSpeed()
251 auto model = unique_ptr<Model>(
258 for (
const auto& [originalAnimationSetupId, originalAnimationSetup]: originalAnimationSetups) {
259 auto animationSetup = model->getAnimationSetup(originalAnimationSetupId);
260 if (animationSetup ==
nullptr) {
261 Console::println(
"ModelEditorTabView::reimportModel(): missing animation setup: " + originalAnimationSetupId);
262 log+=
"Missing animation setup: " + originalAnimationSetupId +
", skipping.\n";
265 Console::println(
"ModelEditorTabView::reimportModel(): reimport animation setup: " + originalAnimationSetupId);
266 animationSetup->setLoop(originalAnimationSetup.loop);
267 animationSetup->setOverlayFromNodeId(originalAnimationSetup.overlayFromNodeId);
268 animationSetup->setSpeed(originalAnimationSetup.speed);
276 if (log.size() > 0) {
283 PrototypeWriter::write(pathName, fileName,
prototype.get());
296 engine->removeEntity(
"model");
301 ComputeNormalsProgressCallback(
ProgressBarScreenController* progressBarScreenController): progressBarScreenController(progressBarScreenController) {
303 virtual void progress(
float value) {
304 progressBarScreenController->
progress(value);
315 engine->removeEntity(
"model");
331 if (sound !=
nullptr) sound->
play();
336 auto model =
static_cast<Object*
>(
engine->getEntity(
"model"));
339 auto attachment1 =
static_cast<Object*
>(
engine->getEntity(
"attachment1"));
340 if (model !=
nullptr && attachment1 !=
nullptr) {
343 transformMatrix*= model->getTransform().getTransformMatrix();
348 attachment1->setRotationAngle(0, euler.getZ());
349 attachment1->setRotationAngle(1, euler.getY());
350 attachment1->setRotationAngle(2, euler.getX());
353 transformMatrix.getScale(scale);
354 attachment1->setScale(scale);
356 attachment1->update();
373 settings.
load(
"settings",
"modeleditor.properties");
378 Console::println(
"ModelEditorTabView::loadSettings(): An error occurred: " +
string(exception.what()));
391 Console::println(
"ModelEditorTabView::initialize(): An error occurred: " +
string(exception.what()));
407 settings.
store(
"settings",
"modeleditor.properties");
409 Console::println(
"ModelEditorTabView::storeSettings(): An error occurred: " +
string(exception.what()));
441 PrototypeReader::read(
454 void ModelEditorTabView::playAnimation(
const string& baseAnimationId,
const string& overlay1AnimationId,
const string& overlay2AnimationId,
const string& overlay3AnimationId) {
455 auto object =
dynamic_cast<Object*
>(
engine->getEntity(
"model"));
456 if (
object ==
nullptr)
return;
458 object->removeOverlayAnimations();
459 object->setAnimation(baseAnimationId);
460 if (overlay1AnimationId.empty() ==
false) object->addOverlayAnimation(overlay1AnimationId);
461 if (overlay2AnimationId.empty() ==
false) object->addOverlayAnimation(overlay2AnimationId);
462 if (overlay3AnimationId.empty() ==
false) object->addOverlayAnimation(overlay3AnimationId);
466 engine->removeEntity(
"attachment1");
470 attachmentModelFile.empty() ==
true?
472 ModelReader::read(Tools::getPathName(attachmentModelFile), Tools::getFileName(attachmentModelFile))
475 Console::println(
"ModelEditorTabView::addAttachment1(): An error occurred: " +
string(exception.what()));
479 Entity* attachment =
nullptr;
494 auto object =
dynamic_cast<Object*
>(
engine->getEntity(
"model"));
495 auto soundDefinition =
prototype->getSound(soundId);
496 if (soundDefinition ==
nullptr || soundDefinition->getFileName().empty() ==
true)
return;
498 if (
object !=
nullptr && soundDefinition->getAnimation().empty() ==
false) object->setAnimation(soundDefinition->getAnimation());
499 auto pathName = PrototypeReader::getResourcePathName(
500 Tools::getPathName(
prototype->getFileName()),
501 soundDefinition->getFileName()
503 auto fileName = Tools::getFileName(soundDefinition->getFileName());
504 auto sound =
new Sound(
509 sound->setGain(soundDefinition->getGain());
510 sound->setPitch(soundDefinition->getPitch());
511 sound->setLooping(soundDefinition->isLooping());
512 sound->setFixed(
true);
516 if (soundDefinition->getOffset() <= 0) {
528 auto object =
dynamic_cast<Object*
>(
engine->getEntity(
"model"));
529 if (
object ==
nullptr ||
prototype ==
nullptr)
return;
530 engine->removeEntity(
"model");
536 auto object =
dynamic_cast<Object*
>(
engine->getEntity(
"model"));
537 if (
object ==
nullptr ||
prototype ==
nullptr)
return;
538 for (
const auto& parameterName: Engine::getShaderParameterNames(
prototype->getShader())) {
539 auto parameterValue =
prototype->getShaderParameters().getShaderParameter(parameterName);
540 object->setShaderParameter(parameterName, parameterValue);
virtual void play()=0
Plays this audio entity.
Interface to audio module.
AudioEntity * getEntity(const string &id)
Returns an audio entity identified by given id.
void addEntity(AudioEntity *entity)
Adds a audio entity.
void removeEntity(const string &id)
Removes an audio entity.
Sound audio entity implementation.
Color 4 definition class.
virtual void addRotation(const Vector3 &axis, const float angle)=0
Add rotation.
Object to be used with engine class.
Bogus/Simple partition implementation.
Representation of a 3D model.
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Base property model class.
Prototype audio definition.
const Matrix4x4 getNodeTransformMatrix(const string &id)
Returns transform matrix for given node.
GUI screen node that represents a screen that can be rendered via GUI system.
Vector3 computeEulerAngles() const
Compute Euler angles (rotation around x, y, z axes)
Matrix4x4 & setTranslation(const Vector3 &translation)
Set translation.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
File system singleton class.
Mutable utf8 aware string class.
Properties class, which helps out with storeing or loading key value pairs from/to property files.
void put(const string &key, const string &value)
Add property.
const string & get(const string &key, const string &defaultValue) const
Get property value by key.
void load(const string &pathName, const string &fileName, FileSystemInterface *fileSystem=nullptr)
Load property file.
void store(const string &pathName, const string &fileName, FileSystemInterface *fileSystem=nullptr) const
Store property file.
std::exception Exception
Exception base class.
int32_t transparentFaceCount