mirror of https://github.com/AxioDL/metaforce.git
Targeted subresource generation for Actor and World blends
This commit is contained in:
parent
de41c5d92d
commit
86f9f62ef6
|
@ -300,6 +300,30 @@ def _out_actions(sact_data, writebuf):
|
|||
mesh = bpy.data.objects[subtype.linked_mesh]
|
||||
write_action_aabb(writebuf, arm, mesh)
|
||||
|
||||
def _out_action_no_subtypes(sact_data, writebuf, action_name):
|
||||
for action_idx in range(len(sact_data.actions)):
|
||||
action = sact_data.actions[action_idx]
|
||||
if action.name == action_name:
|
||||
sact_data.active_action = action_idx
|
||||
writebuf(struct.pack('I', len(action.name)))
|
||||
writebuf(action.name.encode())
|
||||
|
||||
bact = None
|
||||
if action.name in bpy.data.actions:
|
||||
bact = bpy.data.actions[action.name]
|
||||
if not bact:
|
||||
raise RuntimeError('action %s not found' % action.name)
|
||||
|
||||
writebuf(struct.pack('f', 1.0 / bact.hecl_fps))
|
||||
writebuf(struct.pack('b', int(bact.hecl_additive)))
|
||||
writebuf(struct.pack('b', int(bact.hecl_looping)))
|
||||
|
||||
write_action_channels(writebuf, bact)
|
||||
writebuf(struct.pack('I', 0))
|
||||
return
|
||||
|
||||
raise RuntimeError("Unable to find action '%s'" % action_name)
|
||||
|
||||
# Cook
|
||||
def cook(writebuf):
|
||||
bpy.context.scene.hecl_auto_remap = False
|
||||
|
@ -327,6 +351,13 @@ def cook_character_only(writebuf):
|
|||
# Output no actions
|
||||
writebuf(struct.pack('I', 0))
|
||||
|
||||
def cook_action_channels_only(writebuf, action_name):
|
||||
sact_data = bpy.context.scene.hecl_sact_data
|
||||
|
||||
# Output action without AABBs
|
||||
_out_action_no_subtypes(sact_data, writebuf, action_name)
|
||||
|
||||
|
||||
# Access actor's contained armature names
|
||||
def get_armature_names(writebuf):
|
||||
writebuf(struct.pack('I', len(bpy.data.armatures)))
|
||||
|
|
|
@ -347,6 +347,11 @@ def dataout_loop():
|
|||
writepipestr(b'OK')
|
||||
hecl.sact.cook_character_only(writepipebuf)
|
||||
|
||||
elif cmdargs[0] == 'ACTIONCOMPILECHANNELSONLY':
|
||||
actionName = cmdargs[1]
|
||||
writepipestr(b'OK')
|
||||
hecl.sact.cook_action_channels_only(writepipebuf, actionName)
|
||||
|
||||
elif cmdargs[0] == 'GETARMATURENAMES':
|
||||
writepipestr(b'OK')
|
||||
hecl.sact.get_armature_names(writepipebuf)
|
||||
|
|
|
@ -802,6 +802,7 @@ public:
|
|||
|
||||
Actor compileActor();
|
||||
Actor compileActorCharacterOnly();
|
||||
Actor::Action compileActionChannelsOnly(const std::string& name);
|
||||
std::vector<std::string> getArmatureNames();
|
||||
std::vector<std::string> getSubtypeNames();
|
||||
std::vector<std::string> getActionNames();
|
||||
|
|
|
@ -1225,10 +1225,10 @@ BlenderConnection::DataStream::Actor::Action::Action(BlenderConnection& conn)
|
|||
subtypeAABBs.reserve(aabbCount);
|
||||
for (uint32_t i=0 ; i<aabbCount ; ++i)
|
||||
{
|
||||
printf("AABB %s %d\n", name.c_str(), i);
|
||||
subtypeAABBs.emplace_back();
|
||||
subtypeAABBs.back().first.read(conn);
|
||||
subtypeAABBs.back().second.read(conn);
|
||||
printf("AABB %s %d\n", name.c_str(), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1482,6 +1482,25 @@ BlenderConnection::DataStream::compileActorCharacterOnly()
|
|||
return Actor(*m_parent);
|
||||
}
|
||||
|
||||
BlenderConnection::DataStream::Actor::Action
|
||||
BlenderConnection::DataStream::compileActionChannelsOnly(const std::string& name)
|
||||
{
|
||||
if (m_parent->m_loadedType != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"),
|
||||
m_parent->m_loadedBlend.getAbsolutePath().c_str());
|
||||
|
||||
char req[128];
|
||||
snprintf(req, 128, "ACTIONCOMPILECHANNELSONLY %s", name.c_str());
|
||||
m_parent->_writeStr(req);
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile action: %s", readBuf);
|
||||
|
||||
return Actor::Action(*m_parent);
|
||||
}
|
||||
|
||||
BlenderConnection::DataStream::World
|
||||
BlenderConnection::DataStream::compileWorld()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue