Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Add DCLN blend type
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Oct 17, 2017
1 parent 34e28fe commit f949aab
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions blender/hecl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
hecl_typeS = [
('NONE', "None", "Active scene not using HECL", None),
('MESH', "Mesh", "Active scene represents an HMDL Mesh", hmdl.draw),
('CMESH', "Collision Mesh", "Active scene represents a Collision Mesh", None),
('ACTOR', "Actor", "Active scene represents a HECL Actor", sact.draw),
('AREA', "Area", "Active scene represents a HECL Area", srea.draw),
('WORLD', "World", "Active scene represents a HECL World", swld.draw),
Expand Down
13 changes: 13 additions & 0 deletions blender/hecl_blendershell.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ def dataout_loop():
writepipestr(b'OK')
hecl.hmdl.cookcol(writepipebuf, bpy.data.objects[meshName])

elif cmdargs[0] == 'MESHCOMPILECOLLISIONALL':
writepipestr(b'OK')
colCount = 0
for obj in bpy.context.scene.objects:
if obj.type == 'MESH' and not obj.library:
colCount += 1

writepipebuf(struct.pack('I', colCount))

for obj in bpy.context.scene.objects:
if obj.type == 'MESH' and not obj.library:
hecl.hmdl.cookcol(writepipebuf, obj)

elif cmdargs[0] == 'MESHCOMPILEALL':
maxSkinBanks = int(cmdargs[2])
maxOctantLength = float(cmdargs[3])
Expand Down
2 changes: 1 addition & 1 deletion extern/boo
Submodule boo updated 1 files
+4 −4 test/main.cpp
4 changes: 4 additions & 0 deletions include/hecl/Blender/BlenderConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class BlenderConnection
{
None,
Mesh,
ColMesh,
Actor,
Area,
World,
Expand Down Expand Up @@ -791,6 +792,9 @@ class BlenderConnection
/** Compile collision mesh by name (AREA blends only) */
ColMesh compileColMesh(const std::string& name);

/** Compile all meshes as collision meshes (CMESH blends only) */
std::vector<ColMesh> compileColMeshes();

/** Compile all meshes into one (AREA blends only) */
Mesh compileAllMeshes(HMDLTopology topology, int skinSlotCount=10, float maxOctantLength=5.0,
Mesh::SurfProgFunc surfProg=[](int){});
Expand Down
1 change: 1 addition & 0 deletions include/hecl/hecl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ class FourCC
std::string toString() const {return std::string(fcc, 4);}
uint32_t toUint32() const {return num;}
operator uint32_t() const {return num;}
const char* getChars() const {return fcc;}
};
#define FOURCC(chars) FourCC(SBIG(chars))

Expand Down
29 changes: 29 additions & 0 deletions lib/Blender/BlenderConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ static const char* BlendTypeStrs[] =
{
"NONE",
"MESH",
"CMESH",
"ACTOR",
"AREA",
"WORLD",
Expand Down Expand Up @@ -1484,6 +1485,34 @@ BlenderConnection::DataStream::compileColMesh(const std::string& name)
return ColMesh(*m_parent);
}

std::vector<BlenderConnection::DataStream::ColMesh>
BlenderConnection::DataStream::compileColMeshes()
{
if (m_parent->m_loadedType != BlendType::ColMesh)
BlenderLog.report(logvisor::Fatal, _S("%s is not a CMESH blend"),
m_parent->m_loadedBlend.getAbsolutePath().c_str());

char req[128];
snprintf(req, 128, "MESHCOMPILECOLLISIONALL");
m_parent->_writeStr(req);

char readBuf[256];
m_parent->_readStr(readBuf, 256);
if (strcmp(readBuf, "OK"))
BlenderLog.report(logvisor::Fatal, "unable to cook collision meshes: %s", readBuf);

uint32_t meshCount;
m_parent->_readBuf(&meshCount, 4);

std::vector<BlenderConnection::DataStream::ColMesh> ret;
ret.reserve(meshCount);

for (uint32_t i=0 ; i<meshCount ; ++i)
ret.emplace_back(*m_parent);

return ret;
}

BlenderConnection::DataStream::Mesh
BlenderConnection::DataStream::compileAllMeshes(HMDLTopology topology,
int skinSlotCount,
Expand Down

0 comments on commit f949aab

Please sign in to comment.