Browse Source
* Cleaned up namings in OgreInitialize.cake * Added ogre-create-light * Created OgreHlms.cpp, which is copied from Ogre's Sample PbsMaterialsGameState.cpp and modified * Moved declare-extern-function so I could avoid making a header file for test file OgreHlms.cpp * Reorganized where build options are in a few filespitch-detection
9 changed files with 276 additions and 120 deletions
@ -1 +1 @@ |
|||
Subproject commit ec5c500639f1898a49a863782f9e4794e55095bd |
|||
Subproject commit 56869ad3d6d7bf315e493b897cd1687947e1aad1 |
@ -0,0 +1,36 @@ |
|||
(skip-build) |
|||
|
|||
;; Given |
|||
;; (declare-extern-function my-func (i int &return bool)) |
|||
;; Output |
|||
;; bool myFunc(int i); |
|||
;; This is useful for forward declarations of functions or declaring functions linked dynamically |
|||
(defgenerator declare-extern-function (name-token (ref symbol) signature-index (index array)) |
|||
(quick-token-at signature-token signature-index) |
|||
(var return-type-start int -1) |
|||
(var arguments (<> std::vector FunctionArgumentTokens)) |
|||
(unless (parseFunctionSignature tokens signature-index arguments return-type-start) |
|||
(return false)) |
|||
|
|||
(var end-signature-index int (FindCloseParenTokenIndex tokens signature-index)) |
|||
(unless (outputFunctionReturnType tokens output return-type-start startTokenIndex |
|||
end-signature-index |
|||
true ;; Output to source |
|||
false) ;; Output to header |
|||
(return false)) |
|||
|
|||
(addStringOutput (path output . source) (field name-token contents) |
|||
StringOutMod_ConvertFunctionName |
|||
(addr name-token)) |
|||
|
|||
(addLangTokenOutput (field output source) StringOutMod_OpenParen (addr signature-token)) |
|||
|
|||
(unless (outputFunctionArguments tokens output arguments |
|||
true ;; Output to source |
|||
false) ;; Output to header |
|||
(return false)) |
|||
|
|||
(addLangTokenOutput (field output source) StringOutMod_CloseParen (addr signature-token)) |
|||
|
|||
(addLangTokenOutput (field output source) StringOutMod_EndStatement (addr signature-token)) |
|||
(return true)) |
@ -0,0 +1,94 @@ |
|||
#include "OgreHlmsManager.h" |
|||
#include "OgreHlmsPbs.h" |
|||
#include "OgreHlmsPbsDatablock.h" |
|||
#include "OgreHlmsSamplerblock.h" |
|||
#include "OgreItem.h" |
|||
#include "OgreMesh2.h" |
|||
#include "OgreMeshManager.h" |
|||
#include "OgreMeshManager2.h" |
|||
#include "OgreRoot.h" |
|||
#include "OgreSceneManager.h" |
|||
#include "OgreTextureFilters.h" |
|||
#include "OgreTextureGpuManager.h" |
|||
|
|||
// For testing only. Copied from Ogre samples, and modified.
|
|||
|
|||
void ogreCreatePbsSpheres(Ogre::Root* root, Ogre::SceneManager* sceneManager) |
|||
{ |
|||
int numSpheres = 0; |
|||
Ogre::HlmsManager* hlmsManager = root->getHlmsManager(); |
|||
|
|||
assert(dynamic_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS))); |
|||
|
|||
Ogre::HlmsPbs* hlmsPbs = static_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS)); |
|||
|
|||
const int numX = 8; |
|||
const int numZ = 8; |
|||
|
|||
const float armsLength = 1.0f; |
|||
const float startX = (numX - 1) / 2.0f; |
|||
const float startZ = (numZ - 1) / 2.0f; |
|||
|
|||
Ogre::TextureGpuManager* textureMgr = root->getRenderSystem()->getTextureGpuManager(); |
|||
Ogre::SceneNode* rootSceneNode = sceneManager->getRootSceneNode(); |
|||
|
|||
// Convert the sphere mesh (doesn't work due to material)
|
|||
// const Ogre::String meshNameV2 = ("sphere.mesh" + Ogre::String(" Imported"));
|
|||
// {
|
|||
// Ogre::v1::MeshPtr meshV1 = Ogre::v1::MeshManager::getSingleton().load(
|
|||
// "sphere.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
|
|||
// Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC);
|
|||
// bool halfPosition = true;
|
|||
// bool halfUVs = true;
|
|||
// bool useQTangents = true;
|
|||
// Ogre::MeshPtr v2Mesh = Ogre::MeshManager::getSingleton().createByImportingV1(
|
|||
// meshNameV2, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, meshV1.get(),
|
|||
// halfPosition, halfUVs, useQTangents);
|
|||
// meshV1->unload();
|
|||
// }
|
|||
|
|||
for (int x = 0; x < numX; ++x) |
|||
{ |
|||
for (int z = 0; z < numZ; ++z) |
|||
{ |
|||
Ogre::String datablockName = "Test" + Ogre::StringConverter::toString(numSpheres++); |
|||
Ogre::HlmsPbsDatablock* datablock = static_cast<Ogre::HlmsPbsDatablock*>( |
|||
hlmsPbs->createDatablock(datablockName, datablockName, Ogre::HlmsMacroblock(), |
|||
Ogre::HlmsBlendblock(), Ogre::HlmsParamVec())); |
|||
|
|||
Ogre::TextureGpu* texture = textureMgr->createOrRetrieveTexture( |
|||
"SaintPetersBasilica.dds", Ogre::GpuPageOutStrategy::Discard, |
|||
Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB, Ogre::TextureTypes::TypeCube, |
|||
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, |
|||
Ogre::TextureFilter::TypeGenerateDefaultMipmaps); |
|||
|
|||
datablock->setTexture(Ogre::PBSM_REFLECTION, texture); |
|||
datablock->setDiffuse(Ogre::Vector3(0.0f, 1.0f, 0.0f)); |
|||
|
|||
datablock->setRoughness(std::max(0.02f, x / std::max(1.0f, (float)(numX - 1)))); |
|||
datablock->setFresnel(Ogre::Vector3(z / std::max(1.0f, (float)(numZ - 1))), false); |
|||
|
|||
// Ogre::Item* item = nullptr;
|
|||
// {
|
|||
// item = sceneManager->createItem(
|
|||
// meshNameV2, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
|
|||
// Ogre::SCENE_DYNAMIC);
|
|||
// }
|
|||
|
|||
// TODO this is a hack that relies on ogre-load-mesh being called some time before this
|
|||
// This is because "sphere.mesh" is an old-style mesh which I need a convertor for or something
|
|||
Ogre::Item* item = sceneManager->createItem( |
|||
"Suzanne.mesh Imported", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, |
|||
Ogre::SCENE_DYNAMIC); |
|||
item->setDatablock(datablock); |
|||
item->setVisibilityFlags(0x000000002); |
|||
|
|||
Ogre::SceneNode* sceneNode = ((Ogre::SceneNode*)rootSceneNode->createChild()); |
|||
if (!sceneNode) |
|||
return; |
|||
sceneNode->setPosition( |
|||
Ogre::Vector3(armsLength * x - startX, -3.0f, armsLength * z - startZ)); |
|||
sceneNode->attachObject(item); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue