Integrating audio engine

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40208
This commit is contained in:
kearwood
2013-01-04 23:03:40 +00:00
parent b10ee3923b
commit b27b7e10da
4 changed files with 228 additions and 5 deletions

View File

@@ -129,6 +129,10 @@
E488399F15F92BE000BD66D5 /* KRBundleManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E488399B15F92BE000BD66D5 /* KRBundleManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
E48B3CBD14393DF5000C50E2 /* KRCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B3CBC14393DF5000C50E2 /* KRCamera.h */; };
E48B3CC014393E30000C50E2 /* KRCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */; };
E48B68151697794F00D99917 /* KRAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48B68131697794F00D99917 /* KRAudioSource.cpp */; };
E48B68161697794F00D99917 /* KRAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48B68131697794F00D99917 /* KRAudioSource.cpp */; };
E48B68171697794F00D99917 /* KRAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B68141697794F00D99917 /* KRAudioSource.h */; };
E48B68181697794F00D99917 /* KRAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B68141697794F00D99917 /* KRAudioSource.h */; };
E48C696F15374F5B00232E28 /* KRContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E48C696E15374F5A00232E28 /* KRContext.h */; };
E48C697015374F5B00232E28 /* KRContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E48C696E15374F5A00232E28 /* KRContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
E48C697215374F7E00232E28 /* KRContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48C697115374F7E00232E28 /* KRContext.cpp */; };
@@ -351,6 +355,8 @@
E48839A015F92C2800BD66D5 /* visualize_overlay.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = visualize_overlay.fsh; path = Shaders/visualize_overlay.fsh; sourceTree = "<group>"; };
E48B3CBC14393DF5000C50E2 /* KRCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRCamera.h; path = Classes/KRCamera.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRCamera.cpp; path = Classes/KRCamera.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
E48B68131697794F00D99917 /* KRAudioSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRAudioSource.cpp; path = Classes/KRAudioSource.cpp; sourceTree = "<group>"; };
E48B68141697794F00D99917 /* KRAudioSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRAudioSource.h; path = Classes/KRAudioSource.h; sourceTree = "<group>"; };
E48C696E15374F5A00232E28 /* KRContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRContext.h; path = Classes/KRContext.h; sourceTree = "<group>"; };
E48C697115374F7E00232E28 /* KRContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRContext.cpp; path = Classes/KRContext.cpp; sourceTree = "<group>"; };
E491016113C99B9E0098455B /* libKREngine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKREngine.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -457,7 +463,7 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
E414F9A21694D949000B3D58 /* UnknownManager */ = {
E414F9A21694D949000B3D58 /* Unknown */ = {
isa = PBXGroup;
children = (
E414F9A41694D977000B3D58 /* KRUnknownManager.cpp */,
@@ -465,7 +471,7 @@
E414F9AA1694DA37000B3D58 /* KRUnknown.cpp */,
E414F9AB1694DA37000B3D58 /* KRUnknown.h */,
);
name = UnknownManager;
name = Unknown;
sourceTree = "<group>";
};
E416AA96167136FB000F6786 /* AnimationCurve */ = {
@@ -608,7 +614,8 @@
E488399915F92BA300BD66D5 /* Managers */ = {
isa = PBXGroup;
children = (
E414F9A21694D949000B3D58 /* UnknownManager */,
E48B681916977B5600D99917 /* Sound */,
E414F9A21694D949000B3D58 /* Unknown */,
E416AA96167136FB000F6786 /* AnimationCurve */,
E428C2EF166960ED00A16EDF /* Animation */,
E48839AB15F930E200BD66D5 /* Bundle */,
@@ -702,16 +709,41 @@
name = Bundle;
sourceTree = "<group>";
};
E48B68101697791100D99917 /* Audio */ = {
isa = PBXGroup;
children = (
E48B68131697794F00D99917 /* KRAudioSource.cpp */,
E48B68141697794F00D99917 /* KRAudioSource.h */,
);
name = Audio;
sourceTree = "<group>";
};
E48B68121697791C00D99917 /* Physics */ = {
isa = PBXGroup;
children = (
104A335D1672D31C001C8BA6 /* KRCollider.h */,
104A335C1672D31B001C8BA6 /* KRCollider.cpp */,
);
name = Physics;
sourceTree = "<group>";
};
E48B681916977B5600D99917 /* Sound */ = {
isa = PBXGroup;
children = (
);
name = Sound;
sourceTree = "<group>";
};
E48C696C15374A1500232E28 /* Scene Graph Nodes */ = {
isa = PBXGroup;
children = (
E48B68121697791C00D99917 /* Physics */,
E48B68101697791100D99917 /* Audio */,
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */,
E48B3CBC14393DF5000C50E2 /* KRCamera.h */,
E4324BA916444DCB0043185B /* Particle Systems */,
E414BAE11435557300A668C4 /* KRInstance.h */,
E414BAE41435558800A668C4 /* KRInstance.cpp */,
104A335D1672D31C001C8BA6 /* KRCollider.h */,
104A335C1672D31B001C8BA6 /* KRCollider.cpp */,
E461A171152E599E00F2044A /* Lights */,
E4F975311536220900FD60B2 /* KRNode.h */,
E4F975351536221C00FD60B2 /* KRNode.cpp */,
@@ -914,6 +946,7 @@
E44F38241683B23000399B5D /* KRRenderSettings.h in Headers */,
E414F9A81694D977000B3D58 /* KRUnknownManager.h in Headers */,
E414F9AE1694DA37000B3D58 /* KRUnknown.h in Headers */,
E48B68171697794F00D99917 /* KRAudioSource.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -978,6 +1011,7 @@
E414F9AF1694DA37000B3D58 /* KRUnknown.h in Headers */,
E4C454B3167BC04C003586CD /* KRModelSphere.h in Headers */,
E44F38251683B23000399B5D /* KRRenderSettings.h in Headers */,
E48B68181697794F00D99917 /* KRAudioSource.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1118,6 +1152,7 @@
E44F38281683B24800399B5D /* KRRenderSettings.cpp in Sources */,
E414F9A61694D977000B3D58 /* KRUnknownManager.cpp in Sources */,
E414F9AC1694DA37000B3D58 /* KRUnknown.cpp in Sources */,
E48B68151697794F00D99917 /* KRAudioSource.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1182,6 +1217,7 @@
E44F38291683B24800399B5D /* KRRenderSettings.cpp in Sources */,
E414F9A71694D977000B3D58 /* KRUnknownManager.cpp in Sources */,
E414F9AD1694DA37000B3D58 /* KRUnknown.cpp in Sources */,
E48B68161697794F00D99917 /* KRAudioSource.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -0,0 +1,126 @@
//
// KRAudioSource.cpp
// 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
// 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.
//
// 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.
//
#include "KRAudioSource.h"
#include "KRContext.h"
KRAudioSource::KRAudioSource(KRScene &scene, std::string name) : KRNode(scene, name)
{
}
KRAudioSource::~KRAudioSource()
{
}
std::string KRAudioSource::getElementName() {
return "audio_source";
}
tinyxml2::XMLElement *KRAudioSource::saveXML( tinyxml2::XMLNode *parent)
{
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
e->SetAttribute("sound", m_sound.c_str());
return e;
}
void KRAudioSource::loadXML(tinyxml2::XMLElement *e)
{
m_sound = e->Attribute("sound");
KRNode::loadXML(e);
}
void KRAudioSource::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KRViewport &viewport, KRNode::RenderPass renderPass)
{
KRNode::render(pCamera, lights, viewport, renderPass);
bool bVisualize = false;
if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT && bVisualize) {
KRMat4 sphereModelMatrix = getModelMatrix();
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, lights, 0, renderPass)) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
// Disable z-buffer write
GLDEBUG(glDepthMask(GL_FALSE));
// Enable z-buffer test
GLDEBUG(glEnable(GL_DEPTH_TEST));
GLDEBUG(glDepthFunc(GL_LEQUAL));
GLDEBUG(glDepthRangef(0.0, 1.0));
std::vector<KRModel *> sphereModels = getContext().getModelManager()->getModel("__sphere");
if(sphereModels.size()) {
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
sphereModels[0]->renderSubmesh(i);
}
}
// Enable alpha blending
GLDEBUG(glEnable(GL_BLEND));
GLDEBUG(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
}
}
}
void KRAudioSource::play()
{
}
void KRAudioSource::stop()
{
}
bool KRAudioSource::isPlaying()
{
return false;
}
void KRAudioSource::setSound(const std::string &sound_name)
{
m_sound = sound_name;
}
std::string KRAudioSource::getSound()
{
return m_sound;
}

View File

@@ -0,0 +1,58 @@
//
// KRAudioSource.h
// 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
// 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.
//
// 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.
//
#ifndef KRAUDIOSOURCE_H
#define KRAUDIOSOURCE_H
#import "KRResource.h"
#import "KRNode.h"
#import "KRTexture.h"
class KRAudioSource : public KRNode {
public:
KRAudioSource(KRScene &scene, std::string name);
virtual ~KRAudioSource();
virtual std::string getElementName();
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
virtual void loadXML(tinyxml2::XMLElement *e);
void render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
void play();
void stop();
bool isPlaying();
void setSound(const std::string &sound_name);
std::string getSound();
private:
std::string m_sound;
};
#endif /* defined(KRAUDIOSOURCE_H) */

View File

@@ -21,6 +21,7 @@
#import "KRAABB.h"
#import "KRQuaternion.h"
#import "KRBone.h"
#import "KRAudioSource.h"
KRNode::KRNode(KRScene &scene, std::string name) : KRContextObject(scene.getContext())
@@ -234,6 +235,8 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
new_node = new KRCollider(scene, szName, e->Attribute("collider_name"));
} else if(strcmp(szElementName, "bone") == 0) {
new_node = new KRBone(scene, szName);
} else if(strcmp(szElementName, "audio_source") == 0) {
new_node = new KRAudioSource(scene, szName);
}
if(new_node) {