Skip to content
Snippets Groups Projects
Commit d30733fd authored by Tazpn's avatar Tazpn
Browse files

max: Alter code to use WildMagic 4.7 differently.

parent a6b4f88f
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,11 @@ NifTools MaxPlugin
Change log
----------
0.3.0
------
o All
Alter usage of the WildMagic for easier use in development and deployment
0.2.17
------
o All
......
......@@ -81,4 +81,9 @@ and redistributed under the following conditions:
MaxNifTools uses Havok®. ©Copyright 1999-2008 Havok.com Inc. (and its Licensors).
All Rights Reserved. See www.havok.com for details.
\ No newline at end of file
=======================================================================
NifMagic uses WildMagic 4.7. WildMagic 4.7 is open source and is covered
by the GNU Lesser General Public License (LGPL).
\ No newline at end of file
......@@ -6,7 +6,7 @@ AppName=NIF Utilities for 3ds Max
AppVerName=NIF Utilities {code:CurVer} for 3ds Max
AppPublisher=NIF File Format Library and Tools
AppCopyright=Copyright 2008, NIF File Format Library and Tools
OutputBaseFilename=niftools-max-plugins-0.2.17.7
OutputBaseFilename=niftools-max-plugins-0.3.0.0
DisableProgramGroupPage=yes
Compression=lzma
SolidCompression=yes
......@@ -18,7 +18,7 @@ UninstallFilesDir={win}{\}Installer\NifTools
Uninstallable=yes
DisableDirPage=yes
ArchitecturesInstallIn64BitMode=x64
VersionInfoVersion=0.2.17.7
VersionInfoVersion=0.3.0.0
SourceDir=.
;UninstallDisplayIcon={app}{\}..\Oblivion.exe
......@@ -141,7 +141,7 @@ var sVersion: String;
function InitializeSetup(): Boolean;
begin
sVersion := '0.2.17.7';
sVersion := '0.3.0.0';
Result := True;
end;
......
......@@ -17,11 +17,11 @@ HISTORY:
* Define the major, minor, build, patch version numbers
*/
#define VERSION_MAJOR_INT 0
#define VERSION_MINOR_INT 2
#define VERSION_BUILD_INT 17
#define VERSION_PATCH_INT 7
#define VERSION_MINOR_INT 3
#define VERSION_BUILD_INT 0
#define VERSION_PATCH_INT 0
#define VERSION_STRING "0, 2, 17, 7"
#define VERSION_STRING "0, 3, 0, 0"
//#define DEF_VERSION_STRING(a,b,c,d) #a ", " #b ", " #c ", " #d
//#define VERSION_STRING DEF_VERSION_STRING(a,b,c,d)
......
......@@ -4,6 +4,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
MaxNifTools.ini = MaxNifTools.ini
NifPlugins_Development_Readme.txt = NifPlugins_Development_Readme.txt
User_Settings.vsprops = User_Settings.vsprops
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Niflib", "..\niflib\niflib_VC2008.vcproj", "{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}"
......@@ -39,6 +40,8 @@ Global
Debug - Max 8|x64 = Debug - Max 8|x64
Debug - Max 9|Win32 = Debug - Max 9|Win32
Debug - Max 9|x64 = Debug - Max 9|x64
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release - gmax|Win32 = Release - gmax|Win32
Release - gmax|x64 = Release - gmax|x64
Release - Max 2008|Win32 = Release - Max 2008|Win32
......@@ -59,6 +62,8 @@ Global
Release - Max 8|x64 = Release - Max 8|x64
Release - Max 9|Win32 = Release - Max 9|Win32
Release - Max 9|x64 = Release - Max 9|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - gmax|Win32.ActiveCfg = Debug - Static|Win32
......@@ -101,6 +106,9 @@ Global
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - Max 9|Win32.Build.0 = Debug - Static|Win32
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - Max 9|x64.ActiveCfg = Debug - Static|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - Max 9|x64.Build.0 = Debug - Static|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug|Win32.ActiveCfg = Debug - DLL|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug|x64.ActiveCfg = Debug - DLL|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug|x64.Build.0 = Debug - DLL|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - gmax|Win32.ActiveCfg = Release - Static|Win32
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - gmax|Win32.Build.0 = Release - Static|Win32
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - gmax|x64.ActiveCfg = Release - DLL|x64
......@@ -141,6 +149,9 @@ Global
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - Max 9|Win32.Build.0 = Release - Static|Win32
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - Max 9|x64.ActiveCfg = Release - Static|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - Max 9|x64.Build.0 = Release - Static|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release|Win32.ActiveCfg = Release - DLL|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release|x64.ActiveCfg = Release - DLL|x64
{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release|x64.Build.0 = Release - DLL|x64
{466F2D3E-2663-4583-A05C-128683677617}.Debug - gmax|Win32.ActiveCfg = Debug - gmax|Win32
{466F2D3E-2663-4583-A05C-128683677617}.Debug - gmax|Win32.Build.0 = Debug - gmax|Win32
{466F2D3E-2663-4583-A05C-128683677617}.Debug - gmax|x64.ActiveCfg = Debug - gmax|x64
......@@ -181,6 +192,9 @@ Global
{466F2D3E-2663-4583-A05C-128683677617}.Debug - Max 9|Win32.Build.0 = Debug - Max 9|Win32
{466F2D3E-2663-4583-A05C-128683677617}.Debug - Max 9|x64.ActiveCfg = Debug - Max 9|x64
{466F2D3E-2663-4583-A05C-128683677617}.Debug - Max 9|x64.Build.0 = Debug - Max 9|x64
{466F2D3E-2663-4583-A05C-128683677617}.Debug|Win32.ActiveCfg = Debug - Max 2009|x64
{466F2D3E-2663-4583-A05C-128683677617}.Debug|x64.ActiveCfg = Debug - Max 2009|x64
{466F2D3E-2663-4583-A05C-128683677617}.Debug|x64.Build.0 = Debug - Max 2009|x64
{466F2D3E-2663-4583-A05C-128683677617}.Release - gmax|Win32.ActiveCfg = Release - gmax|Win32
{466F2D3E-2663-4583-A05C-128683677617}.Release - gmax|Win32.Build.0 = Release - gmax|Win32
{466F2D3E-2663-4583-A05C-128683677617}.Release - gmax|x64.ActiveCfg = Release - gmax|x64
......@@ -221,6 +235,9 @@ Global
{466F2D3E-2663-4583-A05C-128683677617}.Release - Max 9|Win32.Build.0 = Release - Max 9|Win32
{466F2D3E-2663-4583-A05C-128683677617}.Release - Max 9|x64.ActiveCfg = Release - Max 9|x64
{466F2D3E-2663-4583-A05C-128683677617}.Release - Max 9|x64.Build.0 = Release - Max 9|x64
{466F2D3E-2663-4583-A05C-128683677617}.Release|Win32.ActiveCfg = Release - Max 2009|x64
{466F2D3E-2663-4583-A05C-128683677617}.Release|x64.ActiveCfg = Release - Max 2009|x64
{466F2D3E-2663-4583-A05C-128683677617}.Release|x64.Build.0 = Release - Max 2009|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
MaxNifTools.ini = MaxNifTools.ini
MaxNifTools.iss = MaxNifTools.iss
NifPlugins_Development_Readme.txt = NifPlugins_Development_Readme.txt
User_Settings.vsprops = User_Settings.vsprops
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NifPlugins", "Build\NifPlugins_VC80.vcproj", "{466F2D3E-2663-4583-A05C-128683677617}"
......
......@@ -7,30 +7,6 @@
#include "NifGui.h"
#include "meshadj.h"
// Includes for WildMagic so we can do the Capsule fitting
#if defined(USES_WILDMAGIC) && !defined(_M_X64)
# if _MSC_VER >= 1500
# ifdef _DEBUG
# pragma comment (lib, "Wm4Foundation90d")
# else
# pragma comment (lib, "Wm4Foundation90")
# endif
# else
# ifdef _DEBUG
# pragma comment (lib, "Wm4Foundation80d")
# else
# pragma comment (lib, "Wm4Foundation80")
# endif
# endif
#undef PI
#undef DEG_TO_RAD
#undef RAD_TO_DEG
#define WM4PLATFORMS_H
#define WM4_FOUNDATION_ITEM
#include <Wm4ContCapsule3.h>
#define PI (Wm4::Math<double>::PI)
#endif
using namespace std;
#define MAKE_QUAD(na,nb,nc,nd,sm,b) {MakeQuad(nverts,&(mesh.faces[nf]),na, nb, nc, nd, sm, b);nf+=2;}
......@@ -115,14 +91,14 @@ void CalcAxisAlignedSphere(Mesh& mesh, Point3& center, float& radius)
//--Calculate center & radius--//
//Set lows and highs to first vertex
int nv = mesh.getNumVerts();
size_t nv = mesh.getNumVerts();
Point3 lows = mesh.getVert(0);
Point3 highs = mesh.getVert(0);
//Iterate through the vertices, adjusting the stored values
//if a vertex with lower or higher values is found
for ( unsigned int i = 0; i < nv; ++i ) {
for ( size_t i = 0; i < nv; ++i ) {
const Point3 & v = mesh.getVert(i);
if ( v.x > highs.x ) highs.x = v.x;
......@@ -142,7 +118,7 @@ void CalcAxisAlignedSphere(Mesh& mesh, Point3& center, float& radius)
//The radius will be the largest distance from the center
Point3 diff;
float dist2(0.0f), maxdist2(0.0f);
for ( unsigned int i = 0; i < nv; ++i ) {
for ( size_t i = 0; i < nv; ++i ) {
const Point3 & v = mesh.getVert(i);
diff = center - v;
......@@ -780,32 +756,104 @@ void BuildScubaMesh(Mesh &mesh, int segs, int smooth, int llsegs,
mesh.InvalidateTopologyCache();
}
extern HINSTANCE hInstance;
class MagicCode
{
private:
struct Triangle { int a, b, c; };
typedef int (__stdcall * fnCalcCapsule)
(int nverts, const Point3 *verts,
Point3& pt1, Point3& pt2, float& r1, float& r2);
typedef void (__stdcall * fnCalcMassProps)
( int nverts, const Point3* verts,
int ntris, const Triangle* tris,
int iBodyCoords, float &rfMass,
Point3& rkCenter, Matrix3& rkInertia);
HMODULE hMagicLib;
fnCalcCapsule CalcCapsule;
fnCalcMassProps CalcMassProps;
public:
MagicCode() : hMagicLib(0), CalcCapsule(0), CalcMassProps(0) {
}
~MagicCode() {
if (hMagicLib) FreeLibrary(hMagicLib);
}
bool Initialize()
{
if (hMagicLib == NULL)
{
char curfile[_MAX_PATH];
GetModuleFileName(hInstance, curfile, MAX_PATH);
PathRemoveFileSpec(curfile);
PathAppend(curfile, "NifMagic.dll");
hMagicLib = LoadLibraryA( curfile );
if (hMagicLib == NULL)
hMagicLib = LoadLibraryA( "Nifmagic.dll" );
CalcCapsule = (fnCalcCapsule)GetProcAddress( hMagicLib, "CalcCapsule" );
CalcMassProps = (fnCalcMassProps)GetProcAddress( hMagicLib, "CalcMassProps" );
}
return ( NULL != CalcCapsule && NULL != CalcMassProps );
}
void DoCalcCapsule(Mesh &mesh, Point3& pt1, Point3& pt2, float& r1, float& r2)
{
if ( Initialize() )
{
CalcCapsule( mesh.getNumVerts(), &mesh.verts[0], pt1, pt2, r1, r2);
}
}
void DoCalcMassProps( Mesh &mesh,
bool bBodyCoords, float &rfMass,
Point3& rkCenter, Matrix3& rkInertia)
{
vector<Triangle> tris;
tris.resize(mesh.getNumFaces());
for (int i=0; i<mesh.getNumFaces(); ++i)
{
Triangle& tri = tris[i];
Face& face = mesh.faces[i];
tri.a = face.getVert(0);
tri.b = face.getVert(1);
tri.c = face.getVert(2);
}
CalcMassProps( mesh.getNumVerts(), &mesh.verts[0]
, tris.size(), &tris[0]
, bBodyCoords ? 1 : 0, rfMass, rkCenter, rkInertia );
}
} TheMagicCode;
extern bool CanCalcCapsule()
{
return TheMagicCode.Initialize();
}
// Calculate capsule from mesh. While radii on the endcaps is possible we do
// currently calculate then differently.
extern void CalcCapsule(Mesh &mesh, Point3& pt1, Point3& pt2, float& r1, float& r2)
{
#if defined(USES_WILDMAGIC) && !defined(_M_X64)
int nv = mesh.getNumVerts();
Wm4::Vector3<float>* akPoint = new Wm4::Vector3<float>[nv];
for (int i=0; i<nv; i++)
{
Point3& mp = mesh.verts[i];
Wm4::Vector3<float>& wp = akPoint[i];
wp.X() = mp.x;
wp.Y() = mp.y;
wp.Z() = mp.z;
}
Wm4::Capsule3<float> capsule = ContCapsule (nv, akPoint);
delete [] akPoint;
TheMagicCode.DoCalcCapsule(mesh, pt1, pt2, r1, r2);
}
Wm4::Vector3<float> end1 = capsule.Segment.GetPosEnd();
Wm4::Vector3<float> end2 = capsule.Segment.GetNegEnd();
pt1.Set(end1.X(), end1.Y(), end1.Z());
pt2.Set(end2.X(), end2.Y(), end2.Z());
r1 = r2 = capsule.Radius;
#endif
return;
extern bool CanCalcMassProps()
{
return TheMagicCode.Initialize();
}
extern void CalcMassProps( Mesh &mesh,
bool bBodyCoords, float &rfMass,
Point3& rkCenter, Matrix3& rkInertia)
{
TheMagicCode.DoCalcMassProps(mesh, bBodyCoords, rfMass, rkCenter, rkInertia);
}
extern void BuildCapsule(Mesh &mesh, Point3 pt1, Point3 pt2, float r1, float r2)
......
......@@ -6,6 +6,7 @@ extern void CalcAxisAlignedBox(Mesh& mesh, Box3& box, Matrix3* tm);
extern void CalcAxisAlignedSphere(Mesh& mesh, Point3& center, float& radius);
extern void CalcCenteredSphere(Mesh& mesh, Point3& center, float& radius);
extern void CalcCapsule(Mesh &mesh, Point3& pt1, Point3& pt2, float& r1, float& r2);
extern bool CanCalcCapsule();
extern void BuildBox(Mesh&mesh, float l, float w, float h);
extern void BuildSphere(Mesh&mesh, float radius, int segs=32, int smooth=1, float startAng = 0.0f);
......
......@@ -365,9 +365,7 @@ INT_PTR ProxyParamDlgProc::DlgProc(TimeValue t,IParamMap2 *map,HWND hWnd,UINT ms
so->pblock2->GetValue( PB_MATERIAL, 0, sel, valid);
mCbMaterial.select( sel + 1 );
// Disable all types not currently implemented
#if !defined(USES_WILDMAGIC) || defined(_M_X64)
EnableWindow(GetDlgItem(hWnd, IDC_RDO_CAPSULE), FALSE);
#endif
EnableWindow(GetDlgItem(hWnd, IDC_RDO_CAPSULE), CanCalcCapsule() ? TRUE : FALSE);
//EnableWindow(GetDlgItem(hWnd, IDC_RDO_PACKED_STRIPS), FALSE);
Update(t);
......
......@@ -269,9 +269,7 @@ INT_PTR bhkRigidBodyModifierDlgProc::DlgProc (TimeValue t,IParamMap2 *map,HWND h
int sel = NP_INVALID_HVK_MATERIAL;
mod->pblock->GetValue( PB_MATERIAL, 0, sel, valid);
mCbMaterial.select( sel + 1 );
#if !defined(USES_WILDMAGIC) || defined(_M_X64)
EnableWindow(GetDlgItem(hWnd, IDC_RDO_CAPSULE), FALSE);
#endif
EnableWindow(GetDlgItem(hWnd, IDC_RDO_CAPSULE), CanCalcCapsule() ? TRUE : FALSE);
Update(t);
break;
}
......
......@@ -38,21 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
Version="8.00"
Name="User_Settings"
>
<!--
Uncomment the following to enable compiling with WildMagic 4.
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="USES_WILDMAGIC"
AdditionalIncludeDirectories="$(WildMagic4SDKDir)\Include"
/>
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories="$(WildMagic4SDKDir)\Library\Debug\;$(WildMagic4SDKDir)\Library\Release\"
/>
<UserMacro Name="WildMagic4Dir" Value="$(ProgramFiles)\GeometricTools\WildMagic4\"/>
<UserMacro Name="WildMagic4SDKDir" Value="$(WildMagic4Dir)SDK\"/>
-->
<!--
Uncomment and fix the below settings to match your machine or define the macros in your
......
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