CMake autodetecting boost.
Added KRDataBlock to CMakeLists
This commit is contained in:
@@ -71,6 +71,15 @@ PROPERTIES
|
||||
OUTPUT_NAME kraken
|
||||
)
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON) # only find static libs
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
find_package(Boost 1.65.1)
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(kraken ${Boost_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# add_custom_target(package
|
||||
# COMMENT "Compressing..."
|
||||
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/archive"
|
||||
|
||||
@@ -11,3 +11,6 @@ add_sources(quaternion.cpp)
|
||||
add_sources(matrix4.cpp)
|
||||
add_sources(aabb.cpp)
|
||||
add_sources(hitinfo.cpp)
|
||||
|
||||
# Private Implementation
|
||||
add_sources(KRDataBlock.cpp)
|
||||
|
||||
@@ -20,22 +20,22 @@ class KRAudioBuffer
|
||||
public:
|
||||
KRAudioBuffer(KRAudioManager *manager, KRAudioSample *sound, int index, int frameCount, int frameRate, int bytesPerFrame, void (*fn_populate)(KRAudioSample *, int, void *));
|
||||
~KRAudioBuffer();
|
||||
|
||||
|
||||
int getFrameCount();
|
||||
int getFrameRate();
|
||||
signed short *getFrameData();
|
||||
|
||||
|
||||
KRAudioSample *getAudioSample();
|
||||
int getIndex();
|
||||
private:
|
||||
KRAudioManager *m_pSoundManager;
|
||||
|
||||
|
||||
int m_index;
|
||||
int m_frameCount;
|
||||
int m_frameCount;
|
||||
int m_frameRate;
|
||||
int m_bytesPerFrame;
|
||||
KRDataBlock *m_pData;
|
||||
|
||||
|
||||
KRAudioSample *m_audioSample;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
/*
|
||||
|
||||
This class is a pure-virtual base class intended to be subclassed to define behavior of KRNode's in the scene
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class KRBehavior;
|
||||
@@ -31,16 +31,16 @@ class KRBehavior
|
||||
public:
|
||||
static void RegisterFactoryCTOR(std::string behaviorName, KRBehaviorFactoryFunction fnFactory);
|
||||
static void UnregisterFactoryCTOR(std::string behaviorName);
|
||||
|
||||
|
||||
KRBehavior();
|
||||
virtual ~KRBehavior();
|
||||
KRNode *getNode() const;
|
||||
|
||||
|
||||
virtual void init();
|
||||
virtual void update(float deltaTime) = 0;
|
||||
virtual void visibleUpdate(float deltatime) = 0;
|
||||
void __setNode(KRNode *node);
|
||||
|
||||
|
||||
static KRBehavior *LoadXML(KRNode *node, tinyxml2::XMLElement *e);
|
||||
private:
|
||||
KRNode *__node;
|
||||
|
||||
@@ -135,7 +135,7 @@ bool KRDataBlock::load(const std::string &path)
|
||||
{
|
||||
bool success = false;
|
||||
unload();
|
||||
|
||||
|
||||
struct stat statbuf;
|
||||
m_bReadOnly = true;
|
||||
|
||||
@@ -179,7 +179,7 @@ KRDataBlock *KRDataBlock::getSubBlock(int start, int length)
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if(m_hPackFile) {
|
||||
new_block->m_hPackFile = m_hPackFile;
|
||||
#elif defined(__APPLE)
|
||||
#elif defined(__APPLE__)
|
||||
if (m_fdPackFile) {
|
||||
new_block->m_fdPackFile = m_fdPackFile;
|
||||
#else
|
||||
@@ -237,10 +237,10 @@ void KRDataBlock::expand(size_t size)
|
||||
// ... Or starting with a pointer reference, we must make our own copy and must not free the pointer
|
||||
void *pNewData = malloc(m_data_size + size);
|
||||
assert(pNewData != NULL);
|
||||
|
||||
|
||||
// Copy exising data
|
||||
copy(pNewData);
|
||||
|
||||
|
||||
// Unload existing data allocation, which is now redundant
|
||||
size_t new_size = m_data_size + size; // We need to store this before unload() as unload() will reset it
|
||||
unload();
|
||||
@@ -255,7 +255,7 @@ void KRDataBlock::expand(size_t size)
|
||||
void KRDataBlock::append(void *data, size_t size) {
|
||||
// Expand the data block
|
||||
expand(size);
|
||||
|
||||
|
||||
// Fill the new space with the data to append
|
||||
lock();
|
||||
memcpy((unsigned char *)m_data + m_data_size - size, data, size);
|
||||
@@ -326,7 +326,7 @@ bool KRDataBlock::save(const std::string& path) {
|
||||
HANDLE hNewFile = INVALID_HANDLE_VALUE;
|
||||
HANDLE hFileMapping = NULL;
|
||||
void *pNewData = NULL;
|
||||
|
||||
|
||||
hNewFile = CreateFile(path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hNewFile == INVALID_HANDLE_VALUE) {
|
||||
success = false;
|
||||
@@ -364,7 +364,7 @@ bool KRDataBlock::save(const std::string& path) {
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
int fdNewFile = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
|
||||
if(fdNewFile == -1) {
|
||||
@@ -374,7 +374,7 @@ bool KRDataBlock::save(const std::string& path) {
|
||||
// Seek to end of file and write a byte to enlarge it
|
||||
lseek(fdNewFile, m_data_size-1, SEEK_SET);
|
||||
write(fdNewFile, "", 1);
|
||||
|
||||
|
||||
// Now map it...
|
||||
void *pNewData = mmap(0, m_data_size, PROT_READ | PROT_WRITE, MAP_SHARED, fdNewFile, 0);
|
||||
if(pNewData == (caddr_t) -1) {
|
||||
@@ -384,10 +384,10 @@ bool KRDataBlock::save(const std::string& path) {
|
||||
if(m_data != NULL) {
|
||||
// Copy data to new file
|
||||
copy(pNewData);
|
||||
|
||||
|
||||
// Unmap the new file
|
||||
munmap(pNewData, m_data_size);
|
||||
|
||||
|
||||
// Close the new file
|
||||
close(fdNewFile);
|
||||
}
|
||||
@@ -414,7 +414,7 @@ std::string KRDataBlock::getString()
|
||||
void KRDataBlock::lock()
|
||||
{
|
||||
if(m_lockCount == 0) {
|
||||
|
||||
|
||||
// Memory mapped file; ensure data is mapped to ram
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if(m_hFileMapping) {
|
||||
@@ -439,7 +439,7 @@ void KRDataBlock::lock()
|
||||
#elif defined(__APPLE__)
|
||||
//fprintf(stderr, "KRDataBlock::lock - \"%s\" (%i)\n", m_fileOwnerDataBlock->m_fileName.c_str(), m_lockCount);
|
||||
// Round m_data_offset down to the next memory page, as required by mmap
|
||||
|
||||
|
||||
if ((m_mmapData = mmap(0, m_data_size + alignment_offset, m_bReadOnly ? PROT_READ : PROT_WRITE, MAP_SHARED, m_fdPackFile, m_data_offset - alignment_offset)) == (caddr_t) -1) {
|
||||
int iError = errno;
|
||||
switch(iError) {
|
||||
@@ -489,10 +489,10 @@ void KRDataBlock::unlock()
|
||||
{
|
||||
// We expect that the data block was previously locked
|
||||
assertLocked();
|
||||
|
||||
|
||||
|
||||
|
||||
if(m_lockCount == 1) {
|
||||
|
||||
|
||||
// Memory mapped file; ensure data is unmapped from ram
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (m_hPackFile) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "public/kraken.h"
|
||||
#include "KRHelpers.h"
|
||||
using namespace kraken;
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
@@ -30,8 +31,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "../3rdparty/tinyxml2/tinyxml2.h"
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/mman.h>
|
||||
@@ -51,7 +53,6 @@
|
||||
#include <OpenAL/MacOSX_OALExtensions.h>
|
||||
#endif
|
||||
|
||||
#include "tinyxml2.h"
|
||||
#endif
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
||||
119
kraken/KRMesh.h
119
kraken/KRMesh.h
@@ -3,17 +3,17 @@
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. 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.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''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 KEARWOOD GILBERT OR
|
||||
@@ -23,7 +23,7 @@
|
||||
// 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.
|
||||
//
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
@@ -51,26 +51,25 @@ using namespace kraken;
|
||||
#include "KRMaterialManager.h"
|
||||
#include "KRCamera.h"
|
||||
#include "KRViewport.h"
|
||||
#include "KRHitInfo.h"
|
||||
|
||||
class KRMaterial;
|
||||
class KRNode;
|
||||
|
||||
class KRMesh : public KRResource {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
KRMesh(KRContext &context, std::string name, KRDataBlock *data);
|
||||
KRMesh(KRContext &context, std::string name);
|
||||
virtual ~KRMesh();
|
||||
|
||||
|
||||
kraken_stream_level getStreamLevel();
|
||||
void preStream(float lodCoverage);
|
||||
|
||||
|
||||
bool hasTransparency();
|
||||
|
||||
|
||||
typedef enum {
|
||||
KRENGINE_ATTRIB_VERTEX = 0,
|
||||
KRENGINE_ATTRIB_NORMAL,
|
||||
@@ -86,14 +85,14 @@ public:
|
||||
KRENGINE_ATTRIB_TEXUVB_SHORT,
|
||||
KRENGINE_NUM_ATTRIBUTES
|
||||
} vertex_attrib_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
KRENGINE_MODEL_FORMAT_TRIANGLES = 0,
|
||||
KRENGINE_MODEL_FORMAT_STRIP,
|
||||
KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES,
|
||||
KRENGINE_MODEL_FORMAT_INDEXED_STRIP
|
||||
} model_format_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
model_format_t format;
|
||||
std::vector<Vector3> vertices;
|
||||
@@ -111,29 +110,29 @@ public:
|
||||
std::vector<Matrix4> bone_bind_poses;
|
||||
std::vector<std::vector<float> > bone_weights;
|
||||
} mesh_info;
|
||||
|
||||
|
||||
void render(const std::string &object_name, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, const Matrix4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass, const std::vector<KRBone *> &bones, const Vector3 &rim_color, float rim_power, float lod_coverage = 0.0f);
|
||||
|
||||
|
||||
std::string m_lodBaseName;
|
||||
|
||||
|
||||
virtual std::string getExtension();
|
||||
virtual bool save(const std::string& path);
|
||||
virtual bool save(KRDataBlock &data);
|
||||
|
||||
|
||||
void LoadData(const mesh_info &mi, bool calculate_normals, bool calculate_tangents);
|
||||
void loadPack(KRDataBlock *data);
|
||||
|
||||
|
||||
void convertToIndexed();
|
||||
void optimize();
|
||||
void optimizeIndexes();
|
||||
|
||||
|
||||
void renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const std::string &object_name, const std::string &material_name, float lodCoverage);
|
||||
|
||||
|
||||
GLfloat getMaxDimension();
|
||||
|
||||
|
||||
Vector3 getMinPoint() const;
|
||||
Vector3 getMaxPoint() const;
|
||||
|
||||
|
||||
class Submesh {
|
||||
public:
|
||||
Submesh() {};
|
||||
@@ -148,7 +147,7 @@ public:
|
||||
delete (*itr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GLint start_vertex;
|
||||
GLsizei vertex_count;
|
||||
char szMaterialName[KRENGINE_MAX_NAME_LENGTH];
|
||||
@@ -168,7 +167,7 @@ public:
|
||||
int32_t vertex_count;
|
||||
char szName[KRENGINE_MAX_NAME_LENGTH];
|
||||
} pack_material;
|
||||
|
||||
|
||||
typedef struct {
|
||||
char szName[KRENGINE_MAX_NAME_LENGTH];
|
||||
float bind_pose[16];
|
||||
@@ -176,12 +175,12 @@ public:
|
||||
|
||||
int getLODCoverage() const;
|
||||
std::string getLODBaseName() const;
|
||||
|
||||
|
||||
|
||||
|
||||
static bool lod_sort_predicate(const KRMesh *m1, const KRMesh *m2);
|
||||
bool has_vertex_attribute(vertex_attrib_t attribute_type) const;
|
||||
static bool has_vertex_attribute(int vertex_attrib_flags, vertex_attrib_t attribute_type);
|
||||
|
||||
|
||||
int getSubmeshCount() const;
|
||||
int getVertexCount(int submesh) const;
|
||||
int getTriangleVertexIndex(int submesh, int index) const;
|
||||
@@ -192,7 +191,7 @@ public:
|
||||
Vector2 getVertexUVB(int index) const;
|
||||
int getBoneIndex(int index, int weight_index) const;
|
||||
float getBoneWeight(int index, int weight_index) const;
|
||||
|
||||
|
||||
void setVertexPosition(int index, const Vector3 &v);
|
||||
void setVertexNormal(int index, const Vector3 &v);
|
||||
void setVertexTangent(int index, const Vector3 & v);
|
||||
@@ -200,51 +199,51 @@ public:
|
||||
void setVertexUVB(int index, const Vector2 &v);
|
||||
void setBoneIndex(int index, int weight_index, int bone_index);
|
||||
void setBoneWeight(int index, int weight_index, float bone_weight);
|
||||
|
||||
|
||||
static size_t VertexSizeForAttributes(__int32_t vertex_attrib_flags);
|
||||
static size_t AttributeOffset(__int32_t vertex_attrib, __int32_t vertex_attrib_flags);
|
||||
|
||||
|
||||
int getBoneCount();
|
||||
char *getBoneName(int bone_index);
|
||||
Matrix4 getBoneBindPose(int bone_index);
|
||||
|
||||
|
||||
|
||||
model_format_t getModelFormat() const;
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, KRHitInfo &hitinfo) const;
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, KRHitInfo &hitinfo) const;
|
||||
bool sphereCast(const Matrix4 &model_to_world, const Vector3 &v0, const Vector3 &v1, float radius, KRHitInfo &hitinfo) const;
|
||||
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, HitInfo &hitinfo) const;
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, HitInfo &hitinfo) const;
|
||||
bool sphereCast(const Matrix4 &model_to_world, const Vector3 &v0, const Vector3 &v1, float radius, HitInfo &hitinfo) const;
|
||||
|
||||
static int GetLODCoverage(const std::string &name);
|
||||
|
||||
|
||||
void load(); // Load immediately into the GPU rather than passing through the streamer
|
||||
|
||||
|
||||
protected:
|
||||
bool m_constant; // TRUE if this should be always loaded and should not be passed through the streamer
|
||||
|
||||
|
||||
private:
|
||||
KRDataBlock *m_pData;
|
||||
KRDataBlock *m_pMetaData;
|
||||
KRDataBlock *m_pIndexBaseData;
|
||||
|
||||
|
||||
void getSubmeshes();
|
||||
void getMaterials();
|
||||
|
||||
static bool rayCast(const Vector3 &start, const Vector3 &dir, const Triangle3 &tri, const Vector3 &tri_n0, const Vector3 &tri_n1, const Vector3 &tri_n2, KRHitInfo &hitinfo);
|
||||
static bool sphereCast(const Matrix4 &model_to_world, const Vector3 &v0, const Vector3 &v1, float radius, const Triangle3 &tri, KRHitInfo &hitinfo);
|
||||
|
||||
|
||||
static bool rayCast(const Vector3 &start, const Vector3 &dir, const Triangle3 &tri, const Vector3 &tri_n0, const Vector3 &tri_n1, const Vector3 &tri_n2, HitInfo &hitinfo);
|
||||
static bool sphereCast(const Matrix4 &model_to_world, const Vector3 &v0, const Vector3 &v1, float radius, const Triangle3 &tri, HitInfo &hitinfo);
|
||||
|
||||
int m_lodCoverage; // This LOD level is activated when the bounding box of the model will cover less than this percent of the screen (100 = highest detail model)
|
||||
vector<KRMaterial *> m_materials;
|
||||
set<KRMaterial *> m_uniqueMaterials;
|
||||
|
||||
|
||||
bool m_hasTransparency;
|
||||
|
||||
|
||||
|
||||
|
||||
Vector3 m_minPoint, m_maxPoint;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
char szTag[16];
|
||||
int32_t model_format; // 0 == Triangle list, 1 == Triangle strips, 2 == Indexed triangle list, 3 == Indexed triangle strips, rest are reserved (model_format_t enum)
|
||||
@@ -257,16 +256,16 @@ private:
|
||||
int32_t index_base_count;
|
||||
unsigned char reserved[444]; // Pad out to 512 bytes
|
||||
} pack_header;
|
||||
|
||||
|
||||
vector<Submesh *> m_submeshes;
|
||||
int m_vertex_attribute_offset[KRENGINE_NUM_ATTRIBUTES];
|
||||
int m_vertex_size;
|
||||
void updateAttributeOffsets();
|
||||
|
||||
|
||||
void setName(const std::string name);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pack_material *getSubmesh(int mesh_index) const;
|
||||
unsigned char *getVertexData() const;
|
||||
size_t getVertexDataOffset() const;
|
||||
@@ -276,15 +275,15 @@ private:
|
||||
__uint32_t *getIndexBaseData() const;
|
||||
pack_header *getHeader() const;
|
||||
pack_bone *getBone(int index);
|
||||
|
||||
|
||||
|
||||
|
||||
void getIndexedRange(int index_group, int &start_index_offset, int &start_vertex_offset, int &index_count, int &vertex_count) const;
|
||||
|
||||
|
||||
void releaseData();
|
||||
|
||||
|
||||
void createDataBlocks(KRMeshManager::KRVBOData::vbo_type t);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "KREngine-common.h"
|
||||
#include "KROctreeNode.h"
|
||||
#include "KRHitInfo.h"
|
||||
|
||||
class KRNode;
|
||||
|
||||
@@ -19,22 +18,22 @@ class KROctree {
|
||||
public:
|
||||
KROctree();
|
||||
~KROctree();
|
||||
|
||||
|
||||
void add(KRNode *pNode);
|
||||
void remove(KRNode *pNode);
|
||||
void update(KRNode *pNode);
|
||||
|
||||
|
||||
KROctreeNode *getRootNode();
|
||||
std::set<KRNode *> &getOuterSceneNodes();
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
|
||||
private:
|
||||
KROctreeNode *m_pRootNode;
|
||||
std::set<KRNode *> m_outerSceneNodes;
|
||||
|
||||
|
||||
void shrink();
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define KROCTREENODE_H
|
||||
|
||||
#include "KREngine-common.h"
|
||||
#include "KRHitInfo.h"
|
||||
#include "public/hitinfo.h"
|
||||
|
||||
class KRNode;
|
||||
|
||||
@@ -19,45 +19,45 @@ public:
|
||||
KROctreeNode(KROctreeNode *parent, const AABB &bounds);
|
||||
KROctreeNode(KROctreeNode *parent, const AABB &bounds, int iChild, KROctreeNode *pChild);
|
||||
~KROctreeNode();
|
||||
|
||||
|
||||
KROctreeNode **getChildren();
|
||||
std::set<KRNode *> &getSceneNodes();
|
||||
|
||||
|
||||
void add(KRNode *pNode);
|
||||
void remove(KRNode *pNode);
|
||||
void update(KRNode *pNode);
|
||||
|
||||
|
||||
AABB getBounds();
|
||||
|
||||
|
||||
KROctreeNode *getParent();
|
||||
void setChildNode(int iChild, KROctreeNode *pChild);
|
||||
int getChildIndex(KRNode *pNode);
|
||||
AABB getChildBounds(int iChild);
|
||||
void trim();
|
||||
bool isEmpty() const;
|
||||
|
||||
|
||||
bool canShrinkRoot() const;
|
||||
KROctreeNode *stripChild();
|
||||
|
||||
|
||||
void beginOcclusionQuery();
|
||||
void endOcclusionQuery();
|
||||
|
||||
|
||||
|
||||
|
||||
GLuint m_occlusionQuery;
|
||||
bool m_occlusionTested;
|
||||
bool m_activeQuery;
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
AABB m_bounds;
|
||||
|
||||
|
||||
KROctreeNode *m_parent;
|
||||
KROctreeNode *m_children[8];
|
||||
|
||||
|
||||
std::set<KRNode *>m_sceneNodes;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. 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.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''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 KEARWOOD GILBERT OR
|
||||
@@ -23,7 +23,7 @@
|
||||
// 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.
|
||||
//
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
@@ -52,71 +52,71 @@ class KRScene : public KRResource {
|
||||
public:
|
||||
KRScene(KRContext &context, std::string name);
|
||||
virtual ~KRScene();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual std::string getExtension();
|
||||
virtual bool save(KRDataBlock &data);
|
||||
|
||||
|
||||
static KRScene *Load(KRContext &context, const std::string &name, KRDataBlock *data);
|
||||
|
||||
|
||||
KRNode *getRootNode();
|
||||
KRLight *getFirstLight();
|
||||
|
||||
|
||||
kraken_stream_level getStreamLevel();
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, KRHitInfo &hitinfo, unsigned int layer_mask);
|
||||
|
||||
|
||||
bool lineCast(const Vector3 &v0, const Vector3 &v1, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool rayCast(const Vector3 &v0, const Vector3 &dir, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
bool sphereCast(const Vector3 &v0, const Vector3 &v1, float radius, HitInfo &hitinfo, unsigned int layer_mask);
|
||||
|
||||
void renderFrame(GLint defaultFBO, float deltaTime, int width, int height);
|
||||
void render(KRCamera *pCamera, unordered_map<AABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame);
|
||||
|
||||
|
||||
void render(KROctreeNode *pOctreeNode, unordered_map<AABB, int> &visibleBounds, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass, std::vector<KROctreeNode *> &remainingOctrees, std::vector<KROctreeNode *> &remainingOctreesTestResults, std::vector<KROctreeNode *> &remainingOctreesTestResultsOnly, bool bOcclusionResultsPass, bool bOcclusionTestResultsOnly);
|
||||
|
||||
|
||||
void updateOctree(const KRViewport &viewport);
|
||||
void buildOctreeForTheFirstTime();
|
||||
|
||||
|
||||
void notify_sceneGraphCreate(KRNode *pNode);
|
||||
void notify_sceneGraphDelete(KRNode *pNode);
|
||||
void notify_sceneGraphModify(KRNode *pNode);
|
||||
|
||||
|
||||
void physicsUpdate(float deltaTime);
|
||||
void addDefaultLights();
|
||||
|
||||
|
||||
AABB getRootOctreeBounds();
|
||||
|
||||
|
||||
std::set<KRAmbientZone *> &getAmbientZones();
|
||||
std::set<KRReverbZone *> &getReverbZones();
|
||||
std::set<KRLocator *> &getLocators();
|
||||
std::set<KRLight *> &getLights();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
KRNode *m_pRootNode;
|
||||
KRLight *m_pFirstLight;
|
||||
|
||||
|
||||
std::set<KRNode *> m_newNodes;
|
||||
std::set<KRNode *> m_modifiedNodes;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::set<KRNode *> m_physicsNodes;
|
||||
std::set<KRAmbientZone *> m_ambientZoneNodes;
|
||||
std::set<KRReverbZone *> m_reverbZoneNodes;
|
||||
std::set<KRLocator *> m_locatorNodes;
|
||||
std::set<KRLight *> m_lights;
|
||||
|
||||
|
||||
KROctree m_nodeTree;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
template <class T> T *find()
|
||||
{
|
||||
if(m_pRootNode) return m_pRootNode->find<T>();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
template <class T> T *find(const std::string &name)
|
||||
{
|
||||
if(m_pRootNode) return m_pRootNode->find<T>(name);
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
#include "vector3.h"
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class KRNode;
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class HitInfo {
|
||||
public:
|
||||
HitInfo();
|
||||
|
||||
Reference in New Issue
Block a user