sdk commons 2008

This commit is contained in:
lovebird 2021-10-31 19:39:29 +01:00
parent c84f4acf63
commit 90931a08a6
585 changed files with 141722 additions and 0 deletions

View File

@ -0,0 +1,155 @@
/*********************************************************************NVMH4****
Path: SDK\LIBS\src\NV_D3DCommon
File: DXDiagNVUtil.h
Copyright NVIDIA Corporation 2002
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Comments:
This class allows you to work with DXDiag info in a few ways:
1) Use D3D9's IDxDiagContainer interface to querry for specific fields by name.
You must supply the names of fields to search for, and must sometimes supply
the result of one querry to a later querry (ie. get num display devices in order
to be able to get device video memory).
This is fast.
It requires you to know the COM names of the various IDxDiagContainer nodes.
You can generate a complete list of these names using #2) below.
2) Use D3D9's IDxDiagContainer interface to enumerate all field names for the
COM object. The field names returned are different than what you see in a
dxdiag.exe text dump.
The field names are written using OutputDebugString(..)
** This is slow
The old functions for running DXDIAG.exe, saving the result to a text file, opening,
and parsing that file have been removed.
See Microsoft's:
DXSDK\Samples\C++\Misc\DXDiagOutput demo for more code related to reading DXDiag info
DXSDK\Samples\C++\Misc\DxDiagReport
******************************************************************************/
#ifndef H_DXDIAGNVUTIL_GJ_H
#define H_DXDIAGNVUTIL_GJ_H
#include <dxdiag.h> // in DXSDK\include
#include "3d/NV_Error.h"
#include "3d/NV_Common.h"
#include <vector>
#include <string>
using namespace std;
// forward decls for things defined externally
struct IDxDiagProvider;
struct IDxDiagContainer;
//------------------------------------------------------------
class DXDiagNVUtil
{
public:
//-------- Main interface functions -----------------------------------
// Interface #1 (prefered)
// Call these to allocate & free the IDxDiagContainer interface
// Init will initialize the m_pDxDiagRoot variable
HRESULT InitIDxDiagContainer();
HRESULT FreeIDxDiagContainer();
// ---- The functions below must be called after InitIDxDiagContainer() and before FreeIDxDiagContainer()
// Recursive traverse all children of the pDxDiagContainer node and list their COM names
// This is provided so you can easily create and browse a full list of names
// Names are output to the debug console via OutputDebugString(..)
HRESULT ListAllDXDiagPropertyNames();
HRESULT ListAllDXDiagPropertyNames( IDxDiagContainer * pDxDiagContainer,
WCHAR* wszParentName = NULL );
HRESULT ListAllDXDiagPropertyNamesToTxtFile( FILE * pOpenTextFile,
bool bGetPropertyValues = false,
IDxDiagContainer * pDxDiagContainer = NULL,
WCHAR * wszParentName = NULL );
HRESULT GetNumDisplayDevices( DWORD * out_dwNumAdapters );
HRESULT GetDisplayDeviceNode( DWORD dwDeviceIndex, IDxDiagContainer ** ppNode );
HRESULT GetDisplayDeviceDescription( DWORD dwDevice, wstring * out_pwstrName );
HRESULT GetDisplayDeviceNVDriverVersion( DWORD dwDevice, float * out_fVersion );
HRESULT GetDisplayDeviceDriverVersionStr( DWORD dwDevice, wstring * out_pwstrVers );
HRESULT GetDisplayDeviceMemoryInMB( DWORD dwDevice, int * out_nDisplayMemory );
HRESULT GetDisplayDeviceAGPMemoryStatus( DWORD dwDevice, wstring * pwstrAGPEnabled, wstring * pwstrAGPExists, wstring * pwstrAGPStatus );
HRESULT GetDisplayDeviceProp( DWORD dwDevice, LPCWSTR in_prop_name, wstring * out_pwstrProp );
HRESULT GetPhysicalMemoryInMB( float * out_pfMemory );
HRESULT GetDebugLevels( wstring * pwstrLevels ); // all debug levels returned in 1 string
HRESULT GetDirectXVersion( DWORD * pdwDirectXVersionMajor,
DWORD * pdwDirectXVersionMinor,
TCHAR * pcDirectXVersionLetter );
// ---- Seconardy interface functions for the #1 interface
// Use these to directly querry for a field based on the COM property name.
// You can generate a full list of these names by using ListAllDXDiagPropertyNames()
// Example:
// GetProperty( L"DxDiag_SystemInfo", L"ullPhysicalMemory", & strPropVal );
HRESULT GetProperty( IDxDiagContainer * pContainer, LPCWSTR property_name, wstring * out_value );
// Get properties of containers off of the m_pDxDiagRoot node
HRESULT GetProperty( LPCWSTR container_name0, LPCWSTR property_name, wstring * out_value );
HRESULT GetProperty( LPCWSTR container_name0, LPCWSTR container_name1, LPCWSTR property_name, wstring * out_value );
HRESULT GetProperty( LPCWSTR container_name0, LPCWSTR container_name1, LPCWSTR container_name2, LPCWSTR property_name, wstring * out_value );
HRESULT GetChildContainer( LPCWSTR container_name0, IDxDiagContainer ** out_ppChild );
HRESULT GetChildContainer( LPCWSTR container_name0, LPCWSTR container_name1, IDxDiagContainer ** out_ppChild );
HRESULT GetChildContainer( LPCWSTR container_name0, LPCWSTR container_name1, LPCWSTR container_name2, IDxDiagContainer ** out_ppChild );
HRESULT GetChildByIndex( IDxDiagContainer * in_pParent, DWORD dwIndex, IDxDiagContainer ** out_ppChild );
// ---- End of functions that should be called between InitIDxDiagContainer() and FreeIDxDiagContainer()
// Utility functions for converting strings, etc.
string WStringToString( const wstring * in_pwstring );
string WStringToString( wstring & in_wstring );
string lpcwstrToString( const LPCWSTR in_lpcwstr );
protected:
// data for interface #1 (preferred)
bool m_bCleanupCOM;
IDxDiagProvider * m_pDxDiagProvider;
IDxDiagContainer * m_pDxDiagRoot; // root node of the IDxDiagContainer data
public:
DXDiagNVUtil()
{
SetAllNull();
};
~DXDiagNVUtil()
{
FreeIDxDiagContainer();
SetAllNull();
};
void SetAllNull()
{
// data for interface #1 (preferred)
m_bCleanupCOM = false;
m_pDxDiagProvider = NULL;
m_pDxDiagRoot = NULL;
}
};
#endif

View File

@ -0,0 +1,95 @@
/*--------------------------------------------------------------------- NVMH5 -|----------------------
Path: Sdk\Demos\Direct3D9\src\GetGPUAndSystemInfo\
File: GetGPUAndSystemInfo.h
Copyright NVIDIA Corporation 2003
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND
AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS
SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Comments:
A simple class to demonstrate the use of DXDiagNVUtil which is a convenient wrapper for
the IDxDiagContainer interface from Microsoft.
GetGPUAndSystemInfo gets only a small fraction of the information that IDxDiagContainer
makes available.
Since this class is simple to create and destroy, there is no specific handling for when
the D3D device is lost. Simply Free() and re Initialize() the class if that should happen.
-------------------------------------------------------------------------------|--------------------*/
#ifndef H_GETGPUANDSYSTEMINFO_GJ_H
#define H_GETGPUANDSYSTEMINFO_GJ_H
#include "3D\DXDiagNVUtil.h"
#include <string> // for wstring
struct IDirect3D9;
struct FloatingPointBlendModes
{
bool m_bR16f;
bool m_bR32f;
bool m_bG16R16f;
bool m_bG32R32f;
bool m_bA16B16G16R16f;
bool m_bA32B32G32R32f;
bool m_bA8R8G8B8; // not an fp mode, but there for good measure
};
class GetGPUAndSystemInfo
{
public:
// DXDiagNVUtil is a utility class for creating and querring the IDxDiagContainer interface
DXDiagNVUtil m_DXDiagNVUtil;
// Data fields that will be filled in by the GetData() function
DWORD m_dwNumDisplayDevices;
float m_fDriverVersion;
wstring m_wstrDeviceDesc;
int m_nDeviceMemoryMB;
float m_fSystemPhysicalMemoryMB;
string m_strAGPStatus;
string m_strMachineName;
DWORD m_dwDXVersionMajor;
DWORD m_dwDXVersionMinor;
char m_cDXVersionLetter;
wstring m_wstrDxDebugLevels;
FloatingPointBlendModes m_FPBlendModes;
// ---- Main interface functions --------
HRESULT GetData();
HRESULT IsFPBlendingSupported( IDirect3D9 * pD3D9, FloatingPointBlendModes * pOutResult );
// --------------------------------------
protected:
void SetAllNull()
{
};
public:
GetGPUAndSystemInfo()
{
SetAllNull();
};
~GetGPUAndSystemInfo()
{
SetAllNull();
}
};
#endif

View File

@ -0,0 +1,149 @@
#ifndef _NVFILEDIALOG_H_
#define _NVFILEDIALOG_H_
#pragma warning (disable : 4786)
#include <string>
#pragma warning (disable : 4786)
#include <vector>
#pragma warning (disable : 4786)
#include <TCHAR.H>
typedef std::basic_string<TCHAR> tstring;
////////////
// Helper class to assist in loading files
//
// Usage :
//
// Just create a NV*FileDialog object on the stack, and call Open
//
// NVXFileDialog aDialog;
//
// std::string theFileName;
//
// if ( aDialog.Open( theFileName ) )
// {
// // open the filename and read it in
// }
//
// // That's it !
//
// Use the NVTextureFileDialog for texture files,
//
// or use the NVFileDialog to do arbitrary filters
//
class NVFileDialog
{
private :
OPENFILENAME mOpenFileName;
std::vector< tstring > mFilterNames;
std::vector< tstring > mFilterStrings;
tstring mString;
void Init()
{
memset( &mOpenFileName, 0x00, sizeof( mOpenFileName ) );
mOpenFileName.lStructSize = sizeof( mOpenFileName );
OSVERSIONINFO osinfo;
memset( &osinfo, 0x00, sizeof( osinfo ) );
BOOL bSuccess = ::GetVersionEx( &osinfo );
if ( osinfo.dwMajorVersion >= 0x0500 )
{
mOpenFileName.lStructSize += ( 3 * sizeof( DWORD ) );
}
mString.erase( mString.begin(), mString.end() );
mOpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_SHAREAWARE;
mOpenFileName.nFilterIndex = 1;
for (unsigned int i = 0; i < mFilterNames.size(); ++i )
{
mString += mFilterNames[ i ];
mString += TCHAR(0x00);
mString += mFilterStrings[ i ];
mString += TCHAR(0x00);
}
// Last element must be double terminated
mString += TCHAR(0x00);
mOpenFileName.lpstrFilter = mString.c_str();
}
public :
~NVFileDialog(){;}
NVFileDialog()
{
mFilterNames.push_back(TEXT("*.*"));
mFilterStrings.push_back(TEXT(""));
}
void SetFilters( const std::vector< tstring >& theFilterNames,
const std::vector< tstring >& theFilterStrings )
{
assert( mFilterNames.size() == theFilterStrings.size() );
mFilterNames = theFilterNames;
mFilterStrings = theFilterStrings;
}
void SetFilter( const tstring& theFilterName )
{
mFilterNames.clear();
mFilterStrings.clear();
mFilterNames.push_back( theFilterName );
mFilterStrings.push_back( theFilterName );
}
virtual bool Open( tstring& theResult )
{
Init();
theResult.resize(1024);
theResult[0] = 0;
mOpenFileName.lpstrFile = &theResult[ 0 ];
mOpenFileName.nMaxFile = 1024;
BOOL bSuccess = ::GetOpenFileName( &mOpenFileName );
return ( bSuccess == TRUE );
}
};
class NVXFileDialog : public NVFileDialog
{
public :
NVXFileDialog()
{
SetFilter(TEXT("*.x"));
}
};
class NVTextureFileDialog : public NVFileDialog
{
public :
NVTextureFileDialog()
{
SetFilter(TEXT("*.bmp;*.tga;*.dds"));
}
};
#endif _NVFILEDIALOG_H_

View File

@ -0,0 +1,465 @@
/*--------------------------------------------------------------------- NVMH5 -|----------------------
Path: Sdk\Libs\inc\shared\
File: NV_Common.h
Copyright NVIDIA Corporation 2003
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND
AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS
SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Comments:
Useful macros, etc.
Define these to output messages on delete and release:
#define NVMSG_SAFE_ARRAY_DELETE
#define NVMSG_SAFE_DELETE
#define NVMSG_SAFE_RELEASE
FDebug and FMsg are defined in NV_Error.h. These functions take a variable argument list, similar to
that for fprintf(), and output the string via OutputDebugString. FDebug() outputs only for DEBUG builds.
FMsg() outputs text for bot DEBUG and RELEASE builds.
-------------------------------------------------------------------------------|--------------------*/
#pragma once
#ifndef H_NVCOMMONHEADER_H
#define H_NVCOMMONHEADER_H
#define INLINE __forceinline
#ifndef MULTI_THREAD
#include <windows.h>
#endif
#include <assert.h>
#include "3d\NV_Error.h"
typedef unsigned short USHORT;
typedef unsigned short ushort;
//----------------------------------------------------------------
// Preferred macros
#ifndef MSG_IF
#define MSG_IF( expr, msg ) \
{ \
if( expr ) { FMsg(msg); } \
}
#endif
#ifndef MSG_AND_RET_IF
#define MSG_AND_RET_IF( expr, msg ) \
{ \
if( expr ) { FMsg(msg); return; } \
}
#endif
#ifndef MSG_AND_RET_VAL_IF
#define MSG_AND_RET_VAL_IF( expr, msg, retval ) \
{ \
if( expr ) { FMsg(msg); return( retval ); } \
}
#endif
// Causes a debug assertion if expr is true
#ifndef MSG_AND_BREAK_IF
#define MSG_AND_BREAK_IF( expr, msg ) \
{ \
if( expr ) { FMsg(msg); assert(false); } \
}
#endif
#ifndef MSG_BREAK_AND_RET_IF
#define MSG_BREAK_AND_RET_IF( expr, msg ) \
{ \
if( expr ) { FMsg(msg); assert(false); return; } \
}
#endif
#ifndef MSG_BREAK_AND_RET_VAL_IF
#define MSG_BREAK_AND_RET_VAL_IF( expr, msg, retval ) \
{ \
if( expr ) { FMsg(msg); assert(false); return(retval); } \
}
#endif
// Causes a debug assertion if expr is true
#ifndef BREAK_IF
#define BREAK_IF( expr ) \
{ \
if( expr ) { assert(false); } \
}
#endif
#ifndef BREAK_AND_RET_IF
#define BREAK_AND_RET_IF( expr ) \
{ \
if( expr ) { assert(false); return; } \
}
#endif
#ifndef BREAK_AND_RET_VAL_IF
#define BREAK_AND_RET_VAL_IF( expr, retval ) \
{ \
if( expr ) { assert( false ); return( retval ); } \
}
#endif
#ifndef RET_IF
#define RET_IF( expr ) \
{ \
if( expr ) { return; } \
}
#endif
#ifndef RET_VAL_IF
#define RET_VAL_IF( expr, retval ) \
{ \
if( expr ) { return( retval ); } \
}
#endif
// Macro for checking if a variable is NULL
// This outputs the variable name and returns E_FAIL if the variable == NULL.
// Example:
// pMyPointer = NULL;
// MSGVARNAME_AND_FAIL_IF_NULL( pMyPointer );
// outputs:
// "pMyPointer == NULL" and returns E_FAIL
#ifndef MSGVARNAME_AND_FAIL_IF_NULL
#define MSGVARNAME_AND_FAIL_IF_NULL( var ) \
{ \
if( (var) == NULL ) { FMsg( TEXT(#var) TEXT(" == NULL\n")); return( E_FAIL ); } \
}
#endif
//--------------------------------------------------------------
// Below are macros that can be expressed with the above macros
// These are included for convenience.
#ifndef FAIL_IF_NULL
#define FAIL_IF_NULL( x ) \
{ \
if( (x) == NULL ) { return( E_FAIL ); } \
}
#endif
#ifndef MSG_AND_FAIL_IF_NULL
#define MSG_AND_FAIL_IF_NULL( p, msg ) \
{ \
if( (p) == NULL ) { FMsg(msg); return( E_FAIL ); } \
}
#endif
#ifndef RET_IF_NULL
#define RET_IF_NULL( p ) \
{ \
if( (p) == NULL ) { return; } \
}
#endif
#ifndef RET_VAL_IF_NULL
#define RET_VAL_IF_NULL( p, retval ) \
{ \
if( (p) == NULL ) { return( retval ); } \
}
#endif
#ifndef RET_NULL_IF_NULL
#define RET_NULL_IF_NULL(p) \
{ \
if( (p) == NULL ) { return( NULL ); } \
}
#endif
#ifndef BREAK_AND_RET_VAL_IF_FAILED
#define BREAK_AND_RET_VAL_IF_FAILED( hr ) \
{ \
if( FAILED(hr) ) { assert(false); return( hr ); } \
}
#endif
#ifndef RET_VAL_IF_FAILED
#define RET_VAL_IF_FAILED( hr ) \
{ \
if( FAILED( hr ) ) { return( hr ); } \
}
#endif
//-------------------------------------------------------------------------------------------
// delete a pointer allocated with new <type>[num], and set the pointer to NULL.
#ifndef SAFE_DELETE_ARRAY
#ifdef NVMSG_SAFE_ARRAY_DELETE
#define SAFE_DELETE_ARRAY(p) \
{ \
FMsg(TEXT("SAFE_DELETE_ARRAY: %35s = 0x%8.8X\n"), TEXT(#p), p ); \
if( p != NULL ) \
{ \
delete [] (p); \
p = NULL; \
} \
}
#else
#define SAFE_DELETE_ARRAY(p) \
{ \
if( p != NULL ) \
{ \
delete [] (p); \
p = NULL; \
} \
}
#endif
#endif
#ifndef SAFE_ARRAY_DELETE
#ifdef NVMSG_SAFE_ARRAY_DELETE
#define SAFE_ARRAY_DELETE(p) \
{ \
FMsg(TEXT("SAFE_ARRAY_DELETE: %35s = 0x%8.8X\n"), TEXT(#p), p );\
if( p != NULL ) \
{ \
delete [] (p); \
p = NULL; \
} \
}
#else
#define SAFE_ARRAY_DELETE(p) \
{ \
if( p != NULL ) \
{ \
delete [] (p); \
p = NULL; \
} \
}
#endif
#endif
// deletes all pointers in a vector of pointers, and clears the vector
#ifndef SAFE_VECTOR_DELETE
#define SAFE_VECTOR_DELETE( v ) \
{ \
for( UINT svecdel = 0; svecdel < (v).size(); svecdel++ ) \
{ if( (v).at( svecdel ) != NULL ) \
{ delete( (v).at( svecdel )); \
(v).at( svecdel ) = NULL; \
} \
} \
(v).clear(); \
}
#endif
#ifndef SAFE_DELETE
#ifdef NVMSG_SAFE_DELETE
#define SAFE_DELETE( p ) \
{ \
FMsg(TEXT("SAFE_DELETE: %35s = 0x%8.8X\n"), TEXT(#p), p ); \
if( (p) != NULL) \
{ \
delete(p); \
(p) = NULL; \
} \
}
#else
#define SAFE_DELETE( p ) \
{ \
if( (p) != NULL ) \
{ \
delete(p); \
(p) = NULL; \
} \
}
#endif
#endif
// Releases all pointers in a vector of pointers, and clears the vector
#ifndef SAFE_VECTOR_RELEASE
#define SAFE_VECTOR_RELEASE( v ) \
{ \
for( UINT svecrel = 0; svecrel < (v).size(); svecrel++ ) \
{ if( (v).at( svecrel ) != NULL ) \
{ (v).at( svecrel )->Release(); \
(v).at( svecrel ) = NULL; \
} \
} \
(v).clear(); \
}
#endif
// Calls the Release() member of the object pointed to, and sets the pointer to NULL
#ifndef SAFE_RELEASE
#ifdef NVMSG_SAFE_RELEASE
#define SAFE_RELEASE(p) \
{ \
FMsg(TEXT("SAFE_RELEASE: %35s = 0x%8.8X\n"), TEXT(#p), p ); \
if( (p) != NULL ) \
{ \
(p)->Release(); \
(p) = NULL; \
} \
}
#else
#define SAFE_RELEASE(p) \
{ \
if( (p) != NULL ) \
{ \
(p)->Release(); \
(p) = NULL; \
} \
}
#endif
#endif
#ifndef SAFE_ADDREF
#ifdef NVMSG_SAFE_ADDREF
#define SAFE_ADDREF(p) \
{ \
FMsg(TEXT("SAFE_ADDREF: %35s = 0x%8.8X\n"), TEXT(#p), p ); \
if( (p) != NULL ) \
{ \
(p)->AddRef(); \
} \
}
#else
#define SAFE_ADDREF(p) \
{ \
if( (p) != NULL ) \
{ \
(p)->AddRef(); \
} \
}
#endif
#endif
///////////////////////////////////////////////////////////////
#ifndef CHECK_BOUNDS
#define CHECK_BOUNDS( v, n, x ) \
if( (v < n) || (v > x) ) \
{ FDebug("Variable out of bounds!\n"); \
assert( false ); return; \
}
#endif
#ifndef CHECK_BOUNDS_NULL
#define CHECK_BOUNDS_NULL( v, n, x ) \
if( (v < n) || (v > x) ) \
{ FDebug("Variable out of bounds!\n"); \
assert( false ); return(NULL); \
}
#endif
#ifndef CHECK_BOUNDS_HR
#define CHECK_BOUNDS_HR( v, n, x ) \
if( (v < n) || (v > x) ) \
{ FDebug("Variable out of bounds!\n"); \
assert( false ); return(E_FAIL); \
}
#endif
///////////////////////////////////////////////////////////////
#define ifnot(x) if (!(x))
#define until(x) while(!(x))
#define ever (;;)
#define wait do {}
#define nothing {}
///////////////////////////////////////////////////////////////
// Macro to make sure that a handle is allocated.
// If in_handle is NULL, an object is created at ptr.
// handle will point to ptr;
// If in_handle is not NULL, but it's pointer is NULL, then
// an object is created at (*in_handle)
// ptr is set to same value as (*in_handle)
// handle will point to *in_handle
// class - the type of object to create
// init - text of an Initialize() function called if object is created
//
#ifndef GUARANTEE_ALLOCATED
#define GUARANTEE_ALLOCATED( in_handle, handle, ptr, classname, init ) \
{ \
bool alloc; \
alloc = false; \
bool setptr; \
setptr = false; \
HRESULT hr; \
handle = in_handle; \
if( handle == NULL ) \
{ \
handle = & ptr; \
alloc = true; \
} \
else if( *handle == NULL ) \
{ \
alloc = true; \
setptr = true; \
} \
if( alloc == true ) \
{ \
(*handle) = new classname; \
FAIL_IF_NULL( (*handle) ); \
hr = (*handle)->init; \
BREAK_AND_RET_VAL_IF_FAILED( hr ); \
} \
if( setptr == true ) \
ptr = *handle; \
}
#endif
#ifndef FREE_GUARANTEED_ALLOC
#define FREE_GUARANTEED_ALLOC( handle, ptr ) \
{ \
if( handle != NULL ) \
{ \
if( ptr == *handle ) \
{ \
SAFE_DELETE( (*handle) ); \
ptr = NULL; \
} \
handle = NULL; \
} \
}
#endif
//----------------------------------------------------------------
// Below are older deprecated macros. Please use the macros above instead of these.
#ifndef ASSERT_AND_RET_IF_FAILED
#define ASSERT_AND_RET_IF_FAILED(hres) \
{ \
if( FAILED(hres) ) \
{ \
assert( false ); \
return( hres ); \
} \
}
#endif
//----------------------------------------------------------------
#endif // H_NVCOMMONHEADER_H

View File

@ -0,0 +1,200 @@
/*--------------------------------------------------------------------- NVMH5 -|----------------------
Path: Sdk\Libs\inc\shared\
File: NV_Error.h
Copyright NVIDIA Corporation 2003
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND
AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS
SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Comments:
No longer requires separate .cpp file. Functions defined in the .h with the
magic of the static keyword.
For UNICODE, both TCHAR and char * flavors are defined, so that old code not
using TCHAR args to the functions (ie, not using the TEXT() macro) do not
need to change.
-------------------------------------------------------------------------------|--------------------*/
#pragma warning( disable : 4505 ) // unreferenced local function has been removed
#ifndef H_NV_ERROR_H
#define H_NV_ERROR_H
#pragma warning( disable : 4995 ) // old string functions marked as #pragma deprecated
#include <stdlib.h> // for exit()
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
//---------------------------------------------------------------
#ifndef OUTPUT_POINTER
#define OUTPUT_POINTER(p) { FMsg("%35s = %8.8x\n", #p, p ); }
#endif
#ifndef NULLCHECK
#define NULLCHECK(q, msg,quit) {if(q==NULL) { DoError(msg, quit); }}
#endif
#ifndef IFNULLRET
#define IFNULLRET(q, msg) {if(q==NULL) { FDebug(msg); return;}}
#endif
#ifndef FAILRET
#define FAILRET(hres, msg) {if(FAILED(hres)){FDebug("*** %s HRESULT: %d\n",msg, hres);return hres;}}
#endif
#ifndef HRESCHECK
#define HRESCHECK(q, msg) {if(FAILED(q)) { FDebug(msg); return;}}
#endif
#ifndef NULLASSERT
#define NULLASSERT( q, msg,quit ) {if(q==NULL) { FDebug(msg); assert(false); if(quit) exit(0); }}
#endif
/////////////////////////////////////////////////////////////////
static void OkMsgBox( TCHAR * szCaption, TCHAR * szFormat, ... )
{
TCHAR buffer[256];
va_list args;
va_start( args, szFormat );
_vsntprintf( buffer, 256, szFormat, args );
va_end( args );
buffer[256-1] = '\0'; // terminate in case of overflow
MessageBox( NULL, buffer, szCaption, MB_OK );
}
#ifdef _DEBUG
static void FDebug ( TCHAR * szFormat, ... )
{
// It does not work to call FMsg( szFormat ). The variable arg list will be incorrect
static TCHAR buffer[2048];
va_list args;
va_start( args, szFormat );
_vsntprintf( buffer, 2048, szFormat, args );
va_end( args );
buffer[2048-1] = '\0'; // terminate in case of overflow
OutputDebugString( buffer );
Sleep( 2 ); // OutputDebugString sometimes misses lines if
// called too rapidly in succession.
}
#ifdef UNICODE
static void FDebug( char * szFormat, ... )
{
static char buffer[2048];
va_list args;
va_start( args, szFormat );
_vsnprintf( buffer, 2048, szFormat, args );
va_end( args );
buffer[2048-1] = '\0'; // terminate in case of overflow
#ifdef UNICODE
int nLen = MultiByteToWideChar( CP_ACP, 0, buffer, -1, NULL, NULL );
LPWSTR lpszW = new WCHAR[ nLen ];
if( lpszW != NULL )
{
MultiByteToWideChar( CP_ACP, 0, buffer, -1, lpszW, nLen );
OutputDebugString( lpszW );
delete lpszW;
lpszW = NULL;
}
#else
OutputDebugString( buffer );
#endif
Sleep( 2 ); // OutputDebugString sometimes misses lines if
// called too rapidly in succession.
}
#endif
#pragma warning( disable : 4100 ) // unreferenced formal parameter
inline static void NullFunc( TCHAR * szFormat, ... ) {}
#ifdef UNICODE
inline static void NullFunc( char * szFormat, ... ) {}
#endif
#pragma warning( default : 4100 )
#if 0
#define WMDIAG(str) { OutputDebugString(str); }
#else
#define WMDIAG(str) {}
#endif
#else
inline static void FDebug( TCHAR * szFormat, ... ) { szFormat; }
#ifdef UNICODE
inline static void FDebug( char * szFormat, ... ) { szFormat; }
#endif
inline static void NullFunc( char * szFormat, ... ) { szFormat; }
#define WMDIAG(str) {}
#endif
static void FMsg( TCHAR * szFormat, ... )
{
static TCHAR buffer[2048];
va_list args;
va_start( args, szFormat );
_vsntprintf( buffer, 2048, szFormat, args );
va_end( args );
buffer[2048-1] = '\0'; // terminate in case of overflow
OutputDebugString( buffer );
Sleep( 2 ); // OutputDebugString sometimes misses lines if
// called too rapidly in succession.
}
static void FMsgW( WCHAR * wszFormat, ... )
{
WCHAR wbuff[2048];
va_list args;
va_start( args, wszFormat );
_vsnwprintf( wbuff, 2048, wszFormat, args );
va_end( args );
wbuff[2048-1] = '\0'; // terminate in case of overflow
OutputDebugStringW( wbuff );
Sleep( 2 ); // OutputDebugString sometimes misses lines if
// called too rapidly in succession.
}
#ifdef UNICODE
// You must make sure that the variable arg list is also char * and NOT WCHAR *
// This function allows FMsg("") in old non-UNICODE builds to work without requiring FMsg(TEXT(""))
static void FMsg( char * szFormat, ... )
{
static char buffer[2048];
va_list args;
va_start( args, szFormat );
_vsnprintf( buffer, 2048, szFormat, args );
va_end( args );
buffer[2048-1] = '\0'; // terminate in case of overflow
#ifdef UNICODE
int nLen = MultiByteToWideChar( CP_ACP, 0, buffer, -1, NULL, NULL );
LPWSTR lpszW = new WCHAR[ nLen ];
if( lpszW != NULL )
{
MultiByteToWideChar( CP_ACP, 0, buffer, -1, lpszW, nLen );
OutputDebugString( lpszW );
delete lpszW;
lpszW = NULL;
}
#else
OutputDebugString( buffer );
#endif
Sleep( 2 ); // OutputDebugString sometimes misses lines if
// called too rapidly in succession.
}
#endif
#endif

View File

@ -0,0 +1,180 @@
/*********************************************************************NVMH4****
Path: SDK\LIBS\inc\shared
File: NV_StringFuncs.h
Copyright NVIDIA Corporation 2002
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Comments:
A collection of useful string functions, built upon std::string
They are not all meant to be fast. Many return vectors of strings, which will
require string copies and lots of work by the STL functions. For processing
large strings or a lot of string data you will probably want to devise your
own routines.
A demo of using the functions is provided in:
SDK\DEMOS\common\src\NV_StringFuncs
******************************************************************************/
#ifndef _NV_STRINGFUNCS_GJ_H
#define _NV_STRINGFUNCS_GJ_H
#pragma warning(disable : 4786) // STL warning
#include <Windows.h>
#include <string>
#include <vector>
#include <list>
#include <stdlib.h>
#include <tchar.h>
// sfsizet is size type for the string class used
typedef std::string::size_type sfsizet;
typedef std::basic_string<TCHAR> tstring;
namespace NVStringConv
{
// use as an alternative to wcstombs()
std::string WStringToString( const std::wstring * in_pwstring );
std::string WStringToString( std::wstring & in_wstring );
std::string lpcwstrToString( LPCWSTR in_lpcwstr );
std::wstring StringToWString( const std::string * in_pString );
std::wstring StringToWString( std::string & in_String );
std::wstring lpcstrToWString( LPCSTR str );
}; // namespace NVStringConv
/////////////////////////////////////////////////////////////////////
// macro to expand vector of anything into single string
// example c is "%u " and the %<type> must match type held in vector
// Example:
// string dest;
// vector< int > vint;
// VEC_TO_STR( dest, vint, "%d " );
//
#ifndef VEC_TO_STR
#define VEC_TO_STR( a, b, c ) \
{ \
for( int vectocnt = 0; vectocnt < b.size(); vectocnt++ ) \
{ a += StrPrintf( c, b.at(vectocnt) ); \
} \
}
#endif
//////////////////////////
// Convert list of some type to vector of same type
// L is list, V is vector, T is type
// Example:
// list< string > lStr;
// vector< string > vStr;
// lStr.push_back( "a" );
// lStr.push_back( "b" );
// LIST_TO_VEC( lStr, vStr, std::string );
#ifndef LIST_TO_VEC
#define LIST_TO_VEC( L, V, T ) \
{ \
std::list< T >::const_iterator ltovecmacroiter; \
for( ltovecmacroiter = L.begin(); ltovecmacroiter != L.end(); ltovecmacroiter++ ) \
{ \
V.push_back( *ltovecmacroiter ); \
} \
}
#endif
//////////////////////////
// Convert vector of some type to list of same type
// L is list, V is vector, T is type
//
#ifndef VEC_TO_LIST
#define VEC_TO_LIST( V, L, T ) \
{ \
for( int vtolistc=0; vtolistc < V.size(); vtolistc++ ) \
{ L.push_back( V.at(vtolistc) ); \
} \
}
#endif
/////////////////////////////////////////////////////////////////////
// Create a string using va_args, just like printf, sprintf, etc.
std::string StrPrintf( const char * szFormat, ... );
std::string StrToUpper( const std::string & strIn );
std::string StrToLower( const std::string & strIn );
// Writes each string in the vector to a single output
// string, separating each by a space.
std::string StrsToString( const std::vector< std::string > & vstrIn );
// same, but lets you specify the separator between strings
std::string StrsToString( const std::vector< std::string > & vstrIn,
const std::string & separator );
std::string StrsToString( const std::list< std::string > & lstrIn,
const std::string & separator );
// Like CString::Replace()
// Sequence and it's replacement can be different lengths or empty
std::string StrReplace( const std::string & sequence_to_replace,
const std::string & replacement_string,
const std::string & strIn );
// same as above, only it modifies pOut and also returns pOut
std::string * StrReplace( const std::string & sequence_to_replace,
const std::string & replacement_string,
const std::string & strIn,
std::string * pOut,
bool bVerbose = false );
// applies strtok repeatedly & acumulates ouput tokens
// in output string separated by spaces
std::string StrTokenize( const std::string & strIn, const std::string & delimiters );
// Same as above, but allows you to specify the separator between
// tokens in the output
std::string StrTokenize( const std::string & strIn,
const std::string & delimiters,
const std::string & output_separator );
sfsizet StrFindCaseless( const std::string & strSearchIn, sfsizet start_pos, const std::string & strSearchFor );
std::vector< sfsizet > StrFindAllCaseless( const std::string & strSearchIn,
sfsizet start_pos,
const std::string & strSearchFor );
std::vector< sfsizet > StrFindAll( const std::string & strSearchIn,
sfsizet start_pos,
const std::string & strSearchFor );
std::vector< std::string > StrSort( const std::vector< std::string > & vStrIn );
tstring GetFilenameFromFullPath( const tstring & full_path );
/////////////////////////////////////////////////////////////////////
/*
More ideas for functions to implement
SortCaseless
Sort // case sensitive
_stricmp - compare two strings without regard to case
_strrev = reverse string
*/
#endif

View File

@ -0,0 +1,66 @@
//--------------------------------------------------------------------------------------
// File: DxStdAfx.h
//
// Desc: Header file that is the standard includes for the DirectX SDK samples
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#ifndef DXSDK_STDAFX_H
#define DXSDK_STDAFX_H
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define STRICT
// Works with Windows 2000 and later and Windows 98 or later
#undef _WIN32_IE
#undef WINVER
#undef _WIN32_WINDOWS
#undef _WIN32_WINNT
#define WINVER 0x0500
#define _WIN32_WINDOWS 0x0410
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <assert.h>
#include <wchar.h>
#include <mmsystem.h>
#include <commctrl.h> // for InitCommonControls()
#include <shellapi.h> // for ExtractIcon()
#include <new.h> // for placement new
#include <math.h>
#include <limits.h>
// Enable extra D3D debugging in debug builds if using the debug DirectX runtime.
// This makes D3D objects work well in the debugger watch window, but slows down
// performance slightly.
#if defined(DEBUG) | defined(_DEBUG)
#define D3D_DEBUG_INFO
#endif
// Direct3D includes
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr9.h>
#include <DXUT/DXUT.h>
#include <DXUT/DXUTmisc.h>
#include <DXUT/DXUTenum.h>
#include <DXUT/DXUTmesh.h>
#include <DXUT/DXUTgui.h>
#include <DXUT/DXUTsettingsDlg.h>
#if defined(DEBUG) | defined(_DEBUG)
#define V(x) { hr = x; if( FAILED(hr) ) { DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
#define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
#else
#define V(x) { hr = x; }
#define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return hr; } }
#endif
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
#endif // !defined(DXSDK_STDAFX_H)

View File

@ -0,0 +1,47 @@
/******************************************************************************
Copyright (C) 1999, 2000 NVIDIA Corporation
This file is provided without support, instruction, or implied warranty of any
kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is
not liable under any circumstances for any damages or loss whatsoever arising
from the use or inability to use this file or items derived from it.
Comments:
******************************************************************************/
#ifndef __NVFILE_H
#define __NVFILE_H
//#include "NVDX8Macros.h"
#include "3D\nvmesh.h"
#include "3D\nvframe.h"
#include <D3DX9.h>
#include <TCHAR.H>
typedef std::basic_string<TCHAR> tstring;
//#pragma comment(lib, "d3dxof.lib")
//#pragma comment(lib, "dxguid.lib")
class NVFile : public NVFrame
{
HRESULT LoadMesh( IDirect3DDevice9* pDevice, LPD3DXFILEDATA pFileData,
NVFrame* pParentFrame );
HRESULT LoadFrame( IDirect3DDevice9* pDevice, LPD3DXFILEDATA pFileData,
NVFrame* pParentFrame );
public:
void GetBoundingInfo(NVBounds* pBounds);
HRESULT Create( IDirect3DDevice9* pDevice, const tstring& strFilename );
HRESULT Render( IDirect3DDevice9* pDevice );
NVFile() : NVFrame( _T("NVFile_Root") ) {}
tstring m_strFilePath;
};
#endif

572
usr/Include/Core/AutoLock.h Normal file
View File

@ -0,0 +1,572 @@
/********************************************************************
created: 2005/01/07
created: 7:1:2002 13:08
filename: D:\public\base\AutoLock.h
file path: D:\public\base
file base: AutoLock
file ext: h
author: Günter Baumgart
purpose:
*********************************************************************/
#pragma once
#include <atlbase.h> // Required for ATLASSERT macro
#include <atlstr.h>
namespace AutoLock
{
// SWMR enum wait lock types
enum _LOCKTYPE { LT_WAITTOREAD = 0, LT_WAITTOWRITE = 1 } ;
template<class T>
class CAutoLockT
{
// Attributes
private:
T* m_pObject; // the locked object
// Ctor/dtor
public:
// Critical Section Ctor
inline CAutoLockT( T* pObject ) throw()
: m_pObject(pObject)
{
ATLASSERT( NULL != pObject );
m_pObject->Lock();
}
// Mutex Ctor
inline CAutoLockT( T* pObject, DWORD dwTimeout )
: m_pObject(pObject)
{
ATLASSERT( NULL != pObject );
m_pObject->Lock( dwTimeout );
}
// SRMR Ctor
inline CAutoLockT( T* pObject,
const _LOCKTYPE uLockType,
LPCTSTR szOperation = NULL ) throw()
: m_pObject(pObject)
{
ATLASSERT( NULL != pObject );
m_pObject->Lock( uLockType, szOperation );
}
// dtor
inline ~CAutoLockT()
{
m_pObject->Unlock();
}
};
//+----------------------------------------------------------------------------
// Class: CAutoLockWaitExc
//
// Purpose: CLockableMutex::Lock() method will throw this exception when
// an error occurs.
//
// Comment: NOTE: Callers should catch this exception.
//+----------------------------------------------------------------------------
class CAutoLockWaitExc
{
// Ctor
public:
CAutoLockWaitExc( DWORD dwWaitResult, DWORD dwError )
: m_dwWaitResult( dwWaitResult )
, m_dwError( dwError ) {}
// Public Accessors
public:
inline const DWORD GetWaitResult() { return m_dwWaitResult; };
inline const DWORD GetLastError() { return m_dwError; };
// Attributes
private:
DWORD m_dwWaitResult; // WaitForSingleObject return
DWORD m_dwError; // GetLastError return code
};
//+----------------------------------------------------------------------------
// Class: CAutoLockExc
//
// Purpose: CLockableMutex::Lock() method will throw this exception when
// an error occurs.
//
// Comment: NOTE: Callers should catch this exception.
//+----------------------------------------------------------------------------
class CAutoLockExc
{
// Ctor
public:
CAutoLockExc( DWORD dwError )
: m_dwError( dwError ) {}
// Public Accessors
public:
inline const DWORD GetLastError() { return m_dwError; };
// Attributes
private:
DWORD m_dwError; // GetLastError return code
};
//+----------------------------------------------------------------------------
// Embedded Class: CAutoLockTimeoutExc
//
// Purpose: CLockableMutex::Lock() method will throw this timeout exception
// when the timeout period has been exceeded.
//
// Comment: NOTE: Callers should catch this exception.
//+----------------------------------------------------------------------------
class CAutoLockTimeoutExc
{
// Ctor
public:
CAutoLockTimeoutExc( DWORD dwTimeout ) : m_dwTimeout( dwTimeout ) {}
// Public Accessors
public:
inline const DWORD GetTimeout() { return m_dwTimeout; };
// Attributes
private:
DWORD m_dwTimeout; // Timeout value (although passed in
// to the Lock method, we store it
// here and make it available in the
// exception for convenience
};
//+----------------------------------------------------------------------------
// Class: CLockableCS
//
// Purpose: This class is intended to be used as a base class for a
// multithreaded Critical Section lockable object.
//
//+----------------------------------------------------------------------------
class CLockableCS
{
// Methods
public:
// Ctor / Dtor
inline CLockableCS() throw() { InitializeCriticalSection( &m_CS ); }
inline ~CLockableCS() throw() { DeleteCriticalSection( &m_CS ); }
// Lock / Unlock
inline void Lock() throw() { EnterCriticalSection( &m_CS ); }
inline void Unlock() throw() { LeaveCriticalSection( &m_CS ); }
// Attributes
private:
CRITICAL_SECTION m_CS; // Internal Critical Section
};
//+----------------------------------------------------------------------------
// Class: CLockableMutex
//
// Purpose: This class is intended to be used as a base class for a
// Mutex lockable object.
//
// Comment: NOTE: The lock method for this class will throw a
// CMutexLockExc exception (see below for declaration).
// Callees should catch this exception when calling the Lock method.
//
// Scope: Single or Multiple Processes
//+----------------------------------------------------------------------------
class CLockableMutex
{
public:
inline CLockableMutex( LPCTSTR szName ) //throw()
: m_hMutex( ::CreateMutex( NULL, FALSE, szName ) )
, m_bAlreadyExists( FALSE )
{
// If the call has succeeded, check if the named mutex has already existed
if( NULL != m_hMutex )
{
m_bAlreadyExists = ( ERROR_ALREADY_EXISTS == ::GetLastError( ) );
}
else
{
// The call has failed.
if( ERROR_ACCESS_DENIED == ::GetLastError( ) )
{
// We'll get the Access denied error when the mutex
// exists and the user does not have sufficient permissions
// to create an existing mutex (as in above).
// So we retry using OpenMutex
if( NULL == ( m_hMutex = ::OpenMutex( MUTEX_MODIFY_STATE,
FALSE,
szName ) ))
{
// OpenMutex failed also, so throw an exception
throw CAutoLockExc( ::GetLastError( ) );
}
else
{
m_bAlreadyExists = TRUE;
}
}
else
{
// Other unknown error
throw CAutoLockExc( ::GetLastError( ) );
}
}
}
inline ~CLockableMutex() throw()
{
if(m_hMutex) ::CloseHandle( m_hMutex );
}
//+-------------------------------------------------------------------
// Method: AlreadyExists
// Purpose: Use this method when you want to use a mutex to limit
// an executable to a single instance. Declare a CLockableMutex
// variable and check this param to find out if it existed
// prior to instantiating this class.
//
// Params: void
// Return: void
//
// Comments: See msdn docs on CreateMutex. This
//+-------------------------------------------------------------------
const BOOL AlreadyExists() { return m_bAlreadyExists; };
//+-------------------------------------------------------------------
// Method: Lock
// Purpose: Used by the CAutoLockT class to limit inter-process
// access.
//
// Params: ms Timeout
// Return: void
//
// Comments: Throws CTimeoutException or CException exceptions
//+-------------------------------------------------------------------
inline void Lock( DWORD dwTimeout )
{
DWORD dwWaitResult = 0;
dwWaitResult = ::WaitForSingleObject( m_hMutex, dwTimeout );
switch( dwWaitResult )
{
case WAIT_OBJECT_0:
break;
case WAIT_TIMEOUT:
throw CAutoLockTimeoutExc( dwTimeout );
break;
default:
throw CAutoLockWaitExc( dwWaitResult, ::GetLastError() );
}
}
//+-------------------------------------------------------------------
// Method: Unlock
// Purpose: Used by the CAutoLockT class (CAutoLockT::dtor) to
// release the mutex
//
// Params: void
// Return: void
inline void Unlock() throw()
{
if(m_hMutex)
{
::ReleaseMutex( m_hMutex );
}
}
private:
HANDLE m_hMutex; // Name Mutex Handle
BOOL m_bAlreadyExists; // TRUE if named mutex already exists
};
//+----------------------------------------------------------------------------
// Class: CLockableSWMR
//
// Purpose: This class is intended to be used as a base class for a
// SWMR (Single Writer, Multiple Reader) lockable object.
//
// Acknowledgements:
// This class is base on work by Jeffrey Richter in his book
// "Programming Applications for Microsoft Windows"
//
// Usage:
// Create a class derived from this and another resource class (such as
// an std::list<> class) when you have a scenario where the list seldom
// gets updated, but is frequently read by multiple threads. Under this
// scenario, this class would be more efficient than the CLockableCS
// class because multiple threads could read simultaneously whereas a
// CLockableCS implementation would only allow a single thread to read
// or write. Conversely, because this class makes use of the kernel
// semaphore object, it is not as efficient a CLockableCS under single
// read thread scenarios.
//
// To Lock to Read:
// CAutoLock< CLockableSWMR_Derived > lock( &m_SWMR, LT_WAITTOREAD );
//
// To Lock to Write:
// CAutoLock< CLockableSWMR_Derived > lock( &m_SWMR, LT_WAITTOWRITE );
//
// Public Methods:
// Lock( enumLockType, ... )
// Unlock()
//
// Private Methods:
// WaitToRead(...)
// WaitToWrite(...)
// Scope: Single Process
//+----------------------------------------------------------------------------
class CLockableSWMR
{
public:
CLockableSWMR( ) throw()
: m_hSemReaders( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_hSemWriters( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_nWaitingReaders( 0 )
, m_nWaitingWriters( 0 )
, m_nActive( 0 )
, m_sName( _T("") )
{
}
CLockableSWMR( LPCTSTR szName ) throw()
: m_hSemReaders( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_hSemWriters( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_nWaitingReaders( 0 )
, m_nWaitingWriters( 0 )
, m_nActive( 0 )
, m_sName( szName )
{
}
~CLockableSWMR() throw()
{
m_nWaitingReaders = 0;
m_nWaitingWriters = 0;
m_nActive = 0;
CloseHandle(m_hSemReaders);
CloseHandle(m_hSemWriters);
}
// Attributes
private:
CLockableCS m_InternalCS; // Ensures exclusive access
// to member variables
HANDLE m_hSemReaders; // Readers wait on if a writer has access
HANDLE m_hSemWriters; // Writers wait on if a reader has access
int m_nWaitingReaders; // # of readers waiting
int m_nWaitingWriters; // # of writers waiting
int m_nActive; // # of threads currently w/access
// (0 == no threads,
// >0 == # of readers,
// -1 == 1 writer)
CString m_sName; // Debug diagnostic string
// Thread tracking enum
enum _ACTIVETHREADS { AT_ONEWRITER = -1, AT_NONE = 0 };
// Operations
public:
//+-------------------------------------------------------------------
// Method: Lock
// Purpose: Used by the CAutoLockT class to provide thread safe access.
//
// Params: enumLockType, szOperation (debug operation string)
// Return: void
//+-------------------------------------------------------------------
void Lock(const _LOCKTYPE enumLockType,
LPCTSTR szOperation = NULL ) throw()
{
switch(enumLockType)
{
case LT_WAITTOREAD:
WaitToRead( szOperation );
break;
case LT_WAITTOWRITE:
WaitToWrite( szOperation );
break;
default:
ATLASSERT(0);
}
}
//+-------------------------------------------------------------------
// Method: Unlock
// Purpose: Used by the CAutoLockT class (CAutoLockT::dtor) to
// release the CS
//
// Params: void
// Return: void
//+-------------------------------------------------------------------
void Unlock() throw()
{
HANDLE hSem = NULL; // Assume no threads are waiting
long lCount = 1; // Assume only 1 waiter wakes;
// always true for writers
{ // Lock scope
// Ensure exclusive access to member variables
CAutoLockT< CLockableCS > lock( &m_InternalCS );
ATLTRACE( _T("\t\t%s: Unlock - m_nActive: %d"),
m_sName,
m_nActive);
if (m_nActive > 0)
{
// Readers have control so a reader must be done
m_nActive--;
}
else
{
// Writers have control so a writer must be done
m_nActive++;
}
ATLTRACE( _T("\t\t%s: Unlock - m_nActive: %d\n"),
m_sName,
m_nActive);
if(m_nActive == 0)
{
// No thread has access, who should wake up?
// NOTE: It is possible that readers could never get access
// if there are always writers wanting to write
if (m_nWaitingWriters > 0)
{
// Writers are waiting and they take priority over readers
m_nActive = -1; // A writer will get access
hSem = m_hSemWriters; // Writers wait on this semaphore
m_nWaitingWriters--; // One less writer will be waiting
// NOTE: The semaphore will release only 1 writer thread
ATLTRACE( _T("\b\t\t\t\t%s: Unlock - m_nWaitingWriters: %d\n"),
m_sName,
m_nWaitingWriters);
}
else if (m_nWaitingReaders > 0)
{
// Readers are waiting and no writers are waiting
m_nActive = m_nWaitingReaders;// All readers get access
m_nWaitingReaders = 0; // No readers will be waiting
hSem = m_hSemReaders; // Readers wait on this semaphore
lCount = m_nActive; // Semaphore releases all readers
ATLTRACE( _T("\b\t\t\t\t%s: Unlock - m_nWaitingReaders: %d\n"),
m_sName,
m_nWaitingReaders);
}
else
{
// There are no threads waiting at all;
// no semaphore gets released
ATLTRACE( _T("\b\t\t\t\t%s: Unlock - m_nR/W = 0\n"),
m_sName);
}
}
} // End of CS Lock scope
if (NULL != hSem)
{
// Some threads are to be released
ReleaseSemaphore(hSem, lCount, NULL);
}
}
// Implementation
private:
void WaitToRead( LPCTSTR szOperation )
{
BOOL bResourceWritePending = FALSE;
{ // Lock scope
// Ensure exclusive access to member variables
CAutoLockT< CLockableCS > lock( &m_InternalCS );
// Are there writers waiting or is a writer writing?
bResourceWritePending
= (m_nWaitingWriters || (m_nActive < AT_NONE));
if (bResourceWritePending)
{
// This reader must wait,
// increment the count of waiting readers
m_nWaitingReaders++;
}
else
{
ATLTRACE( _T("%s: WaitToRead - m_nActive: %d\tOp:%s\n"),
m_sName,
m_nActive,
((szOperation) ? szOperation : _T("")));
// This reader can read, increment the count of active readers
m_nActive++;
}
} // End of Lock scope
if (bResourceWritePending)
{
ATLTRACE( _T("%s: WaitToRead - m_nWaitingReaders: %d\tOp:%s\n"),
m_sName,
m_nWaitingReaders,
((szOperation) ? szOperation : _T("")));
// This thread must wait
WaitForSingleObject(m_hSemReaders, INFINITE);
}
}
void WaitToWrite( LPCTSTR szOperation )
{
BOOL bResourceOwned = FALSE;
{ // Lock scope
// Ensure exclusive access to member variables
CAutoLockT< CLockableCS > lock( &m_InternalCS );
// Are there any threads accessing the resource?
bResourceOwned = (AT_NONE != m_nActive);
if(bResourceOwned)
{
// This writer must wait;
// increment the count of waiting writers
m_nWaitingWriters++;
}
else
{
ATLTRACE( _T("%s: WaitToWrite %s - Okay TID: %d\n"),
m_sName,
((szOperation) ? szOperation : _T("")),
GetCurrentThreadId());
// This writer can write, prevent access to others
m_nActive = AT_ONEWRITER;
}
} // End of lock scope
if (bResourceOwned)
{
ATLTRACE( _T("%s: WaitToWrite %s - m_nWaitingWriters: %d TID: %d\n"),
m_sName,
((szOperation) ? szOperation : _T("")),
m_nWaitingWriters,
GetCurrentThreadId());
// This thread must wait
WaitForSingleObject(m_hSemWriters, INFINITE);
}
}
};
} // End of namespace AutoLock

View File

@ -0,0 +1,560 @@
#pragma once //its win32
#include <atlbase.h> // Required for ATLASSERT macro
#include <atlstr.h>
namespace AutoLock
{
// SWMR enum wait lock types
enum _LOCKTYPE { LT_WAITTOREAD = 0, LT_WAITTOWRITE = 1 } ;
template<class T>
class CAutoLockT
{
// Attributes
private:
T* m_pObject; // the locked object
// Ctor/dtor
public:
// Critical Section Ctor
inline CAutoLockT( T* pObject ) throw()
: m_pObject(pObject)
{
ATLASSERT( NULL != pObject );
m_pObject->Lock();
}
// Mutex Ctor
inline CAutoLockT( T* pObject, DWORD dwTimeout )
: m_pObject(pObject)
{
ATLASSERT( NULL != pObject );
m_pObject->Lock( dwTimeout );
}
// SRMR Ctor
inline CAutoLockT( T* pObject,
const _LOCKTYPE uLockType,
LPCTSTR szOperation = NULL ) throw()
: m_pObject(pObject)
{
ATLASSERT( NULL != pObject );
m_pObject->Lock( uLockType, szOperation );
}
// dtor
inline ~CAutoLockT()
{
m_pObject->Unlock();
}
};
//+----------------------------------------------------------------------------
// Class: CAutoLockWaitExc
//
// Purpose: CLockableMutex::Lock() method will throw this exception when
// an error occurs.
//
// Comment: NOTE: Callers should catch this exception.
//+----------------------------------------------------------------------------
class CAutoLockWaitExc
{
// Ctor
public:
CAutoLockWaitExc( DWORD dwWaitResult, DWORD dwError )
: m_dwWaitResult( dwWaitResult )
, m_dwError( dwError ) {}
// Public Accessors
public:
inline const DWORD GetWaitResult() { return m_dwWaitResult; };
inline const DWORD GetLastError() { return m_dwError; };
// Attributes
private:
DWORD m_dwWaitResult; // WaitForSingleObject return
DWORD m_dwError; // GetLastError return code
};
//+----------------------------------------------------------------------------
// Class: CAutoLockExc
//
// Purpose: CLockableMutex::Lock() method will throw this exception when
// an error occurs.
//
// Comment: NOTE: Callers should catch this exception.
//+----------------------------------------------------------------------------
class CAutoLockExc
{
// Ctor
public:
CAutoLockExc( DWORD dwError )
: m_dwError( dwError ) {}
// Public Accessors
public:
inline const DWORD GetLastError() { return m_dwError; };
// Attributes
private:
DWORD m_dwError; // GetLastError return code
};
//+----------------------------------------------------------------------------
// Embedded Class: CAutoLockTimeoutExc
//
// Purpose: CLockableMutex::Lock() method will throw this timeout exception
// when the timeout period has been exceeded.
//
// Comment: NOTE: Callers should catch this exception.
//+----------------------------------------------------------------------------
class CAutoLockTimeoutExc
{
// Ctor
public:
CAutoLockTimeoutExc( DWORD dwTimeout ) : m_dwTimeout( dwTimeout ) {}
// Public Accessors
public:
inline const DWORD GetTimeout() { return m_dwTimeout; };
// Attributes
private:
DWORD m_dwTimeout; // Timeout value (although passed in
// to the Lock method, we store it
// here and make it available in the
// exception for convenience
};
//+----------------------------------------------------------------------------
// Class: CLockableCS
//
// Purpose: This class is intended to be used as a base class for a
// multithreaded Critical Section lockable object.
//
//+----------------------------------------------------------------------------
class CLockableCS
{
// Methods
public:
// Ctor / Dtor
inline CLockableCS() throw() { InitializeCriticalSection( &m_CS ); }
inline ~CLockableCS() throw() { DeleteCriticalSection( &m_CS ); }
// Lock / Unlock
inline void Lock() throw() { EnterCriticalSection( &m_CS ); }
inline void Unlock() throw() { LeaveCriticalSection( &m_CS ); }
// Attributes
private:
CRITICAL_SECTION m_CS; // Internal Critical Section
};
//+----------------------------------------------------------------------------
// Class: CLockableMutex
//
// Purpose: This class is intended to be used as a base class for a
// Mutex lockable object.
//
// Comment: NOTE: The lock method for this class will throw a
// CMutexLockExc exception (see below for declaration).
// Callees should catch this exception when calling the Lock method.
//
// Scope: Single or Multiple Processes
//+----------------------------------------------------------------------------
class CLockableMutex
{
public:
inline CLockableMutex( LPCTSTR szName ) //throw()
: m_hMutex( ::CreateMutex( NULL, FALSE, szName ) )
, m_bAlreadyExists( FALSE )
{
// If the call has succeeded, check if the named mutex has already existed
if( NULL != m_hMutex )
{
m_bAlreadyExists = ( ERROR_ALREADY_EXISTS == ::GetLastError( ) );
}
else
{
// The call has failed.
if( ERROR_ACCESS_DENIED == ::GetLastError( ) )
{
// We'll get the Access denied error when the mutex
// exists and the user does not have sufficient permissions
// to create an existing mutex (as in above).
// So we retry using OpenMutex
if( NULL == ( m_hMutex = ::OpenMutex( MUTEX_MODIFY_STATE,
FALSE,
szName ) ))
{
// OpenMutex failed also, so throw an exception
throw CAutoLockExc( ::GetLastError( ) );
}
else
{
m_bAlreadyExists = TRUE;
}
}
else
{
// Other unknown error
throw CAutoLockExc( ::GetLastError( ) );
}
}
}
inline ~CLockableMutex() throw()
{
if(m_hMutex) ::CloseHandle( m_hMutex );
}
//+-------------------------------------------------------------------
// Method: AlreadyExists
// Purpose: Use this method when you want to use a mutex to limit
// an executable to a single instance. Declare a CLockableMutex
// variable and check this param to find out if it existed
// prior to instantiating this class.
//
// Params: void
// Return: void
//
// Comments: See msdn docs on CreateMutex. This
//+-------------------------------------------------------------------
const BOOL AlreadyExists() { return m_bAlreadyExists; };
//+-------------------------------------------------------------------
// Method: Lock
// Purpose: Used by the CAutoLockT class to limit inter-process
// access.
//
// Params: ms Timeout
// Return: void
//
// Comments: Throws CTimeoutException or CException exceptions
//+-------------------------------------------------------------------
inline void Lock( DWORD dwTimeout )
{
DWORD dwWaitResult = 0;
dwWaitResult = ::WaitForSingleObject( m_hMutex, dwTimeout );
switch( dwWaitResult )
{
case WAIT_OBJECT_0:
break;
case WAIT_TIMEOUT:
throw CAutoLockTimeoutExc( dwTimeout );
break;
default:
throw CAutoLockWaitExc( dwWaitResult, ::GetLastError() );
}
}
//+-------------------------------------------------------------------
// Method: Unlock
// Purpose: Used by the CAutoLockT class (CAutoLockT::dtor) to
// release the mutex
//
// Params: void
// Return: void
inline void Unlock() throw()
{
if(m_hMutex)
{
::ReleaseMutex( m_hMutex );
}
}
private:
HANDLE m_hMutex; // Name Mutex Handle
BOOL m_bAlreadyExists; // TRUE if named mutex already exists
};
//+----------------------------------------------------------------------------
// Class: CLockableSWMR
//
// Purpose: This class is intended to be used as a base class for a
// SWMR (Single Writer, Multiple Reader) lockable object.
//
// Acknowledgments:
// This class is base on work by Jeffrey Richter in his book
// "Programming Applications for Microsoft Windows"
//
// Usage:
// Create a class derived from this and another resource class (such as
// an std::list<> class) when you have a scenario where the list seldom
// gets updated, but is frequently read by multiple threads. Under this
// scenario, this class would be more efficient than the CLockableCS
// class because multiple threads could read simultaneously whereas a
// CLockableCS implementation would only allow a single thread to read
// or write. Conversely, because this class makes use of the kernel
// semaphore object, it is not as efficient a CLockableCS under single
// read thread scenarios.
//
// To Lock to Read:
// CAutoLock< CLockableSWMR_Derived > lock( &m_SWMR, LT_WAITTOREAD );
//
// To Lock to Write:
// CAutoLock< CLockableSWMR_Derived > lock( &m_SWMR, LT_WAITTOWRITE );
//
// Public Methods:
// Lock( enumLockType, ... )
// Unlock()
//
// Private Methods:
// WaitToRead(...)
// WaitToWrite(...)
// Scope: Single Process
//+----------------------------------------------------------------------------
class CLockableSWMR
{
public:
CLockableSWMR( ) throw()
: m_hSemReaders( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_hSemWriters( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_nWaitingReaders( 0 )
, m_nWaitingWriters( 0 )
, m_nActive( 0 )
, m_sName( _T("") )
{
}
CLockableSWMR( LPCTSTR szName ) throw()
: m_hSemReaders( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_hSemWriters( CreateSemaphore(NULL, 0, MAXLONG, NULL) )
, m_nWaitingReaders( 0 )
, m_nWaitingWriters( 0 )
, m_nActive( 0 )
, m_sName( szName )
{
}
~CLockableSWMR() throw()
{
m_nWaitingReaders = 0;
m_nWaitingWriters = 0;
m_nActive = 0;
CloseHandle(m_hSemReaders);
CloseHandle(m_hSemWriters);
}
// Attributes
private:
CLockableCS m_InternalCS; // Ensures exclusive access
// to member variables
HANDLE m_hSemReaders; // Readers wait on if a writer has access
HANDLE m_hSemWriters; // Writers wait on if a reader has access
int m_nWaitingReaders; // # of readers waiting
int m_nWaitingWriters; // # of writers waiting
int m_nActive; // # of threads currently w/access
// (0 == no threads,
// >0 == # of readers,
// -1 == 1 writer)
CString m_sName; // Debug diagnostic string
// Thread tracking enum
enum _ACTIVETHREADS { AT_ONEWRITER = -1, AT_NONE = 0 };
// Operations
public:
//+-------------------------------------------------------------------
// Method: Lock
// Purpose: Used by the CAutoLockT class to provide thread safe access.
//
// Params: enumLockType, szOperation (debug operation string)
// Return: void
//+-------------------------------------------------------------------
void Lock(const _LOCKTYPE enumLockType,
LPCTSTR szOperation = NULL ) throw()
{
switch(enumLockType)
{
case LT_WAITTOREAD:
WaitToRead( szOperation );
break;
case LT_WAITTOWRITE:
WaitToWrite( szOperation );
break;
default:
ATLASSERT(0);
}
}
//+-------------------------------------------------------------------
// Method: Unlock
// Purpose: Used by the CAutoLockT class (CAutoLockT::dtor) to
// release the CS
//
// Params: void
// Return: void
//+-------------------------------------------------------------------
void Unlock() throw()
{
HANDLE hSem = NULL; // Assume no threads are waiting
long lCount = 1; // Assume only 1 waiter wakes;
// always true for writers
{ // Lock scope
// Ensure exclusive access to member variables
CAutoLockT< CLockableCS > lock( &m_InternalCS );
ATLTRACE( _T("\t\t%s: Unlock - m_nActive: %d"),
m_sName,
m_nActive);
if (m_nActive > 0)
{
// Readers have control so a reader must be done
m_nActive--;
}
else
{
// Writers have control so a writer must be done
m_nActive++;
}
ATLTRACE( _T("\t\t%s: Unlock - m_nActive: %d\n"),
m_sName,
m_nActive);
if(m_nActive == 0)
{
// No thread has access, who should wake up?
// NOTE: It is possible that readers could never get access
// if there are always writers wanting to write
if (m_nWaitingWriters > 0)
{
// Writers are waiting and they take priority over readers
m_nActive = -1; // A writer will get access
hSem = m_hSemWriters; // Writers wait on this semaphore
m_nWaitingWriters--; // One less writer will be waiting
// NOTE: The semaphore will release only 1 writer thread
ATLTRACE( _T("\b\t\t\t\t%s: Unlock - m_nWaitingWriters: %d\n"),
m_sName,
m_nWaitingWriters);
}
else if (m_nWaitingReaders > 0)
{
// Readers are waiting and no writers are waiting
m_nActive = m_nWaitingReaders;// All readers get access
m_nWaitingReaders = 0; // No readers will be waiting
hSem = m_hSemReaders; // Readers wait on this semaphore
lCount = m_nActive; // Semaphore releases all readers
ATLTRACE( _T("\b\t\t\t\t%s: Unlock - m_nWaitingReaders: %d\n"),
m_sName,
m_nWaitingReaders);
}
else
{
// There are no threads waiting at all;
// no semaphore gets released
ATLTRACE( _T("\b\t\t\t\t%s: Unlock - m_nR/W = 0\n"),
m_sName);
}
}
} // End of CS Lock scope
if (NULL != hSem)
{
// Some threads are to be released
ReleaseSemaphore(hSem, lCount, NULL);
}
}
// Implementation
private:
void WaitToRead( LPCTSTR szOperation )
{
BOOL bResourceWritePending = FALSE;
{ // Lock scope
// Ensure exclusive access to member variables
CAutoLockT< CLockableCS > lock( &m_InternalCS );
// Are there writers waiting or is a writer writing?
bResourceWritePending
= (m_nWaitingWriters || (m_nActive < AT_NONE));
if (bResourceWritePending)
{
// This reader must wait,
// increment the count of waiting readers
m_nWaitingReaders++;
}
else
{
ATLTRACE( _T("%s: WaitToRead - m_nActive: %d\tOp:%s\n"),
m_sName,
m_nActive,
((szOperation) ? szOperation : _T("")));
// This reader can read, increment the count of active readers
m_nActive++;
}
} // End of Lock scope
if (bResourceWritePending)
{
ATLTRACE( _T("%s: WaitToRead - m_nWaitingReaders: %d\tOp:%s\n"),
m_sName,
m_nWaitingReaders,
((szOperation) ? szOperation : _T("")));
// This thread must wait
WaitForSingleObject(m_hSemReaders, INFINITE);
}
}
void WaitToWrite( LPCTSTR szOperation )
{
BOOL bResourceOwned = FALSE;
{ // Lock scope
// Ensure exclusive access to member variables
CAutoLockT< CLockableCS > lock( &m_InternalCS );
// Are there any threads accessing the resource?
bResourceOwned = (AT_NONE != m_nActive);
if(bResourceOwned)
{
// This writer must wait;
// increment the count of waiting writers
m_nWaitingWriters++;
}
else
{
ATLTRACE( _T("%s: WaitToWrite %s - Okay TID: %d\n"),
m_sName,
((szOperation) ? szOperation : _T("")),
GetCurrentThreadId());
// This writer can write, prevent access to others
m_nActive = AT_ONEWRITER;
}
} // End of lock scope
if (bResourceOwned)
{
ATLTRACE( _T("%s: WaitToWrite %s - m_nWaitingWriters: %d TID: %d\n"),
m_sName,
((szOperation) ? szOperation : _T("")),
m_nWaitingWriters,
GetCurrentThreadId());
// This thread must wait
WaitForSingleObject(m_hSemWriters, INFINITE);
}
}
};
} // End of namespace AutoLock

View File

@ -0,0 +1,132 @@
#ifndef __IPARAMETER_H__
#define __IPARAMETER_H__
#include "vtPhysXBase.h"
/*!
\if internal2
\brief Interface for parameters, implemented as singleton.
Helps to convert from PhysX to Virtools and vice versa.
\Note This class has been introduced to collect parameter exchange related functionality. In the initial implementation of
this SDK, pFactory was responsible to perform these tasks.
\Warning We are migrating all parameter related functions from pFactory to here.
\endif
*/
class MODULE_API IParameter
{
public:
/*!
* \brief Default Constructor. Not been used. This is a singleton class and needs to
be instanced only the PhysicManager
*/
IParameter();
IParameter(PhysicManager*_pManager);
/************************************************************************************************/
/** @name RigidBody
*/
//@{
/**
\brief Conversion for the custom structure #pBSetup.
\param[in] pObjectDescr * dst, w: target object
\param[in] CKParameter * src, r : source parameter.
\return int
@see
*/
int copyTo(pObjectDescr*dst,CKParameter*src);
/**
\brief Conversion for the custom structure #pBSetup.
\param[in] CKParameter * src, r : source parameter.
\param[in] pObjectDescr * dst, w: target object
\return int
@see
*/
int copyTo(CKParameter*dst,pObjectDescr*src);
/**
\brief Conversion for the custom structure #pBPivotSettings.
\param[in] CKParameter * dst, w : target parameter.
\param[in] pObjectDescr * src, w: src object
\return int
@see
*/
int copyTo(pOptimization& dst,CKParameter*src);
int copyTo(CKParameter*dst,pOptimization src);
int copyTo(pCCDSettings& dst,CKParameter*src);
int copyTo(CKParameter*dst,pCCDSettings src);
int copyTo(pAxisReferencedLength&dst,CKParameter*src,bool evaluate=true);
int copyTo(CKParameter*dst,pAxisReferencedLength&src,bool evaluate=true);
int copyTo(pCapsuleSettingsEx& dst,CKParameter*src);
int copyTo(CKParameter*dst,pCapsuleSettingsEx src);
int copyTo(pConvexCylinderSettings& dst,CKParameter*src);
int copyTo(CKParameter*dst,pConvexCylinderSettings& src);
int copyTo(pObjectDescr&dst,CK3dEntity*src,int copyFlags);
int copyTo(pObjectDescr&dst,const pObjectDescr&src);
int copyTo(pMassSettings& dst,CKParameter*src);
int copyTo(CKParameter*dst,pMassSettings src);
int copyTo(pPivotSettings& dst,CKParameter*src);
int copyTo(CKParameter*dst,pPivotSettings src);
int copyTo(pCollisionSettings& dst,CKParameter*src);
int copyTo(CKParameter*dst,pCollisionSettings src);
int copyTo(pWheelDescr& dst,CKParameter*src);
int copyTo(CKParameter*dst,pWheelDescr src);
int copyTo(pVehicleBrakeTable& dst,CKParameter*src);
int copyTo(pLinearInterpolation&dst,CKParameter*src);
int copyTo(pGearBox *dst,CKParameter*src);
int copyTo(CKParameter*dst,pGearBox *src);
int copyTo(pLinearInterpolation&dst,CKParameter*src,int size,float maxValue,float minValue);
//@}
static IParameter* Instance();
private:
PhysicManager* mManager;
};
#define GetIPar() IParameter::Instance()
#endif // __IPARAMETER_H__

View File

@ -0,0 +1,20 @@
/********************************************************************
created: 2009/04/13
created: 13:4:2009 22:08
filename: x:\ProjectRoot\vtmodsvn\tools\VTCPPProjectPremakerSimple\Sdk\Include\Core\Common\MemoryFileMappingPrerequisites.h
file path: x:\ProjectRoot\vtmodsvn\tools\VTCPPProjectPremakerSimple\Sdk\Include\Core\Common
file base: MemoryFileMappingPrerequisites
file ext: h
author: Günter Baumgart
purpose: Forward decalarations for memory file mappings
*********************************************************************/
#ifndef __MEMORY_FILE_MAPPING_PREREQUISITES_H__
#define __MEMORY_FILE_MAPPING_PREREQUISITES_H__
struct vtExternalEvent;
struct TSharedMemory;
struct haptekMsg;
#endif

View File

@ -0,0 +1,19 @@
#ifndef __MEMORY_FILE_MAPPING_TYPES_H__
#define __MEMORY_FILE_MAPPING_TYPES_H__
enum vtEventState
{
EEVT_STARTED,
EEVT_FINISHED
};
struct vtExternalEvent
{
unsigned long timeOfCreation;
char command[MAX_PATH];
char commandArg[MAX_PATH];
vtEventState state;
};
#endif

View File

@ -0,0 +1,22 @@
#ifndef __PREREQUISITES_3TH_PARTY_H__
#define __PREREQUISITES_3TH_PARTY_H__
//################################################################
//
// External : TINY XML
//
class TiXmlNode;
class TiXmlDocument;
class TiXmlElement;
//################################################################
//
// External NxuStream
//
#endif

View File

@ -0,0 +1,53 @@
/********************************************************************
created: 2009/02/16
created: 16:2:2009 9:07
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common\ModulePrerequisites.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common
file base: ModulePrerequisites
file ext: h
author: Günter Baumgart
purpose: Include of all prerequisites
*********************************************************************/
#ifndef __PREREQUISITES_ALL_H__
#define __PREREQUISITES_ALL_H__
//################################################################
//
// Common forward declarations :
//
//################################################################
//
// Virtools related forward declarations :
//
#include "Prerequisites_Virtools.h"
//################################################################
//
// 3th party forward declarations :
//
// + TinyXML
// + NXUStream
//
#include "Prerequisites_3thParty.h"
//################################################################
//
// Main library forward declarations :
//
#include "Prerequisites_PhysX.h"
//################################################################
//
// Forward declarations for this module itself :
//
#include "Prerequisites_Module.h"
#include "Timing.h"
#endif

View File

@ -0,0 +1,97 @@
#ifndef __PREREQUISITES_MODULE_H__
#define __PREREQUISITES_MODULE_H__
class PhysicManager;
//################################################################
//
// Physic Types
//
class pContactReport;
class pTriggerReport;
class pRayCastReport;
class pContactModify;
class pRigidBody;
class pObjectDescr;
class pJointSettings;
class pJoint;
class pJointBall;
class pJointFixed;
class pJointPulley;
class pJointPointOnLine;
class pJointPointInPlane;
class pJointRevolute;
class pJointDistance;
class pJointD6;
class pJointPrismatic;
class pJointCylindrical;
class pClothDesc;
class pCloth;
class pFluid;
class pFluidDesc;
class pFluidEmitterDesc;
class pFluidEmitter;
class pFluidRenderSettings;
class pWheelContactData;
class pSerializer;
class pWorld;
class pFactory;
class pSoftBody;
class pWheelDescr;
class pWheel;
class pWheel1;
class pWheel2;
class pVecicleDescr;
class pVehicle;
class pVehicleMotor;
class pVehicleGears;
class pVehicleMotorDesc;
class pVehicleGearDesc;
class pBoxController;
class pObjectDescr;
class IParameter;
struct pRigidBodyRestoreInfo;
namespace vtAgeia
{
class pWorldSettings;
class pSleepingSettings;
class pShape;
class pErrorStream;
class pCollisionsListener;
}
class pLogger;
class ContactInfo;
namespace vtTools
{
namespace ParameterTools
{
class CustomStructure;
}
}
using namespace vtAgeia;
#endif

View File

@ -0,0 +1,90 @@
#ifndef __PREREQUISITES_PHYS_X_H__
#define __PREREQUISITES_PHYS_X_H__
class NxCompartment;
class NxActor;
class NxActorDesc;
class NxScene;
class NxSceneDescr;
class NxUserNotify;
class NxFluidUserNotify;
class NxCloth;
class NxClothDesc;
class NxClothUserNotify;
class NxClothMeshDesc;
class NxSoftBodyUserNotify;
class NxUserContactModify;
class NxUserTriggerReport;
class NxUserContactReport;
class NxUserActorPairFiltering;
class NxBounds3;
class NxUserScheduler;
class NxSceneDesc;
class NxBodyDesc;
class NxShapeDesc;
class NxMaterial;
class NxMaterialDesc;
class NxUserDebugRenderer;
class NxTriangleMesh;
class NxTriangleMeshDesc;
class NxConvexMesh;
class NxConvexMeshDesc;
class NxUserOutputStream;
class NxUserAllocator;
class NxJoint;
class NxD6Joint;
class NxStream;
class NxFoundationSDK;
class NxCCDSkeleton; //this class doesn't actually exist.
class NxSimpleTriangleMesh;
class NxHeightField;
class NxHeightFieldDesc;
class NxPhysicsSDKDesc;
class NxPhysicsSDK;
class NxMeshData;
class NxClothMesh;
class NxControllerManager;
class NxBoxController;
class NxBoxControllerDesc;
class NxCapsuleController;
class NxCapsuleControllerDesc;
class UserAllocator;
class NxRemoteDebugger;
class NxShape;
class NxContactPair;
class NxConvexShapeDesc;
class NxWheelShape;
class NxConvexShape;
class NxCapsuleShape;
class NxRaycastHit;
class NxWheelContactData;
#if NX_USE_CLOTH_API
class NxClothMesh;
#endif
#if NX_USE_SOFTBODY_API
class NxSoftBodyMesh;
#endif
//----------------------------------------------------------------
//
//! \brief NxU Stream
//
namespace NXU
{
class NxActorDesc;
class NxuPhysicsCollection;
}
#endif

View File

@ -0,0 +1,37 @@
/********************************************************************
created: 2009/02/16
created: 16:2:2009 8:57
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common\vtPreReqs.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common
file base: vtPreReqs
file ext: h
author: Günter Baumgart
purpose: Virtools Forward Declarations
*********************************************************************/
#ifndef __PREREQUISITES_VIRTOOSLS_H__
#define __PREREQUISITES_VIRTOOSLS_H__
//################################################################
//
// Common Types
//
class CKBeObject;
class CKContext;
class CKParameter;
class CKParameterIn;
class CKParameterOut;
class CKParameterManager;
class CKAttributeManager;
//################################################################
//
// 3D Types
//
class CKMesh;
class CK3dEntity;
class CK3dObject;
class CK3dPointCloud;
#endif

View File

@ -0,0 +1,78 @@
#ifndef STREAM_H
#define STREAM_H
#include "NxStream.h"
class UserStream : public NxStream
{
public:
UserStream(const char* filename, bool load);
virtual ~UserStream();
virtual NxU8 readByte() const;
virtual NxU16 readWord() const;
virtual NxU32 readDword() const;
virtual float readFloat() const;
virtual double readDouble() const;
virtual void readBuffer(void* buffer, NxU32 size) const;
virtual NxStream& storeByte(NxU8 b);
virtual NxStream& storeWord(NxU16 w);
virtual NxStream& storeDword(NxU32 d);
virtual NxStream& storeFloat(NxReal f);
virtual NxStream& storeDouble(NxF64 f);
virtual NxStream& storeBuffer(const void* buffer, NxU32 size);
FILE* fp;
};
class MemoryWriteBuffer : public NxStream
{
public:
MemoryWriteBuffer();
virtual ~MemoryWriteBuffer();
void clear();
virtual NxU8 readByte() const { NX_ASSERT(0); return 0; }
virtual NxU16 readWord() const { NX_ASSERT(0); return 0; }
virtual NxU32 readDword() const { NX_ASSERT(0); return 0; }
virtual float readFloat() const { NX_ASSERT(0); return 0.0f;}
virtual double readDouble() const { NX_ASSERT(0); return 0.0; }
virtual void readBuffer(void* buffer, NxU32 size) const { NX_ASSERT(0); }
virtual NxStream& storeByte(NxU8 b);
virtual NxStream& storeWord(NxU16 w);
virtual NxStream& storeDword(NxU32 d);
virtual NxStream& storeFloat(NxReal f);
virtual NxStream& storeDouble(NxF64 f);
virtual NxStream& storeBuffer(const void* buffer, NxU32 size);
NxU32 currentSize;
NxU32 maxSize;
NxU8* data;
};
class MemoryReadBuffer : public NxStream
{
public:
MemoryReadBuffer(const NxU8* data);
virtual ~MemoryReadBuffer();
virtual NxU8 readByte() const;
virtual NxU16 readWord() const;
virtual NxU32 readDword() const;
virtual float readFloat() const;
virtual double readDouble() const;
virtual void readBuffer(void* buffer, NxU32 size) const;
virtual NxStream& storeByte(NxU8 b) { NX_ASSERT(0); return *this; }
virtual NxStream& storeWord(NxU16 w) { NX_ASSERT(0); return *this; }
virtual NxStream& storeDword(NxU32 d) { NX_ASSERT(0); return *this; }
virtual NxStream& storeFloat(NxReal f) { NX_ASSERT(0); return *this; }
virtual NxStream& storeDouble(NxF64 f) { NX_ASSERT(0); return *this; }
virtual NxStream& storeBuffer(const void* buffer, NxU32 size) { NX_ASSERT(0); return *this; }
mutable const NxU8* buffer;
};
#endif

View File

@ -0,0 +1,18 @@
static char* sErrorStrings[]=
{
"OK",
"\t Intern :",
"\t No connection :",
"\t Not joined to a session:",
"\t Session needs right password:",
"\t Session is locked:",
"\t Session already exists:",
"\t Session is full:",
"\t You must be session master:",
"\t Invalid parameter :",
"\t There is not such user :",
"\t Distributed class already exists :",
"\t Couldn't connect to any server :",
"\t You already joined to a session :",
"\t No such session :"
};

View File

@ -0,0 +1,22 @@
#ifndef COOKING_H
#define COOKING_H
#include "NxCooking.h"
class NxPMap;
class NxTriangleMesh;
class NxUserOutputStream;
bool hasCookingLibrary(); // check to see if the cooking library is available or not!
bool InitCooking(NxUserAllocator* allocator = NULL, NxUserOutputStream* outputStream = NULL);
void CloseCooking();
bool CookConvexMesh(const NxConvexMeshDesc& desc, NxStream& stream);
bool CookClothMesh(const NxClothMeshDesc& desc, NxStream& stream);
bool CookTriangleMesh(const NxTriangleMeshDesc& desc, NxStream& stream);
bool CookSoftBodyMesh(const NxSoftBodyMeshDesc& desc, NxStream& stream);
bool CreatePMap(NxPMap& pmap, const NxTriangleMesh& mesh, NxU32 density, NxUserOutputStream* outputStream = NULL);
bool ReleasePMap(NxPMap& pmap);
#endif

View File

@ -0,0 +1,28 @@
#ifndef __G_CONFIG_H__
#define __G_CONFIG_H__
#ifdef _DEBUG
static bool GC_SHOWPARAMETER = true;
#else
static BOOL GC_SHOWPARAMETER = false;
#endif
//#define BBC_JOYSTICK
#define BBC_TOOLS
#define BB_TOOLS
#define HAS_CONFIG
#define BBC_VEHICLES
#define BBC_CLOTHES
#define BBC_JOINTS
#define CORE_CLOTH
#define CORE_PARTICLE
#endif

View File

@ -0,0 +1,168 @@
#ifndef __P_CALLBACK_OBJECT_H__
#define __P_CALLBACK_OBJECT_H__
#include <xBitSet.h>
#include "vtInterfaceEnumeration.h"
class pWheelContactModify;
class pCollisionsEntry;
class pTriggerEntry;
class pContactModifyData;
class pWheelContactModifyData;
class MODULE_API pCallbackObject
{
public:
pCallbackObject()
{
preScript = -1;
postScript = -1;
callMask = 0;
overrideMask = -1;
contactScript = -1;
rayCastScript = -1;
wheelContactScript = -1;
triggerScript = -1;
triggerEventMask = 0 ;
collisionEventMask = 0 ;
}
int contactScript;
int rayCastScript;
int wheelContactScript;
int triggerScript;
int jointBreakScript;
int collisionEventMask;
int contactModificationScript;
int& getCollisionEventMask() { return collisionEventMask; }
void setCollisionEventMask(int val) { collisionEventMask = val; }
int triggerEventMask;
int& getTriggerEventMask() { return triggerEventMask; }
void setTriggerEventMask(int val) { triggerEventMask = val; }
// virtual void advanceTime(float lastDeltaMS);
//----------------------------------------------------------------
//
// generics
//
int overrideMask;
int& getOverrideMask() { return overrideMask; }
void setOverrideMask(int val) { overrideMask = val; }
xBitSet callMask;
xBitSet& getCallMask() { return callMask; }
void setCallMask(int val) { callMask = val; }
int preScript;
int& getPreScript() { return preScript; }
void setPreScript(int val) { preScript = val; }
int postScript;
int& getPostScript() { return postScript; }
void setPostScript(int val) { postScript = val; }
virtual void processPostScript(){};
virtual void processPreScript(){};
virtual int onPreProcess(){ return -1;};
virtual int onPostProcess(){return -1;};
//----------------------------------------------------------------
//
// generic contact call
//
int getContactScript() const { return contactScript; }
virtual void setContactScript(int behaviorID,int eventMask)
{
contactScript = behaviorID;
collisionEventMask = eventMask;
setFlag(getCallMask(),CB_OnContactNotify,behaviorID);
}
virtual int onContact(pCollisionsEntry *report){ return -1;};
//----------------------------------------------------------------
//
// raycast, unused !
//
int getRayCastScript() const { return rayCastScript; }
virtual void setRayCastScript(int val)
{
rayCastScript = val;
setFlag(getCallMask(),CB_OnRayCastHit,val);
}
virtual bool onRayCastHit(NxRaycastHit *report){ return false;};
//----------------------------------------------------------------
//
// trigger
//
int getTriggerScript() const { return triggerScript; }
virtual void setTriggerScript(int behaviorID,int eventMask,CK3dEntity *shapeReference = NULL)
{
triggerScript = behaviorID;
triggerEventMask = eventMask;
setFlag(getCallMask(),CB_OnTrigger,behaviorID);
}
virtual int onTrigger(pTriggerEntry *report){ return -1;};
//----------------------------------------------------------------
//
// trigger
//
int getJointBreakScript() const { return jointBreakScript; }
virtual void setJointBreakScript(int behaviorID,CK3dEntity *shapeReference = NULL)
{
jointBreakScript = behaviorID;
setFlag(getCallMask(),CB_OnJointBreak,behaviorID);
}
virtual int onJointBreak(pBrokenJointEntry *entry){ return -1;};
//----------------------------------------------------------------
//
// wheel related
//
int getWheelContactScript() const { return wheelContactScript; }
virtual void setWheelContactScript(int val) { wheelContactScript = val; }
virtual bool onWheelContact(CK3dEntity* wheelShapeReference, VxVector& contactPoint, VxVector& contactNormal, float& contactPosition, float& normalForce, CK3dEntity* otherShapeReference, int& otherShapeMaterialIndex){return true;}
virtual bool onWheelContactModify(int& changeFlags,pWheelContactModifyData* contact){ return -1;}
//----------------------------------------------------------------
//
// contact modification
//
int getContactModificationScript() const { return contactModificationScript; }
virtual void setContactModificationScript(int val)
{
contactModificationScript = val;
setFlag(getCallMask(),CB_OnContactModify,val);
}
virtual bool onContactConstraint(int& changeFlags,CK3dEntity *sourceObject,CK3dEntity *otherObject,pContactModifyData *data){ changeFlags = CMM_None; return true; };
int processOptions;
virtual int& getProcessOptions() { return processOptions; }
virtual void setProcessOptions(int val) { processOptions = val; }
protected:
private:
};
#endif

View File

@ -0,0 +1,244 @@
#ifndef __P_CALLBACK_SIGNATURE_H__
#define __P_CALLBACK_SIGNATURE_H__
#include "pCommon.h"
#include "IParameter.h"
#include "vtBBHelper.h"
#include "xDebugTools.h"
//----------------------------------------------------------------
//
// wheel contact modify callback inputs
//
typedef enum bInputsWheelContactModifyCallback
{
bbIWC_SrcObject,
bbIWC_Point,
bbIWC_Normal,
bbIWC_Position,
bbIWC_NormalForce,
bbIWC_OtherMaterialIndex,
bbIWC_Stub0,
bbIWC_Stub1,
};
static BBParameter pInMapWheelContactModifyCallback[]=
{
BB_PIN(bbIWC_SrcObject,CKPGUID_3DENTITY,"sourceObject",""),
BB_PIN(bbIWC_Point,CKPGUID_VECTOR,"point",""),
BB_PIN(bbIWC_Normal,CKPGUID_VECTOR,"normal",""),
BB_PIN(bbIWC_Position,CKPGUID_FLOAT,"position",""),
BB_PIN(bbIWC_NormalForce,CKPGUID_FLOAT,"normalForce",""),
BB_PIN(bbIWC_OtherMaterialIndex,CKPGUID_INT,"otherMaterialIndex",""),
BB_PIN(bbIWC_Stub0,CKPGUID_INT,"stub0",""),
BB_PIN(bbIWC_Stub1,CKPGUID_INT,"stub1",""),
};
//----------------------------------------------------------------
//
// wheel contact modify callback outputs
//
typedef enum bOutputsWheelContactModifyCallback
{
bbOWC_CreateContact,
bbOWC_ModificationFlags,
bbOWC_Point,
bbOWC_Normal,
bbOWC_Position,
bbOWC_NormalForce,
bbOWC_OtherMaterialIndex,
bbOWC_Stub0,
bbOWC_Stub1,
};
static BBParameter pOutMapWheelContactModifyCallback[]=
{
BB_PIN(bbOWC_CreateContact,CKPGUID_BOOL,"createContact",""),
BB_PIN(bbOWC_ModificationFlags,VTF_WHEEL_CONTACT_MODIFY_FLAGS,"modificationFlags",""),
BB_PIN(bbOWC_Point,CKPGUID_VECTOR,"_point",""),
BB_PIN(bbOWC_Normal,CKPGUID_VECTOR,"_normal",""),
BB_PIN(bbOWC_Position,CKPGUID_FLOAT,"_position",""),
BB_PIN(bbOWC_NormalForce,CKPGUID_FLOAT,"_normalForce",""),
BB_PIN(bbOWC_OtherMaterialIndex,CKPGUID_INT,"_otherMaterialIndex",""),
BB_PIN(bbOWC_Stub0,CKPGUID_INT,"_stub0",""),
BB_PIN(bbOWC_Stub1,CKPGUID_INT,"_stub1",""),
};
//----------------------------------------------------------------
//
// contact modify callback ( has input and output )
//
typedef enum bInputsContactModifyCallback
{
bbICM_SrcObject,
bbICM_OtherObject,
bbICM_MinImpulse,
bbICM_MaxImpulse,
bbICM_Error,
bbICM_Target,
bbICM_LP0,
bbICM_LP1,
bbICM_LO0,
bbICM_LO1,
bbICM_SF0,
bbICM_SF1,
bbICM_DF0,
bbICM_DF1,
bbICM_Restitution,
};
static BBParameter pInMapContactModifyCallback[]=
{
BB_PIN(bbICM_SrcObject,CKPGUID_3DENTITY,"sourceObject",""),
BB_PIN(bbICM_OtherObject,CKPGUID_3DENTITY,"otherObject",""),
BB_PIN(bbICM_MinImpulse,CKPGUID_FLOAT,"minImpulse",""),
BB_PIN(bbICM_MaxImpulse,CKPGUID_FLOAT,"maxImpulse",""),
BB_PIN(bbICM_Error,CKPGUID_VECTOR,"error",""),
BB_PIN(bbICM_Target,CKPGUID_VECTOR,"target",""),
BB_PIN(bbICM_LP0,CKPGUID_VECTOR,"localPosition0",""),
BB_PIN(bbICM_LP1,CKPGUID_VECTOR,"localPosition1",""),
BB_PIN(bbICM_LO0,CKPGUID_QUATERNION,"localOrientation0",""),
BB_PIN(bbICM_LO0,CKPGUID_QUATERNION,"localOrientation1",""),
BB_PIN(bbICM_SF0,CKPGUID_FLOAT,"staticFriction0",""),
BB_PIN(bbICM_SF1,CKPGUID_FLOAT,"staticFriction1",""),
BB_PIN(bbICM_DF0,CKPGUID_FLOAT,"dynamicFriction0",""),
BB_PIN(bbICM_DF0,CKPGUID_FLOAT,"dynamicFriction1",""),
BB_PIN(bbICM_DF0,CKPGUID_FLOAT,"restitution",""),
};
//----------------------------------------------------------------
//
// contact modify callback ( has input and output )
//
typedef enum bOutputsContactModifyCallback
{
bbOCM_ModifyFlags,
bbOCM_CreateContact,
bbOCM_MinImpulse,
bbOCM_MaxImpulse,
bbOCM_Error,
bbOCM_Target,
bbOCM_LP0,
bbOCM_LP1,
bbOCM_LO0,
bbOCM_LO1,
bbOCM_SF0,
bbOCM_SF1,
bbOCM_DF0,
bbOCM_DF1,
bbOCM_Restitution,
};
static BBParameter pOutMapContactModifyCallback[]=
{
BB_PIN(bbOCM_ModifyFlags,VTF_CONTACT_MODIFY_FLAGS,"_modifyFlags",""),
BB_PIN(bbOCM_CreateContact,CKPGUID_BOOL,"createContact",""),
BB_PIN(bbOCM_MinImpulse,CKPGUID_FLOAT,"_minImpulse",""),
BB_PIN(bbOCM_MaxImpulse,CKPGUID_FLOAT,"_maxImpulse",""),
BB_PIN(bbOCM_Error,CKPGUID_VECTOR,"_error",""),
BB_PIN(bbOCM_Target,CKPGUID_VECTOR,"_target",""),
BB_PIN(bbOCM_LP0,CKPGUID_VECTOR,"_localPosition0",""),
BB_PIN(bbOCM_LP1,CKPGUID_VECTOR,"_localPosition1",""),
BB_PIN(bbOCM_LO0,CKPGUID_QUATERNION,"_localOrientation0",""),
BB_PIN(bbOCM_LO0,CKPGUID_QUATERNION,"_localOrientation1",""),
BB_PIN(bbOCM_SF0,CKPGUID_FLOAT,"_staticFriction0",""),
BB_PIN(bbOCM_SF1,CKPGUID_FLOAT,"_staticFriction1",""),
BB_PIN(bbOCM_DF0,CKPGUID_FLOAT,"_dynamicFriction0",""),
BB_PIN(bbOCM_DF0,CKPGUID_FLOAT,"_dynamicFriction1",""),
BB_PIN(bbOCM_DF0,CKPGUID_FLOAT,"_restitution",""),
};
//----------------------------------------------------------------
//
// contact notify callback
//
typedef enum bInputsContactCallback
{
bbI_SrcObject,
bbI_EventType,
bbI_NormalForce,
bbI_FForce,
bbI_Point,
bbI_PointNormalForce,
bbI_FaceNormal,
bbI_FaceIndex,
bbI_Distance,
bbI_OtherObject,
};
static BBParameter pInMapContactCallback[]=
{
BB_PIN(bbI_SrcObject,CKPGUID_3DENTITY,"sourceObject",""),
BB_PIN(bbI_EventType,VTF_COLLISIONS_EVENT_MASK,"eventType",""),
BB_PIN(bbI_FaceNormal,CKPGUID_VECTOR,"sumNormalForce",""),
BB_PIN(bbI_FForce,CKPGUID_VECTOR,"sumFrictionForce",""),
BB_PIN(bbI_Point,CKPGUID_VECTOR,"point",""),
BB_PIN(bbI_PointNormalForce,CKPGUID_FLOAT,"pointNormalForce",""),
BB_PIN(bbI_FaceNormal,CKPGUID_VECTOR,"faceNormal",""),
BB_PIN(bbI_FaceIndex,CKPGUID_INT,"faceIndex",""),
BB_PIN(bbI_Distance,CKPGUID_FLOAT,"distance",""),
BB_PIN(bbI_OtherObject,CKPGUID_3DENTITY,"otherObject",""),
};
//----------------------------------------------------------------
//
// trigger
//
typedef enum bInputsTriggerCallback
{
bbIT_SrcObject,
bbIT_EventType,
bbIT_OtherObject,
};
static BBParameter pInMapTriggerCallback[]=
{
BB_PIN(bbIT_SrcObject,CKPGUID_3DENTITY,"sourceObject",""),
BB_PIN(bbIT_EventType,VTF_TRIGGER,"eventType",""),
BB_PIN(bbIT_OtherObject,CKPGUID_3DENTITY,"otherObject",""),
};
//----------------------------------------------------------------
//
// trigger
//
typedef enum bInputsRaycastHitCallback
{
bbRH_SrcObject,
bbRH_OtherObject,
bbRH_WorldImpact,
bbRH_WorldNormal,
bbRH_FIndex,
bbRH_FInternalIdex,
bbRH_Distance,
bbRH_UV,
bbRH_Material,
bbRH_Flags,
};
typedef enum bInputsJointBreakCallback
{
bbJB_SrcObject,
bbJB_OtherObject,
bbJB_Force,
};
static BBParameter pInMapRaycastHitCallback[]=
{
BB_PIN(bbRH_SrcObject,CKPGUID_3DENTITY,"sourceObject",""),
BB_PIN(bbRH_OtherObject,CKPGUID_3DENTITY,"otherObject",""),
BB_PIN(bbRH_WorldImpact,CKPGUID_VECTOR,"impact",""),
BB_PIN(bbRH_WorldNormal,CKPGUID_VECTOR,"normal",""),
BB_PIN(bbRH_FIndex,CKPGUID_INT,"faceIndex",""),
BB_PIN(bbRH_FInternalIdex,CKPGUID_INT,"faceInternalIndex",""),
BB_PIN(bbRH_Distance,CKPGUID_FLOAT,"distance",""),
BB_PIN(bbRH_UV,CKPGUID_2DVECTOR,"uv",""),
BB_PIN(bbRH_Material,CKPGUID_INT,"material",""),
BB_PIN(bbRH_Flags,VTF_RAY_HINTS,"flags",""),
};
static BBParameter pInMapJointBreakCallback[]=
{
BB_PIN(bbJB_SrcObject,CKPGUID_3DENTITY,"sourceObject",""),
BB_PIN(bbJB_OtherObject,CKPGUID_3DENTITY,"otherObject",""),
BB_PIN(bbJB_Force,CKPGUID_FLOAT,"Break Force",""),
};
#endif

View File

@ -0,0 +1,41 @@
#ifndef __P_CONFIG_H__
#define __P_CONFIG_H__
#define SESSION_MAX 9000000
#define START_MONTH 7
#define END_MONTH 12
/*
//////////////////////////////////////////////////////////////////////////
#if defined (ReleaseDemo)
#define SESSION_LIMIT
#define MONTH_LIMIT
#ifndef AUTHOR
#define AUTHOR
#endif
#define DEMO_ONLY
#endif
#if defined (ReleaseFree)
#define MONTH_LIMIT
#define AUTHOR
#endif
#if defined (ReleaseRedist)
#define REDIST
#undef DEMO_ONLY
#endif
#if defined (ReleaseDongle)
#define DONGLE_VERSION
#undef DEMO_ONLY
#endif
*/
#endif

View File

@ -0,0 +1,6 @@
#ifndef __P_CONSTANTS_H__
#define __P_CONSTANTS_H__
#endif

View File

@ -0,0 +1,13 @@
#ifndef __PCROSS_TYPES_H__
#define __PCROSS_TYPES_H__
#include "pTypes.h"
//#include "NxWheelDesc.h"
#include "VxMath.h"
#include "XString.h"
#include "CK3DEntity.h"
#include "pVTireFunction.h"
#endif

View File

@ -0,0 +1,22 @@
#ifndef __P_ERRROR_STREAM_H__
#define __P_ERRROR_STREAM_H__
#include "pTypes.h"
#include "NxUserOutputStream.h"
namespace vtAgeia
{
class pErrorStream : public NxUserOutputStream
{
public:
pErrorStream(){}
void reportError(NxErrorCode e, const char* message, const char* file, int line);
NxAssertResponse reportAssertViolation(const char* message, const char* file, int line);
void print(const char* message);
};
}
#endif

View File

@ -0,0 +1,21 @@
#ifndef __PLOGGER_H__
#define __PLOGGER_H__
#include "pTypes.h"
class pLogger
{
public:
pLogger();
~pLogger();
pErrorStream * getErrorStream() const { return mErrorStream; }
void setErrorStream(pErrorStream * val) { mErrorStream = val; }
protected:
pErrorStream *mErrorStream;
};
#endif

View File

@ -0,0 +1,46 @@
#ifndef __XMATH_TOOLS_H__
#define __XMATH_TOOLS_H__
#include "VxMath.h"
#include "NxQuat.h"
namespace pMath
{
VxVector getFromStream(NxVec3 source);
VxQuaternion getFromStream(NxQuat source);
NxVec3 getFromStream(VxVector source);
NxQuat getFromStream(VxQuaternion source);
/*__inline NxVec3 getFrom(const VxVector& sourcein)
{
return NxVec3(sourcein.x,sourcein.y,sourcein.z);
}*/
__inline NxVec3 getFrom(VxVector source)
{
NxVec3 target(0.0f,0.0f,0.0f);
target.x = source.x;
target.y = source.y;
target.z = source.z;
return NxVec3(source.x,source.y,source.z);
}
NxQuat getFrom(VxQuaternion source);
VxQuaternion getFrom(NxQuat source);
__inline VxVector getFrom(NxVec3 source)
{
VxVector result;
source.get(result.v);
return result;
}
}
#endif

View File

@ -0,0 +1,30 @@
#ifndef __P_MISC_H__
#define __P_MISC_H__
#include "vtPhysXBase.h"
namespace vtAgeia
{
VxVector BoxGetZero(CK3dEntity* ent);
void SetEulerDirection(CK3dEntity* ent,VxVector direction);
XString getEnumDescription(CKParameterManager* pm,CKGUID parGuide,int parameterSubIndex);
XString getEnumDescription(CKParameterManager* pm,CKGUID parGuide);
int getEnumIndex(CKParameterManager* pm,CKGUID parGuide,XString enumValue);
int getHullTypeFromShape(NxShape *shape);
CKGUID getEnumGuid(XString name);
int getNbOfPhysicObjects(CK3dEntity *parentObject,int flags=0);
bool calculateOffsets(CK3dEntity*source,CK3dEntity*target,VxQuaternion &quat,VxVector& pos);
bool isChildOf(CK3dEntity*parent,CK3dEntity*test);
CK3dEntity* findSimilarInSourceObject(CK3dEntity *parentOriginal,CK3dEntity* partentCopied,CK3dEntity *copiedObject,CK3dEntity*prev=NULL);
CK3dEntity *getEntityFromShape(NxShape* shape);
}
#endif

View File

@ -0,0 +1,254 @@
#ifndef __P_SDKP_SDK_PARAMETER_H__
#define __P_SDKP_SDK_PARAMETER_H__
/** \addtogroup PhysicSDK
@{
*/
/**
\brief Parameters enums to be used as the 1st arg to setParameter or getParameter.
@see PhysicManager.setParameter() PhysicManager.getParameter()
*/
typedef enum pSDKParameter
{
/* RigidBody-related parameters */
/**
\brief Default value for pShape::skinWidth.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 0.025<br>
<b>Unit:</b> distance.
@see pShape.setSkinWidth
*/
pSDKP_SkinWidth = 1,
/**
\brief The default linear velocity, squared, below which objects start going to sleep.
Note: Only makes sense when the pSDKP_BF_ENERGY_SLEEP_TEST is not set.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> (0.15*0.15)
*/
pSDKP_DefaultSleepLinVelSquared = 2,
/**
\brief The default angular velocity, squared, below which objects start going to sleep.
Note: Only makes sense when the pSDKP_BF_ENERGY_SLEEP_TEST is not set.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> (0.14*0.14)
*/
pSDKP_DefaultSleepAngVelSquared = 3,
/**
\brief A contact with a relative velocity below this will not bounce.
<b>Range:</b> (-inf, 0]<br>
<b>Default:</b> -2
@see pMaterial
*/
pSDKP_BounceThreshold = 4,
/**
\brief This lets the user scale the magnitude of the dynamic friction applied to all objects.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 1
@see pMaterial
*/
pSDKP_DynFrictScaling = 5,
/**
\brief This lets the user scale the magnitude of the static friction applied to all objects.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 1
@see pMaterial
*/
pSDKP_StaFrictionScaling = 6,
/**
\brief See the comment for pRigidBody::setMaxAngularVelocity() for details.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 7
@see pRigidBody.setMaxAngularVelocity()
*/
pSDKP_MaxAngularVelocity = 7,
/* Collision-related parameters: */
/**
\brief Enable/disable continuous collision detection (0.0f to disable)
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 0.0
@see NxPhysicsSDK.createCCDSkeleton()
*/
pSDKP_ContinuousCD = 8,
/* General parameters and new parameters */
/**
\brief Used to enable adaptive forces to accelerate convergence of the solver.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 1.0
*/
pSDKP_AdaptiveForce = 68,
/**
\brief Controls default filtering for jointed bodies. True means collision is disabled.
<b>Range:</b> {true, false}<br>
<b>Default:</b> true
@see pSDKP_JF_CollisionEnabled
*/
pSDKP_CollVetoJointed = 69,
/**
\brief Controls whether two touching triggers generate a callback or not.
<b>Range:</b> {true, false}<br>
<b>Default:</b> true
@see NxUserTriggerReport
*/
pSDKP_TriggerTriggerCallback = 70,
pSDKP_SelectHW_Algo = 71,
/**
\brief Distance epsilon for the CCD algorithm.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 0.01
*/
pSDKP_CCDEpsilon = 73,
/**
\brief Used to accelerate solver.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 0
*/
pSDKP_SolverConvergenceThreshold = 74,
/**
\brief Used to accelerate HW Broad Phase.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 0.001
*/
pSDKP_BBoxNoiseLevel = 75,
/**
\brief Used to set the sweep cache size.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 5.0
*/
pSDKP_ImplicitSweepCacheSize = 76,
/**
\brief The default sleep energy threshold. Objects with an energy below this threshold are allowed
to go to sleep.
Note: Only used when the pSDKP_BF_ENERGY_SLEEP_TEST flag is set.
<b>Range:</b> [0, inf)<br>
<b>Default:</b> 0.005
*/
pSDKP_DefaultSleepEnergy = 77,
/**
\brief Constant for the maximum number of packets per fluid. Used to compute the fluid packet buffer size in NxFluidPacketData.
<b>Range:</b> [925, 925]<br>
<b>Default:</b> 925
@see NxFluidPacketData
*/
pSDKP_ConstantFluidMaxPackets = 78,
/**
\brief Constant for the maximum number of new fluid particles per frame.
<b>Range:</b> [4096, 4096]<br>
<b>Default:</b> 4096
*/
pSDKP_ConstantFluidMaxParticlesPerStep = 79,
/**
\brief [Experimental] Disables scene locks when creating/releasing meshes.
Prevents the SDK from locking all scenes when creating and releasing triangle meshes, convex meshes, height field
meshes, softbody meshes and cloth meshes, which is the default behavior. Can be used to improve parallelism but beware
of possible side effects.
\warning Experimental feature.
*/
pSDKP_AsynchronousMeshCreation = 96,
/**
\brief Epsilon for custom force field kernels.
This epsilon is used in custom force field kernels (NxSwTarget). Methods like recip()
or recipSqrt() evaluate to zero if their input is smaller than this epsilon.
<br>
*/
pSDKP_ForceFieldCustomKernelEpsilon = 97,
/**
\brief Enable/disable improved spring solver for joints and wheelshapes
This parameter allows to enable/disable an improved version of the spring solver for joints and wheelshapes.
\warning
The parameter is introduced for legacy purposes only and will be removed in future versions (such that
the improved spring solver will always be used).
\note
Changing the parameter will only affect newly created scenes but not existing ones.
<b>Range:</b> {0: disabled, 1: enabled}<br>
<b>Default:</b> 1
*/
pSDKP_ImprovedSpringSolver = 98,
/**
\brief This is not a parameter, it just records the current number of parameters (as max(NxParameter)+1) for use in loops.
When a new parameter is added this number should be assigned to it and then incremented.
*/
pSDKP_PARAMS_NUM_VALUES = 99,
pSDKP_PARAMS_FORCE_DWORD = 0x7fffffff
};
/** @} */
#endif

View File

View File

@ -0,0 +1,75 @@
#ifndef __PPREREQS_H_
#define __PPREREQS_H_
class PhysicManager;
//################################################################
//
// Physic Types
//
class pContactReport;
class pTriggerReport;
class pRayCastReport;
class pRigidBody;
class pObjectDescr;
class pJointSettings;
class pJoint;
class pJointBall;
class pJointFixed;
class pJointPulley;
class pJointRevolute;
class pJointDistance;
class pJointD6;
class pJointPrismatic;
class pJointCylindrical;
class pClothDesc;
class pCloth;
class pFluid;
class pFluidDesc;
class pFluidEmitterDesc;
class pFluidEmitter;
class pFluidRenderSettings;
class pSerializer;
class pWorld;
class pFactory;
class pSoftBody;
class pWheelDescr;
class pWheel;
class pWheel1;
class pWheel2;
class pVecicleDescr;
class pVehicle;
class pVehicleMotor;
class pVehicleGears;
class pVehicleMotorDesc;
class pVehicleGearDesc;
class pBoxController;
namespace vtAgeia
{
class pWorldSettings;
class pSleepingSettings;
class pShape;
class pErrorStream;
class pCollisionsListener;
}
class pLogger;
using namespace vtAgeia;
#endif

View File

@ -0,0 +1,96 @@
#ifndef __P_REFERENCED_OBJECT_H__
#define __P_REFERENCED_OBJECT_H__
template<class EngineObject,class ImplementationObject>class MODULE_API pStoredObjectAssociation
{
public:
//xEngineObjectAssociation() : mInternalId(-1) , mClassId(-1) {};
//xEngineObjectAssociation(EngineObject _Object,ImplementationObject _ImplObject,int _EngineObjectId) : mEngineObject(_Object) , mImplementationObject(_ImplObject) , mInternalId(_EngineObjectId) { }
//xEngineObjectAssociation< (EngineObject _Object,ImplementationObject _ImplObject,int _EngineObjectId){}
int getInternalId() const { return mInternalId; }
void setInternalId(int val) { mInternalId = val; }
int getClassId() const { return mClassId; }
void setClassId(int val) { mClassId = val; }
bool existsInCore();
virtual void onCreate(){};
virtual void onCopy(int oldId){};
virtual void onRemove(){};
virtual void onDelete(){};
virtual void onCheck(){};
//operator T(){ return mObject; }
protected:
private:
int mClassId;
int mInternalId;
EngineObject mEngineObject;
ImplementationObject mImplementationObject;
};
template<class T>class MODULE_API xImplementationObject
{
public:
//xLinkedObjectStorage() : mInternalId(-1) , mClassId(-1) {};
typedef void* xImplementationObject<T>::*StoragePtr;
xImplementationObject(){}
xImplementationObject(StoragePtr storage)
{
}
T getImpl() { return mObject; }
protected:
private:
T mObject;
StoragePtr mStorage;
};
template<class T>class MODULE_API xEngineObjectAssociation
{
public:
xEngineObjectAssociation() :
mInternalId(-1) , mClassId(-1) {};
xEngineObjectAssociation(T _Object,int _InternalId) :
mObject(_Object) , mInternalId(_InternalId) { }
int getInternalId() const { return mInternalId; }
void setInternalId(int val) { mInternalId = val; }
int getClassId() const { return mClassId; }
void setClassId(int val) { mClassId = val; }
bool existsInCore();
virtual void onCreate(){};
virtual void onCopy(int oldId){};
virtual void onRemove(){};
virtual void onDelete(){};
virtual void onCheck(){};
//operator T(){ return mObject; }
protected:
private:
int mClassId;
int mInternalId;
T mObject;
};
#endif

View File

@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////
// dSleepingSettings.h
// Implementation of the Class dSleepingSettings
// Created on: 18-Jan-2008 17:15:31
///////////////////////////////////////////////////////////
#if !defined(EA_7D481C15_2B93_4925_B66E_6FAF4DED2A2A__INCLUDED_)
#define EA_7D481C15_2B93_4925_B66E_6FAF4DED2A2A__INCLUDED_
namespace vtAgeia
{
class pSleepingSettings
{
public:
pSleepingSettings()
{
m_AngularThresold = 0.1f;
m_LinearThresold = 0.1f;
m_SleepSteps = 0 ;
m_AutoSleepFlag = 1;
m_SleepTime = 0.0f;
}
virtual ~pSleepingSettings(){}
int SleepSteps() const { return m_SleepSteps; }
void SleepSteps(int val) { m_SleepSteps = val; }
float AngularThresold() const { return m_AngularThresold; }
void AngularThresold(float val) { m_AngularThresold = val; }
int AutoSleepFlag() const { return m_AutoSleepFlag; }
void AutoSleepFlag(int val) { m_AutoSleepFlag = val; }
float LinearThresold() const { return m_LinearThresold; }
void LinearThresold(float val) { m_LinearThresold = val; }
float m_AngularThresold;
int m_AutoSleepFlag;
float m_LinearThresold;
int m_SleepSteps;
float m_SleepTime;
};
}
#endif // !defined(EA_7D481C15_2B93_4925_B66E_6FAF4DED2A2A__INCLUDED_)

View File

@ -0,0 +1,386 @@
/********************************************************************
created: 2009/02/17
created: 17:2:2009 8:26
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\include\core\Common\pTypes.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\include\core\Common
file base: pTypes
file ext: h
author: Günter Baumgart
purpose: Type definitions, Function pointers
*********************************************************************/
#ifndef __P_TYPES_H__
#define __P_TYPES_H__
#include "vtPhysXBase.h"
#include "CKAll.h"
//################################################################
//
// Common used types for rigid bodies and joints
//
/**
\brief Describes a joint spring. The spring is implicitly integrated, so even high spring and damper coefficients should be robust.
pSpring is registered as custom structure #pJSpring and can be accessed or modified through parameter operations.<br>
*/
class pSpring
{
public:
/**
Damper coefficient
*/
float damper;
/**
Spring coefficient
*/
float spring;
/**
Target value (angle/position) of spring where the spring force is zero.
*/
float targetValue;
pSpring()
{
damper = 0.0f;
spring = 0.0f;
targetValue = 0.0f;
}
pSpring(float _damper,float _spring,float _targetValue)
{
damper = _damper;
spring = _spring;
targetValue = _targetValue;
}
};
/** \addtogroup Collision
@{
*/
/**
\brief 128-bit mask used for collision filtering.
The collision filtering equation for 2 shapes S0 and S1 is:
<pre> (G0 op0 K0) op2 (G1 op1 K1) == b </pre>
with
<ul>
<li> G0 = pGroupsMask for shape S0. See ::setGroupsMask </li>
<li> G1 = pGroupsMask for shape S1. See ::setGroupsMask </li>
<li> K0 = filtering constant 0. See ::setFilterConstant0 </li>
<li> K1 = filtering constant 1. See ::setFilterConstant1 </li>
<li> b = filtering boolean. See ::setFilterBool </li>
<li> op0, op1, op2 = filtering operations. See ::setFilterOps </li>
</ul>
If the filtering equation is true, collision detection is enabled.
@see pWorld::setFilterOps()
*/
class pGroupsMask
{
public:
API_INLINE pGroupsMask() {}
API_INLINE ~pGroupsMask() {}
int bits0, bits1, bits2, bits3;
};
class pRay
{
public:
VxVector orig;
VxVector dir;
};
class pRaycastHit
{
public:
float distance;
CK3dEntity *shape;
VxVector worldImpact;
VxVector worldNormal;
int faceID;
int internalFaceID;
float u;
float v;
int materialIndex;
int flags;
pRaycastHit()
{
distance = 0.0;
shape = NULL;
u = 0.0f;
v= 0.0f;
faceID = 0 ;
materialIndex = 0 ;
flags = 0;
}
};
/**
\brief Class for describing rigid bodies ccd settings.
*/
class pCCDSettings
{
public :
bool isValid();
bool setToDefault();
bool evaluate(CKBeObject*referenceObject);
float motionThresold;
int flags;
CK_ID meshReference;
float scale;
pCCDSettings()
{
motionThresold = 0.0;
flags = 0 ;
meshReference =0;
scale = 1.0f;
}
};
/**
\brief Class for describing rigid bodies or its sub shapes collisions settings.
\sa #pRigidBody::updateCollisionSettings()
*/
class pCollisionSettings
{
public:
bool isValid();
bool setToDefault();
/**
\brief collisions group the shape belongs to
- <b>Range:</b> [0,32]
- <b>Default:</b> 0
*/
int collisionGroup;
/**
\brief 128-bit mask used for collision filtering
- <b>Range:</b> [0,4x4 bits]
- <b>Default:</b> all off
*/
pGroupsMask groupsMask;
/**
\brief Additional collisions offset
- <b>Range:</b> [0,1.0f]
- <b>Default:</b>0.25f
- Can NOT altered after creation
*/
float skinWidth;
pCollisionSettings()
{
collisionGroup = 0;
skinWidth = 0.025f;
}
};
//@}
typedef std::vector<NxRaycastHit*>pRayCastHits;
/**
\brief Class for describing rigid bodies optimization.
*/
class MODULE_API pOptimization
{
public :
bool isValid();
bool setToDefault();
/**
\brief Flags to lock a rigid body in certain degree of freedom. See also #pRigidBody::lockTransformation
*/
BodyLockFlags transformationFlags;
/**
\brief Sets the linear damping coefficient. Zero represents no damping. The damping coefficient must be nonnegative. See pRigidBody::setLinearDamping
*/
float linDamping;
/**
\brief Sets the angular damping coefficient.Zero represents no damping. The damping coefficient must be nonnegative.See pRigidBody::setAngularDamping
*/
float angDamping;
/**
\copydoc pRigidBody::setSolverIterationCount
*/
int solverIterations;
/**
\copydoc pRigidBody::setDominanceGroup
*/
int dominanceGroup;
/**
\brief Not Implemented
*/
int compartmentGroup;
/**
\copydoc pRigidBody::setSleepEnergyThreshold
*/
float sleepEnergyThreshold;
/**
\copydoc pRigidBody::setSleepLinearVelocity
*/
float linSleepVelocity;
/**
\copydoc pRigidBody::setSleepAngularVelocity
*/
float angSleepVelocity;
pOptimization()
{
transformationFlags = (BodyLockFlags)0;
linDamping = angDamping = 0.0f;
solverIterations = 24 ;
dominanceGroup=0;
compartmentGroup=0;
sleepEnergyThreshold =0.0f;
linSleepVelocity = angSleepVelocity = 0.0;
}
};
/**
\brief Class for describing a shape's surface properties.
*/
class MODULE_API pMaterial
{
public :
bool isValid();
/**
\brief Flags, a combination of the bits defined by the enum ::pMaterialFlag <br>
- <b>Default:</b> 0
@see MaterialFlags
*/
int flags;
/**
\brief Coefficient of dynamic friction. If set to greater than staticFriction, <br>
the effective value of staticFriction will be increased to match. if flags & MF_Anisotropic is set, then this value is used for the primary direction of anisotropy (U axis)<br>
- <b>Range:</b> [0,+inf)
- <b>Default:</b> [0)
*/
float dynamicFriction;
/**
\brief Coefficient of static friction. If flags & MF_Anisotropic is set,<br>
then this value is used for the primary direction of anisotropy (U axis)
*/
float staticFriction;
/**
\brief Coefficient of restitution. Makes the object bounce as little as possible, higher values up to 1.0 result in more bounce. Note that values close to or above 1 may cause stability problems and/or increasing energy.
- <b>Range:</b> [0,1)
- <b>Default:</b> [0)
*/
float restitution;
/**
\brief Anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy. This is only used if flags & MF_Anisotropic is set.
- <b>Range:</b> [0,inf)
- <b>Default:</b> [0)
*/
float dynamicFrictionV;
/**
\brief Anisotropic static friction coefficient for along the secondary (V) axis of anisotropy. This is only used if flags & MF_Anisotropic is set.
- <b>Range:</b> [0,inf)
- <b>Default:</b> [0)
*/
float staticFrictionV;
/**
\brief Friction combine mode. See the enum CombineMode .
- <b>Range:</b> [CombineMode)
- <b>Default:</b> [CM_Average)
*/
CombineMode frictionCombineMode;
/**
\brief Restitution combine mode. See the enum CombineMode .
- <b>Range:</b> [CombineMode)
- <b>Default:</b> [CM_Average)
*/
CombineMode restitutionCombineMode;
/**
\brief shape space direction (unit vector) of anisotropy. This is only used if flags & MF_Anisotropic is set.
- <b>Range:</b> [vector)
- <b>Default:</b> [1.0f,0.0f,0.0f)
*/
VxVector dirOfAnisotropy;
/**
\brief unique name of the material
*/
const char* name;
/**
\brief Enumeration to identify a material setup from PhysicDefaults.xml. Is being populated automatically on reset.
- <b>Range:</b> [0,Number of material setups in xml file)
- <b>Default:</b> [NONE)
*/
int xmlLinkID;
int getNxMaterialID() const { return mNxMaterialID; }
void setNxMaterialID(int val) { mNxMaterialID = val; }
pMaterial()
{
setToDefault();
}
__inline void setToDefault()
{
dynamicFriction = 0.0f;
staticFriction = 0.0f;
restitution = 0.0f;
dynamicFrictionV= 0.0f;
staticFrictionV = 0.0f;
dirOfAnisotropy = VxVector(1,0,0);
flags = 0;
frictionCombineMode = CM_Average;
restitutionCombineMode = CM_Average;
xmlLinkID =0;
name = "";
}
private :
int mNxMaterialID;
};
#endif

View File

@ -0,0 +1,45 @@
#ifndef __P_VEHICLE_ALL_H__
#define __P_VEHICLE_ALL_H__
#include <stdlib.h>
#include <limits.h>
//using namespace std::numeric_limits;
#define XFLT_EPSILON_MIN 0.00001f
#define XFLT_EPSILON_MAX FLT_MAX
#define xCheckFloat(n) ((fabs(n) > XFLT_EPSILON_MIN && n < XFLT_EPSILON_MAX ) ? n : 0.0f)
typedef enum pVehicleProcessoptions
{
pVPO_Lat_Damping=(1<<0),
pVPO_Long_Damping=(1<<1),
pVPO_SA_Damping=(1<<2),
pVPO_SA_Delay=(1<<3),
pVPO_SV_Tansa=(1<<4),
pVPO_SA_DownSettle=(1<<5),
pVPO_CheckLowSpeed=(1<<6),
pVPO_Wheel_LockAdjust=(1<<7),
pVPO_Wheel_UsePHYSX_Load=(1<<8),
pVPO_Wheel_UsePHYSX_CONTACT_DATA=(1<<9),
pVPO_Wheel_DoGregor=(1<<10),
pVPO_Wheel_DampVerticalVelocityReversal=(1<<11),
pVPO_Wheel_IntegrateImplicitVertical=(1<12),
pVPO_Wheel_DiffDirect=(1<<13),
pVPO_Engine_UseHardRevlimit=(1<<14),
pVPO_Forces_No_Lateral=(1<<15),
};
#include "pEngine.h"
#include "pVehicleTypes.h"
#include "pGearbox.h"
#include "pDifferential.h"
#include "pSteer.h"
#endif

View File

@ -0,0 +1,103 @@
#ifndef __QLIB_TIMER_H
#define __QLIB_TIMER_H
#include <BaseMacros.h>
#include <time.h>
#ifdef linux
#include <sys/time.h>
#endif
// Vertical trace resolution?
//#define USE_VTRACE
#if defined(__sgi)
// UST nanosecond resolution?
#define USE_UST
#endif
#if defined(linux)
// time() usage? Bad resolution and misplaced offsets within the second
#define USE_GETTIMEOFDAY
#endif
#if defined(WIN32)
#define USE_OS_TICK // Use milliseconds NT timer
#endif
#ifndef ulong
typedef unsigned long ulong;
#endif
class MODULE_API QTimer
{
private:
#ifdef USE_TIME
time_t base_secs;
int ticks; // Seconds (not very high frequency!)
#endif
#ifdef USE_GETTIMEOFDAY
int ticks;
struct timeval tv; // Should do microsecs
int base_usecs; // Base time in usecs
struct timeval tvBase; // Base time
#endif
#ifdef USE_OS_TICK
int ticks;
int baseTicks;
#endif
#if defined(__sgi)
ulong base_secs,base_micros; // Intuition (Amiga) style
#ifdef USE_UST
uint64 ticks; // UST ticks go FAST!
uint64 baseUST; // UST timing
#endif
#ifdef USE_VTRACE
int baseVCount; // Vertical retraces base
int ticks; // Current #ticks recorded
#endif
#endif
bool isRunning; // Recording time?
//QClassType ID() const { return QOBJ_TIMER; }
protected:
void ResetBase(); // Base GLX vtrace counter
void UpdateTicks();
public:
QTimer();
~QTimer();
bool IsRunning(){ return isRunning; }
void Reset();
void Start();
void Stop();
// Get time
void GetTime(ulong *secs,ulong *micros);
ulong GetSeconds();
int GetMilliSeconds();
int GetMicroSeconds();
#ifdef WIN32
int GetTicks();
#else
// SGI
#ifdef USE_UST
uint64 GetTicks();
#else
int GetTicks();
#endif
#endif
// Adjust time
void AdjustMilliSeconds(int delta);
// Higher level
void WaitForTime(int secs,int msecs=0);
};
#endif

View File

@ -0,0 +1,19 @@
#ifndef __VC_WARNINGS_H__
#define __VC_WARNINGS_H__
#pragma warning( disable : 4311 )
#pragma warning( disable : 4244 )
#pragma warning( disable : 4267 )
#pragma warning( disable : 4275 )
#pragma warning( disable : 4311)
#pragma warning( disable : 4099)
#pragma warning( disable : 4996)
#pragma warning( disable : 4430)
#endif

View File

@ -0,0 +1,15 @@
#ifndef __VT_AGEIA_H__
#define __VT_AGEIA_H__
#include "pFactory.h"
#include "pWorldSettings.h"
#include "pSleepingSettings.h"
#include "pWorld.h"
#include "pRigidBody.h"
#include "pJoint.h"
#endif

View File

@ -0,0 +1,90 @@
/********************************************************************
created: 2007/11/23
created: 23:11:2007 12:21
filename: e:\ProjectRoot\current\vt_plugins\vtOpenDynamics\Manager\vtOdeTypes.h
file path: e:\ProjectRoot\current\vt_plugins\vtOpenDynamics\Manager
file base: vtOdeTypes
file ext: h
author: mc007
purpose:
*********************************************************************/
#ifndef __VTODE_TYPES_H_
#define __VTODE_TYPES_H_
#include "pSleepingSettings.h"
#include "pWorldSettings.h"
typedef CK3dEntity* vt3DObjectType;
typedef VxVector xVector3;
struct vtHeightFieldData
{
/*
int wS,dS,warp;
float w,d,thickness,scale;
int ID,tID;
float rF,gF,bF,aF;
float maxH;
CK_ID maxHReference;
dHeightfieldDataID heightFieldData;
vtHeightFieldData(float _w,float _d,float _thickness,float _scale,int _wS,int _dS,int _warp,int _ID,int _texID,float _rF,float _gF,float _bF,float _aF) :
w(_w) , d(_d) , thickness(_thickness) , scale(_scale ) ,warp(_warp) , ID(_ID) , wS(_wS) , dS(_dS) ,tID(_texID) , rF(_rF) , gF(_gF) ,bF(_bF) , aF(_aF)
{
heightFieldData = NULL;
}
float lastH;
Vx2DVector lastHCoord;
int lastColor;
*/
};
struct vtWorldInfo
{
/* VxVector Gravity;
float CFM;
float ERP;
float StepResFactor;
int MaxIterations;
int AutoEnableDepth;
float MaximumContactCorrectVelocity;
float ContactSurfaceLayer;
float rF,gF,bF,aF;
vtWorldInfo()
{
Gravity.x = 0.0f;
Gravity.y = -10.0f;
Gravity.z = 0.0f;
CFM = 0.00000001f;
ERP = 0.9f;
AutoEnableDepth = 1;
MaxIterations = 100;
StepResFactor = 0.0085f;
}
vtWorldInfo(VxVector _g,float _CFM,float _ERP,int _Auto,int _Max,float _StepResFactor,float _rF,float _gF,float _bF,float _aF)
: Gravity(_g) , CFM(_CFM) , ERP(_ERP) , AutoEnableDepth(_Auto) , MaxIterations(_Max) , StepResFactor(_StepResFactor) , rF(_rF) , gF(_gF),bF(_bF ),aF(_aF)
{
}
*/
};
//////////////////////////////////////////////////////////////////////////
struct vtIntersectionInfo
{
/*
vt3DObjectType m_ObjectPart;
vt3DObjectType m_TouchedObstacle;
vt3DObjectType m_TouchedSubObstacle;
xVector3 m_position;
xVector3 m_Normal;
float m_Depth;
int m_num;
*/
};
#endif

View File

@ -0,0 +1,85 @@
#ifndef __P_ATTRIBUTE_HELPER_H__
#define __P_ATTRIBUTE_HELPER_H__
#define PHYSIC_BODY_CAT "Physic"
#define ATT_FUNC_TABLE_SIZE 12
#include "vtParameterGuids.h"
#include "pManagerTypes.h"
//################################################################
//
// Declaration of rigid body related attribute callback function
//
int registerRigidBody(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
//################################################################
//
// Declaration of various joint attribute callback functions
//
int registerJDistance(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJFixed(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJBall(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJPrismatic(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJCylindrical(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJPointInPlane(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJPointOnLine(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJRevolute(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJD6(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJD6Drive(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
int registerJLimitPlane(CK3dEntity *target,int attributeType,bool set,bool isPostJob);
//----------------------------------------------------------------
//
//! \brief The global map of parameter type and registration function
//
static ObjectRegistration attributeFunctionMap[] =
{
ObjectRegistration(VTS_PHYSIC_ACTOR,registerRigidBody),
ObjectRegistration(VTS_JOINT_DISTANCE,registerJDistance),
ObjectRegistration(VTS_JOINT_FIXED,registerJFixed),
ObjectRegistration(VTS_JOINT_BALL,registerJBall),
ObjectRegistration(VTS_JOINT_PRISMATIC,registerJPrismatic),
ObjectRegistration(VTS_JOINT_POINT_IN_PLANE,registerJPointInPlane),
ObjectRegistration(VTS_JOINT_POINT_ON_LINE,registerJPointOnLine),
ObjectRegistration(VTS_JOINT_CYLINDRICAL,registerJCylindrical),
ObjectRegistration(VTS_JOINT_REVOLUTE,registerJRevolute),
ObjectRegistration(VTS_JOINT_D6,registerJD6),
ObjectRegistration(VTS_JOINT_D6_DRIVES,registerJD6Drive),
ObjectRegistration(VTS_PHYSIC_JLIMIT_PLANE,registerJLimitPlane),
};
//################################################################
//
// Misc prototypes
//
//----------------------------------------------------------------
//
//! \brief This is the attribute callback function which is expected from Virtools.
// We only use this as dispatcher function because we have our own sub set.
//
void PObjectAttributeCallbackFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg);
//################################################################
//
// OLD
//
//----------------------------------------------------------------
//
//! \brief this has become obselete
//
void recheckWorldsFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg); // --> old !
void rigidBodyAttributeCallback(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg); //-->new !
#endif

View File

@ -0,0 +1,48 @@
#ifndef __VT_C_BB_ERROR_HELPER_H__
#define __VT_C_BB_ERROR_HELPER_H__
#ifndef __X_LOGGER_H__
#include <xLogger.h>
#endif
#define CERROR_STRING(F) sBBErrorStrings[F]
#define bbSErrorME(A) { xLogger::xLog(XL_START,ELOGERROR,E_BB,CERROR_STRING(A));\
XLOG_BB_INFO;\
beh->ActivateOutput(0);\
return CKBR_PARAMETERERROR ; }
#define bbErrorME(A) { xLogger::xLog(XL_START,ELOGERROR,E_BB,A);\
XLOG_BB_INFO;\
beh->ActivateOutput(0);\
return CKBR_PARAMETERERROR ; }
#define bbWarning(A){ xLogger::xLog(XL_START,ELOGWARNING,E_BB,A);\
XLOG_BB_INFO;\
}
/*#define XL_BB_NAME beh->GetPrototype()->GetName()
#define XL_BB_OWNER_SCRIPT beh->GetOwnerScript()->GetName()
#define XL_BB_OWNER_OBJECT beh->GetOwner() ? beh->GetOwner()->GetName() : "none"
#define XL_BB_SIGNATURE ("\n\tScript : %s\n\tBuildingBlock : %s \n\tObject :%s Error :")
#define XLOG_FMT(msg,extro) msg##extro
#define XLOG_MERGE(var, fmt) (#var##fmt )
#define XLOG_MERGE2(var,fmt) (var##fmt)
#define XLOG_BB_INFO xLogger::xLogExtro(0,XL_BB_SIGNATURE,XL_BB_OWNER_SCRIPT,XL_BB_NAME,XL_BB_OWNER_OBJECT)
#define VTERROR_STRING(F) sErrorStrings[F]
#define bbError(F) XLOG_BB_INFO; \
Error(beh,F,BB_OP_ERROR,VTERROR_STRING(F),TRUE,BB_O_ERROR,TRUE)
#define bbNoError(F) Error(beh,F,BB_OP_ERROR,VTERROR_STRING(F),FALSE,BB_O_ERROR,FALSE)
*/
#endif

View File

@ -0,0 +1,99 @@
/********************************************************************
created: 2009/04/14
created: 14:4:2009 10:06
filename: x:\ProjectRoot\vtmodsvn\tools\VTCPPProjectPremakerSimple\SDK\Include\Core\Common\vtGUID.h
file path: x:\ProjectRoot\vtmodsvn\tools\VTCPPProjectPremakerSimple\SDK\Include\Core\Common
file base: vtGUID
file ext: h
author: Günter Baumgart
purpose: Wrapper for CKGuid
*********************************************************************/
class vtGUID
{
private:
CKGUID guid;
public:
CKGUID GetVirtoolsGUID()
{
return guid;
}
vtGUID( DWORD d1=0, DWORD d2=0 ):guid(d1,d2) {}
XString ToString( void )
{
XString laid;
laid << DecimalToHex( guid.d1 );
laid << DecimalToHex( guid.d2 );
return laid;
}
bool FromString( const XString laid )
{
if( laid.Length() != 16 )
return false;
XString d1(laid);
XString d2(laid);
d1.Crop( 0, 8 );
d2.Crop( 8, 8 );
HexToDecimalHI( d1.Str(), guid.d1 );
HexToDecimalLO( d2.Str(), guid.d2 );
return true;
}
vtGUID & operator =( const CKGUID& ckguid )
{
guid.d1 = ckguid.d1;
guid.d2 = ckguid.d2;
return *this;
}
operator XString() { return ToString(); }
private:
XString DecimalToHex( int decimal )
{
XString hexStr;
char hexstring[17];
itoa( decimal, hexstring, 16);
int length = strlen(hexstring);
if (length < 8)
{
int add = 8 - length;
for (int i = 0; i < add; i++)
{
hexStr << "0";
}
}
hexStr << hexstring;
return hexStr;
}
bool HexToDecimalHI (char* HexNumber, unsigned int& Number)
{
char* pStopString;
Number = strtol (HexNumber, &pStopString, 16);
return (bool)(Number != LONG_MAX);
}
bool HexToDecimalLO(char* HexNumber, unsigned int& Number)
{
char* pStopString;
Number = strtoul(HexNumber, &pStopString, 16);
return (bool)(Number != LONG_MAX);
}
};

View File

@ -0,0 +1,773 @@
/********************************************************************
created: 2009/02/16
created: 16:2:2009 20:25
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common\vtInterfaceEnumeration.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common
file base: vtInterfaceEnumeration
file ext: h
author: Günter Baumgart
purpose: Declaration of enumerations with bindings in the interface :
+ VSL
+ Custom Enumeration
Remarks The identifiers described here need to be consistent with types
registered for the interface. All types are used by this SDK
*********************************************************************/
#ifndef __VT_INTERFACE_ENUMERATION_H__
#define __VT_INTERFACE_ENUMERATION_H__
/** \addtogroup Callbacks
@{
*/
typedef enum pCallback
{
CB_OnDelete = (1<<0),
CB_OnCopy = (1<<1),
CB_OnPreProcess = (1<<2),
CB_OnPostProcess = (1<<3),
CB_OnContactNotify = (1<<4),
CB_OnContactModify = (1<<5),
CB_OnRayCastHit = (1<<6),
CB_OnWheelContactModify = (1<<7),
CB_OnTrigger = (1<<8),
CB_OnJointBreak = (1<<9),
CB_Max,
};
typedef enum pWheelContactModifyFlags
{
CWCM_ContactPoint = (1<<0),
CWCM_ContactNormal = (1<<1),
CWCM_ContactPosition = (1<<2),
CWCM_NormalForce = (1<<3),
CWCM_OtherMaterialIndex = (1<<4),
};
/** @} */
/** \addtogroup Collision
@{
*/
/**
\brief Contact pair flags.
@see NxUserContactReport.onContactNotify() NxActor::setContactReportThreshold
*/
typedef enum pContactPairFlags
{
CPF_IgnorePair = (1<<0), //!< disable contact generation for this pair
CPF_OnStartTouch = (1<<1), //!< pair callback will be called when the pair starts to be in contact
CPF_OnEndTouch = (1<<2), //!< pair callback will be called when the pair stops to be in contact
CPF_OnTouch = (1<<3), //!< pair callback will keep getting called while the pair is in contact
CPF_OnImpact = (1<<4), //!< [not yet implemented] pair callback will be called when it may be appropriate for the pair to play an impact sound
CPF_OnRoll = (1<<5), //!< [not yet implemented] pair callback will be called when the pair is in contact and rolling.
CPF_OnSlide = (1<<6), //!< [not yet implemented] pair callback will be called when the pair is in contact and sliding (and not rolling).
CPF_Forces = (1<<7), //!< the (summed total) friction force and normal force will be given in the nxcontactpair variable in the contact report.
CPF_OnStartTouchForceThreshold = (1<<8), //!< pair callback will be called when the contact force between two actors exceeds one of the actor-defined force thresholds
CPF_OnEndTouchForceThreshold = (1<<9), //!< pair callback will be called when the contact force between two actors falls below the actor-defined force thresholds
CPF_OnTouchForceThreshold = (1<<10), //!< pair callback will keep getting called while the contact force between two actors exceeds one of the actor-defined force thresholds
CPF_ContactModification = (1<<16), //!< generate a callback for all associated contact constraints, making it possible to edit the constraint. this flag is not included in CPFall for performance reasons. \see nxusercontactmodify
};
typedef enum pContactModifyMask
{
CMM_None = 0, //!< No changes made
CMM_MinImpulse = (1<<0), //!< Min impulse value changed
CMM_MaxImpulse = (1<<1), //!< Max impulse value changed
CMM_Error = (1<<2), //!< Error vector changed
CMM_Target = (1<<3), //!< Target vector changed
CMM_LocalPosition0 = (1<<4), //!< Local attachment position in shape 0 changed
CMM_LocalPosition1 = (1<<5), //!< Local attachment position in shape 1 changed
CMM_LocalOrientation0 = (1<<6), //!< Local orientation (normal, friction direction) in shape 0 changed
CMM_LocalOrientation1 = (1<<7), //!< Local orientation (normal, friction direction) in shape 1 changed
CMM_StaticFriction0 = (1<<8), //!< Static friction parameter 0 changed. (Note: 0 does not have anything to do with shape 0/1)
CMM_StaticFriction1 = (1<<9), //!< Static friction parameter 1 changed. (Note: 1 does not have anything to do with shape 0/1)
CMM_DynamicFriction0 = (1<<10), //!< Dynamic friction parameter 0 changed. (Note: 0 does not have anything to do with shape 0/1)
CMM_DynamicFriction1 = (1<<11), //!< Dynamic friction parameter 1 changed. (Note: 1 does not have anything to do with shape 0/1)
CMM_Restitution = (1<<12), //!< Restitution value changed.
CMM_Force32 = (1<<31) //!< Not a valid flag value, used by the enum to force the size to 32 bits.
};
/**
Specifies which informations should be generated(when used as hint flags for ray casting methods).
*/
enum pRaycastBit
{
RCH_Shape = (1<<0), //!< "shape" member of #NxRaycastHit is valid
RCH_Impact = (1<<1), //!< "worldImpact" member of #NxRaycastHit is valid
RCH_Normal = (1<<2), //!< "worldNormal" member of #NxRaycastHit is valid
RCH_FaceIndex = (1<<3), //!< "faceID" member of #NxRaycastHit is valid
RCH_Distance = (1<<4), //!< "distance" member of #NxRaycastHit is valid
RCH_UV = (1<<5), //!< "u" and "v" members of #NxRaycastHit are valid
RCH_FaceNormal = (1<<6), //!< Same as RCH_NORMAL but computes a non-smoothed normal
RCH_Material= (1<<7), //!< "material" member of #NxRaycastHit is valid
};
/**
\brief Collision filtering operations.
@see pGroupsMask
*/
enum pFilterOp
{
FO_And,
FO_Or,
FO_Xor,
FO_Nand,
FO_Nor,
FO_NXor,
FO_SwapAnd
};
/**
\brief Used to specify which types(static or dynamic) of shape to test against when used with raycasting and overlap test methods in pWorld.
*/
typedef enum pShapesType
{
/**
\brief Hits static shapes.
*/
ST_Static= 1,
/**
\brief Hits dynamic shapes.
*/
ST_Dynamic= 2,
/**
\brief Hits dynamic and static shapes.
*/
ST_All = ST_Dynamic|ST_Static,
};
/**
\brief Flags which affect the behavior of NxShapes.
@see pRigidBody.setTriggerFlags()
*/
typedef enum pTriggerFlags
{
/**
\brief Disables trigger callback.
*/
TF_Disable = (1<<3),
/**
\brief Trigger callback will be called when a shape enters the trigger volume.
*/
TF_OnEnter = (1<<0),
/**
\brief Trigger callback will be called after a shape leaves the trigger volume.
*/
TF_OnLeave = (1<<1),
/**
\brief Trigger callback will be called while a shape is intersecting the trigger volume.
*/
TF_OnStay = (1<<2)
};
/** @} */
typedef enum E_ENTITY_DATA_FLAGS
{
EDF_MATERIAL_PARAMETER,
EDF_SLEEPING_PARAMETER,
EDF_DAMPING_PARAMETER,
EDF_DEFORMABLE_PARAMETER,
EDF_OPTIMIZATION_PARAMETER,
};
typedef enum WORLD_DATA_FLAGS
{
WDF_HAS_SURFACE_PARAMETER = 0x0001,
WDF_HAS_SLEEPING_PARAMETER = 0x0002,
WDF_HAS_DAMPING_PARAMETER = 0x0004
};
typedef enum WORLD_UPDATE_MODE
{
WUM_UPDATE_FROM_ATTRIBUTE = 0x0001
};
typedef enum WORLD_UPDATE_FLAGS
{
WUF_WORLD_SETTINGS = 0x0001,
WUF_DAMPING_PARAMETER = 0x0002,
WUF_SLEEPING_PARAMETER = 0x0004,
WUF_SURFACE_SETTINGS = 0x0008,
WUF_ALL_PARAMETERS = 0x0010,
};
typedef enum BODY_UPDATE_FLAGS
{
BUF_PHY_PARAMETER = 0x0001,
BUF_DAMPING_PARAMETER = 0x0002,
BUF_SLEEPING_PARAMETER = 0x0004,
BUF_JOINT_PARAMETERS = 0x0008,
BUF_SURFACE_PARAMETERS = 0x0010,
BUF_ALL_PARAMETERS = 0x0020,
BUF_GEOMETRY = 0x0040,
BUF_PIVOT = 0x0080,
BUF_MASS = 0x0100,
BUF_ALL = 0x0200
};
/** \addtogroup Joints
@{
*/
//! Identifies each type of joint.
//! This enum is registered as a custom enumeration for the schematic interface as #pJointType.<br>
typedef enum JType
{
JT_Any =-1,/*!<None*/
JT_Prismatic= 0,/*!<Permits a single translational degree of freedom. See #pJointPrismatic.*/
JT_Revolute,/*!<Also known as a hinge joint, permits one rotational degree of freedom. See #pJointRevolute.*/
JT_Cylindrical,/*!<Formerly known as a sliding joint, permits one translational and one rotational degree of freedom. See #pJointCylindrical.*/
JT_Spherical,/*!<Also known as a ball or ball and socket joint. See #pJointBall.*/
JT_PointOnLine,/*!<A point on one actor is constrained to stay on a line on another. */
JT_PointInPlane,/*!<A point on one actor is constrained to stay on a plane on another.*/
JT_Distance,/*!<A point on one actor maintains a certain distance range to another point on another actor. See #pJointDistance. */
JT_Pulley,/*!<A pulley joint. See #pJointPulley.*/
JT_Fixed,/*!<A "fixed" connection. See #pJointFixed. */
JT_D6,/*!< A 6 degree of freedom joint. See #pJointD6.*/
};
/** @} */
//////////////////////////////////////////////////////////////////////////
// BodyFlags
typedef enum E_DEBUG_FLAGS
{
E_DEBUG_0,
E_DEBUG_1, //ode-body-pos to virtools-entity pos
E_DEBUG_2, //updates changes in dev´s interface mode inda geom space
E_DEBUG_3,
E_DEBUG_4,
E_DEBUG_5
};
/** \addtogroup RigidBody
@{
*/
//! Enumeration is used : <br>
//! -during body registration. <br>
//! -through invoking of #pRigidBody::addSubShape().This needs to have BF_SubShape enabled then!.<br>
//! -as member of #pObjectDescr.<br><br>
//! This enum is registered as a custom flags for the schematic : #pBFlags.<br>
typedef enum BodyFlags{
BF_Moving=1,/*!< Makes the body movable. this can not be altered after creation */
BF_Gravity=2,/*!< Enables gravity. See #pRigidBody::enableGravity() or \ref PBSetPar */
BF_Collision=4,/*!< Enables collisions response. See #pRigidBody::enableCollision() or \ref PBSetPar */
BF_Kinematic=8,/*!< Act as kinematic object. See #pRigidBody::setKinematic() or \ref PBSetPar */
BF_SubShape=16,/*!<Entities with a physic object attribute become physical on scene play. If flag enabled, the holding entity is understood as sub shape of the parent object */
BF_Hierarchy=32,/*!<Parse the entities hierarchy */
BF_AddAttributes=64,/*!<Adds the physic attribute on the entity.*/
BF_TriggerShape=128,/*!<Sets the trigger flag enabled(TF_OnEnter,TF_OnStay and TF_OnLeave). This can only be used if it is a sub shape ! This can be changed by \ref PCSetTriggerMask too*/
BF_Deformable=256,/*!<Creates a metal cloth. A deformable object can not be a sub shape ! */
BF_CollisionNotify=512,/*!< Enables using of collisions building blocks. Use or \ref PBSetPar to alter this */
BF_CollisionsForce=1024,/*!< Enables using of collisions building blocks. Use or \ref PBSetPar to alter this */
BF_ContactModify=2048,/*!< Enables using of collisions building blocks. Use or \ref PBSetPar to alter this */
BF_Sleep=4096/*!< Puts the rigid body to sleep */
};
/**
\brief Flags which describe the format and behavior of a convex mesh.
*/
enum pConvexFlags
{
/**
\brief Used to flip the normals if the winding order is reversed. The PhysX libraries assume that the face normal of a triangle with vertices [a,b,c] can be computed as: edge1 = b-a edge2 = c-a face_normal = edge1 x edge2. Note: this is the same as counterclockwise winding in a right handed graphics coordinate system.
*/
CF_FlipNormals = (1<<0),
/**
\brief Denotes the use of 16-bit vertex indices (otherwise, 32-bit indices are used)
*/
CF_16BitIndices = (1<<1),
/**
\brief Automatically recomputes the hull from the vertices. If this flag is not set, you must provide the entire geometry manually.
*/
CF_ComputeConvex = (1<<2),
/**
\brief Inflates the convex object according to skin width. Note: This flag is only used in combination with CF_ComputeConvex.
*/
CF_InflateConvex = (1<<3),
/**
\brief Instructs cooking to save normals uncompressed. The cooked hull data will be larger, but will load faster.
*/
CF_UncompressedNormals = (1<<6),
};
/*\brief
Enable/disable freezing for this body.
\note This is an EXPERIMENTAL feature which doesn't always work on in all situations, e.g.
for actors which have joints connected to them.
To freeze an actor is a way to simulate that it is static. The actor is however still simulated
as if it was dynamic, it's position is just restored after the simulation has finished. A much
more stable way to make an actor temporarily static is to raise the #BF_Kinematic flag.
*/
typedef enum BodyLockFlags
{
BF_LPX=2,
BF_LPY=4,
BF_LPZ=8,
BF_LRX=16,
BF_LRY=32,
BF_LRZ=64,
};
//! Flags which control the behavior of a material.
//! @see pMaterial
typedef enum MaterialFlags
{
/**
\brief Flag to enable anisotropic friction computation.
For a pair of actors, anisotropic friction is used only if at least one of the two bodies materials are anisotropic.
The anisotropic friction parameters for the pair are taken from the material which is more anisotropic (i.e. the difference
between its two dynamic friction coefficients is greater).
The anisotropy direction of the chosen material is transformed to world space:
dirOfAnisotropyWS = shape2world * dirOfAnisotropy
Next, the directions of anisotropy in one or more contact planes (i.e. orthogonal to the contact normal) have to be determined.
The two directions are:
uAxis = (dirOfAnisotropyWS ^ contactNormal).normalize()
vAxis = contactNormal ^ uAxis
This way [uAxis, contactNormal, vAxis] forms a basis.
It may happen, however, that (dirOfAnisotropyWS | contactNormal).magnitude() == 1
and then (dirOfAnisotropyWS ^ contactNormal) has zero length. This happens when
the contactNormal is coincident to the direction of anisotropy. In this case we perform isotropic friction.
@see pMaterial.dirOfAnisotropy
*/
MF_Anisotropic=1,
/**
If this flag is set, friction computations are always skipped between shapes with this material and any other shape.
It may be a good idea to use this when all friction is to be performed using the tire friction model (see ::pWheel2).
@see pWheel2
*/
MF_DisableFriction = 1 << 4,
/**
The difference between "normal" and "strong" friction is that the strong friction feature
remembers the "friction error" between simulation steps. The friction is a force trying to
hold objects in place (or slow them down) and this is handled in the solver. But since the
solver is only an approximation, the result of the friction calculation can include a small
"error" - e.g. a box resting on a slope should not move at all if the static friction is in
action, but could slowly glide down the slope because of a small friction error in each
simulation step. The strong friction counter-acts this by remembering the small error and
taking it to account during the next simulation step.
However, in some cases the strong friction could cause problems, and this is why it is
possible to disable the strong friction feature by setting this flag. One example is
raycast vehicles, that are sliding fast across the surface, but still need a precise
steering behavior. It may be a good idea to reenable the strong friction when objects
are coming to a rest, to prevent them from slowly creeping down inclines.
Note: This flag only has an effect if the MF_DisableFriction bit is 0.
@see pWheel2
*/
MF_DisableStrongFriction = 1 << 5,
};
//! Enumeration is used : <br>
//! -during body registration. <br>
//! -as member of #pObjectDescr.<br><br>
//! This enum is registered as a custom flags for the schematic : #pBHullType.<br>
typedef enum HullType {
HT_Sphere = 0,
/*!<A spherical shape type defined by the meshes radius.
<br>
*/
HT_Box = 1,
/*!<A box shape. The entities rotation is set to 0,0,0 (degree) temporary in order to determine the box dimension. It assumes the bodies pivot is aligned to the world frame.
<br>
*/
HT_Capsule = 2,
/*!<A capsule shape defined by length and radius. <br>
Assuming bodies pivot is aligned to the world frame, the entities rotation is set to 0,0,0 (degree) temporary in order to determine the capsule parameters whereas :<br>
capsule length = boxMeshSize.y - boxMeshSize.x and <br>
capsule radius = boxMeshSize.x / 2 <br>
<br>
*/
HT_Plane = 3,
/*!<A plane shape.
\todo : not implemented yet !
<br>
*/
HT_Mesh =4,
/*!<A mesh shape.Its utilizing the NxTrianglemesh.
\note The number of vertices is unlimited. <br>
\note This mesh type will not create contact points with another trieangle meshs. Avoid this at any cost, otherwise Virtools will crash!<br>
<br>
*/
HT_ConvexMesh =5,
/*!<A convex mesh shape.
\note The number of vertices is limited to 256 vertices. This is because of Ageia. <br>
\note This type will create contact points with all other types!
<br>
*/
HT_Heightfield=6,
/*!<A plane shape.
\todo : not implemented yet !
<br>
*/
HT_Wheel=7,
/*!<A wheel shape.
\todo : not implemented yet !
<br>
*/
HT_Cloth=8,
/*!<A cloth shape.
\todo : not implemented yet !
<br>
*/
HT_ConvexCylinder=9,
/*!<A convex cylinder shape.
<br>
*/
HT_Unknown,
/*!<Indicates a unspecified type.
<br>
*/
};
/** @} */
typedef enum E_LOG_ITEMS
{
E_LI_AGEIA,
E_LI_MANAGER,
E_VSL,
E_BB,
};
typedef enum E_PHYSIC_ERROR
{
E_PE_OK,
E_PE_AGEIA_ERROR,
E_PE_INVALID_PARAMETER,
E_PE_INVALID_OPERATION,
};
typedef enum E_MANAGER_FLAGS
{
E_MF_OK,
E_MF_PSDK_LOADED,
E_MF_PSDK_FAILED,
E_MF_DEFAULT_WORLD_CREATED,
E_MF_DEFAULT_CONFIG_LOADED,
E_MF_LOADING_DEFAULT_CONFIG_FAILED,
E_MF_FACTORY_CREATED,
};
typedef enum E_MANAGER_INIT_FLAGS
{
E_MFI_LOAD_CONFIG,
E_MFI_CREATE_FACTORY,
E_MFI_CREATE_DEFAULT_WORLD,
E_MFI_USE_XML_WORLD_SETTINGS
};
/** \addtogroup RigidBody
@{
*/
//! This enum is registered as a custom flags for the schematic : #pBForceMode.<br>
//! Enumeration to force related calls.
//*! Is used for force related calls. Registered as custom enumeration #pBForceMode. */
enum ForceMode
{
FM_Force, /*!< parameter has unit of mass * distance/ time^2, i.e. a force*/
FM_Impulse, /*!< parameter has unit of mass * distance /time */
FM_VelocityChange, /*!< parameter has unit of distance / time, i.e. the effect is mass independent: a velocity change.*/
FM_SmoothImpulse, /*!< same as FM_Impulse but the effect is applied over all sub steps. Use this for motion controllers that repeatedly apply an impulse.*/
FM_SmoothVelocityChange, /*!< same as FM_VelocityChange but the effect is applied over all substeps. Use this for motion controllers that repeatedly apply an impulse.*/
FM_Acceleration /*!< parameter has unit of distance/ time^2, i.e. an acceleration. It gets treated just like a force except the mass is not divided out before integration.*/
};
//! This enum is registered as custom hidden enumeration for pCCDSettings-
enum CCDFlags
{
CCD_Shared, /*!< Is reusing a ccd skeleton*/
};
/** @} */
/** \addtogroup RigidBody
@{
*/
//! Flag that determines the combine mode. When two bodies come in contact with each other,
//! they each have materials with various coefficients, but we only need a single set of coefficients for the pair.
//! Physics doesn't have any inherent combinations because the coefficients are determined empirically on a case by case basis. However, simulating this with a pairwise lookup table is often impractical. For this reason the following combine
//! behaviors are available: CM_Average CM_Min CM_Multiply CM_Max
//! The effective combine mode for the pair is max(material0.combineMode, material1.combineMode).
enum CombineMode
{
CM_Average,/*!<Average: (a + b)/2.*/
CM_Min,/*!<Minimum: min(a,b). */
CM_Multiply,/*!<Multiply: a*b. */
CM_Max,/*!<Maximum: max(a,b).*/
};
/** @} */
typedef enum E_BODY_CREATION_FLAGS
{
E_BCF_USE_WORLD_DAMPING,
E_BCF_USE_WORLD_SLEEP_SETTINGS,
E_BCF_USE_WORLD_MATERIAL,
E_BCF_CREATE_ATTRIBUTES
};
/** \addtogroup D6
@{
*/
//! Enumeration is used to specify the range of motions allowed for a DOF in a D6 joint.
//! Registered as custom enumeration #pJD6MotionMode.
typedef enum D6MotionMode
{
D6MM_Locked,/*!<The DOF is locked, it does not allow relative motion. */
D6MM_Limited,/*!<The DOF is limited, it only allows motion within a specific range. */
D6MM_Free,/*!<The DOF is free and has its full range of motions. */
};
/** @} */
/** \addtogroup D6
@{
*/
//! Enumeration is used to specify a particular drive method. i.e. Having a position based goal or a velocity based goal.
//! Registered as custom enumeration #pJD6DriveType.
typedef enum D6DriveType
{
D6DT_Position = 1 <<0,
/*!<Used to set a position goal when driving.<br>
\note The appropriate target positions/orientations should be set.
*/
D6DT_Velocity = 1 << 1,
/*!<Used to set a velocity goal when driving. <br>
\note The appropriate target velocities should beset.*/
};
/** @} */
/** \addtogroup D6
@{
*/
//! Enumeration is used to specify a particular degree of freedom.Registered as custom enumeration #pJD6Axis.
typedef enum D6MotionAxis
{
D6MA_Twist,/*!<Rotational axis.*/
D6MA_Swing1,/*!<Rotational axis.*/
D6MA_Swing2,/*!<Rotational axis. */
D6MA_X,/*!<Linear axis.*/
D6MA_Y,/*!<Linear axis.*/
D6MA_Z/*!< Linear axis.*/
};
/** @} */
/** \addtogroup D6
@{
*/
//! Enumeration is used to specify a particular axis for a soft limit. Registered as custom enumeration #pJD6LimitAxis.
typedef enum D6LimitAxis
{
D6LA_Linear,/*!<Linear axis.*/
D6LA_Swing1,/*!<Rotational axis.*/
D6LA_Swing2,/*!<Rotational axis. */
D6LA_TwistHigh,/*!<Rotational axis. */
D6LA_TwistLow/*!<Rotational axis. */
};
/** @} */
/** \addtogroup D6
@{
*/
//! Enumeration is used to specify a particular axis for drives. Registered as custom enumeration #pJD6DriveAxis.
typedef enum D6DriveAxis
{
D6DA_Twist=0,/*!<Rotational axis.Twist is defined as the rotation about the x-axis */
D6DA_Swing=1,/*!<Rotational axis.Swing is defined as the rotation of the x-axis with respect to the y- and z-axis. */
D6DA_Slerp=2,/*!<Rotational axis. */
D6DA_X=3,/*!<Linear axis = joint axis */
D6DA_Y=4,/*!<Linear axis = joint normal axis. */
D6DA_Z=5,/*!<Linear axis = x-axis cross y-axis. */
};
/** @} */
/** \addtogroup Joints
@{
*/
/**
Joint projection is a method for correcting large joint errors. Joint errors occur when a joint's constraint is violated - imagine the ball being pulled out of the socket in a spherical joint. Under normal circumstances, joint errors are small yet unavoidable due to the imprecise nature of floating point math and numerical integrators. The SDK applies minimal correcting forces to the simulation to try and reduce joint errors over time.
However, if a joint error becomes very large, more drastic measures are necessary, such as joint projection. The SDK can, in some situations, project (or change) the position of objects directly to fix the joint error. But when projecting the joint it is not desirable to completely remove the joint error because the correcting forces, which also affect velocity, would become zero.
*/
typedef enum ProjectionMode
{
PM_None,/*!<Disables projection.*/
PM_MinPointDist,/*!<Performs both linear and angular projection. */
PM_MinLinearDist,/*!<Only projects linear distances, for improved performance.*/
};
/** @} */
/** \addtogroup Vehicle
@{
*/
/**
Flags to describe the internal used shape types behavior. This can be done at any time with : <br>
- building block \ref PVWSet
- #pWheel::setShapeFlags
*/
/**
Flags to describe the wheels control facility. This can be done at any time with : <br>
- building block \ref PVWSet
- #pWheel::setWheelFlags
*/
typedef enum VehicleFlags
{
VF_UseAdvance = (1 << 0),
};
typedef enum WheelShapeFlags
{
/**
\brief Determines whether the suspension axis or the ground contact normal is used for the suspension constraint.
*/
WSF_WheelAxisContactNormal = 1 << 0,
/**
\brief If set, the lateral slip velocity is used as the input to the tire function, rather than the slip angle.
*/
WSF_InputLatSlipVelocity = 1 << 1,
/**
\brief If set, the longitudinal slip velocity is used as the input to the tire function, rather than the slip ratio.
*/
WSF_InputLongSlipVelocity = 1 << 2,
/**
\brief If set, does not factor out the suspension travel and wheel radius from the spring force computation. This is the legacy behavior from the raycast capsule approach.
*/
WSF_UnscaledSpringBehavior = 1 << 3,
/**
\brief If set, the axle speed is not computed by the simulation but is rather expected to be provided by the user every simulation step via NxWheelShape::setAxleSpeed().
*/
WSF_AxleSpeedOverride = 1 << 4,
/**
\brief If set, the wheels shape will emulate the legacy raycast capsule based wheel.
See #pVWheelFunction
*/
WSF_EmulateLegacyWheel = 1 << 5,
/**
\brief If set, the shape will clamp the force in the friction constraints.
See #pVWheelFunction
*/
WSF_ClampedFriction = 1 << 6,
};
/**
Flags to describe the wheels control facility. This can be done at any time with : <br>
- building block \ref PVWSet
- #pWheel::setWheelFlags
*/
typedef enum WheelFlags
{
/**
\brief If set, the wheels shape will emulate the legacy raycast capsule based wheel.
See #pVWheelFunction
*/
WF_SteerableInput = (1 << 0),
WF_SteerableAuto = (1 << 1),
WF_AffectedByHandbrake = (1 << 2),
WF_Accelerated = (1 << 3),
WF_VehicleControlled = (1 << 4),
WF_AffectedByDifferential = (1 << 5),
WF_IgnoreTireFunction = (1 << 6),
WF_AllWheelFlags = WF_SteerableInput
| WF_SteerableAuto
| WF_AffectedByHandbrake
| WF_Accelerated
| WF_VehicleControlled
| WF_AffectedByDifferential,
};
typedef enum E_VEHICLE_STATE_FLAGS
{
E_VSF_HAS_GEARS=(1<<0),
E_VSF_HAS_MOTOR=(1<<1),
E_VSF_HAS_GROUND=(1<<2),
E_VSF_IS_BRAKING=(1<<3),
E_VSF_IS_BREAKPEDAL=(1<<4),
E_VSF_BREAKPEDAL_CHANGED=(1<<5),
E_VSF_ACC_PEDAL=(1<<6),
E_VSF_RELEASING_BRAKE_PEDAL=(1<<7),
};
/** @} */
typedef enum pParticleRenderType
{
PRT_Point,
PRT_Sprite,
};
typedef enum E_OBJECT_CREATION_FLAGS
{
E_OCF_ROTATION,
E_OFC_POSITION,
E_OFC_DIMENSION,
E_OFC_PERISITENT,
};
typedef enum xManagerCallMask
{
XCM_PreProcess = 1 << 0 ,
XCM_PostProcess = 1 << 0
};
#endif // __VTINTERFACEENUMERATION_H__

View File

@ -0,0 +1,49 @@
#ifndef _VTLOG_TOOLS_H_
#define _VTLOG_TOOLS_H_
#include "xLogger.h"
//////////////////////////////////////////////////////////////////////////
//
//
// We different output channels for logging,debugging or assertions :
// + console
// + log file
// + std::err
class CKContext;
class CKGUID;
namespace vtTools
{
class BehaviorInfoTools
{
public :
static const char*getBuildingBlockName(CKContext *ctx,CKGUID* guid);
};
}
#define XL_BB_NAME beh->GetPrototype()->GetName()
#define XL_BB_OWNER_SCRIPT beh->GetOwnerScript()->GetName()
#define XL_BB_OWNER_OBJECT beh->GetOwner() ? beh->GetOwner()->GetName() : "none"
#define XL_BB_SIGNATURE ("\n\tScript : %s\n\tBuildingBlock : %s \n\tObject :%s Error :")
#define XLOG_FMT(msg,extro) msg##extro
#define XLOG_MERGE(var, fmt) (#var##fmt )
#define XLOG_MERGE2(var,fmt) (var##fmt)
#define XLOG_BB_INFO xLogger::xLogExtro(0,XL_BB_SIGNATURE,XL_BB_OWNER_SCRIPT,XL_BB_NAME,XL_BB_OWNER_OBJECT)
#define VTERROR_STRING(F) sErrorStrings[F]
#define bbError(F) XLOG_BB_INFO; \
Error(beh,F,BB_OP_ERROR,VTERROR_STRING(F),TRUE,BB_O_ERROR,TRUE)
#define bbNoError(F) Error(beh,F,BB_OP_ERROR,VTERROR_STRING(F),FALSE,BB_O_ERROR,FALSE)
#define bbErrorMesg(F) xLogger::xLog(ELOGERROR,E_BB,F); \
XLOG_BB_INFO;
#endif

View File

@ -0,0 +1,77 @@
#ifndef __vtModuleConstants_h__
#define __vtModuleConstants_h__
//----------------------------------------------------------------
//
// Include of system headers
//
#include <float.h> // float max
//################################################################
//
// Component specific names, prefixes,etc....
//
//----------------------------------------------------------------
//
//! \brief Global API prefix
//
#define VTCX_API_PREFIX "vt"
//----------------------------------------------------------------
//
//! \brief Module name, merged with module suffix "vt" with see #VTCX_API_PREFIX
//
#define VTCMODULE_NAME VTCX_API_PREFIX("Physic")
//----------------------------------------------------------------
//
//! \brief Modules attribute category prefix , using module name above
//
#define VTCMODULE_ATTRIBUTE_CATAEGORY VTCMODULE_NAME
//----------------------------------------------------------------
//
//! \brief Error enumerations
//
#include "vtModuleErrorCodes.h"
//----------------------------------------------------------------
//
//! \brief Error strings
//
#include "vtModuleErrorStrings.h"
//----------------------------------------------------------------
//
//! \brief Guids of the plug-in it self
//
#include "vtModuleGuids.h"
//----------------------------------------------------------------
//
//! \brief Math oriented values
//
#define pSLEEP_INTERVAL (20.0f*0.02f)
#define pFLOAT_MAX FLT_MAX
//----------------------------------------------------------------
//
//! \brief Constants for building blocks
//
#ifndef VTCX_AUTHOR
#define VTCX_AUTHOR "Guenter Baumgart"
#endif
#ifndef VTCX_AUTHOR_GUID
#define VTCX_AUTHOR_GUID CKGUID(0x79ba75dd,0x41d77c63)
#endif
#endif // vtModuleConstants_h__

View File

@ -0,0 +1,26 @@
#ifndef __VTMODULE_ERROR_CODES_H__
#define __VTMODULE_ERROR_CODES_H__
/*!
* \brief
* Error codes to identifier common errors in the SDK with automatic
* string conversion for building blocks
*/
typedef enum E_BB_ERRORS
{
E_PE_NONE,
E_PE_INTERN,
E_PE_PAR,
E_PE_REF,
E_PE_XML,
E_PE_FILE,
E_PE_NoBody,
E_PE_NoVeh,
E_PE_NoWheel,
E_PE_NoJoint,
E_PE_NoCloth,
E_PE_NoSDK,
};
#endif // __VTMODULEERRORCODES_H__

View File

@ -0,0 +1,50 @@
#ifndef __VT_MODULE_ERROR_STRINGS_H__
#define __VT_MODULE_ERROR_STRINGS_H__
/*!
* \brief
* String to describe the error's source
*/
static char* sLogItems[]=
{
"AGEIA",
"MANAGER",
"VSL",
};
/*!
* \brief
* String to describe generic return codes
*/
static char* sErrorStrings[]=
{
"OK",
"Ageia error",
"Invalid parameter",
"Invalid operation",
};
/*!
* \brief
* String to describe component specific return codes
*
*/
static char* sBBErrorStrings[]=
{
"OK",
"\t Intern :",
"\t Parameter invalid :",
"\t Reference object invalid:",
"\t XML error:",
"\t Invalid File:",
"\t Reference object is not physicalized:",
"\t Reference object doesn't contains a vehicle controller:",
"\t Reference object is not a wheel:",
"\t Reference object is not a joint:",
"\t Reference object is not a cloth:",
"\t Couldn't initialize PhysX :",
};
#endif // __VTMODULEERRORSTRINGS_H__

View File

@ -0,0 +1,25 @@
#ifndef __VTMODULES_GUIDS_H__
#define __VTMODULES_GUIDS_H__
#include "vtBaseMacros.h"
//----------------------------------------------------------------
//
//! \brief The guid of the modules manager. Used
//
//
//! \brief Manager Guid, used in plug-in registration, building blocks and many core components
//
#define GUID_MODULE_MANAGER CKGUID(0x1c0f04e8,0x442e20e5)
//----------------------------------------------------------------
//
//! \brief :: The guid of the modules building blocks
// If defined "WebPack", its using the guid of the built-in camera plug in.
#ifdef WebPack
#define GUID_MODULE_BUILDING_BLOCKS CKGUID(0x12d94eba,0x47057415)
#else
#define GUID_MODULE_BUILDING_BLOCKS CKGUID(0x36834d9e,0x63664944)
#endif
#endif

View File

@ -0,0 +1,272 @@
/********************************************************************
created: 2009/02/14
created: 14:2:2009 15:50
filename: SDK\Include\Core\vtParameterGuids.h
file path: SDK\Include\Core
file base: vtParameterGuids
file ext: h
author: Günter Baumgart
purpose: Unique identifiers for the entire component
*********************************************************************/
#ifndef __VT_PARAMETER_GUIDS_H__
#define __VT_PARAMETER_GUIDS_H__
//################################################################
//
// Common Parameter, used by joints, bodies, -or world objects
//
#define VTS_AXIS_REFERENCED_LENGTH CKGUID(0x19d6054d,0x4c2a2c99)
#define VTE_PHYSIC_DOMINANCE_GROUP CKGUID(0x2ae53cee,0x57ca74d0)
#define VTS_SLEEPING_SETTINGS CKGUID(0x28d13431,0x24186938)
#define VTF_TRIGGER CKGUID(0xe9c412e,0x68025071)
#define VTE_FILTER_OPS CKGUID(0x58340fe5,0x67892b1f)
#define VTE_FILTER_MASK CKGUID(0x30ff289e,0x7e57707c)
#define VTS_FILTER_GROUPS CKGUID(0x14443c3a,0x7c886162)
#define VTF_SHAPES_TYPE CKGUID(0x2ff80c77,0x7ab71a8)
#define VTF_RAY_HINTS CKGUID(0x7f5552d,0x70632e9a)
#define VTS_RAYCAST CKGUID(0x3842035f,0x1bc81c7f)
#define VTF_COLLISIONS_EVENT_MASK CKGUID(0x1beb409d,0x5028494f)
#define VTF_WHEEL_CONTACT_MODIFY_FLAGS CKGUID(0x40495482,0x4ab3283e)
//################################################################
//
// Shape overrides
//
#define VTS_CAPSULE_SETTINGS CKGUID(0x9a441c3,0x1e1d25ce)
#define VTS_CAPSULE_SETTINGS_EX CKGUID(0x16f102dc,0x7cb97e54)
// Wheel type using a convex cylinder, a capsule and a joint spring
#define VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR CKGUID(0x65e30713,0x55ca1048)
//################################################################
//
// World Related
//
#define VTS_PHYSIC_DOMINANCE_SCENE_SETTINGS CKGUID(0x636c3e44,0x658213ea)
#define VTS_PHYSIC_DOMINANCE_ITEM CKGUID(0x7bee51cc,0xb676809)
#define VTS_PHYSIC_DOMINANCE_CONSTRAINT CKGUID(0x6f44420b,0x14b7435d)
#define VTS_WORLD_SETTINGS CKGUID(0x5a0b56eb,0x50fc04d2)
#define VTS_PHYSIC_WORLD_PARAMETER CKGUID(0x27f223a1,0x365777f0)
//################################################################
//
// Rigid Body Related
//
#define VTS_PHYSIC_PARAMETER CKGUID(0x90e519f,0x7ec5345d)
#define VTS_PHYSIC_ACTOR CKGUID(0x381d7e69,0x456458fb)
#define VTF_PHYSIC_SUBSHAPE_INHERITANCE_FLAGS CKGUID(0x55c60b24,0x4ddc754e)
#define VTS_PHYSIC_TRANSFORMATIONS_LIMIT_PARAMETER CKGUID(0x413f3fb4,0x4f545c24)
#define VTF_PHYSIC_BODY_COMMON_SETTINGS CKGUID(0x44bc4e8d,0x16cb3288)
#define VTE_BODY_FORCE_MODE CKGUID(0x28c8214c,0x1ab04db8)
#define VTF_PHYSIC_BODY_UPDATE_FLAGS CKGUID(0x7f824fb3,0x5496b62)
#define VTF_PHYSIC_WORLD_UPDATE_FLAGS CKGUID(0x7f824fb3,0x5496b62)
#define VTF_BODY_FLAGS CKGUID(0x2c173381,0x10f66ab3)
#define VTF_BODY_TRANS_FLAGS CKGUID(0x41242761,0x72e70c27)
#define VTE_COLLIDER_TYPE CKGUID(0x1c415d41,0x5c534d7a)
#define VTF_CONVEX_FLAGS CKGUID(0x2d9d5c3e,0x468c0266)
#define VTF_CONTACT_MODIFY_FLAGS CKGUID(0x7d5c0e7c,0x144d2596)
//----------------------------------------------------------------
//
// XML Setup
//
#define VTS_PHYSIC_ACTOR_XML_SETTINGS_INTERN CKGUID(0x35977af4,0x5b430c0c)
#define VTS_PHYSIC_ACTOR_XML_SETTINGS_EXTERN CKGUID(0x57aa4cab,0x7e173b06)
#define VTS_PHYSIC_ACTOR_XML_IMPORT_FLAGS CKGUID(0x2a2c3ee5,0x33cc3c2f)
#define VTS_PHYSIC_ACTOR_XML_SETUP CKGUID(0x5e916f6,0x6e7a44ed)
#define VTF_PHYSIC_ACTOR_COPY_FLAGS CKGUID(0x7013615f,0x9aa642e)
//----------------------------------------------------------------
//
// Geometry
//
#define VTS_PHYSIC_PIVOT_OFFSET CKGUID(0x19e432af,0x571f5bf7)
//----------------------------------------------------------------
//
// Collision
//
#define VTF_PHYSIC_COLLISION_MASK CKGUID(0x7bf86391,0x1ac73b1)
#define VTS_PHYSIC_CCD_SETTINGS CKGUID(0x37537e0c,0x55b668d6)
#define VTF_PHYSIC_CCD_FLAGS CKGUID(0x25ee18c2,0x3419342d)
#define VTS_PHYSIC_COLLISIONS_SETTINGS CKGUID(0x8027e35,0x7c940e70)
#define VTE_PHYSIC_BODY_COLL_GROUP CKGUID(0xc1e1e0a,0x36fd0de4)
#define VTS_PHYSIC_COLLISIONS_SETUP CKGUID(0x64043794,0x4d9f454b)
//----------------------------------------------------------------
//
// Mass Configuration
//
#define VTS_PHYSIC_MASS_SETUP CKGUID(0x36855c80,0x81a0a4e)
#define VTE_PHYSIC_MASS_TYPE CKGUID(0x71921e8a,0x8e22f63)
//----------------------------------------------------------------
//
// Optimization
//
#define VTS_PHYSIC_SLEEP_SETTINGS CKGUID(0x41450454,0x3b4a65c2)
#define VTS_PHYSIC_DAMPING_PARAMETER CKGUID(0x17ad0411,0x3ccd0dd7)
#define VTS_PHYSIC_ACTOR_OPTIMIZATION CKGUID(0x2fca03db,0x25644fd4)
//----------------------------------------------------------------
//
// Material
//
#define VTS_MATERIAL CKGUID(0x4785249d,0x57af4457)
#define VTF_MATERIAL_FLAGS CKGUID(0x14ce161f,0x27cc5b83)
#define VTE_MATERIAL_COMBINE_MODE CKGUID(0x6dbf7c19,0x3dfb0e12)
#define VTE_XML_MATERIAL_TYPE CKGUID(0x57430496,0x29193343)
//################################################################
//
// Joints :
//
//----------------------------------------------------------------
//
// Common shared types
//
#define VTE_JOINT_TYPE CKGUID(0x5d9c0413,0xcb96c02)
#define VTS_PHYSIC_JAMOTOR_AXIS_TYPE CKGUID(0x21352808,0x1e932c41)
#define VTE_JOINT_MOTION_MODE CKGUID(0x6ec04e81,0xfd537e)
#define VTS_JOINT_DRIVE CKGUID(0x563c20ca,0x581e0e4b)
#define VTS_JOINT_SPRING CKGUID(0x495d0920,0x189674ba)
#define VTS_JLIMIT CKGUID(0x8d61654,0x1fd01503)
#define VTS_JOINT_SLIMIT CKGUID(0xd997313,0x28523dc0)
#define VTS_JOINT_MOTOR CKGUID(0x50ab7cc2,0x37ce0071)
#define VTS_JOINT_D6 CKGUID(0x215a2fa1,0x7cc02701)
#define VTF_JOINT_D6_AXIS_MASK CKGUID(0x461c1af3,0x4b194a84)
#define VTS_JOINT_D6_AXIS_ITEM CKGUID(0x37d01b38,0x10a03ef)
#define VTE_JOINT_MOTION_MODE_AXIS CKGUID(0x5adb450c,0x5798057d)
#define VTE_JOINT_LIMIT_AXIS CKGUID(0x16d654a4,0x276a048f)
#define VTE_JOINT_DRIVE_AXIS CKGUID(0x1c73456a,0x7d846d2a)
#define VTE_JOINT_PROJECTION_MODE CKGUID(0x2cce3d0b,0x60603c02)
#define VTE_JOINT_TYPE CKGUID(0x16f21041,0x7a6479f3)
//----------------------------------------------------------------
//
// Complete Joint Setups
//
#define VTS_JOINT_FIXED CKGUID(0x3a5163bf,0x3c315528)
#define VTS_JOINT_DISTANCE CKGUID(0x1edf6510,0xdea68b2)
#define VTS_JOINT_BALL CKGUID(0x20271cdc,0x645c4212)
#define VTS_JOINT_REVOLUTE CKGUID(0x7d45030c,0x4f6216ef)
#define VTS_JOINT_PRISMATIC CKGUID(0x37fd735c,0x6b83447d)
#define VTS_JOINT_CYLINDRICAL CKGUID(0x45e07719,0xba2297)
#define VTS_JOINT_POINT_IN_PLANE CKGUID(0xed23f6,0x2ba449a3)
#define VTS_JOINT_POINT_ON_LINE CKGUID(0x4429006a,0x34345b66)
#define VTS_JOINT_D6 CKGUID(0x52467f8a,0x3adc012b)
#define VTS_JOINT_D6_DRIVES CKGUID(0x46067fc4,0x56cf693e)
#define VTS_JOINT_BREAKABLE CKGUID(0xe3d7a63,0x2cc61e4a)
#define VTS_JOINT_D6 CKGUID(0x11bd2119,0x3843102b)
#define VTS_PHYSIC_JBALL_PARAMETER CKGUID(0x2c47770d,0x1b7173ad)
#define VTS_PHYSIC_JFIXED_PARAMETER CKGUID(0x780650ae,0x7e6406c5)
#define VTS_PHYSIC_JHINGE_PARAMETER CKGUID(0x5a805563,0x292021ce)
#define VTS_PHYSIC_JHINGE2_PARAMETER CKGUID(0x281717e5,0x353b61f2)
#define VTS_PHYSIC_JUNIVERSAL_PARAMETER CKGUID(0x7a283845,0x53144e6a)
#define VTS_PHYSIC_JSLIDER_PARAMETER CKGUID(0x67837673,0x20c04330)
#define VTS_PHYSIC_JMOTOR_PARAMETER CKGUID(0x677e7eba,0x6505310c)
#define VTS_PHYSIC_JLIMIT_PARAMETER CKGUID(0x17e57c53,0x43585c91)
#define VTE_PHYSIC_JDRIVE_TYPE CKGUID(0x75a51b10,0xe00025c)
//----------------------------------------------------------------
//
// Joint Misc Structures
//
#define VTS_PHYSIC_JLIMIT_PLANE CKGUID(0x5abe5f0b,0x7ca6657e)
//################################################################
//
// Wheel Parameters
//
#define VTF_VSTATE_FLAGS CKGUID(0x49ce782d,0x7566828)
#define VTF_VFLAGS CKGUID(0x5cf964cf,0xd382f37)
#define VTF_VWSHAPE_FLAGS CKGUID(0x7da158eb,0x16e921a1)
#define VTF_VWTIRE_SETTINGS CKGUID(0x2690c24,0xde55e2b)
#define VTE_BRAKE_XML_LINK CKGUID(0x77806807,0x4eac2b27)
#define VTE_BRAKE_LEVEL CKGUID(0x161f2b7d,0x2f657a2a)
#define VTF_BRAKE_FLAGS CKGUID(0x46535a8f,0x11815172)
#define VTS_BRAKE_TABLE CKGUID(0x59052709,0xa555846)
#define VTF_WHEEL_CONEX_SHAPE CKGUID(0x3f913a00,0x372f4a50)
#define VTS_WHEEL_CONTACT CKGUID(0x33f24aa8,0x34a57460)
#define VTS_PHYSIC_WHEEL_DESCR CKGUID(0x5dcd09ae,0x73f72b97)
#define VTS_PHYSIC_WHEEL_FLAGS CKGUID(0x72b70c7d,0x3b60239d)
//################################################################
//
// Vehicle
//
#define VTS_PHYSIC_VEHICLE_DESCR CKGUID(0x54562468,0xd1a6de6)
#define VTS_PHYSIC_VEHICLE_MOTOR_DESCR CKGUID(0x19317402,0x2f4b65a1)
#define VTS_PHYSIC_GEAR_DESCR CKGUID(0x308e5c88,0x433871f9)
#define VTE_XML_VEHICLE_SETTINGS CKGUID(0x67ca76e9,0x452f7ceb)
#define VTE_XML_VMOTOR_SETTINGS CKGUID(0x6af977a6,0x11084c45)
#define VTF_VEHICLE_ENGINE_FLAGS CKGUID(0x23823b40,0x694f152c)
#define VTE_XML_VGEAR_SETTINGS CKGUID(0x9bc7981,0x4a6f7245)
#define VTE_XML_WHEEL_SETTINGS CKGUID(0x1ed80439,0x1f9825c4)
#define VTE_XML_TIRE_SETTINGS CKGUID(0x4cb47505,0x7b022333)
#define VTS_VMOTOR_ENTRY CKGUID(0x12dd3a77,0x5db358f8)
#define VTS_VMOTOR_TVALUES CKGUID(0x34af3aa2,0x23aa6422)
#define VTS_VGEAR_GRAPH_SETTINGS CKGUID(0x25016106,0x3a0024a0)
#define VTS_VGEARBOX_FLAGS CKGUID(0x47d632a5,0x50057698)
#define VTS_VGEAR_RATIO_ENTRY CKGUID(0x36b93b1c,0x79f804c2)
#define VTS_VGEAR_RATIOS CKGUID(0x5a0230db,0x441f5c18)
#define VTS_VGEAR_CURVE CKGUID(0x6352317b,0x41fe3769)
#define VTS_VGEAR_SETTINGS CKGUID(0x7dde30fb,0x701915ea)
#define VTE_VEHICLE_XML_LINK CKGUID(0x4c43611,0x736078b9)
#define VTF_VEHICLE_PROCESS_OPTIONS CKGUID(0x24fa465f,0x1c2f5b88)
//################################################################
//
// Cloth
//
#define VTE_CLOTH_FLAGS CKGUID(0x2c7d5bb6,0x6a9d7c41)
#define VTS_CLOTH_DESCR CKGUID(0x722a5c01,0x5c8d413d)
#define VTS_CLOTH_METAL_DESCR CKGUID(0x1ecb0821,0x709e7bdf)
#define VTE_CLOTH_ATTACH_FLAGS CKGUID(0x428b755b,0x36d60122)
//################################################################
//
// UNknow :
//
#define VTS_PHYSIC_HEIGHTFIELD_PARAMETERS CKGUID(0x37430de4,0x54d06445)
#endif

View File

@ -0,0 +1,25 @@
/********************************************************************
created: 2009/02/16
created: 16:2:2009 7:23
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common\vtParameterAll.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common
file base: vtParameterAll
file ext: h
author: Günter Baumgart
purpose:
*********************************************************************/
#ifndef __VT_PARAMETER_STRUCTS_H__
#define __VT_PARAMETER_STRUCTS_H__
//################################################################
//
// Parameter Structures have been divided by type.
//
#include "vtParameterSubItemIdentifiers_Body.h"
#include "vtParameterSubItemIdentifiers_Joints.h"
#include "vtParameterSubItemIdentifiers_VehicleAndWheelStructs.h"
#include "vtParameterSubItemIdentifiers_World.h"
#endif

View File

@ -0,0 +1,336 @@
#ifndef __VT_BODY_STRUCTS_H__
#define __VT_BODY_STRUCTS_H__
//////////////////////////////////////////////////////////////////////////
//
// @todo : old custom structures, classical registered
//
typedef enum E_PHYSIC_PARAMETER_STRUCT
{
E_PPS_HULLTYPE,
E_PPS_BODY_FLAGS,
E_PPS_DENSITY,
E_PPS_SKIN_WIDTH,
E_PPS_MASS_OFFSET,
E_PPS_SHAPE_OFFSET,
E_PPS_HIRARCHY,
E_PPS_WORLD,
E_PPS_NEW_DENSITY,
E_PPS_TOTAL_MASS,
E_PPS_COLL_GROUP
};
typedef enum E_MATERIAL_STRUCT
{
E_MS_XML_TYPE,
E_MS_DFRICTION,
E_MS_SFRICTION,
E_MS_RESTITUTION,
E_MS_DFRICTIONV,
E_MS_SFRICTIONV,
E_MS_ANIS,
E_MS_FCMODE,
E_MS_RCMODE,
E_MS_FLAGS,
};
typedef enum E_RAY_CAST_STRUCT
{
E_RC_WORLD,
E_RC_ORI,
E_RC_ORI_REF,
E_RC_DIR,
E_RC_DIR_REF,
E_RC_LENGTH,
E_RC_GROUPS,
E_RC_GROUPS_MASK,
E_RC_SHAPES_TYPES
};
typedef enum E_CLOTH_STRUCT
{
E_CS_THICKNESS,
E_CS_DENSITY,
E_CS_BENDING_STIFFNESS,
E_CS_STRETCHING_STIFFNESS,
E_CS_DAMPING_COEFFICIENT,
E_CS_FRICTION,
E_CS_PRESSURE,
E_CS_TEAR_FACTOR,
E_CS_COLLISIONRESPONSE_COEFFICIENT,
E_CS_ATTACHMENTRESPONSE_COEFFICIENT,
E_CS_ATTACHMENT_TEAR_FACTOR,
E_CS_TO_FLUID_RESPONSE_COEFFICIENT,
E_CS_FROM_FLUIDRESPONSE_COEFFICIENT,
E_CS_MIN_ADHERE_VELOCITY,
E_CS_SOLVER_ITERATIONS,
E_CS_EXTERN_ALACCELERATION,
E_CS_WIND_ACCELERATION,
E_CS_WAKE_UP_COUNTER,
E_CS_SLEEP_LINEAR_VELOCITY,
E_CS_COLLISIONG_ROUP,
E_CS_VALID_BOUNDS,
E_CS_RELATIVE_GRID_SPACING,
E_CS_FLAGS,
E_CS_TEAR_VERTEX_COLOR,
E_CS_WORLD_REFERENCE,
E_CS_ATTACHMENT_FLAGS,
};
typedef enum E_WCD_STRUCT
{
E_WCD_CPOINT,
E_WCD_CNORMAL,
E_WCD_LONG_DIR,
E_WCD_LAT_DIR,
E_WCD_CONTACT_FORCE,
E_WCD_LONG_SLIP,
E_WCD_LAT_SLIP,
E_WCD_LONG_IMPULSE,
E_WCD_LAT_IMPULSE,
E_WCD_OTHER_MATERIAL_INDEX,
E_WCD_C_POS,
E_WCD_CONTACT_ENTITY,
};
typedef enum E_VBT_STRUCT
{
E_VBT_0,
E_VBT_1,
E_VBT_2,
E_VBT_3,
E_VBT_4,
E_VBT_5,
E_VBT_6,
E_VBT_7,
E_VBT_8,
E_VBT_9
};
typedef enum WHEEL_DESCR_STRUCT
{
E_WD_XML,
E_WD_SUSPENSION,
E_WD_SPRING_RES,
E_WD_DAMP,
E_WD_SPRING_BIAS,
E_WD_MAX_BFORCE,
E_WD_FSIDE,
E_WD_FFRONT,
E_WD_INVERSE_WHEEL_MASS,
E_WD_FLAGS,
E_WD_SFLAGS,
E_WD_LAT_FUNC,
E_WD_LONG_FUNC,
};
typedef enum E_CAPSULE_STRUCT
{
E_CS_LENGTH_AXIS,
E_CS_RADIUS_AXIS,
E_CS_LENGTH,
E_CS_RADIUS,
};
//////////////////////////////////////////////////////////////////////////
//
// New Structs
//
/**
\brief Data mask to determine which parts of a rigid bodies description have to
be evolved.
*/
enum pObjectDescrMask
{
/**
\brief Description has XML settings
*/
OD_XML = (1 << 0),
/**
\brief Description has pivot override
*/
OD_Pivot = (1 << 1),
/**
\brief Description has mass override
*/
OD_Mass= (1 << 2),
/**
\brief Description has collisions settings
*/
OD_Collision = (1 << 3),
/**
\brief Description has CCD settings
*/
OD_CCD = (1 << 4),
/**
\brief Description has material settings
*/
OD_Material = (1 << 5),
/**
\brief Description has optimization settings
*/
OD_Optimization = (1 << 6),
/**
\brief Description has capsule override
*/
OD_Capsule = (1 << 7),
/**
\brief Description has convex cylinder override
*/
OD_ConvexCylinder = (1 << 8),
/**
\brief Description has wheel settings
*/
OD_Wheel = (1 << 9)
};
enum PB_COPY_FLAGS
{
PB_CF_PHYSICS=1,
PB_CF_SHARE_MESHES=(1<<1),
PB_CF_PIVOT_SETTINGS=(1<<2),
PB_CF_MASS_SETTINGS=(1<<3),
PB_CF_COLLISION=(1<<4),
PB_CF_CCD=(1<<5),
PB_CF_MATERIAL=(1<<6),
PB_CF_OPTIMIZATION=(1<<7),
PB_CF_CAPSULE=(1<<8),
PB_CF_CONVEX_CYLINDER=(1<<9),
PB_CF_FORCE=(1<<10),
PB_CF_VELOCITIES=(1<<11),
PB_CF_JOINTS=(1<<12),
PB_CF_LIMIT_PLANES=(1<<13),
PB_CF_SWAP_JOINTS_REFERENCES=(1<<14),
PB_CF_OVRRIDE_BODY_FLAGS=(1<<15),
PB_CF_COPY_IC=(1<<16),
PB_CF_RESTORE_IC=(1<<17),
};
enum PS_B_COLLISON
{
PS_BC_GROUP,
PS_BC_GROUPSMASK,
PS_BC_SKINWITDH,
PS_BC_CCD_SETUP
};
enum PS_B_CCD
{
PS_B_CCD_MOTION_THRESHOLD,
PS_B_CCD_FLAGS,
PS_B_CCD_SCALE,
PS_B_CCD_MESH_REFERENCE,
};
enum PS_B_COLLISION_SETUP
{
PS_BCS_COLLISION_COMMON,
PS_BCS_CCD,
};
enum PS_B_DAMPING
{
PS_BD_LINEAR,
PS_BD_ANGULAR,
};
enum PS_B_SLEEPING
{
PS_BS_LINEAR_SLEEP,
PS_BS_ANGULAR_SLEEP,
PS_BS_THRESHOLD,
};
enum PS_B_OPTIMISATION
{
PS_BO_LOCKS,
PS_BO_DAMPING,
PS_BO_SLEEPING,
PS_BO_SOLVER_ITERATIONS,
PS_BO_DOMINANCE_GROUP,
PS_BO_COMPARTMENT_ID,
};
enum PS_B_PIVOT
{
PS_BP_LINEAR,
PS_BP_ANGULAR,
PS_BP_REFERENCE,
};
enum PS_B_MASS
{
PS_BM_DENSITY,
PS_BM_TOTAL_MASS,
PS_BM_PIVOT_POS,
PS_BM_PIVOT_ROTATION,
PS_BM_PIVOT_REFERENCE,
};
enum PS_BODY_FULL
{
PS_BODY_XML,
PS_BODY_HULL_TYPE,
PS_BODY_FLAGS,
};
enum PS_BODY_XML_SETUP
{
PS_INTERN_LINK,
PS_EXTERN_LINK,
PS_XML_MPORT_FLAGS,
};
enum PS_BODY_COMMON
{
PS_BC_HULL_TYPE,
PS_BC_DENSITY,
PS_BC_FLAGS,
/* PS_BC_TFLAGS,*/
PS_BC_WORLD
};
enum PS_BODY_SETUP
{
PS_XML_SETUP,
PS_COMMON_SETTINGS,
/*PS_PIVOT,
PS_MASS,*/
PS_COLLISION_SETTINGS,
};
enum PS_AXIS_REFERENCED_LENGTH
{
PS_ARL_VALUE,
PS_ARL_REF_OBJECT,
PS_ARL_REF_OBJECT_AXIS,
};
enum PS_CAPSULE
{
PS_BCAPSULE_RADIUS_REFERENCED_VALUE,
PS_PCAPSULE_HEIGHT_REFERENCED_VALUE,
};
enum PS_CUSTOM_CONVEX_CYLINDER_DESCR
{
PS_CC_APPROXIMATION,
PS_CC_RADIUS_REFERENCED_VALUE,
PS_CC_HEIGHT_REFERENCED_VALUE,
PS_CC_FORWARD_AXIS,
PS_CC_FORWARD_AXIS_REF,
PS_CC_DOWN_AXIS,
PS_CC_DOWN_AXIS_REF,
PS_CC_RIGHT_AXIS,
PS_CC_RIGHT_AXIS_REF,
PS_CC_BUILD_LOWER_HALF_ONLY,
PS_CC_EXTRA_SHAPE_FLAGS
};
#endif

View File

@ -0,0 +1,182 @@
/********************************************************************
created: 2009/02/17
created: 17:2:2009 8:14
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\include\core\Common\vtParameterSubItemIdentifiers_Joints.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\include\core\Common
file base: vtParameterSubItemIdentifiers_Joints
file ext: h
author: Günter Baumgart
purpose: Joint parameter items for custom structures.
*********************************************************************/
#ifndef __VTPARAMETERSUBITEMIDENTIFIERS_JOINTS_H__
#define __VTPARAMETERSUBITEMIDENTIFIERS_JOINTS_H__
enum PS_JPOINT_ON_LINE_MEMBERS
{
PS_JPOL_BODY_B,
PS_JPOL_ANCHOR,
PS_JPOL_ANCHOR_REF,
PS_JPOL_AXIS,
PS_JPOL_AXIS_REF,
PS_JPOL_COLLISION,
PS_JPOL_MAX_FORCE,
PS_JPOL_MAX_TORQUE,
};
enum PS_JPOINT_IN_PLANE_MEMBERS
{
PS_JPIP_BODY_B,
PS_JPIP_ANCHOR,
PS_JPIP_ANCHOR_REF,
PS_JPIP_AXIS,
PS_JPIP_AXIS_REF,
PS_JPIP_COLLISION,
PS_JPIP_MAX_FORCE,
PS_JPIP_MAX_TORQUE,
};
enum PS_JREVOLUTE
{
PS_JREVOLUTE_BODY_B,
PS_JREVOLUTE_ANCHOR,
PS_JREVOLUTE_ANCHOR_REF,
PS_JREVOLUTE_AXIS,
PS_JREVOLUTE_AXIS_REF,
PS_JREVOLUTE_COLLISION,
PS_JREVOLUTE_PROJ_MODE,
PS_JREVOLUTE_PROJ_DISTANCE,
PS_JREVOLUTE_PROJ_ANGLE,
PS_JREVOLUTE_SPRING,
PS_JREVOLUTE_LIMIT_HIGH,
PS_JREVOLUTE_LIMIT_LOW,
PS_JREVOLUTE_MOTOR,
PS_JREVOLUTE_MAX_FORCE,
PS_JREVOLUTE_MAX_TORQUE,
};
enum PS_JCYLINDRICAL_MEMBERS
{
PS_JCYLINDRICAL_BODY_B,
PS_JCYLINDRICAL_ANCHOR,
PS_JCYLINDRICAL_ANCHOR_REF,
PS_JCYLINDRICAL_AXIS,
PS_JCYLINDRICAL_AXIS_REF,
PS_JCYLINDRICAL_COLLISION,
PS_JCYLINDRICAL_MAX_FORCE,
PS_JCYLINDRICAL_MAX_TORQUE,
};
enum PS_JPRISMATIC_MEMBERS
{
PS_JPRISMATIC_BODY_B,
PS_JPRISMATIC_ANCHOR,
PS_JPRISMATIC_ANCHOR_REF,
PS_JPRISMATIC_AXIS,
PS_JPRISMATIC_AXIS_REF,
PS_JPRISMATIC_COLLISION,
PS_JPRISMATIC_MAX_FORCE,
PS_JPRISMATIC_MAX_TORQUE,
};
enum PS_JBALL_MEMBERS
{
PS_JBALL_BODY_B,
PS_JBALL_ANCHOR,
PS_JBALL_ANCHOR_REF,
PS_JBALL_GLOBAL_AXIS,
PS_JBALL_GLOBAL_AXIS_REF,
PS_JBALL_LIMIT_SWING_AXIS,
PS_JBALL_PROJ_MODE,
PS_JBALL_PROJ_DISTANCE,
PS_JBALL_COLLISION,
PS_JBALL_SWING_LIMIT,
PS_JBALL_TWIST_HIGH,
PS_JBALL_TWIST_LOW,
PS_JBALL_SWING_SPRING,
PS_JBALL_TWIST_SPRING,
PS_JBALL_JOINT_SPRING,
PS_JBALL_MAX_FORCE,
PS_JBALL_MAX_TORQUE,
};
enum PS_JFIXED_MEMBERS
{
PS_JFIXED_BODY_B,
PS_JFIXED_MAX_FORCE,
PS_JFIXED_MAX_TORQUE,
};
enum PS_JDISTANCE_MEMBERS
{
PS_JDISTANCE_BODY_B,
PS_JDISTANCE_LOCAL_ANCHOR_A_POS,
PS_JDISTANCE_LOCAL_ANCHOR_A_REF,
PS_JDISTANCE_LOCAL_ANCHOR_B_POS,
PS_JDISTANCE_LOCAL_ANCHOR_B_REF,
PS_JDISTANCE_COLL,
PS_JDISTANCE_MIN_DISTANCE,
PS_JDISTANCE_MAX_DISTANCE,
PS_JDISTANCE_SPRING,
PS_JDISTANCE_MAX_FORCE,
PS_JDISTANCE_MAX_TORQUE,
};
enum PS_JLIMIT_PLANE_MEMBERS
{
PS_JLP_BODY_B_REF,
PS_JLP_JOINT_TYPE,
PS_JLP_RESTITUTION,
PS_JLP_IS_ON_BODY_B,
PS_JLP_LIMIT_POINT,
PS_JLP_LIMIT_POINT_REF,
PS_JLP_NORMAL,
PS_JLP_NORMAL_REF,
PS_JLP_PT_IN_PLANE,
PS_JLP_PT_IN_PLANE_REF,
};
enum PS_D6_AXIS_ITEM
{
PS_D6_AXIS_ITEM_MODE,
PS_D6_AXIS_ITEM_LIMIT,
};
enum PS_D6
{
PS_JD6_BODY_B,
PS_JD6_ANCHOR,
PS_JD6_ANCHOR_REF,
PS_JD6_AXIS,
PS_JD6_AXIS_REF,
PS_JD6_AXIS_MASK,
PS_JD6_X,
PS_JD6_Y,
PS_JD6_Z,
PS_JD6_TWIST_SWING1,
PS_JD6_TWIST_SWING2,
PS_JD6_TWIST_LOW,
PS_JD6_TWIST_HIGH,
};
#endif

View File

@ -0,0 +1,22 @@
#ifndef __VEHICLE_AND_WHEEL_STRUCTS_H__
#define __VEHICLE_AND_WHEEL_STRUCTS_H__
/*
typedef enum PS_WHEELSHAPE
{
E_WD_XML,
E_WD_SUSPENSION,
E_WD_SPRING_RES,
E_WD_DAMP,
E_WD_SPRING_BIAS,
E_WD_MAX_BFORCE,
E_WD_FSIDE,
E_WD_FFRONT,
E_WD_APPROX,
E_WD_FLAGS,
E_WD_SFLAGS,
E_WD_LAT_FUNC,
E_WD_LONG_FUNC,
};
*/
#endif

View File

@ -0,0 +1,37 @@
#ifndef __VT_WORLD_STRUCTS_H__
#define __VT_WORLD_STRUCTS_H__
enum PS_W_DOMINANCE_CONSTRAINT
{
PS_WDC_A,
PS_WDC_B,
};
enum PS_W_DOIMINANCE
{
PS_WD_GROUP_A,
PS_WD_GROUP_B,
PS_WD_CONSTRAINT,
};
enum PS_W_DOIMINANCE_SETUP
{
PS_WDS_ITEM1,
PS_WDS_ITEM2,
PS_WDS_ITEM3,
PS_WDS_ITEM4,
PS_WDS_ITEM5,
};
#endif

View File

@ -0,0 +1,119 @@
/********************************************************************
created: 2009/02/16
created: 16:2:2009 11:07
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common\vtPhysXBase.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common
file base: vtPhysXBase
file ext: h
author: Günter Baumgart
purpose: Minimal includes for the whole component.
+ Generic macros and constants, functions
+ Virtools specific forward decalarations
+ Generic base types such as std::vector
+ Component specific forward decalarations
+ Disabling Module specific Visual Studio compiler Warnings
+ Prerequisites
+ Virtools Base Types ( XString, CKGUID, HashTable )
+ Constants
warning: The order of the includes must stay !
remarks: - This module is using the concept of forward declaration
- This header is the base for all other headers.
- Do not introduce any platform specific dependencies( ie: windows.h )
*********************************************************************/
#ifndef __VT_PHYSX_BASE_H__
#define __VT_PHYSX_BASE_H__
//################################################################
//
// Generic
//
//----------------------------------------------------------------
//
// Include of base types, not involving external dependencies to std,etc..
//
#include <xBaseTypes.h>
//----------------------------------------------------------------
//
// Class to encapsulate a set of flags in a word, using shift operators
//
#include <xBitSet.h>
//----------------------------------------------------------------
//
// Macros for generic DLL exports
//
#include <BaseMacros.h>
//----------------------------------------------------------------
//
// Include of Virtools related macros
//
#include <vtBaseMacros.h>
//################################################################
//
// Component specific constants,strings, error codes
//
//----------------------------------------------------------------
//
// + API Prefix
// + Error Codes
// + Error Strings
//
#include "vtModuleConstants.h"
//----------------------------------------------------------------
//
// Virtools Guids of the plug-in ( manager + building block only !!! )
//
// GUIDS for custom enumerations, structures are included by the managers
// parameter_x.cpp explicitly !
//
#include "vtModuleGuids.h"
//----------------------------------------------------------------
//
// Enumerations to identifier a custom structure's sub item
//
#include "vtParameterSubItemIdentifiers_All.h"
//----------------------------------------------------------------
//
// Enumerations used by the SDK and the Virtools Interface ( Schematics, VSL)
//
#include "vtInterfaceEnumeration.h"
//################################################################
//
// Compiler specific warnings
//
#include "vcWarnings.h"
//################################################################
//
// Prerequisites
//
#include "Prerequisites_All.h"
#endif

View File

@ -0,0 +1,138 @@
#ifndef __VT_STRUCT_HELPER_H__
#define __VT_STRUCT_HELPER_H__
namespace vtTools
{
namespace ParameterTools
{
struct StructurMember
{
CKGUID guid; XString name; XString defaultValue;
CKObject *par;
StructurMember()
{
guid = CKGUID(0,0); name = ""; defaultValue = "";
}
StructurMember(CKGUID _guid,XString _name,XString _defaultValue) :
guid(_guid) , name(_name) , defaultValue(_defaultValue)
{
}
};
class CustomStructure
{
public :
CustomStructure(){}
CustomStructure(XString name,CKGUID guid,StructurMember members[],int size) : mGuid(guid) , mName(name)
{
for (int i = 0 ; i < size ; i ++)
{
StructurMember *p=new StructurMember(members[i].guid,members[i].name,members[i].defaultValue);
getArray().push_back(p);
}
}
std::vector<StructurMember*>pars;
std::vector<StructurMember*>&getArray()
{
return pars;
}
CKGUID mGuid;
XString mName;
};
class StructHelper
{
public :
static XArray<CKGUID>getMemberGuids(CustomStructure _inStructure)
{
XArray<CKGUID>result;
int size = _inStructure.getArray().size();
for (int i = 0 ; i < size ; i ++)
{
StructurMember *m=_inStructure.getArray().at(i);
result.PushBack(m->guid);
}
return result;
}
static XString getLabelNames(CustomStructure _inStructure)
{
XString result;
int size = _inStructure.getArray().size();
for (int i = 0 ; i < size ; i ++)
{
StructurMember *m=_inStructure.getArray().at(i);
result << m->name.CStr();
if (i != size -1)
{
result << ",";
}
}
return result;
}
static XString getDefaultValue(CustomStructure _inStructure)
{
XString result;
int size = _inStructure.getArray().size();
for (int i = 0 ; i < size ; i ++)
{
StructurMember *m=_inStructure.getArray().at(i);
result << m->defaultValue.CStr();
if (i != size -1)
{
result << ";";
}
}
return result;
}
};
}
}
#define STRUCT_ATTRIBUTE(G,N,D) vtTools::ParameterTools::StructurMember(G,N,D)
#define DECLARE_STRUCT(T,N,G,A,S) CustomStructure cs##T(N,G,A,S)
#define STRUCT_SIZE(SOURCE_MAP) (sizeof(SOURCE_MAP) / sizeof(SOURCE_MAP[0]))
#define STRUCT_MEMBER_NAMES(SRC) vtTools::ParameterTools::StructHelper::getLabelNames(cs##SRC)
#define STRUCT_MEMBER_GUIDS(SRC) vtTools::ParameterTools::StructHelper::getMemberGuids(cs##SRC)
#define STRUCT_MEMBER_DEFAULTS(SRC) vtTools::ParameterTools::StructHelper::getDefaultValue(cs##SRC)
#define REGISTER_CUSTOM_STRUCT(NAME,ENUM_TYPE,GUID,MEMBER_ARRAY,HIDDEN) DECLARE_STRUCT(ENUM_TYPE,NAME,GUID,MEMBER_ARRAY,STRUCT_SIZE(MEMBER_ARRAY)); \
XArray<CKGUID> ListGuid##ENUM_TYPE = STRUCT_MEMBER_GUIDS(ENUM_TYPE);\
pm->RegisterNewStructure(GUID,NAME,STRUCT_MEMBER_NAMES(ENUM_TYPE).Str(),ListGuid##ENUM_TYPE);\
CKParameterTypeDesc* param_type##ENUM_TYPE=pm->GetParameterTypeDescription(GUID);\
if (param_type##ENUM_TYPE && HIDDEN) param_type##ENUM_TYPE->dwFlags|=CKPARAMETERTYPE_HIDDEN;\
_getCustomStructures().Insert(GUID,(CustomStructure*)&MEMBER_ARRAY)
#define REGISTER_STRUCT_AS_ATTRIBUTE(NAME,ENUM_TYPE,CATEGORY,GUID,CLASS,MEMBER_ARRAY,USE_DEFAULTS) int att##ENUM_TYPE = attman->RegisterNewAttributeType(NAME,GUID,CLASS);\
attman->SetAttributeCategory(att##ENUM_TYPE,CATEGORY);\
if(USE_DEFAULTS)\
attman->SetAttributeDefaultValue(att##ENUM_TYPE,STRUCT_MEMBER_DEFAULTS(ENUM_TYPE).Str());
#endif

View File

@ -0,0 +1,49 @@
/********************************************************************
created: 2009/02/17
created: 17:2:2009 8:23
filename: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common\xBaseTypes.h
file path: x:\ProjectRoot\svn\local\vtPhysX\SDK\Include\Core\Common
file base: xBaseTypes
file ext: h
author: Günter Baumgart
purpose: Type definitions, Arrays, ...
*********************************************************************/
#ifndef __X_BASE_TYPES_H__
#define __X_BASE_TYPES_H__
//################################################################
//
// Float, Integers, Boolean
//
#ifndef u32
typedef unsigned int u32;
#endif
namespace xBase
{
typedef float xReal32;
typedef int xS32;
typedef unsigned int xU32;
typedef bool xBool;
typedef unsigned short xU16;
}
using xBase::xS32;
using xBase::xU32;
using xBase::xReal32;
using xBase::xBool;
using xBase::xU16;
//################################################################
//
// Containers
//
#include<stdlib.h>
#include <map>
#include <vector>
#endif // __XBASETYPES_H__

View File

@ -0,0 +1,5 @@
#ifndef __VTODE_ENUMS_H_
#define __VTODE_ENUMS_H_
#endif

View File

@ -0,0 +1,42 @@
// racer/time.h
#ifndef __X_TIME_H__
#define __X_TIME_H__
#include <qTimer.h>
#include <BaseMacros.h>
class MODULE_API xTime
// A notion of simulation time
{
protected:
float span; // Time of integration (in seconds)
int spanMS; // Time of integration in milliseconds
QTimer *tmr; // Actual real timer
int curRealTime; // Last recorded REAL time in msecs
int curSimTime; // Time calculated in the sim
int lastSimTime; // Last point of simulation
public:
xTime();
~xTime();
// Attribs
int GetRealTime(){ return curRealTime; }
int GetSimTime(){ return curSimTime; }
int GetLastSimTime(){ return lastSimTime; }
int GetSpanMS(){ return spanMS; }
inline float GetSpan(){ return span; }
void AddSimTime(int msecs);
void SetLastSimTime(){ lastSimTime=curSimTime; }
void SetSpan(int ms);
// Methods
void Start();
void Stop();
void Reset();
void Update();
};
#endif

View File

@ -0,0 +1,332 @@
#include "..\stdafx.h"
#include "InfoZip.h"
#include <winbase.h>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CInfoZip::CInfoZip(){
m_ZipDllHandle = NULL;
m_ZipDllExec = NULL;
m_GetZipDllVersion = NULL;
m_UnzipDllHandle = NULL;
m_UnzipDllExec = NULL;
m_GetUnzipDllVersion = NULL;
}
CInfoZip::~CInfoZip(){
//Finalize();
}
int CInfoZip::GetZipDllVersion()
{
if (GetInitializedZip())
return m_GetZipDllVersion();
else
{
SetLastError(ZERROR_NOT_INITIALIZED);
return 0;
}
}
int CInfoZip::GetUnzipDllVersion()
{
if (GetInitializedUnzip())
return m_GetUnzipDllVersion();
else
{
SetLastError(ZERROR_NOT_INITIALIZED);
return 0;
}
}
void CInfoZip::SetLastError(UINT uiError)
{
m_uiLastError = uiError;
}
UINT CInfoZip::GetLastError()
{
return m_uiLastError;
}
BOOL CInfoZip::GetInitialized()
{
return GetInitializedZip() && GetInitializedUnzip();
}
void CInfoZip::SetDefaultValues(CZipParams * pParams){
pParams->m_hwndHandle = NULL;
pParams->m_pCaller = NULL;
pParams->m_liVersion = GetZipDllVersion();
pParams->m_pfCallbackFunction = DefaultZipCallback;
pParams->m_bTraceEnabled = FALSE;
/*============== Begin Zip Flag section ============== */
pParams->m_pszZipPassword = NULL;
pParams->m_bSuffix = FALSE;
pParams->m_bEncrypt = FALSE;
pParams->m_bSystem = TRUE;
pParams->m_bVolume = FALSE;
pParams->m_bExtra = FALSE;
pParams->m_bNoDirEntries = FALSE;
pParams->m_bDate = FALSE;
pParams->m_bVerboseEnabled = FALSE;
pParams->m_bQuiet = FALSE;
pParams->m_bLevel = 5;
pParams->m_bComprSpecial = FALSE;
pParams->m_bCRLF_LF = FALSE;
pParams->m_bJunkDir = FALSE;
pParams->m_bRecurse = FALSE;
pParams->m_bGrow = TRUE;
pParams->m_bForce = FALSE;
pParams->m_bMove = FALSE;
pParams->m_bDeleteEntries = FALSE;
pParams->m_bUpdate = FALSE;
pParams->m_bFreshen = FALSE;
pParams->m_bJunkSFX = FALSE;
pParams->m_bLatestTime = FALSE;
/*============== End Zip Flag section ============== */
for (int j=0; j<8; j++)
pParams->m_cDate[j] = 0;
pParams->m_liFileCount = 0;
pParams->m_pszArchiveFileName = NULL;
pParams->m_liSeven = 7;
// char *PFileNames[MAX_PATH+1];
}
BOOL CInfoZip::Execute(CZipParams * pParams)
{
if (!GetInitializedZip())
return FALSE;
m_ZipDllExec(pParams);
return TRUE;
}
BOOL CInfoZip::AddFiles(const char *pszArchive, char ** paFiles, int iFileCount)
{
CZipParams zpParams;
SetDefaultValues(&zpParams);
// seting archive name
zpParams.m_pszArchiveFileName = (char*)malloc(strlen(pszArchive)+1);
ZeroMemory(zpParams.m_pszArchiveFileName, strlen(pszArchive)+1);
strcpy(zpParams.m_pszArchiveFileName, pszArchive);
// seting file count
zpParams.m_liFileCount = iFileCount;
// seting file names
for (int i=0; i<iFileCount; i++)
{
zpParams.m_pszFileNames[i] = (char*)malloc(MAX_PATH+1);
ZeroMemory(zpParams.m_pszFileNames[i], MAX_PATH+1);
strcpy(zpParams.m_pszFileNames[i], paFiles[i]);
}
// executing command
int iProcessedCount = m_ZipDllExec(&zpParams);
ReleaseParams(&zpParams);
return (iProcessedCount == iFileCount);
}
BOOL __stdcall DefaultZipCallback(CZipCallbackData *pData)
{
if (pData->m_liErrorCode)
{
char pszErrorCode[1024];
sprintf(pszErrorCode, "Zip error %d:\n%s", pData->m_liErrorCode, pData->m_pszFileNameOrMsg);
AfxMessageBox(pszErrorCode);
}
return FALSE;
}
void CInfoZip::ReleaseParams(CZipParams * pParams)
{
free(pParams->m_pszArchiveFileName);
for (int i=0; i<pParams->m_liFileCount; i++)
free(pParams->m_pszFileNames[i]);
}
BOOL CInfoZip::GetInitializedZip()
{
return m_ZipDllHandle && m_GetZipDllVersion && m_ZipDllExec;
}
BOOL CInfoZip::GetInitializedUnzip()
{
return m_UnzipDllHandle && m_GetUnzipDllVersion && m_UnzipDllExec;
}
BOOL CInfoZip::InitializeZip(char *tempfile){
BOOL bInitialized = GetInitializedZip();
if (GetInitializedUnzip())
return TRUE;
m_ZipDllHandle = LoadLibrary(tempfile);
if (!m_ZipDllHandle)
{
SetLastError(ZERROR_DLL_NOT_FOUND);
return FALSE;
}
m_GetZipDllVersion = (CGetZipDllVersion)GetProcAddress(m_ZipDllHandle, "GetZipDllVersion");
if (!m_GetZipDllVersion)
{
SetLastError(ZERROR_DLL_FOUNCTION_NOT_FOUND);
return FALSE;
}
m_ZipDllExec = (CZipDllExec)GetProcAddress(m_ZipDllHandle, "ZipDllExec");
if (!m_ZipDllExec)
{
SetLastError(ZERROR_DLL_FOUNCTION_NOT_FOUND);
return FALSE;
}
return TRUE;
}
BOOL CInfoZip::InitializeUnzip()
{
BOOL bInitialized = GetInitializedUnzip();
if (GetInitializedUnzip())
return TRUE;
m_UnzipDllHandle = LoadLibrary("UNZDLL.DLL");
if (!m_UnzipDllHandle)
{
SetLastError(ZERROR_DLL_NOT_FOUND);
return FALSE;
}
m_GetUnzipDllVersion = (CGetUnzipDllVersion)GetProcAddress(m_UnzipDllHandle, "GetUnzDllVersion");
if (!m_GetUnzipDllVersion)
{
SetLastError(ZERROR_DLL_FOUNCTION_NOT_FOUND);
return FALSE;
}
m_UnzipDllExec = (CUnzipDllExec)GetProcAddress(m_UnzipDllHandle, "UnzDllExec");
if (!m_UnzipDllExec)
{
SetLastError(ZERROR_DLL_FOUNCTION_NOT_FOUND);
return FALSE;
}
return TRUE;
}
BOOL CInfoZip::FinalizeZip(char *tempfile){
if (GetInitializedZip()){
FreeLibrary(m_ZipDllHandle);
m_ZipDllHandle = NULL;
m_ZipDllExec = NULL;
m_GetZipDllVersion = NULL;
DeleteFile(tempfile);
}
return TRUE;
}
BOOL CInfoZip::FinalizeUnzip()
{
if (GetInitializedUnzip())
{
FreeLibrary(m_UnzipDllHandle);
m_UnzipDllHandle = NULL;
m_UnzipDllExec = NULL;
m_GetUnzipDllVersion = NULL;
}
return TRUE;
}
BOOL CInfoZip::Execute(CUnzipParams * pParams)
{
if (!GetInitializedUnzip())
return FALSE;
m_UnzipDllExec(pParams);
return TRUE;
}
void CInfoZip::ReleaseParams(CUnzipParams * pParams)
{
free(pParams->m_pszArchiveFileName);
for (int i=0; i<pParams->m_liFileCount; i++)
free(pParams->m_pszFileNames[i]);
}
void CInfoZip::SetDefaultValues(CUnzipParams * pParams)
{
pParams->m_wndHandle = NULL;
pParams->m_pCaller = NULL;
pParams->m_liVersion = GetUnzipDllVersion();
pParams->m_pfCallbackFunction = DefaultZipCallback;
pParams->m_bTraceEnabled = FALSE;
pParams->m_bPromptToOverwrite = FALSE;
pParams->m_bTest = FALSE;
pParams->m_bComments = FALSE;
pParams->m_bConvert = FALSE;
pParams->m_bQuiet = FALSE;
pParams->m_bVerboseEnabled = FALSE;
pParams->m_bUpdate = FALSE;
pParams->m_bFreshen = FALSE;
pParams->m_bDirectories = TRUE;
pParams->m_bOverwrite = TRUE;
pParams->m_liFileCount = 0;
pParams->m_pszArchiveFileName = NULL;
pParams->m_liSeven = 7;
pParams->m_pszZipPassword = NULL;
}
BOOL CInfoZip::ExtractFiles(const char * pszArchive, const char * pszTargetFolder)
{
char pszCurrentDir[MAX_PATH+1];
ZeroMemory(pszCurrentDir, MAX_PATH+1);
GetCurrentDirectory(MAX_PATH+1, pszCurrentDir);
SetCurrentDirectory(pszTargetFolder);
CUnzipParams uzpParams;
SetDefaultValues(&uzpParams);
// seting archive name
uzpParams.m_pszArchiveFileName = (char*)malloc(strlen(pszArchive)+1);
ZeroMemory(uzpParams.m_pszArchiveFileName, strlen(pszArchive)+1);
strcpy(uzpParams.m_pszArchiveFileName, pszArchive);
// seting file count
uzpParams.m_liFileCount = 1;
// seting file names
uzpParams.m_pszFileNames[0] = (char*)malloc(MAX_PATH+1);
ZeroMemory(uzpParams.m_pszFileNames[0], MAX_PATH+1);
strcpy(uzpParams.m_pszFileNames[0], "*.*");
// executing command
int iProcessedCount = m_UnzipDllExec(&uzpParams);
ReleaseParams(&uzpParams);
SetCurrentDirectory(pszCurrentDir);
return TRUE;
}

View File

@ -0,0 +1,58 @@
#include "ZipDll.h"
#include "UnzipDll.h"
#include "CKAll.h"
//#include "..\Manager\ZipManager.h"
#define ZERROR_NONE 0
#define ZERROR_DLL_NOT_FOUND 1
#define ZERROR_DLL_FOUNCTION_NOT_FOUND 2
#define ZERROR_NOT_INITIALIZED 3
class CInfoZip {
public:
CInfoZip();
virtual ~CInfoZip();
BOOL ExtractFiles(const char* pszArchive, const char* pszTargetFolder);
void SetDefaultValues(CUnzipParams *pParams);
void ReleaseParams(CUnzipParams *pParams);
BOOL Execute(CUnzipParams *pParams);
BOOL FinalizeUnzip();
BOOL FinalizeZip(char *tempfile);
BOOL InitializeUnzip();
BOOL InitializeZip(char *tempfile);
BOOL GetInitializedUnzip();
BOOL GetInitializedZip();
void ReleaseParams(CZipParams *pParams);
BOOL AddFiles(const char *pszArchive, char **paFiles, int iFileCount);
BOOL Execute(CZipParams *pParams);
void SetDefaultValues(CZipParams *pZipParms);
BOOL GetInitialized();
UINT GetLastError();
int GetZipDllVersion();
int GetUnzipDllVersion();
CZipDllExec m_ZipDllExec;
void SetLastError(UINT uiError);
UINT m_uiLastError;
HINSTANCE m_ZipDllHandle;
HINSTANCE m_UnzipDllHandle;
CUnzipDllExec m_UnzipDllExec;
CGetZipDllVersion m_GetZipDllVersion;
private:
};
BOOL __stdcall DefaultZipCallback(CZipCallbackData *pData);

View File

@ -0,0 +1,41 @@
#ifndef CKPhysicManager_H
#define CKPhysicManager_H "$Id:$"
#include "vtPhysXBase.h"
#include "CKBaseManager.h"
class MODULE_API CKPhysicManager :public CKBaseManager {
public:
#ifdef DOCJETDUMMY // Docjet secret macro
#else
virtual CKERROR OnCKInit()=0;
virtual CKERROR PostClearAll()=0;
virtual CKERROR PreSave()=0;
virtual CKERROR OnCKReset()=0;
virtual CKERROR PreProcess()=0;
virtual CKDWORD GetValidFunctionsMask() { return CKMANAGER_FUNC_PostClearAll|
CKMANAGER_FUNC_OnCKInit|
CKMANAGER_FUNC_PreSave|
CKMANAGER_FUNC_PostLoad|
CKMANAGER_FUNC_OnCKReset|
CKMANAGER_FUNC_PreProcess;
}
virtual void _RegisterParameters()=0;
virtual void _RegisterVSL()=0;
CKPhysicManager(CKContext *Context,CKGUID guid,char* name);
virtual ~CKPhysicManager() {}
#endif // Docjet secret macro
};
// CK2 VERSION ...
#endif

View File

@ -0,0 +1,218 @@
#ifndef DataManager_H
#define DataManager_H "$Id:$"
#include "CKBaseManager.h"
// define whether we use the manager to relay data or the global variable
#define USE_MANAGER
// [4/13/2009 macro willson] new headers for external access added
#include "gConfig.h"
//----------------------------------------------------------------
//
// External access
//
#ifdef G_EXTERNAL_ACCESS
#include <WTypes.h> //! @todo : HANDLE type
#include "MemoryFileMappingTypes.h" //! todo : use forwards
#endif // G_EXTERNAL_ACCESS
//----------------------------------------------------------------
//
// unique object identifiers
//
#define DataManagerGUID CKGUID(0x5164ef93, 0x384edab9)
class DataManager : public CKBaseManager
{
//##############################################################
// Public Part
//##############################################################
public :
DataManager(CKContext* Context);
~DataManager();
VxVector _vPos;
#ifdef G_EXTERNAL_ACCESS
// [4/13/2009 macro willson]
//----------------------------------------------------------------
//
// External access : data members
//
HANDLE m_hMMFile;
vtExternalEvent *m_pData;
//----------------------------------------------------------------
//
// External access : functions
//
/*!
\brief initiates shared memory helper objects. Must be called due CKInit
*/
int _initSharedMemory(int);
/*
\brief handles messages. Must be called in a PreProcess.
*/
int _SharedMemoryTick(int);
/*
\brief Might be silly. Just to clean up. Must be called in PostProcess.
*/
int _SharedMemoryTickPost(int);
//----------------------------------------------------------------
#endif
// [4/13/2009 macro willson] : enabled for external access
/*!
\brief Called at the end of each process loop.
*/
virtual CKERROR PostProcess();
//--- Called at the beginning of each process loop.
virtual CKERROR PreProcess();
// -- Called once at CKPlay. Needed to initiate shared memory
CKERROR OnCKInit();
//- set function mask for pre and post process callbacks
virtual CKDWORD GetValidFunctionsMask()
{
return CKMANAGER_FUNC_OnCKInit|CKMANAGER_FUNC_PostProcess|CKMANAGER_FUNC_PreProcess;
}
// [4/14/2009 macro willson] : end external access ----------------------------------------------------------------
//--------------------------------------------------------------
// Unused methods
//--------------------------------------------------------------
/*
//--- Called after the composition has been restarted.
virtual CKERROR OnCKPostReset();
//--- Called before the composition is reset.
virtual CKERROR OnCKReset();
//--- Called when the process loop is started.
virtual CKERROR OnCKPlay();
//--- Called when the process loop is paused.
virtual CKERROR OnCKPause();
//--- Called before a scene becomes active.
virtual CKERROR PreLaunchScene(CKScene* OldScene, CKScene* NewScene);
//--- Called after a scene became active.
virtual CKERROR PostLaunchScene(CKScene* OldScene, CKScene* NewScene);
//--- Called at the beginning of a copy.
virtual CKERROR OnPreCopy(CKDependenciesContext& context);
//--- Called at the end of a copy.
virtual CKERROR OnPostCopy(CKDependenciesContext& context);
//--- Called when objects are added to a scene.
virtual CKERROR SequenceAddedToScene(CKScene* scn, CK_ID* objids, int count);
//--- Called when objects are removed from a scene.
virtual CKERROR SequenceRemovedFromScene(CKScene* scn, CK_ID* objids, int count);
//--- Called just before objects are deleted.
virtual CKERROR SequenceToBeDeleted(CK_ID* objids, int count);
//--- Called after objects have been deleted.
virtual CKERROR SequenceDeleted(CK_ID* objids, int count);
//--- Called before the rendering of the 3D objects.
virtual CKERROR OnPreRender(CKRenderContext* dev);
//--- Called after the rendering of the 3D objects.
virtual CKERROR OnPostRender(CKRenderContext* dev);
//--- Called after the rendering of 2D entities.
virtual CKERROR OnPostSpriteRender(CKRenderContext* dev);
//--- Called before the backbuffer is presented.
virtual CKERROR OnPreBackToFront(CKRenderContext* dev);
//--- Called after the backbuffer is presented.
virtual CKERROR OnPostBackToFront(CKRenderContext* dev);
//--- Called before switching to/from fullscreen.
virtual CKERROR OnPreFullScreen(BOOL Going2Fullscreen, CKRenderContext* dev);
//--- Called after switching to/from fullscreen.
virtual CKERROR OnPostFullScreen(BOOL Going2Fullscreen, CKRenderContext* dev);
//--- Called at the end of the creation of a CKContext.
//--- Called at deletion of a CKContext.
virtual CKERROR OnCKEnd();
//--- Called at the beginning of a load operation.
virtual CKERROR PreLoad();
//--- Called to load manager data.
virtual CKERROR LoadData(CKStateChunk* chunk, CKFile* LoadedFile) { return CK_OK; }
//--- Called at the end of a load operation.
virtual CKERROR PostLoad();
//--- Called at the beginning of a save operation.
virtual CKERROR PreSave();
//--- Called to save manager data. return NULL if nothing to save.
virtual CKStateChunk* SaveData(CKFile* SavedFile) { return NULL; }
//--- Called at the end of a save operation.
virtual CKERROR PostSave();
//--- Called at the beginning of a CKContext::ClearAll operation.
virtual CKERROR PreClearAll();
//--- Called at the end of a CKContext::ClearAll operation.
virtual CKERROR PostClearAll();
*/
//##############################################################
// Protected Part
//##############################################################
protected :
};
#endif

View File

@ -0,0 +1,149 @@
/********************************************************************
created: 2003/12/01
filename: H:\XLANG PROJECTS\BASE\INCLUDES\Dll_Tools.h
file path: H:\XLANG PROJECTS\BASE\INCLUDES
file base: Dll_Tools
file ext: h
author: Günter Baumgart
purpose: rum DLL´eln
*********************************************************************/
#ifndef __Dll_Tools_h_
#define __Dll_Tools_h_ "$Id:$"
#include <stdlib.h>
#include <string>
#include <windows.h>
//////////////////////////////////////////////////////////////////////////
//ie:
// the fnc prototyp : typedef HINSTANCE(WINAPI *_ShellExec_proto)(HWND,const char *,const char*,const char*,const char *,int);
// the fill : DLL::DllFunc<_ShellExec_proto>_ShellExec(_T("shell32.dll"),"ShellExecute");
template<class T> class DllFunc
{
public:
DllFunc(const char* dllName, const char* fnName ,const bool logging = TRUE ) :
dllHandle( LoadLibrary (dllName) ) , fn(0)
{
if (!dllHandle && logging)
{
//loggin @:
return;
}
fn = ( T )GetProcAddress(dllHandle, fnName);
if (!fn)
{
char modName[_MAX_PATH],logmsg [400],_path[_MAX_PATH];
GetModuleFileName( GetModuleHandle(NULL) ,modName,_MAX_PATH );
// loggin @:
sprintf ( logmsg , "%s %s %s" , modName , "couldn´t get function with prototyp : ", typeid(fn).name() ) ;
sprintf( _path , "%s%s", modName ,".log" ) ;
//loggin :
return;
}
}
operator T(){
return fn;
}
public:
T fn;
HMODULE dllHandle;
void *ret;
};
#endif //__win32Tools_h_
/*
DLL::DynamicFn<_ShellExec_proto>_ShellExec(_T("shell32.dll"),"ShellExecuteA");
// DLL::DynamicFn<ptrM>_ShellExec(_T("shell32.dll"),"ShellExecuteA");
return (*_ShellExec)(NULL,"open","www.gmx.net",NULL,NULL, SW_MAXIMIZE);*/
/*
/********************************************************************
created: 2003/12/01
filename: H:\XLANG PROJECTS\BASE\INCLUDES\Dll_Tools.h
file path: H:\XLANG PROJECTS\BASE\INCLUDES
file base: Dll_Tools
file ext: h
author: Günter Baumgart
purpose: rum DLL´eln
*********************************************************************/
#ifndef __Dll_Tools_h_
#define __Dll_Tools_h_ "$Id:$"
#include <stdlib.h>
#include <string>
#include <windows.h>
//////////////////////////////////////////////////////////////////////////
//ie:
// the fnc prototyp : typedef HINSTANCE(WINAPI *_ShellExec_proto)(HWND,const char *,const char*,const char*,const char *,int);
// the fill : DLL::DllFunc<_ShellExec_proto>_ShellExec(_T("shell32.dll"),"ShellExecute");
template<class T> class DllFunc
{
public:
DllFunc(const char* dllName, const char* fnName ,const bool logging = TRUE ) :
dllHandle( LoadLibrary (dllName) ) , fn(0)
{
if (!dllHandle && logging)
{
char modName[_MAX_PATH],logmsg [400],_path[_MAX_PATH];
GetModuleFileName( GetModuleHandle(NULL) ,modName,_MAX_PATH );
sprintf ( logmsg , "%s %s %s" , modName , "couldn´t find ", dllName ) ;
sprintf( _path , "%s%s", modName ,".log" ) ;
return;
}
fn = ( T )GetProcAddress(dllHandle, fnName);
if (!fn)
{
char modName[_MAX_PATH],logmsg [400],_path[_MAX_PATH];
GetModuleFileName( GetModuleHandle(NULL) ,modName,_MAX_PATH );
// loggin
sprintf ( logmsg , "%s %s %s" , modName , "couldn´t get function with prototyp : ", typeid(fn).name() ) ;
sprintf( _path , "%s%s", modName ,".log" ) ;
return;
}
}
operator T(){
return fn;
}
public:
T fn;
HMODULE dllHandle;
void *ret;
};
#endif //__win32Tools_h_

View File

@ -0,0 +1,197 @@
#ifndef InitMAN_H
#define InitMAN_H
#include "CKBaseManager.h"
#include <stdlib.h>
#include <map>
#define S_PARAMETER_GUID CKGUID(0x7a7104e2,0x72c56435)
#define SFLOAT_PARAMETER_GUID CKGUID(0x6a5b2ec3,0x63f84a40)
#define SCOLOR_PARAMETER_GUID CKGUID(0x47cc15d2,0xf366299)
#define SINT_PARAMETER_GUID CKGUID(0x31d3196f,0x787306e1)
#define CKPGUID_LOOPMODE CKDEFINEGUID(0x63942d15,0x5ac51a7)
typedef enum QAD_OBJECT_TYPE {
CHARACTER = 1,
PUSHBOX = 2,
BALL = 3,
STONE = 4,
COIN = 5,
FUEL = 6,
ROCKET = 7,
MOVINGBOARD = 8,
SPRINGPAIR =9,
}
QAD_OBJECT_TYPE;
//////////////////////////////////////////////////////////////////////////
#define VLEFT VxVector(-1.0f,0.0f,0.0f)
#define VRIGHT VxVector(1.0f,0.0f,0.0f)
#define VUP VxVector(1.0f,1.0f,0.0f)
#define VDOWN VxVector(0.0f,-1.0f,0.0f)
#define VZERO VxVector(0.0f,0.0f,0.0f)
#define PHYSIC_OBJECT_2D_PARAMETER CKDEFINEGUID(0x57ba4ee6,0x4d8740a9)
#define PHYSIC_OBJECT_SIMULATION_FILTER CKDEFINEGUID(0x248f1f51,0x72070f85)
#define PHYSIC_OBJECT_2D_WORLDSPRING_PARAMETER CKDEFINEGUID(0x1b8e268b,0x11041fa0)
//////////////////////////////////////////////////////////////////////////
#include "typedefs.h"
#include "ZipDll.h"
#include "UnzipDll.h"
#include "ZCallBck.h"
BOOL __stdcall DefaultZipCallback(CZipCallbackData *pData);//thanks
#include "sharedStructs.h"
#define INIT_MAN_GUID CKGUID(0x35824c8a,0x4e320ac4)
class InitMan : public CKBaseManager
{
public:
//Ctor
InitMan(CKContext* ctx);
//Dtor
~InitMan();
static InitMan* GetInstance();
//////////////////////////////////////////////////////////////////////////
//virtual file mapping , used for command pipe:
HANDLE m_hMMFile;
vtExternalEvent *m_pData;
typedef XHashTable<vtExternalEvent*,unsigned long>vtExternalEventQueueType;
vtExternalEventQueueType incomingEvents;
void PerformMessages();
void InitMessages(int flags,XString name);
// Initialization
virtual CKERROR OnCKInit();
virtual CKERROR OnCKEnd();
virtual CKERROR OnCKReset();
CKERROR PreProcess();
CKERROR PostProcess();
virtual CKERROR PostClearAll();
virtual CKERROR OnCKPlay();
CKDWORD GetValidFunctionsMask()
{ return CKMANAGER_FUNC_OnCKInit|
CKMANAGER_FUNC_OnCKEnd|
CKMANAGER_FUNC_OnCKReset|
CKMANAGER_FUNC_PreProcess|
CKMANAGER_FUNC_PostProcess|
CKMANAGER_FUNC_PostClearAll|
CKMANAGER_FUNC_OnCKPlay;
}
/************************************************************************/
/* Parameter Functions */
/************************************************************************/
int move_object_att; int moving_board_att; int rocket_att; int keyboard_config_att; int att_character_keyboard_config; int att_character_anim_messages; int att_character_anims; int att_character_ckof; int att_character_object_set; int att_spring_pair;
VxVector Position(CK3dEntity *ent);
int att_rigid_body_2D;
int att_rigid_body_2D_worldspring;
int att_need_update;
int att_do_physics;
int att_sim_filter;
void RegisterVSL();
void RegisterRacknetVSL();
void RegisterCEGUI_VSL(CKContext *ctx);
void RegisterParameters();
void RegisterParameters2();
//void RegisterHUD();
/************************************************************************/
/* zip lib */
/************************************************************************/
ZipJobList zili;
bool AddFileEntry(XString ArchiveName,XString FileEntry);
BOOL LoadZipDll();//from the projects resource
BOOL UnLoadZipDll();
void SetDefaultZipValues(CZipParams *pParams);
int GetZipDllVersion();
/************************************************************************/
/* decompressing funcs */
/************************************************************************/
BOOL LoadUnzipDll();
BOOL UnLoadUnZipDll();
void SetDefaultUnZipValues(CUnzipParams * pParams);
int GetUnzipDllVersion();
UINT m_uiLastError;//unused
/************************************************************************/
/* compress */
/************************************************************************/
HINSTANCE m_ZipDllHandle;
char ZipDllTempFile[MAX_PATH];
CZipDllExec m_ZipDllExec;
CGetZipDllVersion m_GetZipDllVersion;
/************************************************************************/
/* decompress */
/************************************************************************/
HINSTANCE m_UnzipDllHandle;
char UnZipDllTempFile[MAX_PATH];
CGetUnzipDllVersion m_GetUnzipDllVersion;
CUnzipDllExec m_UnzipDllExec;
private:
};
#define GetIManager() InitMan::GetInstance()
#endif

View File

@ -0,0 +1,237 @@
#ifndef PATH_H
#define PATH_H
#include "CKALL.H"
#include "windows.h"
#include <STDLIB.H>
#include <STRING.H>
#include "Shlwapi.h"
#pragma comment (lib,"SHLWAPI.LIB")
class XPath {
private:
char path_separator_;
char drive_separator_;
char extension_separator_;
public:
XString data_;
//ctors
inline XPath();
XPath( const XPath& path );
XPath( const XString& filepath );
XPath( const XString& dirpath, const XString& filename );
XPath
(
const XString& dirpath,
const XString& base,
const XString& extension
);
XPath
(
char drive,
const XString& dirpath,
const XString& filename
);
XPath
(
char drive,
const XString& dirpath,
const XString& base,
const XString& extension
);
//components
XString operator[]( int index ) const;
// Testing.
bool absolute() const;
bool relative() const;
bool directory_path() const;
bool has_directory() const;
bool has_extension() const;
bool has_drive() const;
bool is_valid();
// Conversion.
operator const char*() const;
operator const XString&() const;
// Comparison
int operator==( const XPath& path ) const;
int operator==( const XString& string ) const;
int operator!=( const XPath& path ) const;
int operator!=( const XString& string ) const;
int operator<( const XPath& path ) const;
int operator<( const XString& string ) const;
XPath& operator=( const XString& filepath );
XPath& operator=( const XPath& path );
//used for the objectmode
XPath& operator+=(CKBeObject *beo){
if(data_.Length() == 0)data_ = VxGetTempPath().CStr();
data_ << beo->GetName() << ".nmo";
return *this;
}
// Accessors.
char* GetFileName();
char* GetPath();
char path_separator() const;
char drive_separator() const;
char extension_separator() const;
int absolute_levels() const;
protected:
void init_separators();
// Common finds.
size_t last_extension_separator() const;
};
/************************************************************************/
/* protected funtions */
/************************************************************************/
inline void
XPath::init_separators(){
path_separator_ = '\\';
drive_separator_ = ':';
extension_separator_ = '.';
}
/************************************************************************/
/* ctors //ops // converts */
/************************************************************************/
inline
XPath::XPath(const XString& dirpath, const XString& filename ){
init_separators();
data_ << dirpath <<path_separator_<< filename;
}
inline
XPath::XPath(){
init_separators();
}
inline
XPath::XPath( const XString& filepath ) : data_( filepath ){
init_separators();
}
inline
XPath::XPath( const XPath& path ) : data_( path.data_ ){
init_separators();
}
inline
XPath::operator const XString&() const{
return data_;
}
inline
XPath::operator const char*() const{
return data_.CStr();
}
inline XPath&
XPath::operator=( const XString& filepath ){
data_ = filepath;
return *this;
}
inline XPath&
XPath::operator=( const XPath& path ){
data_ = path.data_;
return *this;
}
inline int
XPath::operator==( const XPath& path ) const{
return data_ == path.data_;
}
inline int
XPath::operator<( const XPath& path ) const{
return data_ < path.data_;
}
inline int
XPath::operator<( const XString& string ) const{
return data_ < string;
}
inline int
XPath::operator==( const XString& string ) const{
return data_ == string;
}
inline int
operator==( const XString& string, const XPath& path ){
return path == string;
}
inline int
XPath::operator!=( const XPath& path ) const{
return data_ != path.data_;
}
inline int
XPath::operator!=( const XString& string ) const{
return data_ != string;
}
inline int
operator!=( const XString& string, const XPath& path ){
return path != string;
}
/************************************************************************/
/* Functions */
/************************************************************************/
inline char
XPath::extension_separator() const{
return extension_separator_;
}
inline bool
XPath::has_drive() const{
return data_.Find( drive_separator(), 0 ) == 1;
}
inline bool
XPath::has_extension() const{
return data_.Find(extension_separator_ , 0 ) == 1;
}
inline bool
XPath::absolute() const{
return has_drive() ||
(data_.Find( path_separator(), 0 ) == 0);
}
inline bool
XPath::relative() const{
return !absolute();
}
/************************************************************************/
/* Get Components */
/************************************************************************/
/************************************************************************/
/* get components */
/************************************************************************/
#endif

View File

@ -0,0 +1,683 @@
#ifndef _PhysicManager_H
#define _PhysicManager_H
#include "vtPhysXBase.h"
#include "CKPhysicsManager.h"
#include "pManagerTypes.h"
#include "pWorldTypes.h"
class xTime;
/**
\brief PhysicManager is a Virtools manager and acts as singleton object.
Its responsible for :
- maintaining of multiple worlds and all other physic objects
- providing quick access to physic objects beyond the world boundaries
- holding default parameters
*/
class MODULE_API PhysicManager : public CKPhysicManager
{
public:
int sceneWasChanged;
void _removeObjectsFromOldScene(CKScene *lastScene);
CKScene* _isSceneObject(CK3dEntity *object);
void _registerNewScene(CKScene*newScene);
JointFeedbackListType m_JointFeedbackList;
JointFeedbackListType& getJointFeedbackList() { return m_JointFeedbackList; }
void setJointFeedbackList(JointFeedbackListType val) { m_JointFeedbackList = val; }
void _cleanOrphanedJoints();
int physicFlags;
int getPhysicFlags() const { return physicFlags; }
void setPhysicFlags(int val) { physicFlags = val; }
pTriggerArray mTriggers;
pTriggerArray& getTriggers() { return mTriggers; }
void _cleanTriggers();
pBodyList bodyListRemove;
int _checkRemovalList();
pBodyList &getRemovalList(){ return bodyListRemove;}
pBodyList bodyListCheck;
int _checkListCheck();
pBodyList &getCheckList(){ return bodyListCheck;}
void copyToAttributes(pObjectDescr src,CK3dEntity *dst);
xTime *time;
bool disablePhysics;
bool checkPhysics;
bool m_IsSimulating;
pBodyList resetList;
pBodyList& _getResetList(){return resetList;}
pRestoreMap *restoreMap;
pRestoreMap* _getRestoreMap();
//################################################################
//
// Friends
//
bool checkCallbackSignature(CKBehavior *beh,int type,XString& errMessage);
//################################################################
//
// Constructors,initialization,registration
//
XString m_LastLogEntry;
XString GetLastLogEntry() const { return m_LastLogEntry; }
void SetLastLogEntry(XString val) { m_LastLogEntry = val; }
//----------------------------------------------------------------
//
//! \brief Constructors
//
PhysicManager(CKContext* ctx);
void _construct(xBitSet flags = 0 );
//----------------------------------------------------------------
//
//! \brief Initialization
//
int initPhysicEngine(int flags = 0);
int initManager(int flags=0);
int performInitialization();
void _initResources(int flags);
//################################################################
//
// Registration of attributes, custom structures, custom
// enumeration and related
//
void _registerWatchers(CKContext*context);//not used
void _unregisterWatchers();// not used
//----------------------------------------------------------------
//
//! \brief Attaches functions per object type. Most
// types are registered by attributes.
//
void _RegisterAttributeCallbacks();
//----------------------------------------------------------------
//
//! \brief Registration of attribute types
//
void _RegisterAttributes();
//----------------------------------------------------------------
//
//! \brief Attribute help functions
//
int getAttributeTypeByGuid(CKGUID guid);
int GetPAttribute(){ return att_physic_object;}
int GetSSAttribute(){ return att_sleep_settings;}
//----------------------------------------------------------------
//
//! \brief Help function, not been used yet.
// Stub
void registerCustomAttribute(XString attributeName,int attributeType);
typedef int (*ObjectConstructorFunction)(PhysicManager*, CK3dEntity*,int);
void registerObjectByAttributeFunction(CK3dEntity *ent,int attributeID,ObjectRegisterFunction cFunc);
AttributeFunctionArrayType& getAttributeFunctions() { return mAttributeFunctions; }
void setAttributeFunctions(AttributeFunctionArrayType val) { mAttributeFunctions = val; }
ObjectRegisterFunction getAttributeFunction(CKGUID attributeParameterGuid);
void populateAttributeFunctions();
void cleanAttributePostObjects();
AttributeFunctionArrayType mAttributeFunctions;
PostRegistrationArrayType mPostCleanAttributeObjects;
CustomParametersArrayType mCustomStructures;
CustomParametersArrayType& _getCustomStructures() { return mCustomStructures; }
void setCustomStructures(CustomParametersArrayType val) { mCustomStructures = val; }
PostRegistrationArrayType& getAttributePostObjects() { return mPostCleanAttributeObjects; }
void setAttributePostObjects(PostRegistrationArrayType val) { mPostCleanAttributeObjects = val; }
ObjectRegistration* getRegistrationTable();
//----------------------------------------------------------------
//
//! \brief Registers all custom parameter, enumeration.
//
void _RegisterParameters();
void _RegisterJointParameters();
void _RegisterBodyParameters();
void _RegisterBodyParameterFunctions();
void _RegisterVehicleParameters();
void _RegisterWorldParameters();
//----------------------------------------------------------------
//
//! \brief Help functions to register customer enumerations which
// are changed by xml files. OnCKReset for instance, the default
// xml file will be re-parsed and the enumerations become update.
//
//
void _RegisterDynamicParameters();
void _RegisterDynamicEnumeration(XString file,XString enumerationName,CKGUID enumerationGuid,PFEnumStringFunction enumFunc,BOOL hidden);
//################################################################
//
// Parameter operations
//
//----------------------------------------------------------------
//
//! \brief Registers all parameter operations at once.
//
void _RegisterParameterOperations();
void _RegisterParameterOperationsBody();
void _RegisterParameterOperationsJoint();
void _RegisterParameterOperationsMisc();
void _RegisterParameterOperationsVehicle();
void _RegisterParameterOperationsCollision();
//################################################################
//
// VSL Support
//
void _RegisterVSL();
void _RegisterVSLCommon();
void _RegisterVSLJoint();
void _RegisterVSLRigidBody();
void _RegisterVSLVehicle();
void _RegisterVSLCloth();
//----------------------------------------------------------------
//
//! \brief The fluid SDK is not finished and is intended as
// additional component.
#ifdef HAS_FLUID
void _RegisterFluid_VSL();
#endif
//----------------------------------------------------------------
//
//! \brief Hooking building blocks, adds settings to built-in building blocks.
//
CKERROR _Hook3DBBs();
CKERROR _HookGenericBBs();
CKERROR _UnHookGenericBBs();
CKERROR _UnHook3DBBs();
//----------------------------------------------------------------
//
//! \brief Destruction
//
~PhysicManager();
void _destruct(xBitSet flags = 0);
void _UnRegister(xBitSet flags=0);
void _UnRegisterAttributeCallbacks(xBitSet flags=0);
void _UnRegisterParameters(xBitSet flags=0);
void cleanAll();
void destroyWorlds();
//################################################################
//
// Settings
//
//----------------------------------------------------------------
//
//! \brief XML related help functions
//
void reloadXMLDefaultFile(const char*fName);
//----------------------------------------------------------------
//
//! \brief Flags to track the state of the manager.
//
xBitSet& _getManagerFlags() { return mManagerFlags; }
void _setManagerFlags(xBitSet val) { mManagerFlags = val; }
bool isValid();
//----------------------------------------------------------------
//
//! \brief Common parameters for a world (NXScene)
//
pWorldSettings * getDefaultWorldSettings(){ return mDefaultWorldSettings; }
void setDefaultWorldSettings(pWorldSettings * val) { mDefaultWorldSettings = val; }
//----------------------------------------------------------------
//
//! \brief Dongle related functions and members
//
XString _getConfigPath();
int DongleHasBasicVersion;
int DongleHasAdvancedVersion;
static void makeDongleTest();
//################################################################
//
// Periodic functions, called by frame.
//
void checkWorldsByType(CKGUID attributeParameterType);
//################################################################
//
// Misc functions
//
//----------------------------------------------------------------
//
//! \brief Logging
//
pLogger* getLogger(){ return mLogger; }
void setLogger(pLogger* val) { mLogger = val; }
void enableLogLevel(int type,int verbosity,int value);
//################################################################
//
// PhysX related helpers
//
NxPhysicsSDK* getPhysicsSDK(){ return mPhysicsSDK; }
void setPhysicsSDK(NxPhysicsSDK* val) { mPhysicsSDK = val; }
int getHWVersion();
int getNbPPUs();
int getInternalVersion(int& apiRev, int& descRev, int& branchId);
//################################################################
//
// Object helpers
//
int getNbObjects(int flags =0);
//----------------------------------------------------------------
//
//! \brief World related
pWorldMap* getWorlds(){ return m_Worlds; }
pWorld *getWorld(CK_ID _o);
pWorld *getWorld(CK3dEntity *_o,CK3dEntity *body=NULL);
pWorld *getWorld(int index =0);
pVehicle* getVehicle(CK3dEntity*bodyReference);
pWheel2* getWheel(CK3dEntity*wheelReference);
pWorld *getWorldByBody(CK3dEntity*ent);
pWorld *getWorldByShapeReference(CK3dEntity *shapeReference);
int getNbWorlds();
void deleteWorld(CK_ID _o);
void setWorlds(pWorldMap *val) { m_Worlds = val; }
float timer;
void advanceTime(float time);
pWorld * getDefaultWorld() { return m_DefaultWorld; }
void setDefaultWorld(pWorld * val) { m_DefaultWorld = val; }
/************************************************************************************************/
/** @name Joints
*/
//@{
/**
\brief Finds a joint object within all existing worlds, identified by two references and its type.
\param[in] CK3dEntity * referenceA , r: the first object participating in the constraint. This argument must be non-zero.<br>
- <b>Range:</b> [object range) <br>
- <b>Default:</b> NULL <br>
\param[in] CK3dEntity * referenceB , r: the second object participating in the constraint. This can be NULL because joint constraints can be created between a rigid body and the global world frame.<br>
- <b>Range:</b> [object range) <br>
- <b>Default:</b> NULL <br>
\param[in] JType type, r: an additional hint to find the right joint object. Notice that one rigid body can have 1:n joints so it makes sense to pass the type to this function. By default its returning the first found joint on the given reference objects. <br>
- <b>Range:</b> [joint type range) <br>
- <b>Default:</b> #JT_Any <br>
\return pJoint*
@see deleteJoint()
*/
pJoint*getJoint(CK3dEntity*referenceA,CK3dEntity*referenceB=NULL,JType type=JT_Any);
/**
\if internal2
\brief Checks 3D entities for attached joint attributes. If so, its registering the new constraint.
\return void
\endif
*/
void _checkObjectsByAttribute(CKScene *newScene = NULL);
int _checkResetList();
//@}
void checkWorlds();
void checkClothes();
void checkBodies();
void _RegisterObjectsByAttribute();
void createWorlds(int flags);
void destroy();
BOOL checkDemo(CK3dEntity*);
pFactory * getCurrentFactory(){ return m_currentFactory; }
void setCurrentFactory(pFactory * val) { m_currentFactory = val; }
/************************************************************************/
/* xml document access */
/************************************************************************/
TiXmlDocument* loadDefaults(XString filename);
TiXmlDocument* getDefaultConfig() const { return m_DefaultDocument; }
void setDefaultConfig(TiXmlDocument* val) { m_DefaultDocument = val; }
/************************************************************************/
/* RigidBody */
/************************************************************************/
pRigidBody *getBody(CK3dEntity*ent,bool lookInSubshapes=false);
pRigidBody *getBody(CK3dEntity*ent,pWorld* world);
pRigidBody *getBody(const char*name,int flags=0);
NxShape *getSubShape(CK3dEntity*referenceObject);
/**
\brief Returns the givens entity's rigid body object to which the sub shape belongs to.
\param[in] CK3dEntity * ent ,the entity r: This argument must be non-zero.<br>
- <b>Range:</b> [object range) <br>
- <b>Default:</b> NULL <br>
\return pRigidBody*
@see deleteJoint()
*/
pRigidBody* isSubShape(CK3dEntity*ent);
NxCCDSkeleton *getCCDSkeleton(CKBeObject *shapeReference);
void doInit();
/************************************************************************/
/* Clothes : */
/************************************************************************/
pCloth *getCloth(CK_ID entityID);
/************************************************************************/
/* Fluids : */
/************************************************************************/
pFluid *getFluid(CK3dEntity *entityReference);
pFluidEmitter *getFluidEmitter(CK3dEntity *entityReferene);
/**
\brief Function that lets you set global simulation parameters.
Returns false if the value passed is out of range for usage specified by the enum.
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
See #pSDKParameter for a description of parameters support by hardware.
\param[in] paramEnum Parameter to set. See #pSDKParameter
\param[in] paramValue The value to set, see #pSDKParameter for allowable values.
\return False if the parameter is out of range.
\note All parameters are available in the variable manager too.
@see pSDKParameter getParameter
*/
void setParameter(pSDKParameter parm,float value);
/**
\brief Function that lets you query global simulation parameters.
See #pSDKParameter for a description of parameters support by hardware.
\param[in] paramEnum The Parameter to retrieve.
\return The value of the parameter.
@see setParameter pSDKParameter
*/
float getParameter(pSDKParameter parm,float value);
void bindVariables();
void unBindVariables();
void setPSDKParameters(pSDKParameters&param);
//----------------------------------------------------------------
//
// character controller
//
UserAllocator * getUserAllocator() const { return mUserAllocator; }
void setUserAllocator(UserAllocator * val) { mUserAllocator = val; }
NxControllerManager* getControllerManager() const { return mControllerManager; }
void setControllerManager(NxControllerManager* val) { mControllerManager = val; }
void _createControllerManager();
void _releaseControllerManager();
private :
UserAllocator *mUserAllocator;
NxControllerManager* mControllerManager;
TiXmlDocument* m_DefaultDocument;
pWorld *m_DefaultWorld;
pFactory *m_currentFactory;
pWorldMap* m_Worlds;
NxPhysicsSDK* mPhysicsSDK;
pLogger*mLogger;
pWorldSettings *mDefaultWorldSettings;
xBitSet mManagerFlags;
NxRemoteDebugger* mRemoteDebugger;
pSDKParameters m_SDKParameters;
pRemoteDebuggerSettings mRemoteDebuggerSettings;
pRemoteDebuggerSettings& getRemoteDebuggerSettings() { return mRemoteDebuggerSettings; }
void setRemoteDebuggerSettings(pRemoteDebuggerSettings val) { mRemoteDebuggerSettings = val; }
IParameter *mIParameter;
public:
int att_physic_object; int att_hull_type; int att_mass; int att_surface_props;int att_physic_limit; BOOL m_DelOnReset;
int att_world_object;int att_sleep_settings;int att_damping;int att_collMask;int att_update_world_flags;int att_update_body_flags;
int att_heightField;int att_JBall;int att_JFixed;int att_JHinge;int att_JHinge2;int att_JSlider;int att_JUniversal;int att_JMotor;
int att_wheelDescr;
int att_clothDescr;
int att_trigger;
int att_deformable;
int att_capsule;
float mLastStepTime;
int _LogInfo;
int _LogTrace;
int _LogWarnings;
int _LogErrors;
int _LogToConsole;
public :
float getLastTimeStep(int flags);
pSDKParameters& getSDKParameters() { return m_SDKParameters; }
void setSDKParameters(pSDKParameters val) { m_SDKParameters = val; }
NxRemoteDebugger* getRemoteDebugger();
void Update();
void update(float stepsize);
static PhysicManager *GetInstance();
static CKContext *GetContext();
static PhysicManager * Cast(CKBaseManager* iM) { return GetInstance();}
CKERROR OnCKInit();
CKERROR PostClearAll();
CKERROR PreSave();
CKERROR OnCKReset();
CKERROR OnCKEnd();
CKERROR PreProcess();
CKERROR SequenceToBeDeleted(CK_ID *objids,int count);
CKERROR OnCKPlay();
CKERROR OnCKPause();
CKERROR PostProcess();
CKERROR SequenceAddedToScene(CKScene *scn,CK_ID *objids,int count);
CKERROR SequenceRemovedFromScene(CKScene *scn,CK_ID *objids,int count);
CKERROR PreLaunchScene(CKScene* OldScene,CKScene* NewScene);
CKERROR PostLaunchScene(CKScene* OldScene,CKScene* NewScene);
CKERROR SequenceDeleted(CK_ID *objids,int count);
CKERROR PreClearAll();
CKERROR OnPostCopy(CKDependenciesContext& context);
CKERROR PostLoad();
int _migrateOldCustomStructures(CKScene *scnene);
//--- Called to save manager data. return NULL if nothing to save...
virtual CKStateChunk* SaveData(CKFile* SavedFile);
void _saveUserEnumeration(CKStateChunk *chunk,CKFile* SavedFile);
virtual CKERROR LoadData(CKStateChunk *chunk,CKFile* LoadedFile);
void _loadUserEnumeration(CKStateChunk *chunk,CKFile* LoadedFile);
//--- Called at the end of a save operation.
CKERROR PostSave();
float getLastDeltaTime(){return mLastStepTime;}
virtual CKDWORD GetValidFunctionsMask()
{
return
CKMANAGER_FUNC_PreLaunchScene|
CKMANAGER_FUNC_PostLaunchScene|
CKMANAGER_FUNC_OnSequenceRemovedFromScene|
CKMANAGER_FUNC_OnSequenceDeleted|
CKMANAGER_FUNC_OnSequenceAddedToScene|
CKMANAGER_FUNC_PreClearAll|
CKMANAGER_FUNC_PostClearAll|
CKMANAGER_FUNC_OnSequenceToBeDeleted|
CKMANAGER_FUNC_OnCKPlay|
CKMANAGER_FUNC_OnCKPause|
CKMANAGER_FUNC_OnCKInit|
CKMANAGER_FUNC_PreSave|
CKMANAGER_FUNC_PostLoad|
CKMANAGER_FUNC_OnPostCopy|
CKMANAGER_FUNC_PostSave|
CKMANAGER_FUNC_OnCKReset|
CKMANAGER_FUNC_PostProcess|
CKMANAGER_FUNC_PreProcess|
CKMANAGER_FUNC_OnCKEnd;
}
int processOptions;
virtual int& getProcessOptions() { return processOptions; }
virtual void setProcessOptions(int val) { processOptions = val; }
};
#define GetPMan() PhysicManager::GetInstance()
#define ctx() PhysicManager::GetInstance()->GetContext()
#define lastStepTimeSec GetPMan()->GetContext()->GetTimeManager()->GetLastDeltaTimeFree() * 0.001f
#define lastStepTimeMS GetPMan()->GetContext()->GetTimeManager()->GetLastDeltaTimeFree()
#endif

View File

@ -0,0 +1,212 @@
#ifndef __PMANAGERTYPES_H__
#define __PMANAGERTYPES_H__
#include "pNxSDKParameter.h"
typedef enum pManagerFlags
{
PMF_DONT_DELETE_SCENES=1<<1,
PMF_DONT_USE_HARDWARE=1<<2,
};
struct pTriggerEntry
{
NxShape *shapeA;
NxShape *shapeB;
int triggerEvent;
bool triggered;
CK3dEntity *triggerBody;
CK3dEntity *otherObject;
CK3dEntity *triggerShapeEnt;
pRigidBody *triggerBodyB;
pRigidBody *otherBodyB;
pTriggerEntry()
{
shapeA = shapeB = NULL;
triggerShapeEnt =otherObject = triggerBody = NULL;
triggerBodyB = otherBodyB = NULL;
triggerEvent;
triggered = false;
}
};
typedef XArray<pTriggerEntry>pTriggerArray;
//################################################################
//
// Help Structures, used by the manager only
//
//----------------------------------------------------------------
//
//! \brief Container to maintain multiple worlds
//
typedef XHashTable<pWorld*,CK3dEntity*> pWorldMap;
typedef XHashTable<pWorld*,CK3dEntity*>::Iterator pWorldMapIt;
typedef XArray<CK_ID>pBodyList;
typedef XArray<CK_ID>::Iterator pBodyListIterator;
typedef XHashTable<pRigidBodyRestoreInfo*,CK_ID> pRestoreMap;
typedef XHashTable<pRigidBodyRestoreInfo*,CK_ID>::Iterator pRestoreMapIt;
//----------------------------------------------------------------
//
//! \brief Function pointer. Used in custom parameter structures to populate
// found xml types
//
typedef XString (pFactory::*PFEnumStringFunction)(const TiXmlDocument * doc);
//----------------------------------------------------------------
//
//! \brief Function pointer to link object registrations per attribute type
//
typedef int (*ObjectRegisterFunction)(CK3dEntity*,int,bool,bool);
//----------------------------------------------------------------
//
//! \brief Meta data for ObjectRegisterFunction. Used for attribute callbacks.
//
struct ObjectRegistration
{
CKGUID guid;
ObjectRegisterFunction rFunc;
ObjectRegistration(CKGUID _guid,ObjectRegisterFunction _func) :
guid(_guid) ,
rFunc(_func)
{
}
};
//----------------------------------------------------------------
//
//! \brief Meta data for attributes callbacks when the scene is playing. <br>
//! Virtools is not initializing the attributes parameter correctly.
// Ths structur is used to track data to the next frame.
//
struct pAttributePostObject
{
CK_ID objectId;
ObjectRegisterFunction func;
int attributeID;
pAttributePostObject() :
objectId(-1) , func(NULL) , attributeID(-1){}
pAttributePostObject(CK_ID _id,ObjectRegisterFunction _func,int _attributeID) :
objectId(_id) ,
func(_func) ,
attributeID(_attributeID)
{
}
};
//----------------------------------------------------------------
//
//! \brief Container type to store objects with uninitialized attribute parameters.
//
typedef XArray<pAttributePostObject>PostRegistrationArrayType;
typedef XArray<pAttributePostObject>::Iterator PostRegistrationArrayIteratorType;
//----------------------------------------------------------------
//
//! \brief Container to store custom function pointer per attribute type
//
typedef XHashTable<ObjectRegisterFunction,int>AttributeFunctionArrayType;
typedef XHashTable<ObjectRegisterFunction,int>::Iterator AttributeFunctionArrayIteratorType;
//----------------------------------------------------------------
//
//! \brief CustomParametersArrayType is responsible to track custom structures and its default value.
//!
typedef XHashTable<vtTools::ParameterTools::CustomStructure*,CKGUID>CustomParametersArrayType;
typedef XHashTable<vtTools::ParameterTools::CustomStructure*,CKGUID>::Iterator CustomParametersArrayIteratorType;
struct pSDKParameters
{
float SkinWidth;
float DefaultSleepLinVelSquared ;
float DefaultSleepAngVel_squared;
float BounceThreshold ;
float DynFrictScaling ;
float StaFrictionScaling;
float MaxAngularVelocity ;
float ContinuousCD ;
float AdaptiveForce ;
float CollVetoJointed ;
float TriggerTriggerCallback ;
float CCDEpsilon ;
float SolverConvergenceThreshold ;
float BBoxNoiseLevel ;
float ImplicitSweepCacheSize ;
float DefaultSleepEnergy ;
float ConstantFluidMaxPackets ;
float ConstantFluidMaxParticlesPerStep ;
float AsynchronousMeshCreation ;
float ForceFieldCustomKernelEpsilon ;
float ImprovedSpringSolver ;
int disablePhysics;
pSDKParameters()
{
SkinWidth = 0.25f;
DefaultSleepLinVelSquared = 0.15f*0.15f;
DefaultSleepAngVel_squared = 0.15f*0.15f;
BounceThreshold = -2.0f ;
DynFrictScaling =1.0f;
StaFrictionScaling = 1.0f;
MaxAngularVelocity = 7.0f ;
ContinuousCD = 0.0f;
AdaptiveForce = 1.0f;
CollVetoJointed = 1.0f;
TriggerTriggerCallback= 1.0f ;
CCDEpsilon = 0.01f;
SolverConvergenceThreshold = 0.0f ;
BBoxNoiseLevel =0.001f ;
ImplicitSweepCacheSize = 5.0f ;
DefaultSleepEnergy = 0.005f;
ConstantFluidMaxPackets = 925.0f ;
ConstantFluidMaxParticlesPerStep = 4096 ;
ImprovedSpringSolver = 1.0f;
disablePhysics = 0;
}
};
class pRemoteDebuggerSettings
{
public :
XString mHost;
int port;
int enabled;
pRemoteDebuggerSettings()
{
mHost= "localhost";
port = 5425;
enabled = 0;
}
};
#endif // __PMANAGERTYPES_H__

View File

@ -0,0 +1,185 @@
/********************************************************************
created: 2004/11/06
created: 6:11:2004 16:53
filename: D:\projects new\vt tools\Manager\typedefs.h
file path: D:\projects new\vt tools\Manager
file base: typedefs
file ext: h
author:
purpose: gBaumgart
*********************************************************************/
#ifndef TYPEDEFS_H
#define TYPEDEFS_H
#include "CKAll.h"
#include <STDLIB.H>
#include <LIST>
#include <MAP>
/*
The following template "Hashfunc" only meets the requests of std::map. the reason for it is the standard compare.(result : int, but bool is used)
from XString.h:
int operator == (const XBaseString& iStr) const
{ return !Compare(iStr); }
if i don´t use this help class i´ll get the following warning:
"
D:\SDK\VC98\INCLUDE\functional(86) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
D:\SDK\VC98\INCLUDE\functional(86) : while compiling class-template member function 'bool __thiscall std::less<class XString>::operator ()(const class XString &,const class XString &) const'
"
by call ZipJobList zili.find(XXX)
or use simply :
struct XStringCMP{
bool operator() (const XString& p, const XString& q) const
{ return strcmp(p.CStr(),q.CStr())<0; }
};
*/
template <class T> struct HashFunc{
bool operator ()(const T& x,const T& y)const;
};
//the XString special:
template <> struct HashFunc<XString>{
bool operator ()(const XString& In1,const XString& In2)const{
return strcmp(In1.CStr(),In2.CStr())<0;
/* or :
size_t out = 0;
const char* key = In1.CStr();
while (*key) out = (out <<1)^*key++;//an integer rep of a c-string
*/
}
};
/*
ZipJobList
+Keystring | Filelist
+......
*/
typedef std::list<XString>XFileList;
typedef std::list<XString>::iterator XFileListIterator;
typedef std::map<XString,XFileList*,HashFunc<XString> >ZipJobList;
typedef std::map<XString,XFileList*,HashFunc<XString> >::iterator ZiJoIt;
/************************************************************************/
/* none zip stuff */
/************************************************************************/
/************************************************************************/
/* a workin array container */
/************************************************************************/
/*
template<class T, int amount> class fake_container{
public:
//standard stuff:
typedef T value_type;
typedef T* iterator;
typedef const T*const_iterator;
typedef T& reference;
typedef const T& const_reference;
typedef const T* const_iterator;
T v[amount];
operator T*() {return v;}
//ops:
iterator& operator++(){return v+1;}
iterator& operator--(){return v-1;}
//..........................................................
//nice:
reference operator[] (ptrdiff_t i) { return v[i] ; }
const_reference operator[] (ptrdiff_t i) const { return v[i] ; }
iterator begin() {return v;}
const_iterator begin() const {return v;}
iterator end() {return v+amount;}
const_iterator end() const {return v + amount;}
size_t size () const { return amount;}
protected:
};
*/
/************************************************************************/
/* tests */
/************************************************************************/
//this should become pointer array, but very strange
/*
template<class T> class Vector{
T*v;
int sz;
public:
Vector();
// explicit Vector(int);
// Vector();
// operator T*() {return v;}
//T& elem(int i){return v[i];}
//T& operator[](int i);
};
*/
//thats becomes a vector - void - pointer - special template
/*
template<> class Vector<void*>{
void **p;
void *&operator[](int i);
};
*/
/************************************************************************/
/* the void* specialist: */
/************************************************************************/
/*
template<class T> class Vector<T*> : private Vector<void*>{
public:
typedef Vector<void*> Base;
Vector() : Base(){}
puplicit Vector()(int i) : Base(i){}
T*elem(int i){ return static_cast<T*&>(Base::elem(i));}
T*& operator[](int i){return static_cast<T*&>(Base::operator [](i));}
};
*/
/*
template<class T> class Vector{
T*v;
int sz;
public:
Vector();
explicit Vector(int);
operator T*() {return v;}
T& elem(int i){return v[i];}
T& operator[](int i);
};
*/
#endif

View File

@ -0,0 +1,38 @@
#ifndef VT_BASE_MANAGER_H__
#define VT_BASE_MANAGER_H__ "$Id:$"
#include "BaseMacros.h"
#include "CKBaseManager.h"
class MODULE_API vtBaseManager : public CKBaseManager
{
public:
virtual CKERROR OnCKInit()=0;
virtual CKERROR PostClearAll()=0;
virtual CKERROR PreSave()=0;
virtual CKERROR OnCKReset()=0;
virtual CKERROR PreProcess()=0;
virtual CKDWORD GetValidFunctionsMask() { return CKMANAGER_FUNC_PostClearAll|
CKMANAGER_FUNC_OnCKInit|
CKMANAGER_FUNC_PreSave|
CKMANAGER_FUNC_PostLoad|
CKMANAGER_FUNC_OnCKReset|
CKMANAGER_FUNC_PreProcess;
}
virtual void RegisterParameters()=0;
virtual void RegisterVSL()=0;
vtBaseManager(CKContext *context,CKGUID guid,char* name) : CKBaseManager(context,guid,name) {};
~vtBaseManager(){};
};
// CK2 VERSION ...
#endif

View File

@ -0,0 +1,7 @@
#include <wtypes.h>
#include "CKAll.h"
HINSTANCE GetModulefromResource(HMODULE hModule,int name,char *tempfile);
HMODULE GetParentModule(CK_PLUGIN_TYPE type,CKGUID guid);

58
usr/Include/Core/Timing.h Normal file
View File

@ -0,0 +1,58 @@
#ifndef TIMING_H
#define TIMING_H
#if defined(__CELLOS_LV2__) || defined(_XBOX) || defined(LINUX) || defined(__PPCGEKKO__)
unsigned long timeGetTime();
#elif defined(WIN32) || defined(_WIN64)
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
#endif
#if defined(__CELLOS_LV2__)
#include <sys/sys_time.h>
#include <sys/time_util.h>
typedef union _LARGE_INTEGER {
uint64_t QuadPart;
} LARGE_INTEGER;
inline void QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount){
SYS_TIMEBASE_GET(lpPerformanceCount->QuadPart);
}
inline void QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency){
lpFrequency->QuadPart = sys_time_get_timebase_frequency();
}
#endif //defined(__CELLOS_LV2__)
#if defined(LINUX)
#include <stdint.h>
#include <time.h>
typedef union _LARGE_INTEGER {
uint64_t QuadPart;
} LARGE_INTEGER;
inline void QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount){
lpPerformanceCount->QuadPart = clock();
}
inline void QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency){
lpFrequency->QuadPart = CLOCKS_PER_SEC;
}
#endif // defined(LINUX)
float getCurrentTime();
float getElapsedTime();
#endif

View File

@ -0,0 +1,49 @@
#ifndef UNZIPDLL_H
#define UNZIPDLL_H
#include "windows.h"
//#include "stdafx.h"
#include "ZCallBck.h"
struct CUnzipParams
{
HWND m_wndHandle;
void * m_pCaller; /* "self" referance of the Delphi form */
/* This is passed back to us in the callback function
so we can direct the info to the proper form instance
- thanks to Dennis Passmore for this idea. */
long int m_liVersion; /* version of DLL we expect to see */
void* m_pfCallbackFunction; /* type def in ZCallBck.PAS */
BOOL m_bTraceEnabled;
/*============== Begin UnZip Flag section ============== */
BOOL m_bPromptToOverwrite; // not used yet
char* m_pszZipPassword; // password pointer
BOOL m_bTest; // if true, test zipfile, don't save extracted files
BOOL m_bComments; // show zip comment (not supported yet)
BOOL m_bConvert; // if true, do ASCII/EBCDIC or EOL translation
BOOL m_bQuiet; // DLL be quiet!
BOOL m_bVerboseEnabled; // verbose flag
BOOL m_bUpdate; // "update" (extract only newer files & brand new files)
BOOL m_bFreshen; // "freshen" (extract only newer files that already exist)
BOOL m_bDirectories; // if true, recreate dir structure
BOOL m_bOverwrite; // if true, overwrite existing (no asking)
/* Count of filespecs to extract - don't forget to set this! */
long int m_liFileCount;
/* ptr to zipfile name */
char *m_pszArchiveFileName;
long int m_liSeven; /* pass a 7 here to validate struct size */
/* Array of filenames contained in the ZIP archive */
char* m_pszFileNames[MAX_FILES];
};
/* Main call to execute a ZIP add or Delete. This call returns the
number of files that were sucessfully operated on. */
typedef DWORD (__stdcall *CUnzipDllExec)(CUnzipParams *pParams);
typedef DWORD (__stdcall *CGetUnzipDllVersion)();
#endif // UNZIPDLL_H

View File

@ -0,0 +1,25 @@
#ifndef __VSL_GLOBAL_FUNCTIONS_H__
#define __VSL_GLOBAL_FUNCTIONS_H__
#include "vtPhysXBase.h"
/************************************************************************************************/
/** @name Joints
*/
//@{
/**
\brief Quick access for #PhysicManager::getJoint
\return pJoint*
@see
*/
pJoint*getJoint(CK3dEntity *referenceA,CK3dEntity *referenceB=NULL,JType type= JT_Any);
//@}
#endif

View File

@ -0,0 +1,27 @@
#ifndef ZCALLBCK_H
#define ZCALLBCK_H
//#include "StdAfx.h"
#include <windows.h>
#define MAX_FILES 4096
#pragma pack (push)
struct CZipCallbackData
{
DWORD m_hwndHandle;
HWND m_pCaller;
long int m_liVersion;
BOOL m_bIsOperationZip;
long int m_liActionCode;
long int m_liErrorCode;
long int m_liFileSize;
char m_pszFileNameOrMsg[512];
};
#pragma pack (pop)
typedef BOOL (__stdcall *ZFunctionPtrType) (CZipCallbackData*);
#endif ZCALLBCK_H // ZCALLBCK_H

124
usr/Include/Core/ZipDLL.h Normal file
View File

@ -0,0 +1,124 @@
#ifndef ZIPDLL_H
#define ZIPDLL_H
#include "ZCallBck.h"
struct CZipParams {
HWND m_hwndHandle;
/* "self" referance of the Delphi form */
/* This is passed back to us in the callback function
so we can direct the info to the proper form instance
- thanks to Dennis Passmore for this idea. */
void *m_pCaller;
long int m_liVersion; /* version of DLL we expect to see */
ZFunctionPtrType m_pfCallbackFunction; /* type def in ZCallBck.PAS */
BOOL m_bTraceEnabled;
/*============== Begin Zip Flag section ============== */
char *m_pszZipPassword; /* password pointer */
BOOL m_bSuffix; /* not used yet */
BOOL m_bEncrypt; /* Encrypt files to be added? */
/* include system and hidden files */
BOOL m_bSystem;
/* Include volume label */
BOOL m_bVolume;
/* Include extra file attributes (read-only, unix timestamps, etc) */
BOOL m_bExtra;
/* Do not add directory names to .ZIP archive */
/* see also: fJunkDir */
BOOL m_bNoDirEntries;
/* Only add files newer a specified date */
/* See the "Date" array below if you set this to TRUE */
BOOL m_bDate;
/* Give a little more information to the user via message boxes */
BOOL m_bVerboseEnabled;
/* Quiet operation - the DLL won't issue any messages at all. */
/* Delphi program MUST handle ALL errors via it's callback function. */
BOOL m_bQuiet;
/* Compression level (0 - 9; 9=max, 0=none) */
/* All of these levels are variations of deflate. */
/* I strongly recommend you use one of 3 values here:
0 = no compression, just store file
3 = "fast" compression
9 = "best" compression */
long int m_bLevel;
/* Try to compress files that appear to be already compressed
based on their extension: .zip, .arc, .gif, ... */
BOOL m_bComprSpecial;
/* translate text file end-of-lines */
BOOL m_bCRLF_LF;
/* junk the directory names */
/* If true, this says not to save dirnames as separate entries,
in addition to being save with filenames. */
/* see also: fNoDirEntries */
BOOL m_bJunkDir;
/* Recurse into subdirectories */
BOOL m_bRecurse;
/* Allow appending to a zip file */
BOOL m_bGrow;
/* Convert filenames to DOS 8x3 names - for compatibility
with PKUNZIP v2.04g, which doesn't understand long filenames */
BOOL m_bForce;
/* Delete orig files that were added or updated in zip file */
/* This is a variation of Add */
BOOL m_bMove;
/* Delete specified files from zip file */
BOOL m_bDeleteEntries;
/* Update zip -- if true, rezip changed, and add new files in fspec */
/* This is a variation of Add */
BOOL m_bUpdate;
/* Freshen zip -- if true, rezip all changed files in fspec */
/* This is a variation of Add */
BOOL m_bFreshen;
/* junk the SFX prefix on the self-extracing .EXE archives */
BOOL m_bJunkSFX;
/* Set zip file time to time of newest file in it */
BOOL m_bLatestTime;
/*============== End Zip Flag section ============== */
/* Cutoff Date for Add-by-date; add files newer than this day */
/* This is only used if the "fDate" option is TRUE */
/* format = MMDDYY plus a trailing null */
char m_cDate[8];
/* Count of files to add or delete - don't forget to set this! */
long int m_liFileCount;
/* ptr to name of zip file */
char *m_pszArchiveFileName;
long int m_liSeven; /* pass a 7 here to validate struct size */
/* Array of filenames contained in the ZIP archive */
char* m_pszFileNames[MAX_FILES];
};
/*
Main call to execute a ZIP add or Delete. This call returns the
number of files that were sucessfully operated on.
*/
typedef DWORD (__stdcall *CZipDllExec)(CZipParams *pParams);
typedef DWORD (__stdcall *CGetZipDllVersion)();
#endif // ZIPDLL_H

View File

@ -0,0 +1,54 @@
/********************************************************************
created: 2006/22/06
created: 22:06:2006 12:26
filename: x:\junctions\ProjectRoot\current\vt_plugins\vt_toolkit\Behaviors\Generic\BGInstancer.h
file path: x:\junctions\ProjectRoot\current\vt_plugins\vt_toolkit\Behaviors\Generic
file base: BGInstancer
file ext: h
author: mc007
purpose: instancing of b-graphs per file
*********************************************************************/
#include "stdafx.h"
#define BGWRAPPER_GUID CKGUID(0x35fb3204,0x6b59721c)
// Parameters for BGWrapper
enum EBGWRAPPERPARAM
{
// local
EBGWRAPPERPARAM_PARAMETER_SCRIPT = 0,
EBGWRAPPERPARAM_PARAMETER_NAME = 1,
EBGWRAPPERPARAM_LOCAL_PARAMETER_COUNT,
};
class BGWrapper
{
public:
static CKObjectDeclaration* FillBehaviour( void );
static CKERROR CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr );
static int BehaviourFunction( const CKBehaviorContext& behaviorContext );
private:
static CKERROR BGWrapperCB(const CKBehaviorContext& behContext);
static BOOL HasIO(CKBehavior* pBeh);
static BOOL DeleteIO(CKBehavior* pBeh);
static BOOL CreateIO(CKBehavior* pBeh, CKBehavior* pScript);
static BOOL CheckIO(CKBehavior* pBeh, CKBehavior* pScript);
static CKBehavior* BGLoader(CKSTRING fileName,const CKBehaviorContext& behContext);
static void ActivateNextFrameSubBB(CKBehavior* scriptObject,BOOL &bActivateNextFrame);
static void DesactivateSubBB(CKBehavior* scriptObject);
static void OwnerSubBB(CKBehavior* scriptObject,CKBeObject*owner);
static void SetNewBG(CKBehavior *behaviour,CKBehavior *newBehavior);
static void DestroyCurrentBG(CKLevel* level,CKBehavior *behaviour,CKBehavior *scriptObject);
};

View File

@ -0,0 +1 @@
int EncryptPassword(char* pcPassword);

View File

@ -0,0 +1,22 @@
/********************************************************************
created: 2009/04/13
created: 13:4:2009 21:58
filename: x:\ProjectRoot\vtmodsvn\tools\VTCPPProjectPremakerSimple\Sdk\Include\Core\gConfig.h
file path: x:\ProjectRoot\vtmodsvn\tools\VTCPPProjectPremakerSimple\Sdk\Include\Core
file base: gConfig
file ext: h
author: Günter Baumgart
purpose: Global configuration for this component
*********************************************************************/
#ifndef __G_CONFIG_H__
#define __G_CONFIG_H__
/*!
\brief Enables access from an external application. All related code needs to enabled
by this macro
*/
//#define G_EXTERNAL_ACCESS
#endif

View File

@ -0,0 +1,24 @@
#pragma once
#include "stdafx.h"
class ExeInThread
{
public:
static CKObjectDeclaration * FillBehaviour( void );
static int CallBack( const CKBehaviorContext& behaviorContext );
static int BehaviourFunction( const CKBehaviorContext& behaviorContext );
static CKERROR CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr );
enum ThreadStatus {
Idle = 0, Requested = 2, Active = 3};
friend unsigned int BlockingThreadFunction(void *arg);
typedef struct ThreadInfo
{
CKBehavior* targetBeh;
int targetInputToActivate;
} AsyncThreadInfo;
};

View File

@ -0,0 +1,52 @@
#ifndef __P_BOX_CONTROLLER_H__
#define __P_BOX_CONTROLLER_H__
#include "pTypes.h"
class BoxController;
class pBoxController
{
public:
pBoxController(const NxControllerDesc& desc, NxScene* scene);
virtual ~pBoxController();
void move(const VxVector& disp, int activeGroups, float minDist, int& collisionFlags, float sharpness, const pGroupsMask* groupsMask);
//bool setPosition(const VxVector& position) { return setPos(position); }
pRigidBody* getBody() const;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// NxpBoxController
const VxVector& getExtents() const;
bool setExtents(const VxVector& extents);
void setStepOffset(const float offset);
VxVector getPosition()const;
VxVector& getFilteredPosition();
bool getWorldBox(VxBbox& box) const;
void setCollision(bool enabled);
//virtual void setInteraction(NxCCTInteractionFlag flag) { Controller::setInteraction(flag); }
//virtual NxCCTInteractionFlag getInteraction() const { return Controller::getInteraction(); }
//vi//rtual void reportSceneChanged();
//virtual void* getUserData() const { return userData; }
private:
BoxController *mBoxController;
};
#endif
//AGCOPYRIGHTBEGIN
///////////////////////////////////////////////////////////////////////////
// Copyright (c) 2005 AGEIA Technologies.
// All rights reserved. www.ageia.com
///////////////////////////////////////////////////////////////////////////
//AGCOPYRIGHTEND

View File

@ -0,0 +1,870 @@
#ifndef __P_CLOTH_H__
#define __P_CLOTH_H__
#include "vtPhysXBase.h"
/** \addtogroup Cloth
@{
*/
/**
brief2 Class for clothes.
*/
class MODULE_API pCloth
{
public:
/************************************************************************/
/* */
/************************************************************************/
void releaseReceiveBuffers();
void allocateClothReceiveBuffers(int numVertices, int numTriangles);
CK_ID getEntityID() const { return mEntityID; }
void setEntityID(CK_ID val) { mEntityID = val; }
NxCloth * getCloth() const { return mCloth; }
void setCloth(NxCloth * val) { mCloth = val; }
pCloth();
virtual ~pCloth();
NxMeshData * getReceiveBuffers() const { return mReceiveBuffers; }
void setReceiveBuffers(NxMeshData * val) { mReceiveBuffers = val; }
bool cookMesh(NxClothMeshDesc* desc);
void releaseMeshDescBuffers(const NxClothMeshDesc* desc);
bool generateMeshDesc(pClothDesc cDesc,NxClothMeshDesc *desc, CKMesh*mesh);
pWorld * getWorld() const { return mWorld; }
void setWorld(pWorld * val) { mWorld = val; }
NxClothMesh * getClothMesh() const { return mClothMesh; }
void setClothMesh(NxClothMesh * val) { mClothMesh = val; }
void updateVirtoolsMesh();
/************************************************************************/
/* */
/************************************************************************/
/**
\brief Sets the cloth bending stiffness in the range from 0 to 1.
\param[in] stiffness The stiffness of this cloth.
@see pClothDesc.bendingStiffness getBendingStiffness()
*/
void setBendingStiffness(float stiffness);
/**
\brief Retrieves the cloth bending stiffness.
\return Bending stiffness of cloth.
@see pClothDesc.bendingStiffness setBendingStiffness()
*/
float getBendingStiffness() const;
/**
\brief Sets the cloth stretching stiffness in the range from 0 to 1.
Note: The stretching stiffness must be larger than 0.
\param[in] stiffness Stiffness of cloth.
@see pClothDesc.stretchingStiffness getStretchingStiffness()
*/
void setStretchingStiffness(float stiffness);
/**
\brief Retrieves the cloth stretching stiffness.
\return stretching stiffness of cloth.
@see pClothDesc.stretchingStiffness setStretchingStiffness()
*/
float getStretchingStiffness() const;
/**
\brief Sets the damping coefficient in the range from 0 to 1.
\param[in] dampingCoefficient damping coefficient of cloth.
@see pClothDesc.dampingCoefficient getDampingCoefficient()
*/
void setDampingCoefficient(float dampingCoefficient);
/**
\brief Retrieves the damping coefficient.
\return damping coefficient of cloth.
@see pClothDesc.dampingCoefficient setDampingCoefficient()
*/
float getDampingCoefficient() const;
/**
\brief Sets the cloth friction coefficient in the range from 0 to 1.
\param[in] friction The friction of the cloth.
@see pClothDesc.friction getFriction()
*/
void setFriction(float friction);
/**
\brief Retrieves the cloth friction coefficient.
\return Friction coefficient of cloth.
@see pClothDesc.friction setFriction()
*/
float getFriction() const;
/**
\brief Sets the cloth pressure coefficient (must be non negative).
\param[in] pressure The pressure applied to the cloth.
@see pClothDesc.pressure getPressure()
*/
void setPressure(float pressure);
/**
\brief Retrieves the cloth pressure coefficient.
\return Pressure of cloth.
@see pClothDesc.pressure setPressure()
*/
float getPressure() const;
/**
\brief Sets the cloth tear factor (must be larger than one).
\param[in] factor The tear factor for the cloth
@see pClothDesc.tearFactor getTearFactor()
*/
void setTearFactor(float factor);
/**
\brief Retrieves the cloth tear factor.
\return tear factor of cloth.
@see pClothDesc.tearFactor setTearFactor()
*/
float getTearFactor() const;
/**
\brief Sets the cloth attachment tear factor (must be larger than one).
\param[in] factor The attachment tear factor for the cloth
@see pClothDesc.attachmentTearFactor getAttachmentTearFactor()
*/
void setAttachmentTearFactor(float factor);
/**
\brief Retrieves the attachment cloth tear factor.
\return tear attachment factor of cloth.
@see pClothDesc.attachmentTearFactor setAttachmentTearFactor()
*/
float getAttachmentTearFactor() const;
/**
\brief Sets the cloth thickness (must be positive).
\param[in] thickness The thickness of the cloth.
@see pClothDesc.thickness getThickness()
*/
void setThickness(float thickness);
/**
\brief Gets the cloth thickness.
\return thickness of cloth.
@see pClothDesc.thickness setThickness()
*/
float getThickness() const;
/**
\brief Gets the cloth density.
\return density of cloth.
@see pClothDesc.density
*/
float getDensity() const;
/**
\brief Gets the relative grid spacing for the broad phase.
The cloth is represented by a set of world aligned cubical cells in broad phase.
The size of these cells is determined by multiplying the length of the diagonal
of the AABB of the initial cloth size with this constant.
\return relative grid spacing.
@see pClothDesc.relativeGridSpacing
*/
float getRelativeGridSpacing() const;
/**
\brief Retrieves the cloth solver iterations.
\return solver iterations of cloth.
@see pClothDesc.solverIterations setSolverIterations()
*/
int getSolverIterations() const;
/**
\brief Sets the cloth solver iterations.
\param[in] iterations The new solver iteration count for the cloth.
@see pClothDesc.solverIterations getSolverIterations()
*/
void setSolverIterations(int iterations);
/**
\brief Returns a world space AABB enclosing all cloth points.
\param[out] bounds Retrieves the world space bounds.
@see NxBounds3
*/
void getWorldBounds(VxBbox & bounds) const;
/**
\brief Attaches the cloth to a shape. All cloth points currently inside the shape are attached.
\note This method only works with primitive and convex shapes. Since the inside of a general
triangle mesh is not clearly defined.
\param[in] shape Shape to which the cloth should be attached to.
\param[in] attachmentFlags One or two way interaction, tearable or non-tearable
@see NxClothAttachmentFlag freeVertex() attachToCollidingShapes()
*/
void attachToShape(CKBeObject *shape, int attachmentFlags);
/**
\brief Attaches the cloth to all shapes, currently colliding.
\note This method only works with primitive and convex shapes. Since the inside of a general
triangle mesh is not clearly defined.
\param[in] attachmentFlags One or two way interaction, tearable or non-tearable
@see NxClothAttachmentFlag pClothDesc.attachmentTearFactor pClothDesc.attachmentResponseCoefficient freeVertex()
*/
void attachToCollidingShapes(int attachmentFlags);
/**
\brief Detaches the cloth from a shape it has been attached to before.
If the cloth has not been attached to the shape before, the call has no effect.
\param[in] shape Shape from which the cloth should be detached.
@see NxClothAttachmentFlag pClothDesc.attachmentTearFactor pClothDesc.attachmentResponseCoefficient freeVertex() attachToShape()
*/
void detachFromShape(CKBeObject *shape);
/**
\brief Attaches a cloth vertex to a local position within a shape.
\param[in] vertexId Index of the vertex to attach.
\param[in] shape Shape to attach the vertex to.
\param[in] localPos The position relative to the pose of the shape.
\param[in] attachmentFlags One or two way interaction, tearable or non-tearable
<b>Platform:</b>
\li PC SW: Yes
\li PPU : Yes
\li PS3 : Yes
\li XB360: Yes
@see NxShape freeVertex() NxClothAttachmentFlag attachToShape()
*/
void attachVertexToShape(int vertexId, CKBeObject *shape, const VxVector &localPos, int attachmentFlags);
/**
\brief Attaches a cloth vertex to a position in world space.
\param[in] vertexId Index of the vertex to attach.
\param[in] pos The position in world space.
@see pClothAttachmentFlag pClothDesc.attachmentTearFactor pClothDesc.attachmentResponseCoefficient freeVertex() attachToShape()
*/
void attachVertexToGlobalPosition(const int vertexId, const VxVector &pos);
/**
\brief Frees a previously attached cloth point.
\param[in] vertexId Index of the vertex to free.
@see attachVertexToGlobalPosition() attachVertexToShape() detachFromShape()
*/
void freeVertex(const int vertexId);
/**
\brief Changes the weight of a vertex in the cloth solver for a period of time.
If this method is called for some vertex, the cloth solver will, during a time
period of length expirationTime, assign a different weight to the vertex
while internal cloth constraints (i.e. bending & stretching) are being resolved.
With a high dominanceWeight, the modified vertex will force neighboring vertices
to strongly accommodate their positions while its own is kept fairly constant.
The reverse holds for smaller dominanceWeights.
Using a dominanceWeight of +infinity has a similar effect as temporarily attaching
the vertex to a global position. However, unlike using attachments, the velocity
of the vertex is kept intact when using this method.
\note The current implementation will not support the full range of dominanceWeights.
All dominanceWeights > 0.0 are treated equally as being +infinity.
\note An expiration time of 0.0 is legal and will result in dominance being
applied throughout one substep before being discarded immediately.
\note Having a large number of vertices dominant at once may result in a performance penalty.
\param[in] vertexId Index of the vertex.
\param[in] expirationTime Time period where dominance will be active for this vertex.
\param[in] dominanceWeight Dominance weight for this vertex.
@see attachVertexToGlobalPosition()
*/
void dominateVertex(int vertexId, float expirationTime, float dominanceWeight);
/**
\brief Return the attachment status of the given vertex.
\param[in] vertexId Index of the vertex.
@see getVertexAttachmentShape() getVertexAttachmentPosition()
*/
xU16 getVertexAttachmentStatus(int vertexId) const;
/**
\brief Returns the pointer to an attached shape pointer of the given vertex.
If the vertex is not attached or attached to a global position, NULL is returned.
\param[in] vertexId Index of the vertex.
@see getVertexAttachmentStatus() getVertexAttachmentPosition()
*/
NxShape* getVertexAttachmentShape(int vertexId) const;
/**
\brief Returns the attachment position of the given vertex.
If the vertex is attached to shape, the position local to the shape's pose is returned.
If the vertex is not attached, the return value is undefined.
\param[in] vertexId Index of the vertex.
@see getVertexAttachmentStatus() getVertexAttachmentShape()
*/
VxVector getVertexAttachmentPosition(int vertexId) const;
/**
\brief Attaches the cloth to an actor.
\note Call this function only once right after the cloth is created.
Turning cloth into metal and vice versa during the simulation is not recommended.
\note This feature is well suited for volumetric objects like barrels.
It cannot handle two dimensional flat pieces well.
After this call, the cloth is infinitely stiff between collisions and simply
moves with the actor. At impacts with an impact impulse greater than impulseThreshold,
the cloth is plastically deformed. Thus, a cloth with a core behaves like a piece of metal.
The core actor's geometry is adjusted automatically. Its size also depends on the
cloth thickness. Thus, it is recommended to choose small values for the thickness.
At impacts, colliding objects are moved closer to the cloth by the value provided in
penetrationDepth which causes a more dramatic collision result.
The core actor must have at least one shape, and currently supported shapes are
spheres, capsules, boxes and compounds of spheres.
It is recommended to specify the density rather than the mass of the core body.
This way the mass and inertia tensor are updated when the core deforms.
The maximal deviation of cloth particles from their initial positions
(modulo the global rigid body transforms translation and rotation) can be
specified via the parameter maxDeformationDistance. Setting this parameter to
zero means that the deformation is not limited.
\param actor The core actor to attach the cloth to.
\param impulseThreshold Threshold for when deformation is allowed.
\param penetrationDepth Amount by which colliding objects are brought closer to the cloth.
\param maxDeformationDistance Maximum deviation of cloth particles from initial position.
*/
void attachToCore(CK3dEntity *body, float impulseThreshold, float penetrationDepth, float maxDeformationDistance);
/**
\brief Tears the cloth at a given vertex.
First the vertex is duplicated. The triangles on one side of the split plane keep
the original vertex. For all triangles on the opposite side the original vertex is
replaced by the new one. The split plane is defined by the world location of the
vertex and the normal provided by the user.
Note: TearVertex performs a user defined vertex split in contrast to an automatic split
that is performed when the flag NX_CLF_TEARABLE is set. Therefore, tearVertex works
even if NX_CLF_TEARABLE is not set in pClothDesc.flags.
Note: For tearVertex to work, the clothMesh has to be cooked with the flag
NX_CLOTH_MESH_TEARABLE set in NxClothMeshDesc.flags.
\param[in] vertexId Index of the vertex to tear.
\param[in] normal The normal of the split plane.
\return true if the split had an effect (i.e. there were triangles on both sides of the split plane)
@see NxClothFlag, NxClothMeshFlags, pClothDesc.flags NxSimpleTriangleMesh.flags
<b>Platform:</b>
\li PC SW: Yes
\li PPU : Yes
\li PS3 : Yes
\li XB360: Yes
*/
bool tearVertex(const int vertexId, const VxVector &normal);
/**
\brief Executes a raycast against the cloth.
\param[in] worldRay The ray in world space.
\param[out] hit The hit position.
\param[out] vertexId Index to the nearest vertex hit by the raycast.
\return true if the ray hits the cloth.
*/
//BOOL raycast(const NxRay& worldRay, VxVector &hit, int &vertexId);
/**
\brief Sets which collision group this cloth is part of.
\param[in] collisionGroup The collision group for this cloth.
@see NxCollisionGroup
*/
void setGroup(int collisionGroup);
/**
\brief Retrieves the value set with #setGroup().
\return The collision group this cloth belongs to.
@see NxCollisionGroup
*/
int getGroup() const;
/**
\brief Sets 128-bit mask used for collision filtering.
\param[in] groupsMask The group mask to set for the cloth.
@see getGroupsMask() NxGroupsMask
*/
void setGroupsMask(const pGroupsMask& groupsMask);
/**
\brief Sets 128-bit mask used for collision filtering.
\return The group mask for the cloth.
@see setGroupsMask() NxGroupsMask
*/
const pGroupsMask getGroupsMask() const;
/**
\brief Sets the valid bounds of the cloth in world space.
If the flag NX_CLF_VALIDBOUNDS is set, these bounds defines the volume
outside of which cloth particle are automatically removed from the simulation.
\param[in] validBounds The valid bounds.
@see pClothDesc.validBounds getValidBounds() NxBounds3
*/
void setValidBounds(const VxBbox& validBounds);
/**
\brief Returns the valid bounds of the cloth in world space.
\param[out] validBounds The valid bounds.
@see pClothDesc.validBounds setValidBounds() NxBounds3
*/
void getValidBounds(NxBounds3& validBounds) const;
/**
\brief Sets the position of a particular vertex of the cloth.
\param[in] position New position of the vertex.
\param[in] vertexId Index of the vertex.
@see getPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles()
*/
void setPosition(const VxVector& position, int vertexId);
/**
\brief Sets the positions of the cloth.
The user must supply a buffer containing all positions (i.e same number of elements as number of particles).
\param[in] buffer The user supplied buffer containing all positions for the cloth.
\param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of VxVector.
@see getPositions() setVelocities() getVelocities() getNumberOfParticles()
*/
void setPositions(void* buffer, int byteStride = sizeof(VxVector));
/**
\brief Gets the position of a particular vertex of the cloth.
\param[in] vertexId Index of the vertex.
@see setPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles()
*/
VxVector getPosition(int vertexId) const;
/**
\brief Gets the positions of the cloth.
The user must supply a buffer large enough to hold all positions (i.e same number of elements as number of particles).
\param[in] buffer The user supplied buffer to hold all positions of the cloth.
\param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of VxVector.
@see setPositions() setVelocities() getVelocities() getNumberOfParticles()
*/
void getPositions(void* buffer, int byteStride = sizeof(VxVector));
/**
\brief Sets the velocity of a particular vertex of the cloth.
\param[in] position New velocity of the vertex.
\param[in] vertexId Index of the vertex.
@see setPosition() getPosition() getVelocity() setVelocities() getVelocities() getNumberOfParticles()
*/
void setVelocity(const VxVector& velocity, int vertexId);
/**
\brief Sets the velocities of the cloth.
The user must supply a buffer containing all velocities (i.e same number of elements as number of particles).
\param[in] buffer The user supplied buffer containing all velocities for the cloth.
\param[in] byteStride The stride in bytes between the velocity vectors in the buffer. Default is size of VxVector.
@see getVelocities() setPositions() getPositions() getNumberOfParticles()
*/
void setVelocities(void* buffer, int byteStride = sizeof(VxVector));
/**
\brief Gets the velocity of a particular vertex of the cloth.
\param[in] vertexId Index of the vertex.
@see setPosition() getPosition() setVelocity() setVelocities() getVelocities() getNumberOfParticles()
*/
VxVector getVelocity(int vertexId) const;
/**
\brief Sets the collision response coefficient.
\param[in] coefficient The collision response coefficient (0 or greater).
@see pClothDesc.collisionResponseCoefficient getCollisionResponseCoefficient()
*/
void setCollisionResponseCoefficient(float coefficient);
/**
\brief Retrieves the collision response coefficient.
\return The collision response coefficient.
@see pClothDesc.collisionResponseCoefficient setCollisionResponseCoefficient()
*/
float getCollisionResponseCoefficient() const;
/**
\brief Sets the attachment response coefficient
\param[in] coefficient The attachment response coefficient in the range from 0 to 1.
@see pClothDesc.attachmentResponseCoefficient getAttachmentResponseCoefficient()
*/
void setAttachmentResponseCoefficient(float coefficient);
/**
\brief Retrieves the attachment response coefficient
\return The attachment response coefficient.
@see pClothDesc.attachmentResponseCoefficient setAttachmentResponseCoefficient()
*/
float getAttachmentResponseCoefficient() const;
/**
\brief Sets the response coefficient for collisions from fluids to this cloth
\param[in] coefficient The response coefficient
@see pClothDesc.fromFluidResponseCoefficient getFromFluidResponseCoefficient()
*/
void setFromFluidResponseCoefficient(float coefficient);
/**
\brief Retrieves response coefficient for collisions from fluids to this cloth
\return The response coefficient.
@see pClothDesc.fromFluidResponseCoefficient setFromFluidResponseCoefficient()
*/
float getFromFluidResponseCoefficient() const;
/**
\brief Sets the response coefficient for collisions from this cloth to fluids
\param[in] coefficient The response coefficient
@see pClothDesc.toFluidResponseCoefficient getToFluidResponseCoefficient()
*/
void setToFluidResponseCoefficient(float coefficient);
/**
\brief Retrieves response coefficient for collisions from this cloth to fluids
\return The response coefficient.
@see pClothDesc.toFluidResponseCoefficient setToFluidResponseCoefficient()
*/
float getToFluidResponseCoefficient() const;
/**
\brief Sets an external acceleration which affects all non attached particles of the cloth
\param[in] acceleration The acceleration vector (unit length / s^2)
@see pClothDesc.externalAcceleration getExternalAcceleration()
*/
void setExternalAcceleration(VxVector acceleration);
/**
\brief Retrieves the external acceleration which affects all non attached particles of the cloth
\return The acceleration vector (unit length / s^2)
@see pClothDesc.externalAcceleration setExternalAcceleration()
*/
VxVector getExternalAcceleration() const;
/**
\brief If the NX_CLF_ADHERE flag is set the cloth moves partially in the frame
of the attached actor.
This feature is useful when the cloth is attached to a fast moving character.
In that case the cloth adheres to the shape it is attached to while only
velocities below the parameter minAdhereVelocity are used for secondary effects.
\param[in] velocity The minimal velocity for cloth to adhere (unit length / s)
@see pClothDesc.minAdhereVelocity getMinAdhereVelocity()
*/
void setMinAdhereVelocity(float velocity);
/**
\brief If the NX_CLF_ADHERE flag is set the cloth moves partially in the frame
of the attached actor.
This feature is useful when the cloth is attached to a fast moving character.
In that case the cloth adheres to the shape it is attached to while only
velocities below the parameter minAdhereVelocity are used for secondary effects.
\return Returns the minimal velocity for cloth to adhere (unit length / s)
@see pClothDesc.minAdhereVelocity setMinAdhereVelocity()
*/
float getMinAdhereVelocity() const;
/**
\brief Sets an acceleration acting normal to the cloth surface at each vertex.
\param[in] acceleration The acceleration vector (unit length / s^2)
@see pClothDesc.windAcceleration getWindAcceleration()
*/
void setWindAcceleration(VxVector acceleration);
/**
\brief Retrieves the acceleration acting normal to the cloth surface at each vertex.
\return The acceleration vector (unit length / s^2)
@see pClothDesc.windAcceleration setWindAcceleration()
*/
VxVector getWindAcceleration() const;
/**
\brief Returns true if this cloth is sleeping.
When a cloth does not move for a period of time, it is no longer simulated in order to save time. This state
is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object,
or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user.
If a cloth is asleep after the call to NxScene::fetchResults() returns, it is guaranteed that the position of the cloth
vertices was not changed. You can use this information to avoid updating dependent objects.
\return True if the cloth is sleeping.
@see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep()
*/
bool isSleeping() const;
/**
\brief Returns the linear velocity below which a cloth may go to sleep.
A cloth whose linear velocity is above this threshold will not be put to sleep.
@see isSleeping
\return The threshold linear velocity for sleeping.
@see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() setSleepLinearVelocity()
*/
float getSleepLinearVelocity() const;
/**
\brief Sets the linear velocity below which a cloth may go to sleep.
A cloth whose linear velocity is above this threshold will not be put to sleep.
If the threshold value is negative, the velocity threshold is set using the NxPhysicsSDK's
NX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter.
\param[in] threshold Linear velocity below which a cloth may sleep. <b>Range:</b> (0,inf]
@see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep()
*/
void setSleepLinearVelocity(float threshold);
/**
\brief Wakes up the cloth if it is sleeping.
The wakeCounterValue determines how long until the cloth is put to sleep, a value of zero means
that the cloth is sleeping. wakeUp(0) is equivalent to NxCloth::putToSleep().
\param[in] wakeCounterValue New sleep counter value. <b>Range:</b> [0,inf]
@see isSleeping() getSleepLinearVelocity() putToSleep()
*/
void wakeUp(float wakeCounterValue = pSLEEP_INTERVAL);
/**
\brief Forces the cloth to sleep.
The cloth will fall asleep.
@see isSleeping() getSleepLinearVelocity() wakeUp()
*/
void putToSleep();
/**
\brief Sets the flags, a combination of the bits defined by the enum ::NxClothFlag.
\param[in] flags #NxClothFlag combination.
@see pClothDesc.flags NxClothFlag getFlags()
*/
void setFlags(int flags);
/**
\brief Retrieves the flags.
\return The cloth flags.
@see pClothDesc.flags NxClothFlag setFlags()
*/
int getFlags() const;
/**
\brief Sets a name string for the object that can be retrieved with getName().
This is for debugging and is not used by the SDK. The string is not copied by
the SDK, only the pointer is stored.
\param[in] name String to set the objects name to.
@see getName()
*/
void setName(const char* name);
/**
\brief Applies a force (or impulse) defined in the global coordinate frame, to a particular
vertex of the cloth.
Because forces are reset at the end of every timestep,
you can maintain a total external force on an object by calling this once every frame.
::NxForceMode determines if the force is to be conventional or impulsive.
\param[in] force Force/impulse to add, defined in the global frame. <b>Range:</b> force vector
\param[in] vertexId Number of the vertex to add the force at. <b>Range:</b> position vector
\param[in] mode The mode to use when applying the force/impulse
(see #ForceMode, supported modes are FM_Force, FM_Impulse, FM_Acceleration, FM_VelocityChange)
@see ForceMode
*/
void addForceAtVertex(const VxVector& force, int vertexId, ForceMode mode = FM_Force);
/**
\brief Applies a radial force (or impulse) at a particular position. All vertices
within radius will be affected with a quadratic drop-off.
Because forces are reset at the end of every timestep,
you can maintain a total external force on an object by calling this once every frame.
::NxForceMode determines if the force is to be conventional or impulsive.
\param[in] position Position to apply force at.
\param[in] magnitude Magnitude of the force/impulse to apply.
\param[in] radius The sphere radius in which particles will be affected. <b>Range:</b> position vector
\param[in] mode The mode to use when applying the force/impulse
(see #ForceMode, supported modes are FM_Force, FM_Impulse, FM_Acceleration, FM_VelocityChange).
@see ForceMode
*/
void addForceAtPos(const VxVector& position, float magnitude, float radius, ForceMode mode = FM_Force);
/**
\brief Applies a directed force (or impulse) at a particular position. All vertices
within radius will be affected with a quadratic drop-off.
Because forces are reset at the end of every timestep,
you can maintain a total external force on an object by calling this once every frame.
::NxForceMode determines if the force is to be conventional or impulsive.
\param[in] position Position to apply force at.
\param[in] force Force to apply.
\param[in] radius The sphere radius in which particles will be affected. <b>Range:</b> position vector
\param[in] mode The mode to use when applying the force/impulse
(see #ForceMode, supported modes are FM_Force, FM_Impulse, FM_Acceleration, FM_VelocityChange).
@see ForceMode
*/
void addDirectedForceAtPos(const VxVector& position, const VxVector& force, float radius, ForceMode mode = FM_Force);
/**
\brief Finds triangles touching the input bounds.
\warning This method returns a pointer to an internal structure using the indices member. Hence the
user should use or copy the indices before calling any other API function.
\param[in] bounds Bounds to test against in world space. <b>Range:</b> See #NxBounds3
\param[out] nb Retrieves the number of triangle indices touching the AABB.
\param[out] indices Returns an array of touching triangle indices.
The triangle indices correspond to the triangles referenced to by pClothDesc.meshdata (#NxMeshData).
Triangle i has the vertices 3i, 3i+1 and 3i+2 in the array NxMeshData.indicesBegin.
\return True if there is an overlap.
@see NxBounds3 pClothDesc NxMeshData
*/
bool overlapAABBTriangles(const NxBounds3& bounds, int& nb, const int*& indices) const;
protected:
private:
NxMeshData *mReceiveBuffers;
CK_ID mEntityID;
NxCloth *mCloth;
NxClothMesh *mClothMesh;
pWorld *mWorld;
};
/** @} */
#endif

View File

@ -0,0 +1,237 @@
#include "pTypes.h"
/** \addtogroup Cloth
@{
*/
//! Collection of flags describing the behavior of a cloth object.
enum pClothFlag
{
/**
\brief Enable/disable pressure simulation.
Note: Pressure simulation only produces meaningful results for closed meshes.
*/
PCF_Pressure = (1<<0),
/**
\brief Makes the cloth static.
*/
PCF_Static = (1<<1),
/**
\brief
PCF_Static = (1<<1),/*!<Makes the cloth static. */
/**
\brief Disable collision handling with the rigid body scene.
@see pClothDesc.collisionResponseCoefficient
*/
PCF_DisableCollision = (1<<2),
/**
\brief Enable/disable self-collision handling within a single piece of cloth.
@see PCF_triangle_collision
*/
PCF_SelfCollision = (1<<3),
/**
\brief Enable/disable gravity. If off, the cloth is not subject to the gravitational force
of the rigid body scene.
*/
PCF_Gravity = (1<<5),
/**
\brief Enable/disable bending resistance. Select the bending resistance through
pClothDesc.bendingStiffness. Two bending modes can be selected via the PCF_BendingOrtho flag.
@see pClothDesc.bendingStiffness PCF_BendingOrtho
*/
PCF_Bending = (1<<6),
/**
\brief Enable/disable orthogonal bending resistance. This flag has an effect only if
PCF_Bending is set. If PCF_BendingOrtho is not set, bending is modeled via an
additional distance constraint. This mode is fast but not independent of stretching
resistance. If PCF_BendingOrtho is set, bending is modeled via an angular spring
between adjacent triangles. This mode is slower but independent of stretching resistance.
@see pClothDesc.bendingStiffness PCF_Bending
*/
PCF_BendingOrtho = (1<<7),
/**
\brief Enable/disable damping of internal velocities. Use pClothDesc.dampingCoefficient
to control damping.
@see pClothDesc.dampingCoefficient
*/
PCF_Damping = (1<<8),
/**
\brief Enable/disable two way collision of cloth with the rigid body scene.
In either case, cloth is influenced by colliding rigid bodies.
If PCF_CollisionTwoway is not set, rigid bodies are not influenced by
colliding pieces of cloth. Use pClothDesc.collisionResponseCoefficient to
control the strength of the feedback force on rigid bodies.
When using two way interaction care should be taken when setting the density of the attached objects.
For example if an object with a very low or high density is attached to a cloth then the simulation
may behave poorly. This is because impulses are only transfered between the cloth and rigid body solver
outside the solvers.
Two way interaction works best when NX_SF_SEQUENTIAL_PRIMARY is set in the primary scene. If not set,
collision and attachment artifacts may happen.
@see pClothDesc.collisionResponseCoefficient
*/
PCF_CollisionTwoway = (1<<9),
/**
Not supported in current release.
\brief Enable/disable collision detection of cloth triangles against the scene.
If PCF_TriangleCollision is not set, only collisions of cloth particles are detected.
If PCF_TriangleCollision is set, collisions of cloth triangles are detected as well.
*/
PCF_TriangleCollision = (1<<11),
/**
\brief Defines whether the cloth is tearable.
Note: Make sure meshData.maxVertices and the corresponding buffers
in meshData are substantially larger (e.g. 2x) then the number
of original vertices since tearing will generate new vertices.
When the buffer cannot hold the new vertices anymore, tearing stops.
Note: For tearing, make sure you cook the mesh with the flag
NX_CLOTH_MESH_TEARABLE set in the NxClothMeshDesc.flags.
@see pClothDesc.tearFactor
*/
PCF_Tearable = (1<<12),
/**
\brief Defines whether this cloth is simulated on the PPU.
To simulate a piece of cloth on the PPU
set this flag and create the cloth in a regular software scene.
Note: only use this flag during creation, do not change it using NxCloth.setFlags().
*/
PCF_Hardware = (1<<13),
/**
\brief Enable/disable center of mass damping of internal velocities.
This flag only has an effect if the flag PCF_Damping is set. If set,
the global rigid body modes (translation and rotation) are extracted from damping.
This way, the cloth can freely move and rotate even under high damping.
Use pClothDesc.dampingCoefficient to control damping.
@see pClothDesc.dampingCoefficient
*/
PCF_ComDamping = (1<<14),
/**
\brief If the flag PCF_ValidBounds is set, cloth particles outside the volume
defined by pClothDesc.validBounds are automatically removed from the simulation.
@see pClothDesc.validBounds
*/
PCF_ValidBounds = (1<<15),
/**
\brief Enable/disable collision handling between this cloth and fluids.
Note: With the current implementation, do not switch on fluid collision for
many cloths. Create scenes with a few large pieces because the memory usage
increases linearly with the number of cloths.
The performance of the collision detection is dependent on both, the thickness
and the particle radius of the fluid so tuning these parameters might improve
the performance significantly.
Note: The current implementation does not obey the pWorld::setGroupCollisionFlag
settings. If PCF_FluidCollision is set, collisions will take place even if
collisions between the groups that the corresponding cloth and fluid belong to are
disabled.
@see pClothDesc.toFluidResponseCoefficient pClothDesc.fromFluidResponseCoefficient
*/
PCF_FluidCollision = (1<<16),
/**
\brief Disable continuous collision detection with dynamic actors.
Dynamic actors are handled as static ones.
*/
PCF_DisableDynamicCCD = (1<<17),
/**
\brief Moves cloth partially in the frame of the attached actor.
This feature is useful when the cloth is attached to a fast moving character.
In that case the cloth adheres to the shape it is attached to while only
velocities below the parameter minAdhereVelocity are used for secondary effects.
@see pClothDesc.minAdhereVelocity
*/
PCF_AddHere = (1<<18),
/**
\brief Invokes #attachToShape() automatically during the clothes creation procedure.
This is only to be used when the entity has a physic attribute attached whereas it has to have
the BF_SubShape flags enabled and the entity must be in the hierarchy of the rigid body.
*/
PCF_AttachToParentMainShape = (1<<19),
/**
\brief Invokes #attachToCollidingShapes() automatically during the clothes creation procedure.
*/
PCF_AttachToCollidingShapes = (1<<20),
/**
\brief Invokes #attachToCore() automatically during the clothes creation procedure.
*/
PCF_AttachToCore = (1<<21),
/**
\brief Attaches a cloth attribute after the clothes creation.
*/
PCF_AttachAttributes = (1<<22),
};
/**
\brief Cloth attachment flags.
@see pCloth.attachToShape() pCloth.attachToCollidingShapes() pCloth.attachVertexToShape()
*/
enum pClothAttachmentFlag
{
/**
\brief The default is only object->cloth interaction (one way).
With this flag set, cloth->object interaction is turned on as well.
*/
PCAF_ClothAttachmentTwoway = (1<<0),
/**
\brief When this flag is set, the attachment is tearable.
\note If the cloth is attached to a dynamic shape using two way interaction
half way torn attachments can generate unexpected impluses on the shape.
To prevent this, only attach one row of cloth vertices to the shape.
@see pClothDesc.attachmentTearFactor
*/
PCAF_ClothAttachmentTearable = (1<<1),
};
/** @} */

View File

@ -0,0 +1,367 @@
#ifndef __PCLOTHTYPES_H__
#define __PCLOTHTYPES_H__
#include "pClothFlags.h"
/** \addtogroup Cloth
@{
*/
/**
\brief Descriptor class for pCloth.
*/
class MODULE_API pClothDesc
{
public:
/**
\brief Thickness of the cloth.
The thickness is usually a fraction of the overall extent of the cloth and
should not be set to a value greater than that. A good value is the maximal
distance between two adjacent cloth particles in their rest pose. Visual
artifacts or collision problems may appear if the thickness is too small.
<b>Default:</b> 0.01 <br>
<b>Range:</b> [0,inf)
@see pCloth.setThickness()
*/
float thickness;
/**
\brief Density of the cloth (mass per area).
<b>Default:</b> 1.0 <br>
<b>Range:</b> (0,inf)
*/
float density;
/**
\brief Bending stiffness of the cloth in the range 0 to 1.
Only has an effect if the flag PCF_Bending is set.
<b>Default:</b> 1.0 <br>
<b>Range:</b> [0,1]
@see PCF_Bending pCloth.setBendingStiffness()
*/
float bendingStiffness;
/**
\brief Stretching stiffness of the cloth in the range 0 to 1.
Note: stretching stiffness must be larger than 0.
<b>Default:</b> 1.0 <br>
<b>Range:</b> (0,1]
@see pCloth.setStretchingStiffness()
*/
float stretchingStiffness;
/**
\brief Spring damping of the cloth in the range 0 to 1.
Only has an effect if the flag PCF_Damping is set.
<b>Default:</b> 0.5 <br>
<b>Range:</b> [0,1]
@see PCF_Damping pCloth.setDampingCoefficient()
*/
float dampingCoefficient;
/**
\brief Friction coefficient in the range 0 to 1.
Defines the damping of the velocities of cloth particles that are in contact.
<b>Default:</b> 0.5 <br>
<b>Range:</b> [0,1]
@see pCloth.setFriction()
*/
float friction;
/**
\brief If the flag PCF_Pressure is set, this variable defines the volume
of air inside the mesh as volume = pressure * restVolume.
For pressure < 1 the mesh contracts w.r.t. the rest shape
For pressure > 1 the mesh expands w.r.t. the rest shape
<b>Default:</b> 1.0 <br>
<b>Range:</b> [0,inf)
@see PCF_pressure pCloth.setPressure()
*/
float pressure;
/**
\brief If the flag PCF_Tearable is set, this variable defines the
elongation factor that causes the cloth to tear.
Must be larger than 1.
Make sure meshData.maxVertices and the corresponding buffers
in meshData are substantially larger (e.g. 2x) than the number
of original vertices since tearing will generate new vertices.
When the buffer cannot hold the new vertices anymore, tearing stops.
<b>Default:</b> 1.5 <br>
<b>Range:</b> (1,inf)
@see pCloth.setTearFactor()
*/
float tearFactor;
/**
\brief Defines a factor for the impulse transfer from cloth to colliding rigid bodies.
Only has an effect if PCF_CollisionTwoWay is set.
<b>Default:</b> 0.2 <br>
<b>Range:</b> [0,inf)
@see PCF_CollisionTwoWay pCloth.setCollisionResponseCoefficient()
*/
float collisionResponseCoefficient;
/**
\brief Defines a factor for the impulse transfer from cloth to attached rigid bodies.
Only has an effect if the mode of the attachment is set to nx_cloth_attachment_twoway.
<b>Default:</b> 0.2 <br>
<b>Range:</b> [0,1]
@see pCloth.attachToShape pCloth.attachToCollidingShapes pCloth.attachVertexToShape pCloth.setAttachmentResponseCoefficient()
*/
float attachmentResponseCoefficient;
/**
\brief If the flag nx_cloth_attachment_tearable is set in the attachment method of pCloth,
this variable defines the elongation factor that causes the attachment to tear.
Must be larger than 1.
<b>Default:</b> 1.5 <br>
<b>Range:</b> (1,inf)
@see pCloth.setAttachmentTearFactor() pCloth.attachToShape pCloth.attachToCollidingShapes pCloth.attachVertexToShape
*/
float attachmentTearFactor;
/**
\brief Defines a factor for the impulse transfer from this cloth to colliding fluids.
Only has an effect if the PCF_FluidCollision flag is set.
<b>Default:</b> 1.0 <br>
<b>Range:</b> [0,inf)
Note: Large values can cause instabilities
@see pClothDesc.flags pClothDesc.fromFluidResponseCoefficient
*/
float toFluidResponseCoefficient;
/**
\brief Defines a factor for the impulse transfer from colliding fluids to this cloth.
Only has an effect if the PCF_FluidCollision flag is set.
<b>Default:</b> 1.0 <br>
<b>Range:</b> [0,inf)
Note: Large values can cause instabilities
@see pClothDesc.flags pClothDesc.ToFluidResponseCoefficient
*/
float fromFluidResponseCoefficient;
/**
\brief If the PCF_Adhere flag is set the cloth moves partially in the frame
of the attached actor.
This feature is useful when the cloth is attached to a fast moving character.
In that case the cloth adheres to the shape it is attached to while only
velocities below the parameter minAdhereVelocity are used for secondary effects.
<b>Default:</b> 1.0
<b>Range:</b> [0,inf)
@see PCF_ADHERE
*/
float minAdhereVelocity;
/**
\brief Number of solver iterations.
Note: Small numbers make the simulation faster while the cloth gets less stiff.
<b>Default:</b> 5
<b>Range:</b> [1,inf)
@see pCloth.setSolverIterations()
*/
unsigned int solverIterations;
/**
\brief External acceleration which affects all non attached particles of the cloth.
<b>Default:</b> (0,0,0)
@see pCloth.setExternalAcceleration()
*/
VxVector externalAcceleration;
/**
\brief Acceleration which acts normal to the cloth surface at each vertex.
<b>Default:</b> (0,0,0)
@see pCloth.setWindAcceleration()
*/
VxVector windAcceleration;
/**
\brief The cloth wake up counter.
<b>Range:</b> [0,inf)<br>
<b>Default:</b> 20.0f*0.02f
@see pCloth.wakeUp() pCloth.putToSleep()
*/
float wakeUpCounter;
/**
\brief Maximum linear velocity at which cloth can go to sleep.
If negative, the global default will be used.
<b>Range:</b> [0,inf)<br>
<b>Default:</b> -1.0
@see pCloth.setSleepLinearVelocity() pCloth.getSleepLinearVelocity()
*/
float sleepLinearVelocity;
/**
\brief Sets which collision group this cloth is part of.
<b>Range:</b> [0, 31]
<b>Default:</b> 0
pCloth.setCollisionGroup()
*/
xU16 collisionGroup;
/**
\brief Sets the 128-bit mask used for collision filtering.
<b>Default:</b> 0
@see NxGroupsMask pCloth.setGroupsMask() pCloth.getGroupsMask()
*/
pGroupsMask groupsMask;
/**
\brief Force Field Material Index, index != 0 has to be created.
<b>Default:</b> 0
*/
xU16 forceFieldMaterial;
/**
\brief If the flag PCF_ValidBounds is set, this variable defines the volume
outside of which cloth particle are automatically removed from the simulation.
@see PCF_ValidBounds pCloth.setValidBounds()
*/
VxBbox validBounds;
/**
\brief This parameter defines the size of grid cells for collision detection.
The cloth is represented by a set of world aligned cubical cells in broad phase.
The size of these cells is determined by multiplying the length of the diagonal
of the AABB of the initial cloth size with this constant.
<b>Range:</b> [0.01,inf)<br>
<b>Default:</b> 0.25
*/
float relativeGridSpacing;
/**
\brief Flag bits.
<b>Default:</b> PCF_GRAVITY
@see NxClothFlag pCloth.setFlags()
*/
unsigned int flags;
/**
\brief Possible debug name. The string is not copied by the SDK, only the pointer is stored.
<b>Default:</b> NULL
@see pCloth.setName() pCloth.getName()
*/
const char* name;
/**
\brief Vertex color to identify vertieces as tearable.
<b>Default:</b> 255,255,254
*/
VxColor tearVertexColor;
/**
\brief Reference object to identify the world.
<b>Default:</b> pDefaultWorld
*/
CK_ID worldReference;
/**
\brief Attachment flags.
<b>Default:</b> PCAF_ClothAttachmentTwoway
@see #pClothAttachmentFlag
*/
pClothAttachmentFlag attachmentFlags;
/**
\brief Constructor sets to default.
*/
pClothDesc();
/**
\brief (Re)sets the structure to the default.
*/
void setToDefault();
/**
\brief Returns true if the current settings are valid
*/
bool isValid() const;
};
/** @} */
#endif
// __PCLOTHTYPES_H__

View File

@ -0,0 +1,25 @@
#ifndef __P_COMMON_H__
#define __P_COMMON_H__
#include "vtPhysXBase.h"
#include "vtPhysXAll.h"
#include "vtLogTools.h"
#include "vtCBBErrorHelper.h"
#include <virtools/vtBBHelper.h>
#include <virtools/vtBBMacros.h>
#define HAS_CONFIG
#ifdef HAS_CONFIG
#include "gConfig.h"
#endif
using namespace vtTools::BehaviorTools;
#endif

View File

@ -0,0 +1,303 @@
#ifndef __P_FACTORY_H__
#define __P_FACTORY_H__
#include "vtPhysXBase.h"
/**
\brief Singleton class to create physic objects.
*/
class MODULE_API pFactory
{
public:
//friend class PhysicManager;
virtual ~pFactory();
void findAttributeIdentifiersByGuid(CKGUID guid,std::vector<int>&targetList);
pFactory();
pFactory(PhysicManager* prm1,TiXmlDocument*prm2);
int reloadConfig(const char *fName);
TiXmlDocument* loadConfig(const char* filename);
pWorldSettings *createWorldSettings(const XString nodeName="Default",const TiXmlDocument * doc = NULL);
pWorldSettings *createWorldSettings(const char* nodeName,const char *filename);
pWorldSettings*getWorldSettings(CK3dEntity*ent);
pWorld* createDefaultWorld(XString name);
const TiXmlElement*getFirstDocElement(const TiXmlElement *root);
TiXmlDocument* getDefaultDocument() const { return m_DefaultDocument; }
TiXmlDocument* getDocument(XString filename);
NxPhysicsSDK* getPhysicSDK() { return mPhysicSDK; }
void setPhysicSDK(NxPhysicsSDK* val) { mPhysicSDK = val; }
PhysicManager * getManager() const { return mManager; }
void setManager(PhysicManager * val) { mManager = val; }
void setDefaultDocument(TiXmlDocument* val) { m_DefaultDocument = val; }
void clean();
void destroy();
//////////////////////////////////////////////////////////////////////////
int copyTo(CKParameter *src,pDominanceSetupItem&dst);
pSleepingSettings *CreateSleepingSettings(XString nodeName="Default", TiXmlDocument * doc = NULL);
pSleepingSettings*CreateSleepingSettings(const char* nodeName,const char *filename);
pSleepingSettings*getSleepingSettings(CK3dEntity*ent);
pWorld *createWorld(CK3dEntity *referenceObject,pWorldSettings*worldSettings=NULL,pSleepingSettings*sleepSettings=NULL);
pRemoteDebuggerSettings createDebuggerSettings(const TiXmlDocument * doc);
/************************************************************************************************/
/** @name RigidBody
*/
//@{
pRigidBody *cloneRigidBody(CK3dEntity *src,CK3dEntity *dst,CKDependencies *deps,int copyFlags,int bodyFlags=0);
NxShape *cloneShape(CK3dEntity *src,CK3dEntity *dst,CK3dEntity*dstBodyReference,int copyFlags,int bodyFlags=0);
pJoint* cloneJoint(pJoint *src,CK3dEntity *srcReference,CK3dEntity *dstReference,int copyFlags);
int cloneLimitPlanes(pJoint *src,pJoint *dst,CK3dEntity *srcReference,CK3dEntity *dstReference);
void cloneJoints(CK3dEntity *src,CK3dEntity *dst,int copyFlags);
pRigidBody *createRigidBodyFull(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject=NULL);
pRigidBody *createBody(CK3dEntity *referenceObject,pObjectDescr descriction,CK3dEntity *worldReferenceObject=NULL);
pRigidBody *createBody(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject=NULL);
pRigidBody *createBody(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,NXU::NxActorDesc *desc,int flags);
pRigidBody *createRigidBody(CK3dEntity *referenceObject,pObjectDescr& oDescr);
pRigidBody *createBox(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,pObjectDescr*descr,int creationFlags);
pRigidBody *createCapsule(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,pObjectDescr*descr,int creationFlags);
int createSubShape(CK3dEntity*target,CK3dEntity*child);
NxCCDSkeleton *createCCDSkeleton(CKBeObject *meshReference,int flags);
//@}
/************************************************************************************************/
/** @name Joints
*/
//@{
pJoint *createJoint(CK3dEntity*,CK3dEntity*,int);
pJointDistance*createDistanceJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor0=VxVector(0,0,0),VxVector anchor1=VxVector(0,0,0),float minDistance=0.0f,float maxDistance=0.0f,pSpring sSettings=pSpring(),bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJDistance");
pJointD6* createD6Joint(CK3dEntity*a,CK3dEntity*b,VxVector globalAnchor=VxVector(0,0,0),VxVector globalAxis=VxVector(0,-1,0),bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f);
pJointFixed* createFixedJoint(CK3dEntity*a,CK3dEntity*b,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJFixed");
pJointPulley*createPulleyJoint(CK3dEntity*a,CK3dEntity*b,VxVector pulley0,VxVector pulley1, VxVector anchor0, VxVector anchor1,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f);
pJointBall *createBallJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector swingAxis,VxVector globalAxis=VxVector(0,1,0),bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJBall");
pJointPrismatic*createPrismaticJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJPrismatic");
pJointCylindrical*createCylindricalJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJCylindrical");
pJointRevolute *createRevoluteJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJRevolute");
pJointPointInPlane *createPointInPlaneJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJPointInPlane");
pJointPointOnLine *createPointOnLineJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName="pJPointOnLine");
pJoint *GetJoint(CK3dEntity*,CK3dEntity*);
pJoint *GetJoint(CK3dEntity*,int);
pJointSettings *CreateJointSettings(const XString nodeName="Default",const TiXmlDocument * doc = NULL);
pJointSettings *CreateJointSettings(const char* nodeName,const char *filename);
int jointCheckPreRequisites(CK3dEntity*,CK3dEntity*,int);
//@}
//////////////////////////////////////////////////////////////////////////
//nx
NxShapeDesc& createShape(int hullType,CK3dEntity*ent,float density = 1.0f);
NxMaterialDesc* createMaterialFromXML(const char* nodeName="Default",const TiXmlDocument * doc = NULL);
NxMaterialDesc* createMaterialFromEntity(CKBeObject*object);
CKParameterOut* findSettings(pWheelDescr&dst,CKBeObject*src);
bool findSettings(pMaterial&dst,CKBeObject*src);
bool copyTo(pMaterial& dst,CKParameter*src);
bool copyTo(pMaterial& dst,NxMaterial*src);
bool copyTo(NxMaterial&dst,pMaterial*src);
bool copyTo(CKParameterOut*dst,const pMaterial&src);
bool copyTo(NxMaterialDesc&dst,const pMaterial&src);
bool loadFrom(pMaterial& dst,const char* nodeName="Default",const TiXmlDocument * doc = NULL);
bool loadMaterial(pMaterial&dst,const char* nodeName);
pMaterial loadMaterial(const char* nodeName,int& error);
//////////////////////////////////////////////////////////////////////////
//nx mesh :
void createMesh(NxScene *scene,CKMesh *mesh,NxTriangleMeshDesc&descr,bool hardware=false);
void createConvexMesh(NxScene *scene,CKMesh *mesh,NxConvexMeshDesc&descr,bool hardware=false);
NxShape *createShape(CK3dEntity *bodyReference,pObjectDescr descr,CK3dEntity *srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);
static pFactory* Instance();
pSpring createSpringFromParameter(CKParameter *par);
pJointLimit createLimitFromParameter(CKParameter *par);
pMotor createMotorFromParameter(CKParameter *par);
pTireFunction createTireFuncFromParameter(CKParameter *par);
pObjectDescr *createPObjectDescrFromParameter(CKParameter *par);
/************************************************************************/
/* clothes : */
/************************************************************************/
pClothDesc *createClothDescrFromParameter(CKParameter *par);
pCloth *createCloth(CK3dEntity *srcReference,pClothDesc descr);
void copyToClothDescr(NxClothDesc* dst,pClothDesc src );
void copyTo(pDeformableSettings &dst,CKParameter*par);
/************************************************************************/
/*Special Case Capsule : */
/************************************************************************/
bool copyTo(pCapsuleSettings&dst,CKParameter*src);
bool findSettings(pCapsuleSettings&dst,CKBeObject *src);
bool findSettings(pCapsuleSettingsEx&dst,CKBeObject *src);
bool findSettings(pConvexCylinderSettings&dst,CKBeObject *src);
bool findSettings(pCCDSettings&dst,CKBeObject *src);
bool findSettings(pMassSettings&dst,CKBeObject *src);
bool findSettings(pPivotSettings&dst,CKBeObject *src);
bool findSettings(pOptimization&dst,CKBeObject *src);
bool findSettings(pCollisionSettings&dst,CKBeObject*src);
CKParameterOut* findSettingsParameter(CKBeObject *src,CKGUID guid);
/************************************************************************/
/* fluids : */
/************************************************************************/
//pFluid*createFluid(CK3dEntity *srcReference ,pFluidDesc desc);
//void copyToFluidDescr(NxFluidDesc &dst , pFluidDesc src );
//CK3dEntity *createFluidEntity();
//void initParticles(pFluidDesc &desc,NxParticleData&dst,CK3dEntity*srcReference,CK3dEntity*dstEntity);
//void copyToEmitterDesc(NxFluidEmitterDesc&dst,pFluidEmitterDesc src);
//CK3dPointCloud* createPointCloud(const pFluidDesc&descr);
/************************************************************************/
/* Vehicle */
/************************************************************************/
pVehicle *createVehicle(CK3dEntity *body,pVehicleDesc descr);
pVehicleMotor *createVehicleMotor(pVehicleMotorDesc descr);
pVehicleGears *createVehicleGears(pVehicleGearDesc descr);
pWheel *createWheelSubShape(pRigidBody *body,CK3dEntity* subEntity,CKMesh *mesh,pObjectDescr *descr,VxVector localPos, VxQuaternion localRotation,NxShape*dstShape);
XString _getMaterialsAsEnumeration(const TiXmlDocument * doc);
XString _getBodyXMLInternalEnumeration(const TiXmlDocument * doc);
XString _getBodyXMLExternalEnumeration(const TiXmlDocument * doc);
XString _getVehicleTireFunctionAsEnumeration(const TiXmlDocument * doc);
XString _getVehicleWheelAsEnumeration(const TiXmlDocument * doc);
XString _getVehicleSettingsAsEnumeration(const TiXmlDocument * doc);
XString _getVehicleMotorSettingsAsEnumeration(const TiXmlDocument * doc);
XString _getVehicleGearSettingsAsEnumeration(const TiXmlDocument * doc);
XString _getEnumDescription(const TiXmlDocument * doc,XString identifier);
int _getEnumIdentifier(const TiXmlDocument * doc,XString type);
int _getEnumIndex(XString enumerationFull,XString enumValue);
NxShape *createWheelShape(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CK3dEntity*srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);
NxShape *_createWheelShape1(NxActor *actor,pWheel1 *dstWheel,pObjectDescr *descr,pWheelDescr *wheelDescr,CK3dEntity*srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);
NxShape *_createWheelShape2(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CK3dEntity*srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);
NxShape *createWheelShape(CK3dEntity*bodyReference,pWheelDescr wheelDescr,CK3dEntity*wheelReference);
pWheel *createWheel(pRigidBody *body,pWheelDescr descr,CK3dEntity *wheelShapeReference);
pWheel* createWheel(CK3dEntity *bodyReference,CK3dEntity*srcReference,pWheelDescr wheelDescr,pConvexCylinderSettings convexCylinder,VxVector localPositionOffset);
NxShape *createWheelShape2(CK3dEntity *bodyReference,CK3dEntity*wheelReference,pWheelDescr wheelDescr);
NxShape *createWheelShape1(CK3dEntity *bodyReference,CK3dEntity*wheelReference,pWheelDescr wheelDescr);
NxShape *_createConvexCylinder(NxActor *actor,int approximation,VxVector _forwardAxis,VxVector _downAxis,VxVector _rightAxis,float height,float radius,bool buildLowerHalf,int shapeFlags);
bool _createConvexCylinder(NxConvexShapeDesc* shape,CK3dEntity*dstBodyReference,pObjectDescr *oDescr=NULL);
bool _createConvexCylinderMesh(NxConvexShapeDesc *dstShapeDescription,pConvexCylinderSettings& srcSettings,CK3dEntity*referenceObject);
NxShape *_createConvexCylinder(const pConvexCylinderSettings& cylinderDescr,CK3dEntity *srcReference);
int loadVehicleDescrFromXML(pVehicleDesc& dst,const char* nodeName/* =NULL */,const TiXmlDocument * doc /* = NULL */ );
//////////////////////////////////////////////////////////////////////////
//
// Geometry related structures :
//
void copyTo(pAxisReferencedLength&dst,CKParameter*src,bool evaluate=true);
bool copyTo(pConvexCylinderSettings&dst,CKParameter*src,bool evaluate=true);
//////////////////////////////////////////////////////////////////////////
//
// wheels
int copyTo(pWheelDescr *dst,CKParameter *src);
int loadFrom(pTireFunction& dst,const char* nodeName/* = */,const TiXmlDocument * doc /* = NULL */);
int loadWheelDescrFromXML(pWheelDescr& dst,const char* nodeName/* =NULL */,const TiXmlDocument * doc /* = NULL */ );
bool loadFrom(pWheelDescr& dst,const char* nodeName/* =NULL */);
int copyTo(CKParameterOut *dst,pWheelDescr *src);
int copyTo(pWheelDescr &dst,CKParameterOut *src);
int copyTo(CKParameterOut *dst,const pTireFunction& src);
//contact data :
int copyTo(CKParameterOut *dst,const pWheelContactData& src);
//////////////////////////////////////////////////////////////////////////
//
//
// collision structures
int copyTo(pGroupsMask &dst,CKParameter*src);
int copyTo(CKParameterOut*dst,pGroupsMask src);
CK3dEntity *getMostTopParent(CK3dEntity*ent);
protected:
PhysicManager *mManager;
TiXmlDocument* m_DefaultDocument;
NxPhysicsSDK* mPhysicSDK;
VxVector _str2Vec(XString _in);
int _str2MaterialFlag(XString _in);
int _str2WheelFlag(XString _in);
int _str2SceneFlags(XString _in);
int _str2PhysicFlags(XString _in);
int _str2WheelShapeFlag(XString _in);
XString ResolveFileName(const char *input);
int _str2CombineMode(const char*input);
CK3dEntity *createFrame(const char* name);
};
#endif // !defined(EA_10DFC1E8_486F_4770_9451_7898DBDAD59F__INCLUDED_)

View File

@ -0,0 +1,550 @@
#ifndef __P_FLUID_H__
#define __P_FLUID_H__
#include "pTypes.h"
#include "NxPlane.h"
#include "pFluidFlags.h"
#include "pTypes.h"
class CK3dPointCloud;
/** \addtogroup Fluid
@{
*/
/**
\brief2 Describes an pFluidDesc.
*/
class MODULE_API pFluidDesc
{
public:
/**
\brief Sets the maximal number of particles for the fluid used in the simulation.
If more particles are added directly, or more particles are emitted into the
fluid after this limit is reached, they are simply ignored.
*/
int maxParticles;
/**
\brief Defines the number of particles which are reserved for creation at runtime.
If pFluidDesc.flags.PFF_PriorityMode is set the oldest particles are removed until
there are no more than (maxParticles - numReserveParticles) particles left. This removal
is carried out for each simulation step, on particles which have a finite life time
(i.e. > 0.0). The deletion guarantees a reserve of numReserveParticles particles which
can be added for each simulaiton step. Note that particles which have equal lifetime can
get deleted at the same time. In order to avoid this, the particle lifetimes
can be varied randomly.
This parameter must be smaller than pFluidDesc.maxParticles.
*/
int numReserveParticles;
/**
\brief The particle resolution given as particles per linear meter measured when the fluid is
in its rest state (relaxed).
Even if the particle system is simulated without particle interactions, this parameter defines the
emission density of the emitters.
*/
float restParticlesPerMeter;
/**
\brief Target density for the fluid (water is about 1000).
Even if the particle system is simulated without particle interactions, this parameter defines
indirectly in combination with restParticlesPerMeter the mass of one particle
( mass = restDensity/(restParticlesPerMeter^3) ).
The particle mass has an impact on the repulsion effect on emitters and actors.
*/
float restDensity;
/**
\brief Radius of sphere of influence for particle interaction.
This parameter is relative to the rest spacing of the particles, which is defined by the parameter
restParticlesPerMeter
( radius = kernelRadiusMultiplier/restParticlesPerMeter ).
This parameter should be set around 2.0 and definitely below 2.5 for optimal performance and simulation quality.
@see restParticlesPerMeter
*/
float kernelRadiusMultiplier;
/**
\brief Maximal distance a particle is allowed to travel within one timestep.
This parameter is relative to the rest spacing of the particles, which is defined by the parameter
restParticlesPerMeter:
( maximal travel distance = motionLimitMultiplier/restParticlesPerMeter ).
Default value is 3.6 (i.e., 3.0 * kernelRadiusMultiplier).
The value must not be higher than the product of packetSizeMultiplier and kernelRadiusMultiplier.
@see restParticlesPerMeter
*/
float motionLimitMultiplier;
/**
\brief Defines the distance between particles and collision geometry, which is maintained during simulation.
For the actual distance, this parameter is divided by the rest spacing of the particles, which is defined by the parameter
restParticlesPerMeter:
( distance = collisionDistanceMultiplier/restParticlesPerMeter ).
It has to be positive and not higher than packetSizeMultiplier*kernelRadiusMultiplier.
Default value is 0.12 (i.e., 0.1 * kernelRadiusMultiplier).
@see restParticlesPerMeter, kernelRadiusMultiplier
*/
float collisionDistanceMultiplier;
/**
\brief This parameter controls the parallelization of the fluid.
The spatial domain is divided into so called packets, equal sized cubes, aligned in a grid.
The parameter given defines the edge length of such a packet. This parameter is relative to the interaction
radius of the particles, given as kernelRadiusMultiplier/restParticlesPerMeter.
It has to be a power of two, no less than 4.
*/
int packetSizeMultiplier;
/**
\brief The stiffness of the particle interaction related to the pressure.
This factor linearly scales the force which acts on particles which are closer to each other than
the rest spacing.
Setting this parameter appropriately is crucial for the simulation. The right value depends on many factors
such as viscosity, damping, and kernelRadiusMultiplier. Values which are too high will result in an
unstable simulation, whereas too low values will make the fluid appear "springy" (the fluid
acts more compressible).
Must be positive.
*/
float stiffness;
/**
\brief The viscosity of the fluid defines its viscous behavior.
Higher values will result in a honey-like behavior. Viscosity is an effect which depends on the
relative velocity of neighboring particles; it reduces the magnitude of the relative velocity.
Must be positive.
*/
float viscosity;
/**
\brief The surfaceTension of the fluid defines an attractive force between particles
Higher values will result in smoother surfaces.
Must be nonnegative.
*/
float surfaceTension;
/**
\brief Velocity damping constant, which is globally applied to each particle.
It generally reduces the velocity of the particles. Setting the damping to 0 will leave the
particles unaffected.
Must be nonnegative.
*/
float damping;
/**
\brief Defines a timespan for the particle "fade-in".
This feature is experimental. When a particle is created it has no influence on the simulation.
It takes fadeInTime until the particle has full influence. If set to zero, the particle has full
influence on the simulation from start.
<b>Default:</b> 0.0 <br>
<b>Range:</b> [0,inf)
*/
float fadeInTime;
/**
\brief Acceleration (m/s^2) applied to all particles at all time steps.
Useful to simulate smoke or fire.
This acceleration is additive to the scene gravity. The scene gravity can be turned off
for the fluid, using the flag PFF_DisableGravity.
@see pFluid.getExternalAcceleration() pFluid.setExternalAcceleration()
*/
VxVector externalAcceleration;
/**
\brief Defines the plane the fluid particles are projected to. This parameter is only used if
PFF_ProjectToPlane is set.
<b>Default:</b> XY plane
@see PFF_ProjectToPlane pFluid.getProjectionPlane() pFluid.setProjectionPlane()
*/
NxPlane projectionPlane;
/**
\brief Defines the restitution coefficient used for collisions of the fluid particles with static shapes.
Must be between 0 and 1.
A value of 0 causes the colliding particle to get a zero velocity component in the
direction of the surface normal of the static shape at the collision location; i.e.
it will not bounce.
A value of 1 causes a particle's velocity component in the direction of the surface normal to invert;
i.e. the particle bounces off the surface with the same velocity magnitude as it had before collision.
(Caution: values near 1 may have a negative impact on stability)
*/
float restitutionForStaticShapes;
/**
\brief Defines the dynamic friction of the fluid regarding the surface of a static shape.
Must be between 0 and 1.
A value of 1 will cause the particle to lose its velocity tangential to
the surface normal of the shape at the collision location; i.e. it will not slide
along the surface.
A value of 0 will preserve the particle's velocity in the tangential surface
direction; i.e. it will slide without resistance on the surface.
*/
float dynamicFrictionForStaticShapes;
/**
\brief Defines the static friction of the fluid regarding the surface of a static shape.
This feature is currently unimplemented!
*/
float staticFrictionForStaticShapes;
/**
\brief Defines the strength of attraction between the particles and static rigid bodies on collision.
This feature is currently unimplemented!
*/
float attractionForStaticShapes;
/**
\brief Defines the restitution coefficient used for collisions of the fluid particles with dynamic shapes.
Must be between 0 and 1.
(Caution: values near 1 may have a negative impact on stability)
@see restitutionForStaticShapes
*/
float restitutionForDynamicShapes;
/**
\brief Defines the dynamic friction of the fluid regarding the surface of a dynamic shape.
Must be between 0 and 1.
@see dynamicFrictionForStaticShapes
*/
float dynamicFrictionForDynamicShapes;
/**
\brief Defines the static friction of the fluid regarding the surface of a dynamic shape.
This feature is currently unimplemented!
*/
float staticFrictionForDynamicShapes;
/**
\brief Defines the strength of attraction between the particles and the dynamic rigid bodies on collision.
This feature is currently unimplemented!
*/
float attractionForDynamicShapes;
/**
\brief Defines a factor for the impulse transfer from fluid to colliding rigid bodies.
Only has an effect if PFF_CollisionTwoway is set.
<b>Default:</b> 0.2 <br>
<b>Range:</b> [0,inf)
@see PFF_CollisionTwoway pFluid.setCollisionResponseCoefficient()
*/
float collisionResponseCoefficient;
/**
\brief pFluidSimulationMethod flags. Defines whether or not particle interactions are considered
in the simulation.
@see pFluidSimulationMethod
*/
pFluidSimulationMethod simulationMethod;
/**
\brief pFluidCollisionMethod flags. Selects whether static collision and/or dynamic collision
with the environment is performed.
@see pFluidCollisionMethod
*/
pFluidCollisionMethod collisionMethod;
/**
\brief Sets which collision group this fluid is part of.
<b>Default:</b> 0
pFluid.setCollisionGroup()
*/
int collisionGroup;
/**
\brief Sets the 128-bit mask used for collision filtering.
<b>Default:</b> 0
@see NxGroupsMask pFluid.setGroupsMask() pFluid.getGroupsMask()
*/
NxGroupsMask groupsMask;
/**
\brief Flags defining certain properties of the fluid.
@see pFluidFlag
*/
unsigned int flags;
void* userData; //!< Will be copied to NxFluid::userData
const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored.
/**
\brief Constructor sets to default.
*/
pFluidDesc();
/**
\brief (Re)sets the structure to the default.
*/
void setToDefault();
/**
\brief Returns true if the current settings are valid
*/
bool isValid() const;
/**
\brief Retrieve the fluid desc type.
\return The fluid desc type. See #pFluidDescType
*/
xU16 getType() const;
CK_ID worldReference;
protected:
NxFluidDescType type;
};
struct pParticle
{
NxVec3 position;
NxVec3 velocity;
float density;
float lifetime;
unsigned int id;
NxVec3 collisionNormal;
};
/**
\brief The fluid class represents the main module for the particle based fluid simulation.
SPH (Smoothed Particle Hydrodynamics) is used to animate the particles.
There are two kinds of particle interaction forces which govern the behavior of the fluid:
<ol>
<li>
Pressure forces: These forces result from particle densities higher than the
"rest density" of the fluid. The rest density is given by specifying the inter-particle
distance at which the fluid is in its relaxed state. Particles which are closer than
the rest spacing are pushed away from each other.
<li>
Viscosity forces: These forces act on neighboring particles depending on the difference
of their velocities. Particles drag other particles with them which is used to simulate the
viscous behaviour of the fluid.
</ol>
The fluid class manages a set of particles.
Particles can be created in two ways:
<ol>
<li>
Particles can be added by the user directly.
<li>
The user can add emitters to the fluid and configure the parameters of the emission.
(See pFluidEmitter)
</ol>
Particles can be removed in two ways as well:
<ol>
<li>
The user can specify a lifetime for the particles. When its lifetime expires, a particle is deleted.
<li>
Shapes can be configured to act as drains. When a particle intersects with a drain, the particle is deleted.
(See pShapeFlag)
</ol>
Particles collide with static and dynamic shapes. Particles are also affected by the scene gravity and a user force,
as well as global velocity damping. In order to render a fluid, the user can supply the fluid instance with a
user buffer into which the particle state is written after each simuation step.
For a good introduction to SPH fluid simulation,
see http://graphics.ethz.ch/~mattmuel/publications/sca03.pdf
@see pFluidDesc, pFluidEmitter, pFluidEmitterDesc, pShapeFlag
*/
class pFluid
{
public:
pFluid(NxFluidDesc &desc, bool trackUserData, bool provideCollisionNormals, const VxVector& color, float particleSize);
~pFluid();
NxFluid* getNxFluid() { return mFluid; }
pParticle* getParticles() { return mParticleBuffer; }
unsigned getParticlesNum() { return mParticleBufferNum; }
const unsigned* getCreatedIds() { return mCreatedParticleIds; }
unsigned getCreatedIdsNum() { return mCreatedParticleIdsNum; }
const unsigned* getDeletedIds() { return mDeletedParticleIds; }
unsigned getDeletedIdsNum() { return mDeletedParticleIdsNum; }
void setParticleSize(float size) { mParticleSize = size; }
float getParticleSize() { return mParticleSize; }
void draw();
NxFluid* getFluid() const { return mFluid; }
void setFluid(NxFluid* val) { mFluid = val; }
CK_ID getEntityID() const { return entityID; }
void setEntityID(CK_ID val) { entityID = val; }
void updateVirtoolsMesh();
CK3dEntity *getParticleObject();
pParticle* mParticleBuffer;
/************************************************************************/
/* emitter operations : */
/************************************************************************/
/**
\brief Creates an emitter for this fluid.
pFluidEmitterDesc::isValid() must return true.
\param desc The fluid emitter descriptor. See #pFluidEmitterDesc.
\return The new fluid.
@see pFluidEmitter
*/
pFluidEmitter* createEmitter(const pFluidEmitterDesc& desc);
/**
\brief Deletes the specified emitter.
The emitter must belong to this fluid. Do not keep a reference to the deleted instance.
Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls).
\param emitter The emitter to release.
*/
void releaseEmitter(pFluidEmitter& emitter);
/**
\brief Returns the number of emitters.
\return The number of emitters.
*/
int getNbEmitters()const;
CK3dPointCloud* mPointCloud;
CK3dPointCloud* getPointCloud() const { return mPointCloud; }
void setPointCloud(CK3dPointCloud* val) { mPointCloud = val; }
void updateCloud();
private:
unsigned mParticleBufferNum;
NxFluid* mFluid;
VxVector mParticleColor;
float mParticleSize;
unsigned int mMaxParticles;
CK_ID entityID;
/**
These fields are only relevant for tracking user particle data (MyParticle)
*/
bool mTrackUserData;
pFluid* mMyParticleBuffer;
unsigned int mCreatedParticleIdsNum;
unsigned int* mCreatedParticleIds;
unsigned int mDeletedParticleIdsNum;
unsigned int* mDeletedParticleIds;
//rendering
float* mRenderBuffer;
float* mRenderBufferUserData;
protected:
private:
};
/** @} */
#endif

View File

@ -0,0 +1,386 @@
#ifndef __P_FLUIDS_FLUID_EMITTER_H__
#define __P_FLUIDS_FLUID_EMITTER_H__
/** \addtogroup fluids
@{
*/
#include "Nxp.h"
#include "NxPhysicsSDK.h"
#include "pFluidEmitterDesc.h"
class pFluid;
class pFluidEmitterDesc;
class NxShape;
/**
\brief The fluid emitter class. It represents an emitter (fluid source) which is associated with one fluid.
The emitter is an alternative to adding particles to the fluid via the pFluid::addParticles() method.
Emission always takes place in a plane given by the orientation and position of the emitter. The
shape of the area of emission is either a rectangle or an ellipse. The direction of emission is usually
perpendicular to the emission plane. However, this can be randomly modulated using the setRandomAngle()
method. An emitter can have two types of operation:
<ol>
<li>
<i>Constant pressure.</i>
In this case the state of the surrounding fluid is taken into account. The emitter tries
to match the rest spacing of the particles. Nice rays of water can be generated this way.
<li>
<i>Constant flow rate.</i>
In this case the emitter keeps emitting the same number of particles each frame. The rate can
be adjusted dynamically.
</ol>
The emitter's pose can be animated directly or attached to a shape which belongs to a
dynamic actor. This shape is called the frame shape. When attaching an emitter to a shape, one
has the option of enabling impulse transfer from the emitter to the body of the shape.
The impulse generated is dependent on the rate, density,
and velocity of the emitted particles.
*/
class MODULE_API pFluidEmitter
{
public:
pFluidEmitter();
~pFluidEmitter() {}
/**
\brief Sets the position of the emitter in world space.
\param[in] vec New position in world space.
*/
void setGlobalPosition(const VxVector& vec);
/**
\brief Sets the orientation of the emitter in world space.
\param[in] rot New orientation in world space.
*/
void setGlobalOrientation(const VxQuaternion& rot);
/**
\brief Returns the position of the emitter in world space.
\return The world space position.
*/
VxVector getGlobalPosition()const;
/**
\brief Returns the orientation of the emitter in world space.
\return The world space orientation.
*/
VxQuaternion getGlobalOrientation()const;
/**
\brief Sets the position of the emitter relative to the frameShape.
The pose is relative to the shape frame.
If the frameShape is NULL, world space is used.
\param[in] vec The new local position of the emitter.
@see pFluidEmitterDesc.relPose
*/
void setLocalPosition(const VxVector& vec) ;
/**
\brief Sets the orientation of the emitter relative to the frameShape.
The pose is relative to the shape frame.
If the frameShape is NULL, world space is used.
\param[in] mat The new local orientation of the emitter.
@see pFluidEmitterDesc.relPose
*/
void setLocalOrientation(const VxQuaternion& mat);
/**
\brief Returns the position of the emitter relative to the frameShape.
The pose is relative to the shape frame.
If the frameShape is NULL, world space is used.
\return The local position of the emitter.
@see pFluidEmitterDesc.relPose
*/
VxVector getLocalPosition()const;
/**
\brief Returns the orientation of the emitter relative to the frameShape.
The pose is relative to the shape frame.
If the frameShape is NULL, world space is used.
\return The local orientation of the emitter.
@see pFluidEmitterDesc.relPose
*/
VxQuaternion getLocalOrientation()const;
/**
\brief Sets the frame shape. Can be set to NULL.
\param[in] shape The frame shape.
@see pFluidEmitterDesc.frameShape
*/
void setFrameShape(CK3dEntity* shape);
/**
\brief Returns the frame shape. May be NULL.
\return The frame shape.
@see pFluidEmitterDesc.frameShape
*/
CK3dEntity * getFrameShape() const;
/**
\brief Returns the radius of the emitter along the x axis.
\return Radius of emitter along the X axis.
@see pFluidEmitterDesc.dimensionX
*/
float getDimensionX() const;
/**
\brief Returns the radius of the emitter along the y axis.
\return Radius of emitter along the Y axis.
@see pFluidEmitterDesc.dimensionY
*/
float getDimensionY()const;
/**
\brief Sets the maximal random displacement in every dimension.
\param[in] disp The maximal random displacement of particles.
@see pFluidEmitterDesc.randomPos
*/
void setRandomPos(VxVector disp);
/**
\brief Returns the maximal random displacement in every dimension.
\return The maximal random displacement of particles.
@see pFluidEmitterDesc.randomPos
*/
VxVector getRandomPos()const;
/**
\brief Sets the maximal random angle offset (in radians).
<b>Unit:</b> Radians
\param[in] angle Maximum random angle for emitted particles.
@see pFluidEmitterDesc.randomAngle
*/
void setRandomAngle(float angle);
/**
\brief Returns the maximal random angle offset (in radians).
<b>Unit:</b> Radians
\return Maximum random angle for emitted particles.
@see pFluidEmitterDesc.randomAngle
*/
float getRandomAngle();
/**
\brief Sets the velocity magnitude of the emitted particles.
\param[in] vel New velocity magnitude of emitted particles.
@see pFluidEmitterDesc.fluidVelocityMagnitude
*/
void setFluidVelocityMagnitude(float vel) ;
/**
\brief Returns the velocity magnitude of the emitted particles.
\return Velocity magnitude of emitted particles.
@see pFluidEmitterDesc.fluidVelocityMagnitude
*/
float getFluidVelocityMagnitude() const;
/**
\brief Sets the emission rate (particles/second).
Only used if the pEmitterType is PFET_ConstantFlowRate.
\param[in] rate New emission rate.
@see pFluidEmitterDesc.rate
*/
void setRate(float rate);
/**
\brief Returns the emission rate.
\return Emission rate.
@see pFluidEmitterDesc.rate
*/
float getRate() const;
/**
\brief Sets the particle lifetime.
\param[in] life Lifetime of emitted particles.
@see pFluidEmitterDesc.particleLifetime
*/
void setParticleLifetime(float life) ;
/**
\brief Returns the particle lifetime.
\return Lifetime of emitted particles.
@see pFluidEmitterDesc.particleLifetime
*/
float getParticleLifetime() const;
/**
\brief Sets the repulsion coefficient.
\param[in] coefficient The repulsion coefficient in the range from 0 to inf.
@see pFluidEmitterDesc.repulsionCoefficient getRepulsionCoefficient()
*/
void setRepulsionCoefficient(float coefficient);
/**
\brief Retrieves the repulsion coefficient.
\return The repulsion coefficient.
@see pFluidEmitterDesc.repulsionCoefficient setRepulsionCoefficient()
*/
float getRepulsionCoefficient() const;
/**
\brief Resets the particle reservoir.
\param[in] new maxParticles value.
@see pFluidEmitterDesc.maxParticles
*/
void resetEmission(int maxParticles);
/**
\brief Returns the maximal particle number to be emitted.
\return max particles.
@see pFluidEmitterDesc.maxParticles
*/
int getMaxParticles() const;
/**
\brief Returns the number of particles that have been emitted already.
\return number of particles already emitted.
*/
int getNbParticlesEmitted() const;
/**
\brief Sets the emitter flags.
\param[in] flag Member of #pFluidEmitterFlag.
\param[in] val New flag value.
@see pFluidEmitterFlag
*/
void setFlag(pFluidEmitterFlag flag, bool val);
/**
\brief Returns the emitter flags.
\param[in] flag Member of #pFluidEmitterFlag.
\return The current flag value.
@see pFluidEmitterFlag
*/
bool getFlag(pFluidEmitterFlag flag) const;
/**
\brief Get the emitter shape.
\param[in] shape Member of #pEmitterShape.
\return True if it is of type shape.
@see pFluidEmitterDesc.shape
*/
bool getShape(pEmitterShape shape) const;
/**
\brief Get the emitter type.
\param[in] type Member of #pEmitterType
\return True if it is of type type.
@see pEmitterType
*/
bool getType(pEmitterType type) const;
NxFluidEmitter* getEmitter() const { return mEmitter; }
void setEmitter(NxFluidEmitter* val) { mEmitter = val; }
/**
\brief Returns the owner fluid.
\return The fluid this emitter is associated with.
*/
pFluid * getFluid() const { return mFluid; }
void setFluid(pFluid * val) { mFluid = val; }
CK_ID getEntityReference() const { return mEntityReference; }
void setEntityReference(CK_ID val) { mEntityReference = val; }
pFluidRenderSettings * getRenderSettings() const { return mRenderSettings; }
void setRenderSettings(pFluidRenderSettings * val) { mRenderSettings = val; }
private :
NxFluidEmitter* mEmitter;
pFluid *mFluid;
CK_ID mEntityReference;
pFluidRenderSettings *mRenderSettings;
};
/** @} */
#endif

View File

@ -0,0 +1,201 @@
#ifndef __P_FLUID_EMITTER_DESC_H__
#define __P_FLUID_EMITTER_DESC_H__
/** \addtogroup fluids
@{
*/
/**
\brief Flags which control the behavior of fluid emitters.
@see pFluidEmitter
*/
enum pFluidEmitterFlag
{
/**
\brief Flags whether the emitter should be visualized for debugging or not.
*/
PFEF_Visualization = (1<<0),
/**
\brief This flag specifies whether the emission should cause a force on
the shapes body that the emitter is attached to.
*/
PFEF_ForceOnBody = (1<<2),
/**
\brief If set, the velocity of the shapes body is added to the emitted particle velocity.
This is the default behavior .
*/
PFEF_AddBodyVelocity = (1<<3),
/**
\brief Flag to start and stop the emission. On default the emission is enabled.
*/
PFEF_Enabled = (1<<4),
};
/**
\brief Flags to specify the shape of the area of emission.
Exactly one flag should be set at any time.
*/
enum pEmitterShape
{
PFES_Rectangular = (1<<0),
PFES_Ellipse = (1<<1)
};
/**
\brief Flags to specify the emitter's type of operation.
Exactly one flag should be set at any time.
@see pFluidEmitter
*/
enum pEmitterType
{
PFET_ConstantPressure = (1<<0),
PFET_ConstantFlowRate = (1<<1)
};
/**
\brief Descriptor for pFluidEmitter class. Used for saving and loading the emitter state.
*/
class MODULE_API pFluidEmitterDesc
{
public:
CK_ID entityReference;
/**
\brief A pointer to the shape to which the emitter is attached to.
If this pointer is set to NULL, the emitter is attached to the world frame. The shape
must be in the same scene as the emitter.
*/
CK3dEntity* frameShape;
/**
\brief The emitter's mode of operation.
Either the simulation enforces constant pressure or constant flow rate at the emission site,
given the velocity of emitted particles.
@see NxEmitterType
*/
pEmitterType type;
/**
\brief The maximum number of particles which are emitted from this emitter.
If the total number of particles in the fluid already hit the maxParticles parameter of the fluid,
this maximal values can't be reached.
If set to 0, the number of emitted particles is unrestricted.
*/
int maxParticles;
/**
\brief The emitter's shape can either be rectangular or elliptical.
@see pEmitterShape
*/
pEmitterShape shape;
/**
\brief The sizes of the emitter in the directions of the first and the second axis of its orientation
frame (relPose).
The dimensions are actually the radii of the size.
*/
float dimensionX;
float dimensionY;
/**
\brief Random vector with values for each axis direction of the emitter orientation.
The values have to be positive and describe the maximal random particle displacement in each dimension.
The z value describes the randomization in emission direction. The emission direction
is specified by the third orientation axis of relPose.
*/
VxVector randomPos;
/**
\brief Random angle deviation from emission direction.
The emission direction is specified by the third orientation axis of relPose.
<b>Unit:</b> Radians
*/
float randomAngle;
/**
\brief The velocity magnitude of the emitted fluid particles.
*/
float fluidVelocityMagnitude;
/**
\brief The rate specifies how many particles are emitted per second.
The rate is only considered in the simulation if the type is set to PFET_ConstantFlowRate.
@see NxEmitterType
*/
float rate;
/**
\brief This specifies the time in seconds an emitted particle lives.
If set to 0, each particle will live until it collides with a drain.
*/
float particleLifetime;
/**
\brief Defines a factor for the impulse transfer from attached emitter to body.
Only has an effect if PFEF_ForceOnBody is set.
<b>Default:</b> 1.0 <br>
<b>Range:</b> [0,inf)
@see PFEF_ForceOnBody NxFluidEmitter.setRepulsionCoefficient()
*/
float repulsionCoefficient;
/**
\brief A combination of pFluidEmitterFlags.
@see pFluidEmitterFlag
*/
pFluidEmitterFlag flags;
~pFluidEmitterDesc();
/**
\brief (Re)sets the structure to the default.
*/
void setToDefault();
/**
\brief Returns true if the current settings are valid
*/
bool isValid() const;
/**
\brief Constructor sets to default.
*/
pFluidEmitterDesc();
};
/** @} */
#endif

View File

@ -0,0 +1,121 @@
#ifndef __P_FLUID_FLAGS_
#define __P_FLUID_FLAGS_
/** \addtogroup Fluid
@{
*/
/**
\brief Fluid flags
*/
enum pFluidFlag
{
/**
\brief Enables debug visualization for the NxFluid.
*/
PFF_VISUALIZATION = (1<<0),
/**
\brief Disables scene gravity for the NxFluid.
*/
PFF_DisableGravity = (1<<1),
/**
\brief Enable/disable two way collision of fluid with the rigid body scene.
In either case, fluid is influenced by colliding rigid bodies.
If PFF_CollisionTwoway is not set, rigid bodies are not influenced by
colliding pieces of fluid. Use pFluidDesc.collisionResponseCoefficient to
control the strength of the feedback force on rigid bodies.
@see NxFluidDesc.collisionResponseCoefficient
*/
PFF_CollisionTwoway = (1<<2),
/**
\brief Enable/disable execution of fluid simulation.
*/
PFF_Enabled = (1<<3),
/**
\brief Defines whether this fluid is simulated on the PPU.
*/
PFF_Hardware = (1<<4),
/**
\brief Enable/disable particle priority mode.
If enabled, the oldest particles are deleted to keep a certain budget for
new particles. Note that particles which have equal lifetime can get deleted
at the same time. In order to avoid this, the particle lifetimes
can be varied randomly.
@see pFluidDesc.numReserveParticles
*/
PFF_PriorityMode = (1<<5),
/**
\brief Defines whether the particles of this fluid should be projected to a plane.
This can be used to build 2D fluid applications, for instance. The projection
plane is defined by the parameter pFluidDesc.projectionPlane.
@see pFluidDesc.projectionPlane
*/
PFF_ProjectToPlane = (1<<6),
/**
\brief Forces fluid static mesh cooking format to parameters given by the fluid descriptor.
Currently not implemented!
*/
PFF_ForceStrictCookingFormat = (1<<7),
};
/**
\brief Describes the particle simulation method
Particles can be treated in two ways: either they are simulated considering
interparticular forces (SPH), or they are simulated independently.
In the latter case (with the simulation method set to PFS_NO_PARTICLE_INTERACTION),
you still get collision between particles and static/dynamic shapes, damping,
acceleration due to gravity, and the user force.
*/
enum pFluidSimulationMethod
{
/**
\brief Enable simulation of inter particle forces.
*/
PFS_SPH = (1<<0),
/**
\brief Do not simulate inter particle forces.
*/
PFS_NoParticleInteraction = (1<<1),
/**
\brief Alternate between SPH and simple particles
*/
PFS_MixedMode = (1<<2),
};
/**
\brief The fluid collision method
*/
enum pFluidCollisionMethod
{
/**
\brief collide with static objects
*/
PFCM_Static = (1<<0),
/**
\brief collide with dynamic objects
*/
PFCM_Dynamic = (1<<1),
};
/** @} */
#endif

View File

@ -0,0 +1,134 @@
#ifndef __P_FLUID_RENDER_SETTINGS_H__
#define __P_FLUID_RENDER_SETTINGS_H__
#include "pTypes.h"
class MODULE_API pFluidRenderSettings
{
public:
pFluidRenderSettings();
// Constructor
pFluidRenderSettings(CKContext* ctx,CK_ID entity,char* name);
// the emitter 3d entity
CK_ID m_Entity;
CK_ID m_Texture;
CK_ID m_Group;
int m_MessageType;
VxBbox m_EntityBbox;
pParticleRenderType mRenderType;
int m_MaximumParticles;
// total number of particles
int totalParticles;
// particles already emitted
int particleCount;
// emits per frame
int emitsPerFrame;
// emits variation
int emitsVar;
// medium lifeSpan
float m_Life;
// life variation
float m_LifeVariation;
// trailing particles
int m_TrailCount;
// historic of recent particles.
// render callback
int (*m_RenderParticlesCallback)(CKRenderContext *dev,CKRenderObject *mov,void *arg);
void SetState(CKRenderContext* dev,CKBOOL gouraud = FALSE);
// NULL terminated linked list
// the particles pool
BYTE* m_BackPool;
// start size
float m_StartSize;
float m_StartSizeVar;
// end size
float m_EndSize;
float m_EndSizeVar;
// Blend Modes
VXBLEND_MODE m_SrcBlend;
VXBLEND_MODE m_DestBlend;
// Colors
/////////////
VxColor m_StartColor;
VxColor m_StartColorVar;
VxColor m_EndColor;
VxColor m_EndColorVar;
// Texture
/////////////
int m_InitialTextureFrame;
int m_InitialTextureFrameVariance;
int m_SpeedTextureFrame;
int m_SpeedTextureFrameVariance;
int m_TextureFrameCount;
int m_TextureFrameloop;
// FLAGS
int m_EvolutionsFlags;
int m_VariancesFlags;
int m_InteractorsFlags;
int m_DeflectorsFlags;
int m_RenderMode;
// Mesh
CK_ID m_Mesh;
// Context
CKContext* m_Context;
pFluidEmitter* mEmitter;
pFluidEmitter* getEmitter() const { return mEmitter; }
void setEmitter(pFluidEmitter* val) { mEmitter = val; }
void setToDefault();
struct ParticleHistoric
{
inline ParticleHistoric() {}
inline ParticleHistoric(unsigned int size) :
start(0),
count(0)
{
particles.Resize(size);
}
int start;
int count;
XArray<pParticle*> particles;
};
// Old particles.
XClassArray<ParticleHistoric> old_pos;
ParticleHistoric &GetParticleHistoric(pParticle *part);
CKBehavior* m_Behavior;
volatile bool hasBeenRendered; //used for cases where we compute once and render twice
volatile bool hasBeenEnqueud; //used for cases where we compute once and render twice
protected:
private:
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,200 @@
#ifndef __PJOINTTYPES_H__
#define __PJOINTTYPES_H__
/** \addtogroup Joints
@{
*/
/**
\brief Describes a joint motor. Some joints can be motorized, this allows them to apply a force to cause attached actors to move. Joints which can be motorized: #pJointPulley #pJointRevolute is used for a similar purpose with pJointD6.
*/
class pMotor
{
public :
/**
The relative velocity the motor is trying to achieve.Default = 0.0f.
*/
float targetVelocity;
/**
The maximum force (or torque) the motor can exert.Default = 0.0f.
*/
float maximumForce;
/**
If true, motor will not brake when it spins faster than velTarget.Default = false.
*/
bool freeSpin;
pMotor()
{
targetVelocity = 0.0f;
maximumForce =0.0f;
freeSpin = false;
}
};
/**
\brief Describes a joint limit. pJointLimit is registered as custom structure #pJLimit and can be accessed or modified through parameter operations.<br>
This is used for ball joints.
\sa \ref PJBall.
*/
class pJointLimit
{
public:
/**
[not yet implemented!] Limit can be made softer by setting this to less than 1. Default = 0.0f;
*/
float hardness;
/**
The angle / position beyond which the limit is active. Default = 0.0f;
*/
float value;
/**
The limit bounce. Default = 0.0f;
*/
float restitution;
pJointLimit()
{
hardness = 0.0f;
value = 0.0f;
restitution = 0.0f;
}
pJointLimit(float _h,float _r, float _v)
{
hardness = _h;
restitution = _r;
value = _v;
}
};
/**
\brief Describes a joint soft limit for D6 usage. pJD6SoftLimit is registered as custom structure #pJD6SLimit and can be accessed or modified through parameter operations.<br>
\sa #PJD6.
*/
class pJD6SoftLimit
{
public:
/**\brief If spring is greater than zero, this is the damping of the spring.
*/
float damping;
/**\brief If greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit.
<b>Range:</b> [0,inf)<br>
<b>Default:</b> 0.0
*/
float spring;
/**\brief The angle or position beyond which the limit is active.
Which side the limit restricts depends on whether this is a high or low limit.
<b>Unit:</b> Angular: Radians
<b>Range:</b> Angular: (-PI,PI)<br>
<b>Range:</b> Positional: [0.0,inf)<br>
<b>Default:</b> 0.0
*/
float value;
/**\brief Controls the amount of bounce when the joint hits a limit.
<br>
<br>
A restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit. A value of zero causes the joint to stop dead.
In situations where the joint has many locked DOFs (e.g. 5) the restitution may not be applied correctly. This is due to a limitation in the solver which causes the restitution velocity to become zero as the solver enforces constraints on the other DOFs.
This limitation applies to both angular and linear limits, however it is generally most apparent with limited angular DOFs.
Disabling joint projection and increasing the solver iteration count may improve this behavior to some extent.
Also, combining soft joint limits with joint motors driving against those limits may affect stability.
<b>Range:</b> [0,1]<br>
<b>Default:</b> 0.0
*/
float restitution;
pJD6SoftLimit()
{
damping = 0.0f;
spring = 0.0f;
value = 0.0f;
restitution = 0.0f;
}
pJD6SoftLimit(float _damping,float _spring,float _value,float _restitution)
{
damping = _damping;
spring = _spring;
value = _value;
restitution = _restitution;
}
};
/**
\brief Class used to describe drive properties for a #pJointD6.
*/
class pJD6Drive
{
public:
/**
Damper coefficient
<b>Default:</b> 0
<b>Range:</b> [0,inf)
*/
float damping;
/**
Spring coefficient
<b>Default:</b> 0
<b>Range:</b> (-inf,inf)
*/
float spring;
/**
The maximum force (or torque) the drive can exert.
<b>Default:</b> FloatMax
<b>Range:</b> [0,inf)
*/
float forceLimit;
/**
Type of drive to apply.See #D6DriveType.
<b>Default:</b> FloatMax
<b>Range:</b> [0,inf)
*/
int driveType;
pJD6Drive()
{
damping = 0.0f;
spring = 0.0f;
forceLimit = 3.402823466e+38F;
driveType = 0;
}
pJD6Drive(float _damping,float _spring,float _forceLimit,int _driveType)
{
damping = _damping;
spring = _spring;
forceLimit = _forceLimit;
driveType = _driveType;
}
};
/** @} */
#endif // __PJOINTTYPES_H__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,615 @@
#ifndef __PRIGIDBODYTYPES_H__
#define __PRIGIDBODYTYPES_H__
#include "vtPhysXBase.h"
#include "pVTireFunction.h"
//#include "pWheelTypes.h"
/** \addtogroup RigidBody
@{
*/
struct pRigidBodyRestoreInfo
{
bool hierarchy;
bool removeJoints;
pRigidBodyRestoreInfo() : hierarchy(false) , removeJoints(false){}
};
/**
\brief Class describing a rigid bodies mass offset.
*/
class MODULE_API pMassSettings
{
public:
/**
\brief Density scale factor of the shapes belonging to the body
- <b>Range:</b> [0,inf)
- <b>Default:</b> [0)
**/
float newDensity;
/**
\brief Total mass of the actor(or zero).
- <b>Range:</b> [0,inf)
- <b>Default:</b> 0.0f
**/
float totalMass;
/**
\brief Local position offset
- <b>Range:</b> [vector)
- <b>Default:</b> (0,0,0)
**/
VxVector localPosition;
/**
\brief Local orientation offset
- <b>Range:</b> [0,inf)
- <b>Default:</b> (0,0,0)
**/
VxVector localOrientation;
/**
\brief Reference object to determine the mass local position. The members "Linear" and "Angular" are being used to transform the final matrix.
- <b>Range:</b> [object)
- <b>Default:</b> 0
**/
CK_ID massReference;
pMassSettings()
{
newDensity = totalMass = 0.0f;
massReference = 0 ;
}
};
/**
\brief Class to describe a pivot offset
*/
class MODULE_API pPivotSettings
{
public:
bool isValid();
bool setToDefault();
bool evaluate(CKBeObject*referenceObject);
/**
\brief Local position offset. The local position of can be changed by #pRigidBody::setPosition
- <b>Range:</b> [vector)
- <b>Default:</b> (0,0,0)
**/
VxVector localPosition;
/**
\brief Local orientation offset. The local orientation of can be changed by #pRigidBody::setRotation
- <b>Range:</b> [0,inf)
- <b>Default:</b> (0,0,0)
**/
VxVector localOrientation;
/**
\brief Reference object to determine the shape local matrix. The members "Linear" and "Angular" are being used to transform the final matrix.
- <b>Range:</b> [object)
- <b>Default:</b> 0
**/
CK_ID pivotReference;
pPivotSettings()
{
pivotReference=0;
}
};
//----------------------------------------------------------------
//
//! \brief Help info to specify a length by an entity reference
//
class MODULE_API pAxisReferencedLength
{
public:
bool isValid();
bool setToDefault();
bool evaluate(CKBeObject *referenceObject);
float value;
CKBeObject *reference;
int referenceAxis;
pAxisReferencedLength() :
value(0.0f) ,
reference(NULL) ,
referenceAxis(0)
{
}
};
//----------------------------------------------------------------
//
//! \brief Additional information for deformable objects
//
struct MODULE_API pDeformableSettings
{
public :
bool isValid();
bool setToDefault();
bool evaluate(CKBeObject*referenceObject);
float ImpulsThresold;
float PenetrationDepth;
float MaxDeform;
pDeformableSettings()
{
ImpulsThresold = 50.0f;
PenetrationDepth = 0.1f ;
MaxDeform= 0.1f;
}
};
//----------------------------------------------------------------
//
//! \brief Additional settings to override a default capsule
//
struct pCapsuleSettings
{
public :
int localLengthAxis;
int localRadiusAxis;
float height;
float radius;
pCapsuleSettings()
{
localRadiusAxis=0;
localLengthAxis=0;
height = 0.0f;
radius = 0.0f;
}
};
//----------------------------------------------------------------
//
//! \brief Additional settings to override a default capsule
//
struct MODULE_API pCapsuleSettingsEx
{
public :
bool isValid();
bool setToDefault();
bool evaluate(CKBeObject*referenceObject);
/**
\brief Radius specified by value or an objects local box size and an axis
**/
pAxisReferencedLength radius;
/**
\brief Height specified by value or an objects local box size and an axis
**/
pAxisReferencedLength height;
pCapsuleSettingsEx()
{
}
};
//----------------------------------------------------------------
//
//! \brief Optional override to describe a convex cylinder.
//
class MODULE_API pConvexCylinderSettings
{
public:
bool isValid();
bool setToDefault();
bool evaluate(CKBeObject*referenceObject);
/**
\brief Radius specified by value or an objects local box size and an axis
**/
pAxisReferencedLength radius;
/**
\brief Height specified by value or an objects local box size and an axis
**/
pAxisReferencedLength height;
/**
\brief Amount of cap segments
**/
int approximation;
/**
\brief Rotation part 1. If a forward axis reference has been specified, the vector gets transformed
**/
VxVector forwardAxis;
/**
\brief Reference to specify the "Dir" axis
**/
CK_ID forwardAxisRef;
/**
\brief Rotation part 2. If a down axis reference has been specified, the vector gets transformed
**/
VxVector downAxis;
/**
\brief Reference to specify the "Up" axis
**/
CK_ID downAxisRef;
/**
\brief Rotation part 3. If a right axis reference has been specified, the vector gets transformed
**/
VxVector rightAxis;
/**
\brief Reference to specify the "Right" axis
**/
CK_ID rightAxisRef;
/**
\brief Create only a half cylinder
*/
bool buildLowerHalfOnly;
/**
\brief Flags which describe the format and behavior of a convex mesh. See #pConvexFlags
*/
pConvexFlags convexFlags;
pConvexCylinderSettings() :
approximation(0),
forwardAxisRef(0),
rightAxisRef(0),
downAxisRef(0),
buildLowerHalfOnly(false)
{
setToDefault();
convexFlags=((pConvexFlags)(CF_ComputeConvex));
}
};
class MODULE_API pWheelDescr
{
public :
//################################################################
//
// Wheel Capsule Specific
//
int wheelApproximation;
pAxisReferencedLength radius;
float width;
//################################################################
//
// Wheel Common Attributes
//
float wheelSuspension;
float springRestitution;
float springDamping;
float springBias;
float maxBrakeForce;
float frictionToSide;
float frictionToFront;
WheelFlags wheelFlags;
//################################################################
//
// Wheel Shape Specific
//
WheelShapeFlags wheelShapeFlags;
float inverseWheelMass;
pConvexCylinderSettings convexCylinder;
pConvexCylinderSettings getConvexCylinderSettings() { return convexCylinder; }
void setConvexCylinderSettings(pConvexCylinderSettings val) { convexCylinder = val; }
pTireFunction latFunc;int latFuncXML_Id;
pTireFunction longFunc;int longFuncXML_Id;
pWheelDescr(){ setToDefault(); }
~pWheelDescr(){}
void* userData;
void setToDefault();
bool isValid() const;
};
//----------------------------------------------------------------
//
//! \brief Container to store joints
//
typedef XArray<pJoint*>JointListType;
class pClothDescr
{
};
/**
! \brief Describes a rigid body.
This is used by #pFactory::createBody() and #pRigidBody::addSubShape() only.
*/
class MODULE_API pObjectDescr
{
public :
int mask;
typedef enum E_OD_VERSION
{
OD_DECR_V0,
OD_DECR_V1,
};
CK_ID worlReference;
int version;
/**
\brief The shape type of the body. Default = HT_Sphere.
*/
HullType hullType;
/**
\brief The shape type of the body. Default = 1.0f.
*/
float density;
/**
\brief Translates the mass center after the body is created in local space.
*/
VxVector massOffset;
/**
\brief Translates the pivot after the body is created in local space.
*/
VxVector shapeOffset;
/**
\brief Translates the pivot after the body is created in local space.
*/
VxVector pivotOffsetLinear;
/**
\brief Translates the pivot after the body is created in local space.
*/
CK_ID pivotOffsetReference;
/**
\brief Translates the pivot after the body is created in local space.
*/
VxVector pivotOffsetAngular;
/**
\brief Describes several properties. See #BodyFlags. Default = 0.
*/
BodyFlags flags;
/**
\brief Will parse the entities hierarchy for additional sub shapes. Child objects needs to have the physic object attribute attached. Default = false.
*/
bool hirarchy;
/**
\brief If there are sub shape attached, #pRigidBodie::addSubShape will call #pRigidBody::updateMassFromShapes(). Default = 0.0f.
*/
float newDensity;
/**
\brief If there are sub shape attached, #pRigidBodie::addSubShape will call #pRigidBody::updateMassFromShapes(). Default = 0.0f.
*/
float totalMass;
int subEntID;
int transformationFlags;
int internalXmlID;
int externalXmlID;
int xmlImportFlags;
VxVector pivotAngularOffset;
/************************************************************************************************/
/** @name Collision
*/
//@{
/**
\brief Sets 128-bit mask used for collision filtering. See comments for ::pGroupsMask
*/
pGroupsMask groupsMask;
/**
\brief Adds an additional offset for collision response.
*/
float skinWidth;
/**
\brief The collision group the body belongs to. Default = 0.
*/
int collisionGroup;
//@}
/************************************************************************************************/
/** @name CCD Settings
*/
//@{
float ccdMotionThresold;
int ccdFlags;
CK_ID ccdMeshReference;
float ccdScale;
//@}
/************************************************************************************************/
/** @name Damping
*/
//@{
/**
\brief the linear damping.
*/
float linearDamping;
/**
\brief the angular damping.
*/
float angularDamping;
//@}
/************************************************************************************************/
/** @name Sleeping Settings
*/
//@{
float linearSleepVelocity;
float angularSleepVelocity;
float sleepingEnergyThresold;
//@}
/************************************************************************************************/
/** @name Optimization
*/
//@{
int solverIterations;
int dominanceGroups;
int compartmentID;
//@}
/************************************************************************************************/
/** @name Mass
*/
//@{
VxVector massOffsetLinear;
VxVector massOffsetAngular;
CK_ID massOffsetReference;
//@}
pOptimization optimization;
pOptimization& getOptimization() { return optimization; }
void setOptimization(pOptimization val) { optimization = val; }
pMaterial material;
pMaterial& getMaterial() { return material; }
void setMaterial(pMaterial val) { material = val; }
pCCDSettings ccd;
pCCDSettings& getCCD() { return ccd; }
void setCCD(pCCDSettings val) { ccd = val; }
pCapsuleSettingsEx capsule;
pCapsuleSettingsEx& getCapsule() { return capsule; }
void setCapsule(pCapsuleSettingsEx val) { capsule = val; }
pConvexCylinderSettings convexCylinder;
pConvexCylinderSettings& getConvexCylinder() { return convexCylinder; }
void setConvexCylinder(pConvexCylinderSettings val) { convexCylinder = val; }
pMassSettings mass;
pMassSettings& getMass() { return mass; }
void setMass(pMassSettings val) { mass = val; }
pPivotSettings pivot;
pPivotSettings& getPivot() { return pivot; }
void setPivot(pPivotSettings val) { pivot = val; }
pCollisionSettings collision;
pCollisionSettings& getCollision() { return collision; }
void setCollision(pCollisionSettings val) { collision = val; }
pWheelDescr wheel;
pWheelDescr& getWheel() { return wheel; }
void setWheel(pWheelDescr val) { wheel = val; }
pObjectDescr()
{
setToDefault();
}
bool isValid();
bool setToDefault();
};
//----------------------------------------------------------------
//
//! \brief Meta data to track the relation between a NxShape and an CK3dEntity.
//! Also used to track a wheel object in the NxShapes user data.
//
struct pSubMeshInfo
{
pObjectDescr initDescription;
NxCCDSkeleton *ccdSkeleton;
int meshID;
CKBeObject *mesh;
int entID;
CKBeObject *refObject;
CK_ID ccdReference;
pWheel *wheel;
pSubMeshInfo()
{
wheel = NULL;
meshID = -1;
entID = -1 ;
mesh = NULL;
refObject = NULL;
ccdSkeleton = NULL;
ccdReference = 0;
}
};
/** @} */
#endif // __PRIGIDBODYTYPES_H__

View File

@ -0,0 +1,38 @@
#ifndef __PSHAPE_H_
#define __PSHAPE_H_
#include "vtOdeEnums.h"
#include "vtOdeTypes.h"
#include "pPrereqs.h"
namespace vtAgeia
{
class pShape
{
public :
pShape()
{
}
virtual ~pShape(){}
dGeomID m_OdeGeomID;
dGeomID OdeGeomID() const { return m_OdeGeomID; }
void OdeGeomID(dGeomID val) { m_OdeGeomID = val; }
void SetOffsetPosition (VxVector position);
void setOffsetQuaternion(VxQuaternion quad);
void setOffsetWorldPosition(VxVector position);
void setOffsetWorldQuaternion(VxQuaternion orientation) ;
};
}
#endif

View File

@ -0,0 +1,37 @@
#ifndef __P_SERIALIZER_H__
#define __P_SERIALIZER_H__
#include "vtPhysXBase.h"
/** \addtogroup Serialization
@{
*/
/**
\brief Class to import and export NxStream files. Those files can be created by 3D related content editors
such as Maya and 3D-SMax. Also, you can dump the entire Virtools scene and load it in the
supplied PhysX Viewer.
*/
class MODULE_API pSerializer
{
public:
pSerializer();
~pSerializer();
static pSerializer*Instance();
NXU::NxuPhysicsCollection *getCollection(const char *pFilename,int type);
bool overrideBody(pRigidBody *body,int flags);
int loadCollection(const char*fileName,int flags);
int saveCollection(const char*filename);
void parseFile(const char*filename,int flags);
protected:
NXU::NxuPhysicsCollection *mCollection;
private:
};
/** @} */
#endif

Some files were not shown because too many files have changed in this diff Show More