updates to existing importer (bugs, etc.) and addition of importer audio objects skeleton code

--HG--
branch : nfb
This commit is contained in:
Peter
2013-12-05 15:54:28 -08:00
parent 971dadd7f6
commit fef872cc6d
6 changed files with 493 additions and 0 deletions

View File

@@ -10,6 +10,14 @@
104A335E1672D31C001C8BA6 /* KRCollider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 104A335C1672D31B001C8BA6 /* KRCollider.cpp */; };
104A335F1672D31C001C8BA6 /* KRCollider.h in Headers */ = {isa = PBXBuildFile; fileRef = 104A335D1672D31C001C8BA6 /* KRCollider.h */; settings = {ATTRIBUTES = (); }; };
10CC33A5168534F000BB9846 /* KRCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */; };
500CB1E5185113DA0097F31B /* simpleList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50B6C531185111C600047FF8 /* simpleList.cpp */; };
500CB1E6185113E60097F31B /* ImporterAudioLists.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50B6C52F185111C600047FF8 /* ImporterAudioLists.cpp */; };
500CB1ED185115280097F31B /* ImporterAudioLists.h in Headers */ = {isa = PBXBuildFile; fileRef = 500CB1EB185115280097F31B /* ImporterAudioLists.h */; };
500CB1EE185115280097F31B /* simpleList.h in Headers */ = {isa = PBXBuildFile; fileRef = 500CB1EC185115280097F31B /* simpleList.h */; };
500CB1F5185117600097F31B /* simpleList.h in Headers */ = {isa = PBXBuildFile; fileRef = 500CB1EC185115280097F31B /* simpleList.h */; settings = {ATTRIBUTES = (Public, ); }; };
500CB1F61851176D0097F31B /* ImporterAudioLists.h in Headers */ = {isa = PBXBuildFile; fileRef = 500CB1EB185115280097F31B /* ImporterAudioLists.h */; };
50B6C533185111C600047FF8 /* ImporterAudioLists.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50B6C52F185111C600047FF8 /* ImporterAudioLists.cpp */; };
50B6C535185111C600047FF8 /* simpleList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50B6C531185111C600047FF8 /* simpleList.cpp */; };
E4030E4C160A3CF000592648 /* KRStockGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = E4030E4B160A3CF000592648 /* KRStockGeometry.h */; settings = {ATTRIBUTES = (); }; };
E4030E4D160A3CF000592648 /* KRStockGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = E4030E4B160A3CF000592648 /* KRStockGeometry.h */; settings = {ATTRIBUTES = (Public, ); }; };
E40BA45415EFF79500D7C3DD /* KRAABB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40BA45215EFF79500D7C3DD /* KRAABB.cpp */; };
@@ -408,6 +416,10 @@
104A335C1672D31B001C8BA6 /* KRCollider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRCollider.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
104A335D1672D31C001C8BA6 /* KRCollider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRCollider.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
10CC33A3168530A300BB9846 /* libPVRTexLib.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libPVRTexLib.a; path = Utilities/PVRTexLib/MacOS/libPVRTexLib.a; sourceTree = PVRSDK; };
500CB1EB185115280097F31B /* ImporterAudioLists.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImporterAudioLists.h; sourceTree = "<group>"; };
500CB1EC185115280097F31B /* simpleList.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = simpleList.h; sourceTree = "<group>"; };
50B6C52F185111C600047FF8 /* ImporterAudioLists.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = ImporterAudioLists.cpp; sourceTree = "<group>"; };
50B6C531185111C600047FF8 /* simpleList.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = simpleList.cpp; sourceTree = "<group>"; };
E4030E4B160A3CF000592648 /* KRStockGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRStockGeometry.h; sourceTree = "<group>"; };
E40BA45215EFF79500D7C3DD /* KRAABB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRAABB.cpp; sourceTree = "<group>"; };
E40BA45315EFF79500D7C3DD /* KRAABB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAABB.h; sourceTree = "<group>"; };
@@ -708,6 +720,17 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
50B6C52E1851117A00047FF8 /* Audio Import */ = {
isa = PBXGroup;
children = (
50B6C52F185111C600047FF8 /* ImporterAudioLists.cpp */,
500CB1EB185115280097F31B /* ImporterAudioLists.h */,
50B6C531185111C600047FF8 /* simpleList.cpp */,
500CB1EC185115280097F31B /* simpleList.h */,
);
name = "Audio Import";
sourceTree = "<group>";
};
E414F9A21694D949000B3D58 /* Unknown */ = {
isa = PBXGroup;
children = (
@@ -1056,6 +1079,7 @@
E491016613C99B9E0098455B /* kraken */ = {
isa = PBXGroup;
children = (
50B6C52E1851117A00047FF8 /* Audio Import */,
E4F9753815362A5200FD60B2 /* 3rdparty */,
E488399915F92BA300BD66D5 /* Managers */,
E461A173152E59DF00F2044A /* Math */,
@@ -1259,6 +1283,7 @@
E468448117FFDF51001F1FA1 /* KRLocator.h in Headers */,
E43F70E71824D9AB00136169 /* KRTextureStreamer.h in Headers */,
E4F975321536220900FD60B2 /* KRNode.h in Headers */,
500CB1EE185115280097F31B /* simpleList.h in Headers */,
E46C214715364BC8009CABF3 /* tinyxml2.h in Headers */,
E48C696F15374F5B00232E28 /* KRContext.h in Headers */,
E46F4A0B155E002100CCF8B8 /* KRDataBlock.h in Headers */,
@@ -1309,6 +1334,7 @@
E48CF944173453990005EBBB /* KRFloat.h in Headers */,
E43F71011824E73100136169 /* KRMeshStreamer.h in Headers */,
E45134B81746A4A300443C21 /* KRBehavior.h in Headers */,
500CB1ED185115280097F31B /* ImporterAudioLists.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1351,6 +1377,7 @@
E428C312166971FF00A16EDF /* KRAnimationLayer.h in Headers */,
E4AFC6B615F7C46800DDB4C8 /* KRAABB.cpp in Headers */,
E428C3171669A24B00A16EDF /* KRAnimationAttribute.h in Headers */,
500CB1F5185117600097F31B /* simpleList.h in Headers */,
E4AFC6BE15F7C9E600DDB4C8 /* KROctreeNode.h in Headers */,
E4AFC6BD15F7C9DA00DDB4C8 /* KROctree.h in Headers */,
E46A6B701559EF0A000DBD37 /* KRResource+blend.h in Headers */,
@@ -1394,6 +1421,7 @@
E48CF945173453990005EBBB /* KRFloat.h in Headers */,
E499BF1F16AE753E007FCDBE /* KRCollider.h in Headers */,
E499BF2316AE7636007FCDBE /* kraken-prefix.pch in Headers */,
500CB1F61851176D0097F31B /* ImporterAudioLists.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1607,6 +1635,7 @@
E43F70DC181B20E400136169 /* KRLODSet.cpp in Sources */,
E414BAE51435558900A668C4 /* KRModel.cpp in Sources */,
E414BAE91435585A00A668C4 /* KRScene.cpp in Sources */,
500CB1E5185113DA0097F31B /* simpleList.cpp in Sources */,
E48B3CC014393E30000C50E2 /* KRCamera.cpp in Sources */,
E497B946151BA99500D3DC67 /* KRVector2.cpp in Sources */,
E497B94D151BCF2500D3DC67 /* KRResource.cpp in Sources */,
@@ -1632,6 +1661,7 @@
E4B175AC161F5A1000B8FB80 /* KRTexture.cpp in Sources */,
E4B175B2161F5FAF00B8FB80 /* KRTextureCube.cpp in Sources */,
E4CA10E91637BD2B005D9400 /* KRTexturePVR.cpp in Sources */,
500CB1E6185113E60097F31B /* ImporterAudioLists.cpp in Sources */,
E4CA10EF1637BD58005D9400 /* KRTextureTGA.cpp in Sources */,
E4CA11781639CC90005D9400 /* KRViewport.cpp in Sources */,
E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */,
@@ -1706,6 +1736,8 @@
E46A6B6D1559E97D000DBD37 /* KRResource+blend.cpp in Sources */,
E40F982D184A7A2700CFA4D8 /* KRMeshQuad.cpp in Sources */,
E46F4A0F155E003000CCF8B8 /* KRDataBlock.cpp in Sources */,
50B6C533185111C600047FF8 /* ImporterAudioLists.cpp in Sources */,
50B6C535185111C600047FF8 /* simpleList.cpp in Sources */,
E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */,
E4AFC6BB15F7C7D600DDB4C8 /* KROctreeNode.cpp in Sources */,
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */,

View File

@@ -0,0 +1,212 @@
//
// ImporterAudioLists.cpp
//
#include "ImporterAudioLists.h"
//
// (1) UTILITIES
void IMPORTER_AUDIO_UTILITIES() { }
//
// Utility to convert a file code from a resource file into an object id
// <n> will convert to <n>
// <n>H will convert to <n> << 8
// <n>A will convert to <n> << 16
// A result of 0 implies a bad input code
//
unsigned long codeToID(char *code)
{
static char decode[64];
size_t l = strlen(code);
if (l <= 0) return 0; // no code string
if (l > 63) l = 63;
int type = 0;
switch (code[l-1]) {
case 'A' :
case 'a' :
type = 8;
case 'H' :
case 'h' :
type += 8;
strncpy(decode, code, l-1); // (dst, src, maxlength)
decode[l-1] = 0;
break;
default :
strncpy(decode, code, l);
decode[l] = 0;
break;
};
unsigned long id = strtol(decode, 0, 0); // (str, endptr, base)
id = id << type;
return id;
}
//
// (2) ZONE CORNERS
void IMPORTER_AUDIO_ZONE_CORNERS() { }
//
// (2a) A corners list for a given room/space
void zoneRoomCornersList::addCorner(zoneCorner *c)
{
}
void zoneRoomCornersList::generateZones(simpleList *zonelist)
{
}
//
// (2b) A list of all the corners lists
void zoneAllCornersList::addCorner(zoneCorner *c)
{
}
void zoneAllCornersList::generateSpheresFor(unsigned long id, simpleList *zonelist)
{
}
void zoneAllCornersList::generateSpheres(simpleList *zonelist)
{
}
//
// (3) RESOURCES
void IMPORTER_AUDIO_RESOURCES() { }
bool zoneResourceList::load(char *path1, char *path2)
{
return true;
}
//
// (4) ZONE NODE MANAGER
void IMPORTER_AUDIO_MANAGER() { }
zoneNodeManager::zoneNodeManager()
{
}
zoneNodeManager::~zoneNodeManager()
{
}
// (1) parse the resource files and create the resource list
bool zoneNodeManager::loadResources(char *path1, char *path2)
{
return resources.load(path1, path2);
}
// (2) given a locator add it to the correct list
//
// insert vector table list into this space!
bool addLocator_audioNode(zoneNodeManager *manager, char *idstring, KRVector3 where, double radius)
{
return true;
}
bool addLocator_ambientZone(zoneNodeManager *manager, char *idstring, KRVector3 where, double radius)
{
return true;
}
bool addLocator_reverbZone(zoneNodeManager *manager, char *idstring, KRVector3 where, double radius)
{
return true;
}
bool addLocator_ambientCorner(zoneNodeManager *manager, char *idstring, KRVector3 where, double radius)
{
return true;
}
bool addLocator_reverbCorner(zoneNodeManager *manager, char *idstring, KRVector3 where, double radius)
{
return true;
}
typedef bool (*addLocatorFunction)(zoneNodeManager *, char *, KRVector3, double);
typedef struct {
const char *prefix;
unsigned long prefix_length;
addLocatorFunction function;
} addLocatorTableItem;
addLocatorTableItem addLocatorVectorTable[] = {
{ "AN_", 3, addLocator_audioNode },
{ "AZpoint_", 8, addLocator_ambientZone },
{ "RZpoint_", 8, addLocator_reverbZone },
{ "AZcorner_", 9, addLocator_ambientCorner },
{ "RZcorner_", 9, addLocator_reverbCorner },
{ NULL, 0, NULL },
};
addLocatorTableItem *addLocator_findType(char *name)
{
addLocatorTableItem *result = addLocatorVectorTable;
while (NULL != result->prefix)
{
if (0 == strncmp(result->prefix, name, result->prefix_length)) return result;
result++;
}
return NULL;
}
bool zoneNodeManager::addLocatorToAList(char *name, KRVector3 point, double radius)
{
// (1) parse the name and add it to a list where appropriate
// AN_<node_name>_<unique> is an audio node
// AZpoint_<n>_<unique> is an audio zone point with a radius
// RZpoint_<n><p>_<unique> is a reverb zone point with a radius
// AZcorner_<n>_<order> is a corner for an ambient zone
// RZcorner_<n><p>_<order> is a corner for a reverb zone
//
addLocatorTableItem *item = addLocator_findType(name);
if (NULL != item)
{
//**** IN HERE we want to parse the args into the ID arg and the unique/order arg
//**** UPDATE (*addLocatorFunction) to handle the 'order' arg
char arg[AUDIO_IMPORTER_STRLEN];
strncpy(arg, &name[item->prefix_length], AUDIO_IMPORTER_STRLEN-1);
arg[AUDIO_IMPORTER_STRLEN-1] = 0;
item->function(this, arg, point, radius);
return true; // return true if this is an audio locator that was added to a list
}
return false; // return false if the FBX importer should handle the locator itself
}
// (3) turn corner definitions into spheres
void zoneNodeManager::generateSpheresForAllZones()
{
ambientCornersList.generateSpheres(&ambientZoneList);
reverbCornersList.generateSpheres(&reverbZoneList);
}
// (4) output ambient zones
// (5) output reverb zones
// (6) output audio nodes (props)
bool zoneNodeManager::outputAmbientZones()
{
return true;
}
bool zoneNodeManager::outputReverbZones()
{
return true;
}
bool zoneNodeManager::outputAudioNodes()
{
return true;
}
// END OF ImporterAudioLists.cpp

View File

@@ -0,0 +1,123 @@
//
// ImporterAudioLists.h
//
#ifndef _IMPORTER_AUDIO_LISTS_H_
#define _IMPORTER_AUDIO_LISTS_H_
#include "KRVector3.h"
#include "simpleList.h"
enum {
AUDIO_IMPORTER_STRLEN = 128
};
//
// (1) Nodes and Dummy Props
// A locator point
// AN_<node_name>_<unique>
struct audioPoint : public simpleListObject {
KRVector3 point;
char name[AUDIO_IMPORTER_STRLEN]; // this could change to a std::string
};
//
// (2) Zone Locators - for ambient zones and reverb zones
// A zone sphere object
// RZpoint_<n><p>_<unique> locRadius and AZpoint_<n>_<unique> locRadius
struct zone : public simpleListObject {
KRVector3 point;
double radius;
unsigned long id;
};
// A zone corner object
// RZcorner_<n><p>_<order_clockwise> and AZcorner_<n>_<order_clockwise>
struct zoneCorner : public simpleListObject {
KRVector3 point;
unsigned long id;
};
//
// A list of corners for a particular location
struct zoneRoomCornersList : public simpleListObject {
unsigned long id;
simpleList corners; // the zoneCorner objects for a given id
void addCorner(zoneCorner *c);
// add it into the list in presorted place/location_number order starting bottom left and going clockwise
void generateZones(simpleList *zonelist);
// create a set of spheres that fill in the space defined by the corners
// and add these spheres to the 'zonelist'
};
//
// A master list of lists of corners
struct zoneAllCornersList : public simpleList {
void addCorner(zoneCorner *c);
// find or create a zoneRoomCornersList for the incoming id, then use that list's addCorner() method
void generateSpheresFor(unsigned long id, simpleList *zonelist);
void generateSpheres(simpleList *zonelist);
// routines to generate circle points for the geometery of a given place + location_number
// .. and to place these cirlces into a given zone list
};
// A resource object
// <n><p> <resource file name> or <n> <resource file name>
struct zoneResource : public simpleListObject {
unsigned long id;
char resource_name[AUDIO_IMPORTER_STRLEN];
};
struct zoneResourceList : public simpleList {
bool load(char *path1, char *path2 = NULL);
// all resources are loaded into the same list from either 1 or 2 input files
// we can either put all the reverb and ambient info in 1 file, or split it across 2 files
};
//
// (3) Zone and Node Manager
struct zoneNodeManager {
zoneResourceList resources;
simpleList ambientZoneList; // list of 'zone' objects
zoneAllCornersList ambientCornersList;
simpleList reverbZoneList; // list of 'zone' objects
zoneAllCornersList reverbCornersList;
simpleList audioNodesList; // a list of 'audioPoint' objects
zoneNodeManager();
virtual ~zoneNodeManager();
// (1) parse the resource files and create the resource list
bool loadResources(char *path1, char *path2=NULL); // passed through to resources.load()
// (2) given a locator add it to the correct list
bool addLocatorToAList(char *name, KRVector3 point, double radius);
// (3) turn corner definitions into spheres
void generateSpheresForAllZones();
// (4) output ambient zones
// (5) output reverb zones
// (6) output audio nodes (props)
virtual bool outputAmbientZones();
virtual bool outputReverbZones();
virtual bool outputAudioNodes();
};
#endif
// END OF ImporterAudioLists.h

View File

@@ -1613,6 +1613,9 @@ KRNode *LoadLocator(KRNode *parent_node, FbxScene* pFbxScene, FbxNode* pNode) {
//**** HACK A BIT TO FIND OUT HOW IT WORKS
const char *node_name = pNode->GetName();
FbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSourcePivot);
KRVector3 node_translation = KRVector3(local_translation[0], local_translation[1], local_translation[2]);
// if(strncmp(node_name, "physics_collider_", strlen("physics_collider_")) == 0) {
// // example hard coded compare
// }
@@ -1644,6 +1647,7 @@ KRNode *LoadLocator(KRNode *parent_node, FbxScene* pFbxScene, FbxNode* pNode) {
//
// create_prop telegraph_radio dummyprop 94.371559 4.400661 31.469673 0.05
// - creates a reference point that the radio sound is 'located at' later in the script
// create_node mitchell_phone 22.7842 18.7481 9.1446
//
// TO BE ADDED

View File

@@ -0,0 +1,87 @@
//
// simpleList.cpp
//
#include "simpleList.h"
simpleListObject::simpleListObject() { next = previous = NULL; }
simpleListObject::~simpleListObject() { }
simpleList::simpleList() {
first = last = NULL;
nelements = 0;
};
simpleList::~simpleList() { while((first)) remove(first); }
void simpleList::add(simpleListObject *elem, simpleListObject *after) {
if (NULL == elem) return;
if (NULL == first) {
first = last = elem;
elem->next = elem->previous = NULL;
}
else {
if (NULL == after) { after = last; }
if (last == after) {
elem->next = NULL;
elem->previous = last;
last->next = elem;
last = elem;
}
else {
elem->previous = after;
elem->next = after->next;
after->next->previous = elem;
after->next = elem;
}
}
nelements++;
}
void simpleList::insert(simpleListObject *elem, simpleListObject *before) {
if (NULL == elem) return;
if (NULL == first) {
first = last = elem;
elem->next = elem->previous = NULL;
}
else {
if (NULL == before) { before = first; }
if (first == before) {
elem->previous = NULL;
elem->next = first;
first->previous = elem;
first = elem;
}
else {
elem->previous = before->previous;
elem->next = before;
before->previous->next = elem;
before->previous = elem;
}
}
nelements++;
}
void simpleList::remove(simpleListObject *elem) {
if (0 == nelements) return;
if (NULL == elem) return;
if (NULL != elem->previous) elem->previous->next = elem->next;
if (NULL != elem->next) elem->next->previous = elem->previous;
if (elem == last) last = elem->previous;
if (elem == first) first = elem->next;
elem->previous = elem->next = NULL;
nelements--;
}
simpleListObject *simpleList::findByIndex(unsigned long index) {
simpleListObject *result = NULL;
if (index < nelements) {
simpleListObject *current = first;
for (unsigned long i = 0; (i < index) && (NULL != current); i++)
current = current->next;
result = current;
}
return result;
}
// END OF simpleList.cpp

View File

@@ -0,0 +1,35 @@
//
// simpleList.h
//
#ifndef _SIMPLE_LIST_OBJECTS_H_
#define _SIMPLE_LIST_OBJECTS_H_
#include <cstddef> // include for pre c++11 defines
struct simpleListObject {
simpleListObject *next;
simpleListObject *previous;
simpleListObject();
~simpleListObject();
}; // end of struct simpleListObject
struct simpleList {
simpleListObject *first;
simpleListObject *last;
unsigned long nelements;
simpleList();
~simpleList();
void add(simpleListObject *elem, simpleListObject *after=NULL);
void insert(simpleListObject *elem, simpleListObject *before=NULL);
void remove(simpleListObject *elem);
simpleListObject *findByIndex(unsigned long index);
}; // end of struct simpleList
#endif
// END OF simpleList.h