Better split between runtime library and editor.
This commit is contained in:
@@ -4,7 +4,10 @@
|
||||
|
||||
#include "AnimGraphEditor.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "AnimGraphResource.h"
|
||||
#include "SkinnedMesh.h"
|
||||
#include "imgui.h"
|
||||
#include "imnodes.h"
|
||||
#include "misc/cpp/imgui_stdlib.h"
|
||||
@@ -63,6 +66,83 @@ void RemoveConnectionsForSocket(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SyncTrackEditor(SyncTrack* sync_track) {
|
||||
ImGui::SliderFloat("duration", &sync_track->m_duration, 0.001f, 10.f);
|
||||
|
||||
ImGui::Text("Marker");
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%d", sync_track->m_num_intervals);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("+")) {
|
||||
if (sync_track->m_num_intervals < cSyncTrackMaxIntervals) {
|
||||
sync_track->m_num_intervals ++;
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("-")) {
|
||||
if (sync_track->m_num_intervals > 0) {
|
||||
sync_track->m_num_intervals --;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("Marker:");
|
||||
for (int i = 0; i < sync_track->m_num_intervals; i++) {
|
||||
ImGui::Text("%2d:", i);
|
||||
ImGui::SameLine();
|
||||
std::ostringstream marker_stream;
|
||||
marker_stream << i;
|
||||
ImGui::SliderFloat(
|
||||
marker_stream.str().c_str(),
|
||||
&sync_track->m_sync_markers[i],
|
||||
0.f,
|
||||
1.f);
|
||||
}
|
||||
|
||||
if (ImGui::Button ("Update Intervals")) {
|
||||
sync_track->CalcIntervals();
|
||||
}
|
||||
}
|
||||
|
||||
void SkinnedMeshWidget(SkinnedMesh* skinned_mesh) {
|
||||
if (ImGui::TreeNode("Bones")) {
|
||||
for (int i = 0; i < skinned_mesh->m_skeleton.num_joints(); i++) {
|
||||
ImGui::Text("%s", skinned_mesh->m_skeleton.joint_names()[i]);
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::Text("Animations");
|
||||
|
||||
const char* items[255] = {0};
|
||||
static int selected = -1;
|
||||
for (int i = 0; i < skinned_mesh->m_animations.size(); i++) {
|
||||
items[i] = skinned_mesh->m_animation_names[i].c_str();
|
||||
}
|
||||
|
||||
ImGui::Combo("Animation", &selected, items, skinned_mesh->m_animations.size());
|
||||
|
||||
ImGui::Text("Sync Track");
|
||||
if (selected >= 0 && selected < skinned_mesh->m_animations.size()) {
|
||||
SyncTrackEditor(&skinned_mesh->m_animation_sync_track[selected]);
|
||||
skinned_mesh->m_override_anim = selected;
|
||||
|
||||
ImGui::Checkbox("Override Animation", &skinned_mesh->m_sync_track_override);
|
||||
if (skinned_mesh->m_sync_track_override) {
|
||||
ImGui::SliderFloat("Ratio", &skinned_mesh->m_override_ratio, 0.f, 1.f);
|
||||
|
||||
ozz::animation::SamplingJob sampling_job;
|
||||
sampling_job.animation = skinned_mesh->m_animations[selected];
|
||||
sampling_job.context = &skinned_mesh->m_sampling_context;
|
||||
sampling_job.ratio = skinned_mesh->m_override_ratio;
|
||||
sampling_job.output = make_span(skinned_mesh->m_local_matrices);
|
||||
if (!sampling_job.Run()) {
|
||||
ozz::log::Err() << "Error sampling animation." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AnimGraphEditorRenderSidebar(
|
||||
AnimGraphResource& graph_resource,
|
||||
AnimNodeResource& node_resource) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "AnimGraph.h"
|
||||
|
||||
struct SkinnedMesh;
|
||||
|
||||
inline int GenerateInputAttributeId(int node_id, int input_index) {
|
||||
return ((input_index + 1) << 14) + node_id;
|
||||
}
|
||||
@@ -27,6 +29,10 @@ SplitOutputAttributeId(int attribute_id, int* node_id, int* output_index) {
|
||||
*output_index = (attribute_id >> 23) - 1;
|
||||
}
|
||||
|
||||
void SyncTrackEditor(SyncTrack* sync_track);
|
||||
|
||||
void SkinnedMeshWidget(SkinnedMesh* skinned_mesh);
|
||||
|
||||
void AnimGraphEditorUpdate();
|
||||
|
||||
void AnimGraphEditorGetRuntimeGraph(AnimGraph& anim_graph);
|
||||
|
||||
Reference in New Issue
Block a user