Program Listing for File StaticGeometry.h#
↰ Return to documentation for file (include/Karana/Scene/StaticGeometry.h)
/*
*Copyright(c)2024-2025KaranaDynamicsPtyLtd.Allrightsreserved.
*
*NOTICETOUSER:
*
*Thissourcecodeand/ordocumentation(the"LicensedMaterials")is
*theconfidentialandproprietaryinformationofKaranaDynamicsInc.
*UseoftheseLicensedMaterialsisgovernedbythetermsandconditions
*ofaseparatesoftwarelicenseagreementbetweenKaranaDynamicsandthe
*Licensee("LicenseAgreement").Unlessexpresslypermittedunderthat
*agreement,anyreproduction,modification,distribution,ordisclosure
*oftheLicensedMaterials,inwholeorinpart,toanythirdparty
*withoutthepriorwrittenconsentofKaranaDynamicsisstrictlyprohibited.
*
*THELICENSEDMATERIALSAREPROVIDED"ASIS"WITHOUTWARRANTYOFANYKIND.
*KARANADYNAMICSDISCLAIMSALLWARRANTIES,EXPRESSORIMPLIED,INCLUDING
*BUTNOTLIMITEDTOWARRANTIESOFMERCHANTABILITY,NON-INFRINGEMENT,AND
*FITNESSFORAPARTICULARPURPOSE.
*
*INNOEVENTSHALLKARANADYNAMICSBELIABLEFORANYDAMAGESWHATSOEVER,
*INCLUDINGBUTNOTLIMITEDTOLOSSOFPROFITS,DATA,ORUSE,EVENIF
*ADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGES,WHETHERINCONTRACT,TORT,
*OROTHERWISEARISINGOUTOFORINCONNECTIONWITHTHELICENSEDMATERIALS.
*
*U.S.GovernmentEndUsers:TheLicensedMaterialsarea"commercialitem"
*asdefinedat48C.F.R.2.101,andareprovidedtotheU.S.Government
*onlyasacommercialenditemunderthetermsofthislicense.
*
*AnyuseoftheLicensedMaterialsinindividualorcommercialsoftwaremust
*include,intheuserdocumentationandinternalsourcecodecomments,
*thisNotice,Disclaimer,andU.S.GovernmentUseProvision.
*/
#pragmaonce
#include<string>
#include<variant>
#include"Karana/KCore/Base.h"
#include"Karana/KCore/SharedPointer.h"
#include"Karana/Math/AABB.h"
namespaceKarana::Scene{
classStaticMeshGeometry;
classAbstractStaticGeometry:publicKarana::Core::Base{
public:
AbstractStaticGeometry(std::string_viewname);
virtual~AbstractStaticGeometry();
virtualoperatorStaticMeshGeometry()const=0;
virtualKarana::Math::AABBaabb()const=0;
};
classBoxGeometry:publicAbstractStaticGeometry{
public:
BoxGeometry(floatwidth,floatheight,floatdepth);
BoxGeometry(constBoxGeometry&);
BoxGeometry&operator=(constBoxGeometry&)=delete;
BoxGeometry(BoxGeometry&&)=delete;
BoxGeometry&operator=(BoxGeometry&&)=delete;
operatorStaticMeshGeometry()constoverride;
Karana::Math::AABBaabb()constoverride;
constfloatwidth;
constfloatheight;
constfloatdepth;
};
classCapsuleGeometry:publicAbstractStaticGeometry{
public:
CapsuleGeometry(floatradius,floatheight);
CapsuleGeometry(constCapsuleGeometry&);
CapsuleGeometry&operator=(constCapsuleGeometry&)=delete;
CapsuleGeometry(CapsuleGeometry&&)=delete;
CapsuleGeometry&operator=(CapsuleGeometry&&)=delete;
operatorStaticMeshGeometry()constoverride;
Karana::Math::AABBaabb()constoverride;
constfloatradius;
constfloatheight;
};
classConeGeometry:publicAbstractStaticGeometry{
public:
ConeGeometry(floatradius,floatheight);
ConeGeometry(constConeGeometry&);
ConeGeometry&operator=(constConeGeometry&)=delete;
ConeGeometry(ConeGeometry&&)=delete;
ConeGeometry&operator=(ConeGeometry&&)=delete;
operatorStaticMeshGeometry()constoverride;
Karana::Math::AABBaabb()constoverride;
constfloatradius;
constfloatheight;
};
classCylinderGeometry:publicAbstractStaticGeometry{
public:
CylinderGeometry(floatradius,floatheight);
CylinderGeometry(constCylinderGeometry&);
CylinderGeometry&operator=(constCylinderGeometry&)=delete;
CylinderGeometry(CylinderGeometry&&)=delete;
CylinderGeometry&operator=(CylinderGeometry&&)=delete;
operatorStaticMeshGeometry()constoverride;
Karana::Math::AABBaabb()constoverride;
constfloatradius;
constfloatheight;
};
classRoundFrustumGeometry:publicAbstractStaticGeometry{
public:
RoundFrustumGeometry(floatbottom_radius,floattop_radius,floatheight);
RoundFrustumGeometry(constRoundFrustumGeometry&);
RoundFrustumGeometry&operator=(constRoundFrustumGeometry&)=delete;
RoundFrustumGeometry(RoundFrustumGeometry&&)=delete;
RoundFrustumGeometry&operator=(RoundFrustumGeometry&&)=delete;
operatorStaticMeshGeometry()constoverride;
Karana::Math::AABBaabb()constoverride;
constfloatbottom_radius;
constfloattop_radius;
constfloatheight;
};
classSphereGeometry:publicAbstractStaticGeometry{
public:
SphereGeometry(floatradius);
SphereGeometry(constSphereGeometry&);
SphereGeometry&operator=(constSphereGeometry&)=delete;
SphereGeometry(SphereGeometry&&)=delete;
SphereGeometry&operator=(SphereGeometry&&)=delete;
operatorStaticMeshGeometry()constoverride;
Karana::Math::AABBaabb()constoverride;
constfloatradius;
};
classStaticMeshGeometry:publicAbstractStaticGeometry{
public:
//UsingRowMajorsothattheunderlying
//buffercanbeusedas-isinclient
//libraries
usingFloat3Array=Eigen::Matrix<float,Eigen::Dynamic,3,Eigen::RowMajor>;
usingFloat2Array=Eigen::Matrix<float,Eigen::Dynamic,2,Eigen::RowMajor>;
usingInt3Array=Eigen::Matrix<int,Eigen::Dynamic,3,Eigen::RowMajor>;
StaticMeshGeometry(constFloat3Array&positions,
constInt3Array&faces,
constFloat3Array&normals,
constFloat2Array&surface_map_coords);
StaticMeshGeometry(constStaticMeshGeometry&);
StaticMeshGeometry&operator=(constStaticMeshGeometry&)=delete;
StaticMeshGeometry(StaticMeshGeometry&&)=delete;
StaticMeshGeometry&operator=(StaticMeshGeometry&&)=delete;
#pragmaGCCdiagnosticpush
#pragmaGCCdiagnosticignored"-Wclass-conversion"
//Aconversionoperatortothesametypeispointlessandgeneratesawarning.
//Westillneedanimplementationtobeconcrete,sowesuppressthewarning.
operatorStaticMeshGeometry()constoverride;
#pragmaGCCdiagnosticpop
Karana::Math::AABBaabb()constoverride;
constFloat3Arraypositions;
constInt3Arrayfaces;
constFloat3Arraynormals;
constFloat2Arraysurface_map_coords;
std::stringfilename="";
};
usingVarStaticGeometry=std::variant<Karana::Core::ks_ptr<BoxGeometry>,
Karana::Core::ks_ptr<CapsuleGeometry>,
Karana::Core::ks_ptr<ConeGeometry>,
Karana::Core::ks_ptr<CylinderGeometry>,
Karana::Core::ks_ptr<RoundFrustumGeometry>,
Karana::Core::ks_ptr<SphereGeometry>,
Karana::Core::ks_ptr<StaticMeshGeometry>,
Karana::Core::ks_ptr<AbstractStaticGeometry>>;
constVarStaticGeometry&defaultGeometry();
}//namespaceKarana::Scene