diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Samples/SampleFramework/framework/include | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'PhysX_3.4/Samples/SampleFramework/framework/include')
20 files changed, 1840 insertions, 0 deletions
diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/AgPerfMonEventDefs.h b/PhysX_3.4/Samples/SampleFramework/framework/include/AgPerfMonEventDefs.h new file mode 100644 index 00000000..d5e3bfc7 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/AgPerfMonEventDefs.h @@ -0,0 +1,103 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +// This file is used to define a list of AgPerfMon events. +// +// This file is included exclusively by AgPerfMonEventSrcAPI.h +// and by AgPerfMonEventSrcAPI.cpp, for the purpose of building +// an enumeration (enum xx) and an array of strings () +// that contain the list of events. +// +// This file should only contain event definitions, using the +// DEFINE_EVENT macro. E.g.: +// +// DEFINE_EVENT(sample_name_1) +// DEFINE_EVENT(sample_name_2) +// DEFINE_EVENT(sample_name_3) + + +// Statistics from the fluid mesh packet cooker +DEFINE_EVENT(renderFunction) +DEFINE_EVENT(SampleRendererVBwriteBuffer) +DEFINE_EVENT(SampleOnTickPreRender) +DEFINE_EVENT(SampleOnTickPostRender) +DEFINE_EVENT(SampleOnRender) +DEFINE_EVENT(SampleOnDraw) +DEFINE_EVENT(D3D9Renderer_createVertexBuffer) +DEFINE_EVENT(Renderer_render) +DEFINE_EVENT(Renderer_render_depthOnly) +DEFINE_EVENT(Renderer_render_deferred) +DEFINE_EVENT(Renderer_render_lit) +DEFINE_EVENT(Renderer_render_unlit) +DEFINE_EVENT(Renderer_renderMeshes) +DEFINE_EVENT(Renderer_renderDeferredLights) +DEFINE_EVENT(D3D9RendererMesh_renderIndices) +DEFINE_EVENT(D3D9RendererMesh_renderVertices) +DEFINE_EVENT(D3D9Renderer_createIndexBuffer) +DEFINE_EVENT(D3D9RendererMesh_renderVerticesInstanced) +DEFINE_EVENT(D3D9Renderer_createInstanceBuffer) +DEFINE_EVENT(D3D9Renderer_createTexture2D) +DEFINE_EVENT(D3D9Renderer_createTarget) +DEFINE_EVENT(D3D9Renderer_createMaterial) +DEFINE_EVENT(D3D9Renderer_createMesh) +DEFINE_EVENT(D3D9Renderer_createLight) +DEFINE_EVENT(D3D9RendererMesh_renderIndicesInstanced) +DEFINE_EVENT(OGLRenderer_createVertexBuffer) +DEFINE_EVENT(OGLRenderer_createIndexBuffer) +DEFINE_EVENT(OGLRenderer_createInstanceBuffer) +DEFINE_EVENT(OGLRenderer_createTexture2D) +DEFINE_EVENT(OGLRenderer_createTarget) +DEFINE_EVENT(OGLRenderer_createMaterial) +DEFINE_EVENT(OGLRenderer_createMesh) +DEFINE_EVENT(OGLRenderer_createLight) +DEFINE_EVENT(OGLRendererMaterial_compile_vertexProgram) +DEFINE_EVENT(OGLRendererMaterial_load_vertexProgram) +DEFINE_EVENT(OGLRendererMaterial_compile_fragmentProgram) +DEFINE_EVENT(OGLRendererMaterial_load_fragmentProgram) +DEFINE_EVENT(OGLRendererVertexBufferBind) +DEFINE_EVENT(OGLRendererSwapBuffers) +DEFINE_EVENT(writeBufferSemanticStride) +DEFINE_EVENT(writeBufferfixUV) +DEFINE_EVENT(writeBufferConvertFromApex) +DEFINE_EVENT(writeBufferGetFormatSemantic) +DEFINE_EVENT(writeBufferlockSemantic) +DEFINE_EVENT(OGLRendererVertexBufferLock) +DEFINE_EVENT(Renderer_meshRenderLast) +DEFINE_EVENT(Renderer_atEnd) +DEFINE_EVENT(renderMeshesBindMeshContext) +DEFINE_EVENT(renderMeshesFirstIf) +DEFINE_EVENT(renderMeshesSecondIf) +DEFINE_EVENT(renderMeshesThirdIf) +DEFINE_EVENT(renderMeshesForthIf) +DEFINE_EVENT(OGLRendererBindMeshContext) +DEFINE_EVENT(OGLRendererBindMeshcg) +DEFINE_EVENT(cgGLSetMatrixParameter) +DEFINE_EVENT(D3D9RenderVBlock) +DEFINE_EVENT(D3D9RenderVBunlock) +DEFINE_EVENT(D3D9RenderIBlock) +DEFINE_EVENT(D3D9RenderIBunlock) diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/FrameworkFoundation.h b/PhysX_3.4/Samples/SampleFramework/framework/include/FrameworkFoundation.h new file mode 100644 index 00000000..1a38a213 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/FrameworkFoundation.h @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef FRAMEWORK_FOUNDATION_H +#define FRAMEWORK_FOUNDATION_H + +#include <stdio.h> +#include "foundation/PxPreprocessor.h" + +namespace physx +{ + namespace shdfnd{} +} + +namespace SampleFramework +{ + + using namespace physx; + namespace Fnd = physx::shdfnd; + typedef ::FILE File; + +} // namespace Renderer + +#include <foundation/PxSimpleTypes.h> +#include <foundation/PxVec3.h> +#include <foundation/PxMat33.h> +#include <foundation/PxMat44.h> +#include <foundation/PxTransform.h> +#include <foundation/PxBounds3.h> +#include <foundation/PxErrorCallback.h> + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/ODBlock.h b/PhysX_3.4/Samples/SampleFramework/framework/include/ODBlock.h new file mode 100644 index 00000000..57191076 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/ODBlock.h @@ -0,0 +1,168 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. +#ifndef ODBLOCK_H +#define ODBLOCK_H +/*----------------------------------------------------------------------------*\ +| +| Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/* +ObjectDescription Scripts +-------------------------- +ODScript = Block +Statement = Block | Terminal +Block = indent '{' {Statement} '}' +Terminal = ident ';' + +Comments: + # = line comment + / * * / = multiline comment. The / character cannot be used in identifiers. + +idents may be enclosed in quotes, and should be unique to facilitate searching. + +In a typical application, program would look for known Blocks, and read out its user set terminal(s). +Particular users define semantics: + +SHIPFILE + { + Shipname + { + Client + { + ShipModel + { + MeshFile + { + Filename; + lodlevels; + } + Texturefile + { + Filename; + } + } + CockpitModel + { + ... + } + } + Server + { + ... + } + } + } +*/ +#include <stdio.h> +#include "FrameworkFoundation.h" +#include "SampleArray.h" + +#define OD_MAXID 30 //max identifier length +class ODBlock; +typedef SampleFramework::Array<ODBlock *> ODBlockList; + + +class ODBlock +/*-------------------------\ +| Block = indent '{' {Statement} '}' +| Terminals are simply empty blocks +| +| +\-------------------------*/ + { + class ODSyntaxError + { + public: + enum Error { ODSE_UNEX_QUOTE, ODSE_UNEX_OBRACE, ODSE_UNEX_CBRACE, ODSE_UNEX_LITERAL,ODSE_UNEX_EOF,ODSE_ENC_UNKNOWN }; + private: + Error err; + public: + ODSyntaxError(Error e) {err = e;} + const char * asString(); + }; + enum State {WAIT_IDENT,IDENT,WAIT_BLOCK,BLOCK}; + char identifier[128]; + unsigned identSize; //size of above array. + bool bTerminal; + ODBlockList subBlocks; + ODBlockList::Iterator termiter; //iterator for reading terminals + + + public: + ODBlock(); //create a new one + ~ODBlock(); + bool loadScript(SampleFramework::File* fp); + bool saveScript(SampleFramework::File* writeP, bool bQuote);//saves this block to scipt file. set bQuote == true if you want to machine parse output. + + //reading: + const char * ident(); + inline unsigned numSubBlocks() {return subBlocks.size(); }//returns number of sub blocks + bool isTerminal(); //resets to first statement returns false if its a terminal == no contained Blocks + + //writing: + void ident(const char *); //identifier of the block + void addStatement(ODBlock &); + + //queries: return true in success + ODBlock * getBlock(const char * identifier,bool bRecursiveSearch=false); //returns block with given identifier, or NULL. + + void reset(); //prepares to get first terminal or sub block of current block + + //getting terminals: + bool moreTerminals(); //returns true if more terminals are available + char * nextTerminal(); //returns a pointer to the next immediate terminal child of current block's identifier string. + + //getting terminals: + bool moreSubBlocks(); //returns true if more sub blocks (including terminals) are available + ODBlock * nextSubBlock(); //returns a pointer to the next sub block. + + // hig level macro functs, return true on success: (call for obj containing:) + bool getBlockInt(const char * ident, int* p = 0, unsigned count = 1); //reads blocks of form: ident{ 123;} + bool getBlockU32(const char * ident, physx::PxU32* p = 0, unsigned count = 1); //reads blocks of form: ident{ 123;} + + bool getBlockString(const char * ident, const char **); //of form: ident{abcdef;} + bool getBlockStrings(const char * ident, const char **, unsigned count); //of form: ident{abcdef; abcdef; ...} + + bool getBlockFloat(const char * ident, float * p = 0); //of form: ident{123.456;} + bool getBlockFloats(const char * ident, float *, unsigned count);//form: ident{12.3; 12.3; 12.3; ... }; + + bool addBlockFloats(const char * ident, float *, unsigned count); + bool addBlockInts(const char * ident, int *, unsigned count); + + //errors + static const char * lastError; + }; + + +#endif //ODBLOCK_H + diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleActor.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleActor.h new file mode 100644 index 00000000..9e909591 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleActor.h @@ -0,0 +1,54 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_ACTOR_H +#define SAMPLE_ACTOR_H + +#include "FrameworkFoundation.h" + +namespace SampleFramework +{ + + class SampleActor + { + public: + SampleActor(void) {} + virtual ~SampleActor(void) {} + + void release(void) { delete this; } + + public: + virtual void tick(float /*dtime*/, bool /*rewriteBuffers*/ = false) {} + virtual void render(bool /*rewriteBuffers*/ = false) {} + //virtual void render(const PxMat44 &eyeT) { render(); } // TODO: provide a version of render() with some info about the current scene like camera pose... + virtual int getType() { return -1; } + }; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleApplication.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleApplication.h new file mode 100644 index 00000000..2d8cd1f1 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleApplication.h @@ -0,0 +1,183 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef SAMPLE_APPLICATION_H +#define SAMPLE_APPLICATION_H + +#include <Renderer.h> +#include <RendererWindow.h> +#include <RendererDesc.h> + +#include <FrameworkFoundation.h> + +#include <SampleAssetManager.h> +#include <PsTime.h> +#include <PsString.h> +#include "foundation/PxMat44.h" +#include <SampleUserInput.h> + +namespace physx { + class PxFoundation; +} + +#define SMOOTH_CAM + +namespace SampleFramework +{ + + class SampleCommandLine; + + template <typename T> + class Transform + { + public: + Transform() : m_dirty(true) {} + + void setForwardTransform( const T& t ) + { + m_fwd = t; + m_dirty = true; + } + + void setInverseTransform( const T& t ) + { + m_inv = t; + m_fwd = t.inverseRT(); + m_dirty = false; + } + + const T& getForwardTransform() const + { + return m_fwd; + } + + const T& getInverseTransform() const + { + if(m_dirty) + { + m_inv = m_fwd.inverseRT(); + m_dirty = false; + } + return m_inv; + } + + private: + T m_fwd; + mutable T m_inv; + mutable bool m_dirty; + }; + + class SampleApplication : public SampleRenderer::RendererWindow + { + public: + SampleApplication(const SampleCommandLine& cmdline, const char* assetPathPrefix="media", PxI32 camMoveButton = -1); + virtual ~SampleApplication(void); + SampleRenderer::Renderer* getRenderer(void) { return m_renderer; } + SampleAssetManager* getAssetManager(void) { return m_assetManager; } + inline const char* getAssetPathPrefix(void) const { return m_assetPathPrefix; } + + const PxMat44& getEyeTransform(void) const { return m_worldToView.getInverseTransform(); } + void setEyeTransform(const PxMat44& eyeTransform); + void setEyeTransform(const PxVec3& pos, const PxVec3& rot); + void setViewTransform(const PxMat44& viewTransform); + const PxMat44& getViewTransform(void) const; + + const SampleCommandLine& getCommandLine(void) const { return m_cmdline; } + + virtual void onInit(void) = 0; + virtual void onShutdown(void) = 0; + + virtual float tweakElapsedTime(float dtime) { return dtime; } + virtual void onTickPreRender(float dtime) = 0; + virtual void onRender(void) = 0; + virtual void onTickPostRender(float dtime) = 0; + + virtual void onOpen(void); + virtual bool onClose(void); + + virtual void onDraw(void); + + virtual void onAnalogInputEvent(const InputEvent& , float val); + virtual void onDigitalInputEvent(const InputEvent& , bool val); + virtual void onPointerInputEvent(const InputEvent&, physx::PxU32 x, physx::PxU32 y, physx::PxReal dx, physx::PxReal dy, bool val); + + virtual void rotateCamera(PxF32 dx, PxF32 dy); + virtual void moveCamera(PxF32 dx, PxF32 dy); + + virtual void doInput(void); + virtual void fatalError(const char * msg); + + virtual PxF32 getRotationSpeedScale(void) const { return m_rotationSpeedScale; } + virtual void setRotationSpeedScale(PxF32 scale) { m_rotationSpeedScale = scale; } + virtual PxF32 getMoveSpeedScale(void) const { return m_moveSpeedScale; } + virtual void setMoveSpeedScale(PxF32 scale) { m_moveSpeedScale = scale; } + + virtual bool getRightStickRotate(void) const { return m_rightStickRotate; } + virtual void setRightStickRotate(bool rsr) { m_rightStickRotate = rsr; } + + protected: + + virtual void setupRendererDescription(SampleRenderer::RendererDesc& renDesc); + + const SampleCommandLine& m_cmdline; + + PxF32 m_sceneSize; + + SampleRenderer::Renderer* m_renderer; + + char m_assetPathPrefix[256]; + SampleAssetManager* m_assetManager; + + PxVec3 m_eyeRot; + Transform<PxMat44> m_worldToView; + + PxI32 m_camMoveButton; + +#if defined(SMOOTH_CAM) + PxVec3 m_targetEyeRot; + PxVec3 m_targetEyePos; +#endif + physx::PxU64 m_timeCounter; + physx::shdfnd::Time m_time; + PxF32 m_lastDTime; + bool m_disableRendering; + + void* android_window_ptr; + PxF32 m_rotationSpeedScale; + PxF32 m_moveSpeedScale; + + bool m_rightStickRotate; + bool m_rewriteBuffers; + + private: + // get rid of C4512 + void operator=(const SampleApplication&); + }; + +} //namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleArray.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleArray.h new file mode 100644 index 00000000..e1c7a103 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleArray.h @@ -0,0 +1,48 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef SAMPLEFRAMEWORK_ARRAY +#define SAMPLEFRAMEWORK_ARRAY + +#include "PsArray.h" +#include "PsInlineArray.h" +#include "PsHashMap.h" +#include "PsAllocator.h" + +namespace SampleFramework +{ + template<typename T> + class Array : public physx::shdfnd::Array<T, physx::shdfnd::RawAllocator> + { + public: + PX_INLINE explicit Array() : physx::shdfnd::Array<T, physx::shdfnd::RawAllocator>() {} + PX_INLINE explicit Array(physx::PxU32 size, const T& a = T()) : physx::shdfnd::Array<T, physx::shdfnd::RawAllocator>(size, a) {} + }; +} + + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleAsset.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleAsset.h new file mode 100644 index 00000000..597831a1 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleAsset.h @@ -0,0 +1,70 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef SAMPLE_ASSET_H +#define SAMPLE_ASSET_H + +#include "FrameworkFoundation.h" + +namespace SampleFramework +{ + + class SampleAsset + { + friend class SampleAssetManager; + public: + enum Type + { + ASSET_MATERIAL = 0, + ASSET_TEXTURE, + ASSET_INPUT, + + NUM_TYPES + }_Type; + + virtual bool isOk(void) const = 0; + + Type getType(void) const { return m_type; } + const char *getPath(void) const { return m_path; } + + protected: + SampleAsset(Type type, const char *path); + virtual ~SampleAsset(void); + + virtual void release(void) { delete this; } + + private: + SampleAsset &operator=(const SampleAsset&) { return *this; } + + const Type m_type; + char *m_path; + PxU32 m_numUsers; + }; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleAssetManager.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleAssetManager.h new file mode 100644 index 00000000..167ad9b6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleAssetManager.h @@ -0,0 +1,114 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_ASSET_MANAGER_H +#define SAMPLE_ASSET_MANAGER_H + +#include <stdio.h> +#include <vector> + +#include <SampleAsset.h> +#include <SampleTextureAsset.h> + +#include <RendererConfig.h> + + + +namespace SampleRenderer +{ + class Renderer; +} + +namespace SampleFramework +{ + class SampleAsset; + + class SampleAssetManager + { + public: + + class SampleAssetCreator { + public: + virtual ~SampleAssetCreator() {} + virtual SampleAsset* create(const char*, SampleAsset::Type) = 0; + }; + + public: + SampleAssetManager(SampleRenderer::Renderer &renderer, + SampleAssetCreator* fallbackAssetCreator = NULL); + ~SampleAssetManager(); + + SampleRenderer::Renderer& getRenderer() { return m_renderer; } + + SampleAsset* getAsset(const char* path, SampleAsset::Type type); + void returnAsset(SampleAsset& asset); + + protected: + SampleAsset* findAsset(const char* path); + SampleAsset* loadAsset(const char* path, SampleAsset::Type type); + void releaseAsset(SampleAsset& asset); + + void addAssetUser(SampleAsset& asset); + void addAsset(SampleAsset* asset); + void deleteAsset(SampleAsset* asset); + + SampleAsset* loadXMLAsset(File& file, const char* path); + SampleAsset* loadTextureAsset(File& file, const char* path, SampleTextureAsset::Type texType); + SampleAsset* loadODSAsset(File& file, const char* path); + + private: + SampleAssetManager& operator=(const SampleAssetManager&) { return *this; } + + protected: + SampleRenderer::Renderer& m_renderer; + SampleAssetCreator* m_fallbackAssetCreator; + std::vector<SampleAsset*> m_assets; + }; + + void addSearchPath(const char* path); + void clearSearchPaths(); + File* findFile(const char* path, bool binary = true); + const char* findPath(const char* path); + + /** + Search for the speficied path in the current directory. If not found, move up in the folder hierarchy + until the path can be found or until the specified maximum number of steps is reached. + + \note On consoles no recursive search will be done + + \param [in] path The path to look for + \param [out] buffer Buffer to store the (potentially) adjusted path + \param [in] bufferSize Size of buffer + \param [in] maxRecursion Maximum number steps to move up in the folder hierarchy + return true if path was found + */ + bool searchForPath(const char* path, char* buffer, int bufferSize, bool isReadOnly, int maxRecursion); + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleCommandLine.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleCommandLine.h new file mode 100644 index 00000000..3f65bace --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleCommandLine.h @@ -0,0 +1,98 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef SAMPLE_COMMANDLINE_H +#define SAMPLE_COMMANDLINE_H + +#include <assert.h> + +namespace SampleFramework +{ + + // Container for command-line arguments. + // This class assumes argument 0 is always the executable path! + class SampleCommandLine + { + public: + //! commandLineFilePathFallback is an optional fall-back to a configuration file containing command line arguments. + // Its contents are only processed and used if the other constructor arguments yield only an executable path. + // This is especially useful in the case of an Andriod platform, which does not support command line options. + // e.g. commandLineFilePathFallback = "commandline.txt" + // e.g. contents of commandline.txt = --argument1 --argument2 + + SampleCommandLine(unsigned int argc, const char *const* argv, const char * commandLineFilePathFallback = 0); + SampleCommandLine(const char *args, const char * commandLineFilePathFallback = 0); + ~SampleCommandLine(void); + + //! has a given command-line switch? + // e.g. s=="foo" checks for -foo + bool hasSwitch(const char *s, const unsigned int argNum = invalidArgNum) const; + + //! gets the value of a switch... + // e.g. s="foo" returns "bar" if '-foo=bar' is in the commandline. + const char* getValue(const char *s, unsigned int argNum = invalidArgNum) const; + + // return how many command line arguments there are + unsigned int getNumArgs(void) const; + + // what is the program name + const char* getProgramName(void) const; + + // get the string that contains the unsued args + unsigned int unusedArgsBufSize(void) const; + + // get the string that contains the unsued args + const char* getUnusedArgs(char *buf, unsigned int bufSize) const; + + //! if the first argument is the given command. + bool isCommand(const char *s) const; + + //! get the first argument assuming it isn't a switch. + // e.g. for the command-line "myapp.exe editor -foo" it will return "editor". + const char *getCommand(void) const; + + //! get the raw command-line argument list... + unsigned int getArgC(void) const { return m_argc; } + const char *const*getArgV(void) const { return m_argv; } + + //! whether or not an argument has been read already + bool isUsed(unsigned int argNum) const; + + private: + SampleCommandLine(const SampleCommandLine&); + SampleCommandLine(void); + SampleCommandLine operator=(const SampleCommandLine&); + void initCommon(const char * commandLineFilePathFallback); + unsigned int m_argc; + const char *const *m_argv; + void *m_freeme; + static const unsigned int invalidArgNum = 0xFFFFFFFFU; + bool* m_argUsed; + }; + +} // namespace SampleFramework + +#endif // SAMPLE_COMMANDLINE_H diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleDirManager.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleDirManager.h new file mode 100644 index 00000000..c1ad3804 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleDirManager.h @@ -0,0 +1,48 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef SAMPLE_DIR_MANAGER_H +#define SAMPLE_DIR_MANAGER_H + +namespace SampleFramework +{ + class SampleDirManager + { + public: + SampleDirManager(const char* relativePathRoot, bool isReadOnly = true, int maxRecursion = 20); + + public: + const char* getPathRoot() const { return mPathRoot; } + const char* getFilePath(const char* relativeFilePath, char* pathBuffer, bool testFileValidity = true); + + private: + char mPathRoot[256]; + bool mIsReadOnly; + }; +} + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleFilesystem.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleFilesystem.h new file mode 100644 index 00000000..85d8d788 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleFilesystem.h @@ -0,0 +1,59 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_FILESYSTEM_H +#define SAMPLE_FILESYSTEM_H + +#include "FrameworkFoundation.h" + +#error "Is this file ever used?" + +namespace SampleFramework +{ + + /*class SampleStream : public PxFileBuf + { + + }; + + class SampleFilesystem + { + public: + SampleFilesystem(const char *pathPrefix = "../../../../../externals/"); + ~SampleFilesystem(void); + + SampleStream *openStream(const char *path); + void closeStream(SampleStream &stream); + + private: + char *m_pathPrefix; + }; + */ +} + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleFrameworkInputEventIds.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleFrameworkInputEventIds.h new file mode 100644 index 00000000..b087f991 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleFrameworkInputEventIds.h @@ -0,0 +1,92 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef SAMPLE_FRAMEWORK_INPUT_EVENT_IDS_H +#define SAMPLE_FRAMEWORK_INPUT_EVENT_IDS_H + +static const float GAMEPAD_ROTATE_SENSITIVITY = 0.7f; +static const float GAMEPAD_DEFAULT_SENSITIVITY = 1.0f; + +// InputEvents used by SampleApplication +enum SampleFrameworkInputEventIds +{ + CAMERA_SHIFT_SPEED = 0, + CAMERA_MOVE_LEFT, + CAMERA_MOVE_RIGHT, + CAMERA_MOVE_UP, + CAMERA_MOVE_DOWN, + CAMERA_MOVE_FORWARD, + CAMERA_MOVE_BACKWARD, + CAMERA_SPEED_INCREASE, + CAMERA_SPEED_DECREASE, + + CAMERA_MOUSE_LOOK, + CAMERA_MOVE_BUTTON, + + CAMERA_GAMEPAD_ROTATE_LEFT_RIGHT, + CAMERA_GAMEPAD_ROTATE_UP_DOWN, + CAMERA_GAMEPAD_MOVE_LEFT_RIGHT, + CAMERA_GAMEPAD_MOVE_FORWARD_BACK, + + CAMERA_JUMP, + CAMERA_CROUCH, + CAMERA_CONTROLLER_INCREASE, + CAMERA_CONTROLLER_DECREASE, + + NUM_SAMPLE_FRAMEWORK_INPUT_EVENT_IDS, +}; + +// InputEvent descriptions used by SampleApplication +const char* const SampleFrameworkInputEventDescriptions[] = +{ + "change the camera speed", + "move the camera left", + "move the camera right", + "move the camera up", + "move the camera down", + "move the camera forward", + "move the camera backward", + "increase the camera move speed", + "decrease the camera move speed", + + "look around with the camera", + "enable looking around with the camera", + + "look left and right with the camera", + "look up and down look with the camera", + "move the camera left and right", + "move the camera forward and backward", + + "jump", + "crouch", + "next controller", + "previous controller", +}; + +PX_COMPILE_TIME_ASSERT(PX_ARRAY_SIZE(SampleFrameworkInputEventDescriptions) == NUM_SAMPLE_FRAMEWORK_INPUT_EVENT_IDS); + +#endif + diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleInputAsset.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleInputAsset.h new file mode 100644 index 00000000..cf43aa0e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleInputAsset.h @@ -0,0 +1,67 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_INPUT_ASSET_H +#define SAMPLE_INPUT_ASSET_H + + +#include <SampleAssetManager.h> +#include <SampleAsset.h> +#include <SampleUserInput.h> +#include <ODBlock.h> + +namespace SampleFramework +{ + + class SampleInputAsset : public SampleAsset + { + friend class SampleAssetManager; + protected: + SampleInputAsset(File* file, const char *path); + virtual ~SampleInputAsset(void); + + public: + virtual bool isOk(void) const; + + const T_SampleInputData& GetSampleInputData() const { return m_SampleInputData; } + + private: + void LoadData(ODBlock* odsSettings); + + private: + T_SampleInputData m_SampleInputData; + ODBlock* m_SettingsBlock; + ODBlock m_Mapping; + File* m_File; + }; + +} // namespace SampleFramework + + + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleLineDebugRender.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleLineDebugRender.h new file mode 100644 index 00000000..e69f2fa1 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleLineDebugRender.h @@ -0,0 +1,89 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_LINE_DEBUG_RENDER_H +#define SAMPLE_LINE_DEBUG_RENDER_H + +#include <RendererMeshContext.h> + +#include <FrameworkFoundation.h> + +namespace SampleRenderer +{ + class Renderer; + class RendererColor; + class RendererVertexBuffer; +} + +namespace SampleFramework +{ + + class SampleAssetManager; + class SampleMaterialAsset; + + class SampleLineDebugRender + { + public: + void addLine(const PxVec3 &p0, const PxVec3 &p1, const SampleRenderer::RendererColor &color); + void checkResizeLine(PxU32 maxVerts); + void queueForRenderLine(void); + void clearLine(void); + protected: + SampleLineDebugRender(SampleRenderer::Renderer &renderer, SampleAssetManager &assetmanager); + virtual ~SampleLineDebugRender(void); + + private: + void checkLock(void); + void checkUnlock(void); + void addVert(const PxVec3 &p, const SampleRenderer::RendererColor &color); + + private: + SampleLineDebugRender &operator=(const SampleLineDebugRender&) { return *this; } + + private: + SampleRenderer::Renderer &m_renderer; + SampleAssetManager &m_assetmanager; + + SampleMaterialAsset *m_material; + + PxU32 m_maxVerts; + PxU32 m_numVerts; + SampleRenderer::RendererVertexBuffer *m_vertexbuffer; + SampleRenderer::RendererMesh *m_mesh; + SampleRenderer::RendererMeshContext m_meshContext; + + void *m_lockedPositions; + PxU32 m_positionStride; + + void *m_lockedColors; + PxU32 m_colorStride; + }; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleMaterialAsset.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleMaterialAsset.h new file mode 100644 index 00000000..bcce930d --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleMaterialAsset.h @@ -0,0 +1,81 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_MATERIAL_ASSET_H +#define SAMPLE_MATERIAL_ASSET_H + +#include <SampleAsset.h> +#include <vector> + +namespace FAST_XML +{ + class xml_node; +} + +namespace SampleRenderer +{ + class RendererMaterial; + class RendererMaterialInstance; +} + +namespace SampleFramework +{ + class SampleAssetManager; + + class SampleMaterialAsset : public SampleAsset + { + friend class SampleAssetManager; + protected: + SampleMaterialAsset(SampleAssetManager &assetManager, FAST_XML::xml_node &xmlroot, const char *path); + SampleMaterialAsset(SampleAssetManager &assetManager, Type type, const char *path); + virtual ~SampleMaterialAsset(void); + + public: + size_t getNumVertexShaders() const; + SampleRenderer::RendererMaterial *getMaterial(size_t vertexShaderIndex = 0); + SampleRenderer::RendererMaterialInstance *getMaterialInstance(size_t vertexShaderIndex = 0); + unsigned int getMaxBones(size_t vertexShaderIndex) const; + + public: + virtual bool isOk(void) const; + + protected: + SampleAssetManager &m_assetManager; + struct MaterialStruct + { + SampleRenderer::RendererMaterial *m_material; + SampleRenderer::RendererMaterialInstance *m_materialInstance; + unsigned int m_maxBones; + }; + std::vector<MaterialStruct> m_vertexShaders; + std::vector<SampleAsset*> m_assets; + }; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SamplePointDebugRender.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SamplePointDebugRender.h new file mode 100644 index 00000000..46cba14a --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SamplePointDebugRender.h @@ -0,0 +1,88 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_POINT_DEBUG_RENDER_H +#define SAMPLE_POINT_DEBUG_RENDER_H + +#include <RendererMeshContext.h> +#include <FrameworkFoundation.h> + +namespace SampleRenderer +{ + class Renderer; + class RendererColor; + class RendererVertexBuffer; +} + +namespace SampleFramework +{ + class SampleAssetManager; + class SampleMaterialAsset; + + class SamplePointDebugRender + { + public: + void addPoint(const PxVec3 &p0, const SampleRenderer::RendererColor &color); + + void queueForRenderPoint(void); + + protected: + SamplePointDebugRender(SampleRenderer::Renderer &renderer, SampleAssetManager &assetmanager); + virtual ~SamplePointDebugRender(void); + + void checkResizePoint(PxU32 maxVerts); + void clearPoint(void); + + private: + void checkLock(void); + void checkUnlock(void); + void addVert(const PxVec3 &p, const SampleRenderer::RendererColor &color); + + SamplePointDebugRender &operator=(const SamplePointDebugRender&) { return *this; } + + SampleRenderer::Renderer &m_renderer; + SampleAssetManager &m_assetmanager; + + SampleMaterialAsset *m_material; + + PxU32 m_maxVerts; + PxU32 m_numVerts; + SampleRenderer::RendererVertexBuffer *m_vertexbuffer; + SampleRenderer::RendererMesh *m_mesh; + SampleRenderer::RendererMeshContext m_meshContext; + + void *m_lockedPositions; + PxU32 m_positionStride; + + void *m_lockedColors; + PxU32 m_colorStride; + }; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTextureAsset.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTextureAsset.h new file mode 100644 index 00000000..78efeb62 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTextureAsset.h @@ -0,0 +1,81 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_TEXTURE_ASSET_H +#define SAMPLE_TEXTURE_ASSET_H + +#include <stdio.h> + +#include <SampleAsset.h> + +namespace SampleRenderer +{ + class Renderer; + class RendererTexture; +} + +namespace SampleFramework +{ + + class SampleTextureAsset : public SampleAsset + { + friend class SampleAssetManager; + + public: + enum Type + { + DDS, + TGA, + BMP, + PVR, + TEXTURE_FILE_TYPE_COUNT, + }; + + public: + SampleTextureAsset(SampleRenderer::Renderer &renderer, File &file, const char *path, Type texType); + virtual ~SampleTextureAsset(void); + + public: + SampleRenderer::RendererTexture *getTexture(void); + const SampleRenderer::RendererTexture *getTexture(void) const; + + public: + virtual bool isOk(void) const; + + private: + void loadDDS(SampleRenderer::Renderer &renderer, File &file); + void loadTGA(SampleRenderer::Renderer &renderer, File &file); + void loadPVR(SampleRenderer::Renderer &renderer, File &file); + void loadBMP(SampleRenderer::Renderer &renderer, File &file); + + SampleRenderer::RendererTexture *m_texture; + }; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTree.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTree.h new file mode 100644 index 00000000..0e6aca5a --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTree.h @@ -0,0 +1,83 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef SAMPLE_TREE_H +#define SAMPLE_TREE_H + +#include "foundation/Px.h" + +namespace SampleFramework +{ + +class Tree +{ +public: + class Node + { + public: + Node() : mParent(NULL), mHead(NULL), mTail(NULL), mPrev(NULL), mNext(NULL) + { + } + + private: + Node(const Node& node); + Node& operator=(const Node& node); + + public: + PX_FORCE_INLINE bool isRoot() const { return NULL == mParent; } + PX_FORCE_INLINE bool isLeaf() const { return NULL == mHead; } + + PX_FORCE_INLINE Node* getParent() const { return mParent; } + PX_FORCE_INLINE Node* getFirstChild() const { return mHead; } + PX_FORCE_INLINE Node* getLastChild() const { return mTail; } + PX_FORCE_INLINE Node* getPrevSibling() const { return mPrev; } + PX_FORCE_INLINE Node* getNextSibling() const { return mNext; } + + PX_FORCE_INLINE Node* getFirstLeaf() const { return NULL == mHead ? const_cast<Node*>(this) : mHead->getFirstLeaf(); } + PX_FORCE_INLINE Node* getLastLeaf() const { return NULL == mTail ? const_cast<Node*>(this) : mTail->getLastLeaf(); } + + bool isOffspringOf(const Node& node) const + { + return (this == &node) || (NULL != mParent && mParent->isOffspringOf(node)); + } + + public: + bool appendChild(Node& node); + bool removeChild(Node& node); + + private: + Node* mParent; + Node* mHead; + Node* mTail; + Node* mPrev; + Node* mNext; + }; +}; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTriangleDebugRender.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTriangleDebugRender.h new file mode 100644 index 00000000..e65710dd --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleTriangleDebugRender.h @@ -0,0 +1,95 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef SAMPLE_TRIANGLE_DEBUG_RENDER_H +#define SAMPLE_TRIANGLE_DEBUG_RENDER_H + +#include <RendererMeshContext.h> +#include <FrameworkFoundation.h> + +namespace SampleRenderer +{ + class Renderer; + class RendererColor; + class RendererVertexBuffer; +} + +namespace SampleFramework +{ + + class SampleAssetManager; + class SampleMaterialAsset; + + class SampleTriangleDebugRender + { + public: + void addTriangle(const PxVec3 &p0, const PxVec3 &p1, const PxVec3 &p2, const SampleRenderer::RendererColor &color); + void addTriangle(const PxVec3 &p0, const PxVec3 &p1, const PxVec3 &p2, const PxVec3& n0, const PxVec3& n1, const PxVec3& n2, const SampleRenderer::RendererColor &color); + + void queueForRenderTriangle(void); + + protected: + SampleTriangleDebugRender(SampleRenderer::Renderer &renderer, SampleAssetManager &assetmanager); + virtual ~SampleTriangleDebugRender(void); + + void checkResizeTriangle(PxU32 maxVerts); + void clearTriangle(void); + + private: + void checkLock(void); + void checkUnlock(void); + void addVert(const PxVec3 &p, const PxVec3 &n, const SampleRenderer::RendererColor &color); + + private: + SampleTriangleDebugRender &operator=(const SampleTriangleDebugRender&) { return *this; } + + private: + SampleRenderer::Renderer &m_renderer; + SampleAssetManager &m_assetmanager; + + SampleMaterialAsset *m_material; + + PxU32 m_maxVerts; + PxU32 m_numVerts; + SampleRenderer::RendererVertexBuffer *m_vertexbuffer; + SampleRenderer::RendererMesh *m_mesh; + SampleRenderer::RendererMeshContext m_meshContext; + + void *m_lockedPositions; + PxU32 m_positionStride; + + void *m_lockedNormals; + PxU32 m_normalStride; + + void *m_lockedColors; + PxU32 m_colorStride; + }; + +} // namespace SampleFramework + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/framework/include/SampleXml.h b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleXml.h new file mode 100644 index 00000000..f9cdecb8 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/framework/include/SampleXml.h @@ -0,0 +1,163 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef SAMPLE_XML_H +#define SAMPLE_XML_H + +#include "PsFastXml.h" +#include "PsString.h" +#include "SampleTree.h" + +namespace FAST_XML +{ + +class xml_node : private SampleFramework::Tree::Node +{ +public: + xml_node(const char* name, const char* data, const physx::shdfnd::FastXml::AttributePairs& attr) + : mName(name), mData(data) + { + PX_ASSERT( (attr.getNbAttr()*2+1) < MAX_ARGS); + for(physx::PxI32 i=0; i<attr.getNbAttr(); i++) + { + mArgv[i*2] = attr.getKey(i); + mArgv[i*2+1] = attr.getValue(i); + } + physx::shdfnd::FastXml::AttributePairs tmp(attr.getNbAttr()*2, mArgv); + mAttr = tmp; + } + + ~xml_node() + { + xml_node* node = first_node(); + while (node != NULL) + { + xml_node* child = node; + node = node->next_sibling(); + delete child; + } + } + +public: + xml_node* parent() const { return static_cast<xml_node*>(getParent()); } + xml_node* first_node() const { return static_cast<xml_node*>(getFirstChild()); } + xml_node* next_sibling() const { return static_cast<xml_node*>(getNextSibling()); } + bool append_node(xml_node& node) { return appendChild(node); } + + xml_node* first_node(const char* name) const + { + for (xml_node* node = first_node(); node != NULL; node = node->next_sibling()) + { + if (0 == strcmp(node->name(), name)) + { + return node; + } + } + + return NULL; + } + +public: + const char* name() const { return mName; } + const char* value() const { return mData; } + const char *getXMLAttribute(const char *attr) const + { + return mAttr.get(attr); + } + +private: + static const physx::PxI32 MAX_ARGS = 50; + + const char* mName; + const char* mData; + const char* mArgv[MAX_ARGS]; + physx::shdfnd::FastXml::AttributePairs mAttr; +}; + +class XmlBuilder : public physx::shdfnd::FastXml::Callback +{ +public: + XmlBuilder() : mRoot(NULL), mThis(NULL) {} + virtual ~XmlBuilder() + { + delete mRoot; + } + +public: + xml_node* rootnode() const { return mRoot; } + + virtual bool processComment(const char *comment) + { + return true; + } + + virtual bool processClose(const char *element, physx::PxU32 depth, bool &isError) + { + mThis = mThis->parent(); + return true; + } + + virtual bool processElement( + const char *elementName, // name of the element + const char *elementData, // element data, null if none + const physx::shdfnd::FastXml::AttributePairs& attr, // attributes + physx::PxI32 lineno) + { + xml_node* node = new xml_node(elementName, elementData, attr); + + if (NULL != mThis) + mThis->append_node(*node); + else if (NULL == mRoot) + mRoot = node; + else + { + physx::shdfnd::printFormatted("error: more than 1 root node in xml file\n"); + return false; + } + + mThis = node; + return true; + } + + virtual void* allocate(physx::PxU32 size) + { + return malloc(size); + } + + virtual void deallocate(void *mem) + { + free(mem); + } + +private: + xml_node* mRoot; + xml_node* mThis; +}; + +} + +#endif |