diff --git a/application/editormodeselftest.cpp b/application/editormodeselftest.cpp index a62a02f53..0088a9aa9 100644 --- a/application/editormodeselftest.cpp +++ b/application/editormodeselftest.cpp @@ -100,6 +100,7 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c // lineside the tab of the objects along the track in the track window // event queues the event // eventrun runs the event at once, its targets found first, as the simulation does (the editor runs none) +// channel sets a channel of the model of the instance (EU07M) // clip [speed] starts an animation clip of the model of the instance (EU07M), by the simulation time // animate turns a submodel of a model instance to the angles, as an animation event does (the // editor doesn't run the events); the animation goes by the simulation time diff --git a/application/editormodeselftestscene.cpp b/application/editormodeselftestscene.cpp index 71c0ce808..becfafa8a 100644 --- a/application/editormodeselftestscene.cpp +++ b/application/editormodeselftestscene.cpp @@ -586,6 +586,17 @@ editor_mode::selftest_result editor_mode::selftest_scene(std::string const &comm WriteLog("SELFTEST eventrun " + name + (event != nullptr ? " run" : ": no such event")); return selftest_result::handled; } + if (command == "channel") + { + std::string node; + std::string name; + float value{0.f}; + words >> node >> name >> value; + auto *model{simulation::Instances.find(node)}; + auto const set{(model != nullptr) && model->set_channel(name, value)}; + WriteLog(format("SELFTEST channel %s %s %.3f: %s", node.c_str(), name.c_str(), value, set ? "set" : "no such channel")); + return selftest_result::handled; + } if (command == "clip") { std::string node; diff --git a/model/AnimModel.cpp b/model/AnimModel.cpp index d4abeb0b3..22fa34c39 100644 --- a/model/AnimModel.cpp +++ b/model/AnimModel.cpp @@ -759,6 +759,10 @@ void TAnimModel::RaPrepare() entry->PrepareModel(); } apply_clips(); + // after the clips playing, as they may set the same nodes + if( ( pModel != nullptr ) && ( false == pModel->channels().empty() ) ) { + apply_channels(); + } } // the state of the lit and the dark part of a numbered light, as RaPrepare() shows them @@ -817,6 +821,51 @@ void TAnimModel::stop_clips() { m_autoplaystarted = true; } +bool TAnimModel::set_channel( std::string_view const Name, float const Value ) { + + if( pModel == nullptr ) { return false; } + auto const &channels { pModel->channels() }; + auto const found { std::ranges::find( channels, Name, &animation::channel::name ) }; + if( found == channels.end() ) { return false; } + if( m_channels.size() != channels.size() ) { + m_channels.resize( channels.size() ); + std::ranges::transform( channels, m_channels.begin(), &animation::channel::initial ); + } + auto const index { static_cast( std::distance( channels.begin(), found ) ) }; + m_channels[ index ] = animation::channel_value( *found, Value ); + return true; +} + +void TAnimModel::apply_channels() { + + auto const &channels { pModel->channels() }; + auto const &clips { pModel->clips() }; + auto *root { pModel->GetSMRoot() }; + auto const count { pModel->submodel_count() }; + for( std::size_t idx = 0; idx < channels.size(); ++idx ) { + auto const &channel { channels[ idx ] }; + auto const value { idx < m_channels.size() ? m_channels[ idx ] : channel.initial }; + for( auto const &binding : channel.bindings ) { + auto const target { value * binding.scale + binding.offset }; + if( binding.target == animation::binding_target::joint ) { + if( ( binding.joint.node >= 0 ) && ( binding.joint.node < count ) ) { + root[ binding.joint.node ].SetClipTransform( animation::joint_transform( binding.joint, target ) ); + } + continue; + } + if( binding.clip >= clips.size() ) { continue; } + // the share of the duration of the clip + auto const &clip { clips[ binding.clip ] }; + auto const time { std::clamp( target, 0.f, 1.f ) * clip.duration }; + for( auto const &node : clip.nodes ) { + if( ( node.node >= 0 ) && ( node.node < count ) ) { + root[ node.node ].SetClipTransform( animation::local_transform( clip, node, time ) ); + } + } + } + } +} + void TAnimModel::apply_clips() { if( ( pModel == nullptr ) || pModel->clips().empty() ) { return; } diff --git a/model/AnimModel.h b/model/AnimModel.h index 986103591..a5567679d 100644 --- a/model/AnimModel.h +++ b/model/AnimModel.h @@ -194,6 +194,9 @@ public: bool play_clip( std::string_view Name, float Speed = 1.f ); // stops the clips playing, the nodes they moved stay where they were last put till the next clip moves them void stop_clips(); + // sets the channel of the model (EU07M) with the name to Value, kept within its range; the joints and the clips it's bound to + // follow the next time the instance is drawn. false when the model has no channel of the name + bool set_channel( std::string_view Name, float Value ); // radius() subclass details, calculates node's bounding radius float radius_() const override; @@ -250,6 +253,10 @@ public: bool m_autoplaystarted { false }; // the clips of the model to play on their own were started // the transforms of the nodes moved by the clips playing, set on the submodels for the instance drawn (RaPrepare()) void apply_clips(); + // the values of the channels of the model on the instance, their initial values till one is set + std::vector m_channels; + // the joints and the clips bound to the channels set on the submodels for the instance drawn (RaPrepare()) + void apply_channels(); // true if this instance is eligible for the batched/instanced render path: // no lights, no submodel animations, no replacable skins, no seasonal variants. diff --git a/model/Model3d.h b/model/Model3d.h index 41c9dc7eb..e540207b0 100644 --- a/model/Model3d.h +++ b/model/Model3d.h @@ -327,6 +327,7 @@ private: std::uint32_t m_stateversion { 0 }; // see state_version() std::vector m_skins; // of an EU07M model, the skinned submodels refer to them std::vector m_clips; // of an EU07M model, the nodes are the submodels of the same index + std::vector m_channels; // of an EU07M model void finish_binary( bool dynamic, bool hastangents ); @@ -354,6 +355,8 @@ public: return m_skins; } std::vector const & clips() const { return m_clips; } + std::vector const & channels() const { + return m_channels; } int submodel_count() const { return iSubModelsCount; } TSubModel * AddToNamed(const char *Name, TSubModel *SubModel); diff --git a/model/clip.cpp b/model/clip.cpp index 0d6eea2f0..2013227f7 100644 --- a/model/clip.cpp +++ b/model/clip.cpp @@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/. #include #include +#include #include @@ -125,4 +126,34 @@ glm::mat4 local_transform(clip const &Clip, node_tracks const &Node, float const return glm::translate(glm::mat4{1.f}, translation) * glm::mat4_cast(rotation) * glm::scale(glm::mat4{1.f}, scale); } +float channel_value(channel const &Channel, float const Value) +{ + auto const low{std::min(Channel.minimum, Channel.maximum)}; + auto const high{std::max(Channel.minimum, Channel.maximum)}; + return std::clamp(Value, low, high); +} + +glm::mat4 joint_transform(joint_binding const &Joint, float const Value) +{ + auto value{Value}; + if (Joint.limited) + { + value = std::clamp(value, std::min(Joint.minimum, Joint.maximum), std::max(Joint.minimum, Joint.maximum)); + } + auto const length{glm::length(Joint.axis)}; + if (length <= 0.f) + { + return Joint.rest; + } + auto const axis{Joint.axis / length}; + switch (Joint.type) + { + case joint_type::hinge: return Joint.rest * glm::rotate(glm::mat4{1.f}, value, axis); + case joint_type::slider: return Joint.rest * glm::translate(glm::mat4{1.f}, axis * value); + case joint_type::screw: + return Joint.rest * glm::translate(glm::mat4{1.f}, axis * (value / (2.f * std::numbers::pi_v) * Joint.pitch)) * glm::rotate(glm::mat4{1.f}, value, axis); + default: return Joint.rest; + } +} + } // namespace animation diff --git a/model/clip.h b/model/clip.h index 2c498fa94..e6fe7f9fd 100644 --- a/model/clip.h +++ b/model/clip.h @@ -77,4 +77,56 @@ glm::quat sample_rotation(track const &Track, float Time); // the transform of the node within its parent at Time: T * R * S, each part from its track or the rest of the node glm::mat4 local_transform(clip const &Clip, node_tracks const &Node, float Time); +// the channels of an EU07M model (CHNL): a named value which moves joints (JOIN) and sets the time of clips +enum class joint_type : std::uint8_t +{ + fixed, + hinge, // turns about the axis, radians + ball, // not driven by a channel + slider, // moves along the axis, metres + screw // turns about the axis, radians, and moves along it by the pitch for each turn +}; + +struct joint_binding +{ + int node{-1}; + joint_type type{joint_type::hinge}; + glm::vec3 axis{1.f, 0.f, 0.f}; // in the space of the node + bool limited{false}; + float minimum{0.f}; + float maximum{0.f}; + float pitch{0.f}; // metres for each turn of a screw + glm::mat4 rest{1.f}; // the transform of the node within its parent, which the joint moves from +}; + +enum class binding_target : std::uint8_t +{ + joint, + clip +}; + +struct channel_binding +{ + binding_target target{binding_target::joint}; + joint_binding joint; // of a joint + std::size_t clip{0}; // of a clip: its index; the value is the share of its duration, 0 to 1 + float scale{1.f}; // the value of the target = the value of the channel * scale + offset + float offset{0.f}; +}; + +struct channel +{ + std::string name; + float minimum{0.f}; + float maximum{1.f}; + float initial{0.f}; + std::vector bindings; +}; + +// the value of the channel kept within its range +float channel_value(channel const &Channel, float Value); +// the transform of the node of the joint within its parent with the joint at Value (kept within its limits when it has them): the rest +// of the node, then the turn or the move along the axis. a fixed or a ball joint leaves the node at rest +glm::mat4 joint_transform(joint_binding const &Joint, float Value); + } // namespace animation diff --git a/model/eu07m/eu07m_format.h b/model/eu07m/eu07m_format.h index 8d46b97b7..d99b58bfd 100644 --- a/model/eu07m/eu07m_format.h +++ b/model/eu07m/eu07m_format.h @@ -525,7 +525,7 @@ static_assert(sizeof(channel) == 20); struct channel_binding { binding_kind kind{binding_kind::joint}; std::array reserved{}; - std::uint32_t target{no_index}; // component + std::uint32_t target{no_index}; // a JOIN component, a clip (its index in ACLP), a VARI or an LSLT component float scale{1.f}; // target value = channel value * scale + offset float offset{0.f}; }; diff --git a/model/eu07m/eu07m_io.cpp b/model/eu07m/eu07m_io.cpp index 2efcc6869..7a8612a20 100644 --- a/model/eu07m/eu07m_io.cpp +++ b/model/eu07m/eu07m_io.cpp @@ -706,13 +706,26 @@ bool valid_variants(model const &Model, payload_reader &Reader) { return all_nodes(Model, Reader, listsize); } +// a clip is named by its index in ACLP, the other targets are components; a joint has to be one +bool valid_binding_target(model const &Model, payload::channel_binding const &Binding) { + if (Binding.target == no_index) + return true; + if (Binding.kind == payload::binding_kind::clip) + return Binding.target < Model.clips.size(); + if (Binding.kind == payload::binding_kind::joint) + return Binding.target < Model.components.size() && Model.components[Binding.target].type == component::joint; + return valid_optional_component(Model, Binding.target); +} + bool valid_channel(model const &Model, payload_reader &Reader) { payload::channel channel; if (false == Reader.get(channel) || false == valid_string(Model, channel.name)) return false; for (std::uint32_t idx = 0; idx < channel.binding_count; ++idx) { payload::channel_binding binding; - if (false == Reader.get(binding) || binding.kind > payload::binding_kind::light_slot || false == valid_optional_component(Model, binding.target)) + if (false == Reader.get(binding) || binding.kind > payload::binding_kind::light_slot) + return false; + if (false == valid_binding_target(Model, binding)) return false; } return true; diff --git a/model/eu07m/eu07m_load.cpp b/model/eu07m/eu07m_load.cpp index 3ff9ac189..0400125a2 100644 --- a/model/eu07m/eu07m_load.cpp +++ b/model/eu07m/eu07m_load.cpp @@ -403,6 +403,64 @@ animation::clip make_clip(eu07m::model const &Model, eu07m::clip_record const &R return clip; } +// the joint of a JOIN component of a node, moving the node from its own transform +std::optional make_joint(eu07m::model const &Model, std::uint32_t const Component, std::vector const &Locals) { + if (Component >= Model.components.size()) + return std::nullopt; + auto const &record{Model.components[Component]}; + if (record.type != eu07m::component::joint || record.kind != eu07m::target_kind::node || record.target >= Model.nodes.size()) + return std::nullopt; + eu07m::payload::joint joint; + if (eu07m::payload_reader reader{Model.component_payload(Component)}; false == reader.get(joint)) + return std::nullopt; + animation::joint_binding result; + result.node = static_cast(record.target); + result.type = static_cast(joint.kind); + result.axis = {joint.axis[0], joint.axis[1], joint.axis[2]}; + result.limited = joint.limited != 0; + result.minimum = joint.minimum; + result.maximum = joint.maximum; + result.pitch = joint.pitch; + result.rest = Locals[record.target]; + return result; +} + +// the channel of a CHNL component, with the bindings the game knows (joints and clips); the others are left out +animation::channel make_channel(eu07m::model const &Model, std::uint32_t const Component, std::vector const &Locals) { + animation::channel channel; + eu07m::payload_reader reader{Model.component_payload(Component)}; + eu07m::payload::channel record; + if (false == reader.get(record)) + return channel; + channel.name = Model.string(record.name); + channel.minimum = record.minimum; + channel.maximum = record.maximum; + channel.initial = record.initial; + for (std::uint32_t idx = 0; idx < record.binding_count; ++idx) { + eu07m::payload::channel_binding binding; + if (false == reader.get(binding)) + break; + animation::channel_binding result; + result.scale = binding.scale; + result.offset = binding.offset; + if (binding.kind == eu07m::payload::binding_kind::joint) { + auto const joint{make_joint(Model, binding.target, Locals)}; + if (false == joint.has_value()) + continue; + result.target = animation::binding_target::joint; + result.joint = *joint; + } + else if (binding.kind == eu07m::payload::binding_kind::clip && binding.target < Model.clips.size()) { + result.target = animation::binding_target::clip; + result.clip = binding.target; + } + else + continue; + channel.bindings.push_back(result); + } + return channel; +} + } // namespace bool TModel3d::LoadFromEU07M(std::string const &FileName, bool const dynamic) { @@ -456,6 +514,19 @@ bool TModel3d::LoadFromEU07M(std::string const &FileName, bool const dynamic) { Root[node.node].WillBeAnimated(); m_clips.push_back(std::move(clip)); } + // the channels; the nodes of their joints are animated too + m_channels.clear(); + auto const locals{eu07m::local_transforms(model)}; + for (std::uint32_t idx = 0; idx < model.components.size(); ++idx) { + if (model.components[idx].type != eu07m::component::channel) + continue; + auto channel{make_channel(model, idx, locals)}; + for (auto const &binding : channel.bindings) { + if (binding.target == animation::binding_target::joint) + Root[binding.joint.node].WillBeAnimated(); + } + m_channels.push_back(std::move(channel)); + } m_vertexcount += builder.vertex_count; m_indexcount += builder.index_count; // the tangents come with the vertices diff --git a/tests/unit/test_clip.cpp b/tests/unit/test_clip.cpp index d306d0de9..c1d061911 100644 --- a/tests/unit/test_clip.cpp +++ b/tests/unit/test_clip.cpp @@ -156,3 +156,76 @@ TEST_CASE("clip: the clips go through the file and its checks") { broken.clips[0].track_count = 2; CHECK_FALSE(eu07m::validate(broken, 16).empty()); } + +TEST_CASE("clip: a joint turns or moves its node from the rest, within its limits") { + animation::joint_binding hinge; + hinge.type = animation::joint_type::hinge; + hinge.axis = {2.f, 0.f, 0.f}; // made a unit vector + hinge.rest = glm::translate(glm::mat4{1.f}, glm::vec3{0.f, 0.f, 2.f}); + auto const turned{animation::joint_transform(hinge, std::numbers::pi_v / 2.f)}; + // the rest first: the node stays at z = 2, its +z turned to -y + CHECK(turned[3].z == doctest::Approx(2.f)); + CHECK(glm::vec3{turned * glm::vec4{0.f, 0.f, 1.f, 0.f}}.y == doctest::Approx(-1.f)); + hinge.limited = true; + hinge.minimum = -0.5f; + hinge.maximum = 0.5f; + auto const limited{animation::joint_transform(hinge, 3.f)}; + CHECK(glm::vec3{limited * glm::vec4{0.f, 0.f, 1.f, 0.f}}.y == doctest::Approx(-std::sin(0.5f))); + + animation::joint_binding slider; + slider.type = animation::joint_type::slider; + slider.axis = {0.f, 1.f, 0.f}; + CHECK(animation::joint_transform(slider, 0.25f)[3].y == doctest::Approx(0.25f)); + + // a screw of 0.012 m a turn moves 0.006 m in half a turn + animation::joint_binding screw; + screw.type = animation::joint_type::screw; + screw.axis = {0.f, 0.f, 1.f}; + screw.pitch = 0.012f; + CHECK(animation::joint_transform(screw, std::numbers::pi_v)[3].z == doctest::Approx(0.006f)); + + animation::joint_binding fixed; + fixed.type = animation::joint_type::fixed; + fixed.rest = hinge.rest; + CHECK(animation::joint_transform(fixed, 1.f)[3].z == doctest::Approx(2.f)); +} + +TEST_CASE("clip: a channel keeps its value within its range") { + animation::channel channel; + channel.minimum = 1.f; + channel.maximum = -1.f; // the other way round, still the range + CHECK(animation::channel_value(channel, 5.f) == doctest::Approx(1.f)); + CHECK(animation::channel_value(channel, -5.f) == doctest::Approx(-1.f)); + CHECK(animation::channel_value(channel, 0.25f) == doctest::Approx(0.25f)); +} + +TEST_CASE("clip: a channel names a clip by its index and a joint by its component") { + auto model{clip_model()}; + auto const joint{model.add_component(eu07m::component::joint, eu07m::target_kind::node, 0, eu07m::payload_writer{}.put(eu07m::payload::joint{}).data())}; + eu07m::payload::channel channel; + channel.name = model.intern("swing"); + channel.binding_count = 2; + eu07m::payload::channel_binding toclip; + toclip.kind = eu07m::payload::binding_kind::clip; + toclip.target = 0; + eu07m::payload::channel_binding tojoint; + tojoint.target = joint; + auto const component{model.add_component(eu07m::component::channel, eu07m::target_kind::model, 0, eu07m::payload_writer{}.put(channel).put(toclip).put(tojoint).data())}; + CHECK(eu07m::validate(model, 16).empty()); + // a clip past the clips of the model, a joint which isn't a JOIN + auto broken{model}; + toclip.target = 7; + broken.component_data.clear(); + broken.components.clear(); + broken.add_component(eu07m::component::joint, eu07m::target_kind::node, 0, eu07m::payload_writer{}.put(eu07m::payload::joint{}).data()); + broken.add_component(eu07m::component::channel, eu07m::target_kind::model, 0, eu07m::payload_writer{}.put(channel).put(toclip).put(tojoint).data()); + CHECK_FALSE(eu07m::validate(broken, 16).empty()); + broken = model; + toclip.target = 0; + tojoint.target = component; // the channel itself + broken.component_data.clear(); + broken.components.clear(); + broken.add_component(eu07m::component::joint, eu07m::target_kind::node, 0, eu07m::payload_writer{}.put(eu07m::payload::joint{}).data()); + broken.add_component(eu07m::component::channel, eu07m::target_kind::model, 0, eu07m::payload_writer{}.put(channel).put(toclip).put(tojoint).data()); + CHECK_FALSE(eu07m::validate(broken, 16).empty()); +} diff --git a/tests/unit/test_skinning.cpp b/tests/unit/test_skinning.cpp index e30abd3ba..2bfb0bb7d 100644 --- a/tests/unit/test_skinning.cpp +++ b/tests/unit/test_skinning.cpp @@ -224,3 +224,52 @@ TEST_CASE("skinning: the tube bent by a clip of its own") { output.write(reinterpret_cast(file.data()), static_cast(file.size())); CHECK(output.good()); } + +TEST_CASE("skinning: the tube moved by channels") { + // "bend" turns the tip on a hinge about x, limited to +-1.2 rad; "phase" scrubs the clip "swing" (the base, so the whole tube, + // to 60 degrees and back in 2 s, not played on its own), 0 to 1 of its duration + auto model{skinned_tube()}; + eu07m::clip_record clip; + clip.name = model.intern("swing"); + clip.track_count = 1; + clip.duration = 2.f; + model.clips.push_back(clip); + eu07m::track_record track; + track.node = 2; // tube_base + track.path = eu07m::track_path::rotation; + track.key_count = 3; + model.clip_tracks.push_back(track); + model.key_times = {0.f, 1.f, 2.f}; + for (auto const degrees : {0.f, 60.f, 0.f}) { + auto const rotation{glm::angleAxis(glm::radians(degrees), glm::vec3{1.f, 0.f, 0.f})}; + model.key_rotations.push_back(eu07m::encode_rotation({rotation.x, rotation.y, rotation.z, rotation.w})); + } + eu07m::payload::joint hinge; + hinge.kind = eu07m::payload::joint_kind::hinge; + hinge.limited = 1; + hinge.minimum = -1.2f; + hinge.maximum = 1.2f; + auto const joint{model.add_component(eu07m::component::joint, eu07m::target_kind::node, 3, eu07m::payload_writer{}.put(hinge).data())}; + eu07m::payload::channel bend; + bend.name = model.intern("bend"); + bend.minimum = -1.f; + bend.maximum = 1.f; + bend.binding_count = 1; + eu07m::payload::channel_binding tojoint; + tojoint.target = joint; + tojoint.scale = 1.2f; + model.add_component(eu07m::component::channel, eu07m::target_kind::model, 0, eu07m::payload_writer{}.put(bend).put(tojoint).data()); + eu07m::payload::channel phase; + phase.name = model.intern("phase"); + phase.binding_count = 1; + eu07m::payload::channel_binding toclip; + toclip.kind = eu07m::payload::binding_kind::clip; + toclip.target = 0; + model.add_component(eu07m::component::channel, eu07m::target_kind::model, 0, eu07m::payload_writer{}.put(phase).put(toclip).data()); + CHECK(eu07m::validate(model, 16).empty()); + auto const file{eu07m::write(model, {true, 9})}; + auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "channel_tube.eu07m"}; + std::ofstream output{path, std::ios::binary}; + output.write(reinterpret_cast(file.data()), static_cast(file.size())); + CHECK(output.good()); +} diff --git a/world/Event.cpp b/world/Event.cpp index cf02e9409..613c6e2b7 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -1576,8 +1576,8 @@ animation_event::init() { // animacja modelu init_targets( simulation::Instances, "model instance" ); // custom target initialization code - if( m_animationtype == clip_animation ) { - // clips go by the model, not by its submodels + if( ( m_animationtype == clip_animation ) || ( m_animationtype == channel_animation ) ) { + // clips and channels go by the model, not by its submodels return; } if( m_animationtype == 4 ) { @@ -1669,6 +1669,14 @@ animation_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) Input.getTokens( 1 ); Input >> m_animationparams[ 0 ]; } + else if( token == "channel" ) { + // a channel of the model (EU07M): its name and value + Input.getTokens(); + Input >> m_animationsubmodel; + m_animationtype = channel_animation; + Input.getTokens( 1 ); + Input >> m_animationparams[ 0 ]; + } else if( token.ends_with(".vmd") ) // na razie tu, może będzie inaczej { // animacja z pliku VMD { @@ -1704,7 +1712,7 @@ void animation_event::run_() { WriteLog( "Type: Animation" ); - if( m_animationtype == clip_animation ) { + if( ( m_animationtype == clip_animation ) || ( m_animationtype == channel_animation ) ) { run_clips(); return; } @@ -1743,6 +1751,12 @@ animation_event::run_clips() const { for( auto const &target : m_targets ) { auto *model { static_cast( std::get( target ) ) }; if( model == nullptr ) { continue; } + if( m_animationtype == channel_animation ) { + if( false == model->set_channel( m_animationsubmodel, static_cast( m_animationparams[ 0 ] ) ) ) { + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") can't find channel " + m_animationsubmodel + " in model instance \"" + model->name() + "\"" ); + } + continue; + } if( m_animationparams[ 0 ] <= 0.0 ) { model->stop_clips(); } @@ -1766,8 +1780,8 @@ animation_event::finish() const { void animation_event::export_as_text_( std::ostream &Output ) const { - if( m_animationtype == clip_animation ) { - Output << "clip " << m_animationsubmodel << ' ' << m_animationparams[ 0 ] << ' '; + if( ( m_animationtype == clip_animation ) || ( m_animationtype == channel_animation ) ) { + Output << ( m_animationtype == clip_animation ? "clip " : "channel " ) << m_animationsubmodel << ' ' << m_animationparams[ 0 ] << ' '; return; } // animation type diff --git a/world/Event.h b/world/Event.h index d6125ff38..a64cf2ef0 100644 --- a/world/Event.h +++ b/world/Event.h @@ -441,6 +441,8 @@ public: void finish() const; // the form "clip ": an animation clip of the model (EU07M) started, or the clips stopped with a pace of 0 static constexpr int clip_animation{ 16 }; + // the form "channel ": a channel of the model (EU07M) set, which moves the joints and the clips bound to it + static constexpr int channel_animation{ 32 }; private: // methods