Init
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
168
physx/samples/sampleframework/framework/include/ODBlock.h
Normal file
168
physx/samples/sampleframework/framework/include/ODBlock.h
Normal file
@ -0,0 +1,168 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,180 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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);
|
||||
virtual ~SampleApplication(void);
|
||||
SampleRenderer::Renderer* getRenderer(void) { return m_renderer; }
|
||||
SampleAssetManager* getAssetManager(void) { return m_assetManager; }
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
PxF32 m_rotationSpeedScale;
|
||||
PxF32 m_moveSpeedScale;
|
||||
|
||||
bool m_rightStickRotate;
|
||||
bool m_rewriteBuffers;
|
||||
|
||||
private:
|
||||
// get rid of C4512
|
||||
void operator=(const SampleApplication&);
|
||||
};
|
||||
|
||||
} //namespace SampleFramework
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,48 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,70 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,114 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,98 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,48 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,92 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,89 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,81 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,88 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,81 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
83
physx/samples/sampleframework/framework/include/SampleTree.h
Normal file
83
physx/samples/sampleframework/framework/include/SampleTree.h
Normal file
@ -0,0 +1,83 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,95 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
163
physx/samples/sampleframework/framework/include/SampleXml.h
Normal file
163
physx/samples/sampleframework/framework/include/SampleXml.h
Normal file
@ -0,0 +1,163 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
Reference in New Issue
Block a user