Skip to content
Snippets Groups Projects
Commit 7adbe608 authored by Gundalf's avatar Gundalf
Browse files

fixed collision generation

parent 15498f31
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,17 @@ Exporter::Exporter(Interface *i)
Exporter::Result Exporter::export(NiNodeRef &root, INode *node)
{
BSXFlagsRef bsx = DynamicCast<BSXFlags>(CreateBlock("BSXFlags"));
bsx->SetName("BSX");
bsx->SetFlags(0x00000002);
NiStringExtraDataRef strings = DynamicCast<NiStringExtraData>(CreateBlock("NiStringExtraData"));
strings->SetName("UPB");
strings->SetData("Ellasticity = 0.300000\r\nFriction = 0.300000\r\nUnyielding = 0\r\nProxy_Geometry = <None>\r\nUse_Display_Proxy = 0\r\nDisplay_Children = 1\r\nDisable_Collisions = 0\r\nInactive = 0\r\nDisplay_Proxy = <None>\r\nMass = 0.000000\r\nSimulation_Geometry = 2\r\nCollision_Groups = 589825\r\n");
root->AddExtraData(DynamicCast<NiExtraData>(bsx));
root->AddExtraData(DynamicCast<NiExtraData>(strings));
mNiRoot = root;
return exportTree(root, node);
}
......
......@@ -314,6 +314,25 @@
</FileConfiguration>
</File>
</Filter>
<Filter
Name="TriStripper"
Filter="">
<File
RelativePath="TriStripper\tri_stripper.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"/>
</FileConfiguration>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
......@@ -346,6 +365,22 @@
RelativePath="NvTriStrip\VertexCache.h">
</File>
</Filter>
<Filter
Name="TriStripper"
Filter="">
<File
RelativePath="TriStripper\cache_simulator.h">
</File>
<File
RelativePath="TriStripper\graph_array.h">
</File>
<File
RelativePath="TriStripper\heap_array.h">
</File>
<File
RelativePath="TriStripper\tri_stripper.h">
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
......
#include "pch.h"
using namespace triangle_stripper;
void Exporter::strippify(TriStrips &strips, vector<Vector3> &verts, vector<Vector3> &norms, const Triangles &tris)
{
unsigned short *data = (unsigned short *)malloc(tris.size() * 3 * 2);
vector<unsigned int> idcs(tris.size()*3);
int i;
for (i=0; i<tris.size(); i++)
{
data[i * 3 + 0] = tris[i][0];
data[i * 3 + 1] = tris[i][1];
data[i * 3 + 2] = tris[i][2];
idcs[i * 3 + 0] = tris[i][0];
idcs[i * 3 + 1] = tris[i][1];
idcs[i * 3 + 2] = tris[i][2];
}
PrimitiveGroup * groups = 0;
unsigned short numGroups = 0;
// GF 3+
SetCacheSize(CACHESIZE_GEFORCE3);
// don't generate hundreds of strips
SetStitchStrips(true);
GenerateStrips(data, tris.size()*3, &groups, &numGroups);
tri_stripper stripper(idcs);
free( data );
if (!groups)
return;
tri_stripper::primitives_vector groups;
stripper.Strip(&groups);
if (!mRemapIndices)
for (i=0; i<groups.size(); i++)
{
for (int g=0; g<numGroups; g++)
{
if (groups[g].type == PT_STRIP)
{
strips.push_back(TriStrip(groups[g].numIndices));
TriStrip &strip = strips.back();
for (int s=0; s<groups[g].numIndices; s++)
strip[s] = groups[g].indices[s];
}
}
} else
{
// remap indices
PrimitiveGroup *rmGroups;
RemapIndices(groups, numGroups, verts.size(), &rmGroups);
vector<Vector3> tverts = verts;
vector<Vector3> tnorms = norms;
for (int g=0; g<numGroups; g++)
{
if (rmGroups[g].type == PT_STRIP)
{
strips.push_back(TriStrip(rmGroups[g].numIndices));
TriStrip &strip = strips.back();
for (int s=0; s<rmGroups[g].numIndices; s++)
{
strip[s] = rmGroups[g].indices[s];
unsigned short a = strip[s], b = groups[g].indices[s];
verts[a] = tverts[b];
norms[a] = tnorms[b];
}
}
}
delete [] rmGroups;
if (groups[i].m_Type != tri_stripper::PT_Triangle_Strip)
continue;
strips.push_back(TriStrip(groups[i].m_Indices.size()));
TriStrip &strip = strips.back();
for (int j=0; j<groups[i].m_Indices.size(); j++)
strip[j] = groups[i].m_Indices[j];
}
delete [] groups;
}
void Exporter::strippify(TriStrips &strips, FaceGroup &grp)
......@@ -143,7 +101,6 @@ void Exporter::strippify(TriStrips &strips, FaceGroup &grp)
}
delete [] rmGroups;
}
delete [] groups;
}
......
......@@ -39,7 +39,7 @@ string NiExtraData::GetName() {
return name;
}
void NiExtraData::SetName( string & new_name ) {
void NiExtraData::SetName( const string & new_name ) {
name = new_name;
}
......
......@@ -60,7 +60,7 @@ public:
* version NIF files.
* \param new_name The new name for this NiExtraData object.
*/
void SetName( string & new_name );
void SetName( const string & new_name );
/*!
* Formats a human readable string that includes the type of the object
......
......@@ -41,7 +41,7 @@ string NiObjectNET::GetName() {
return name;
}
void NiObjectNET::SetName( string & new_name ) {
void NiObjectNET::SetName( const string & new_name ) {
name = new_name;
}
......
......@@ -41,7 +41,7 @@ public:
virtual list<NiObjectRef> GetRefs() const;
string GetName();
void SetName( string & new_name );
void SetName( const string & new_name );
/*!
* Formats a human readable string that includes the type of the object
* \return A string in the form: address(type) {name}
......
......@@ -22,8 +22,12 @@
#include "niflib/obj/NiMaterialProperty.h"
#include "niflib/obj/NiTexturingProperty.h"
#include "niflib/obj/NiSourceTexture.h"
#include "niflib/obj/BsxFlags.h"
#include "niflib/obj/NiStringExtraData.h"
#include "NvTriStrip/NvTriStrip.h"
#include <deque>
#include "TriStripper/tri_stripper.h"
#include "../NifPlugins.h"
#include "Exporter.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment