本文整理汇总了C++中AABox::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ AABox::contains方法的具体用法?C++ AABox::contains怎么用?C++ AABox::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABox
的用法示例。
在下文中一共展示了AABox::contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendEnvironmentPacket
void sendEnvironmentPacket(const SharedNodePointer& node, AudioMixerClientData& data) {
bool hasReverb = false;
float reverbTime, wetLevel;
auto& reverbSettings = AudioMixer::getReverbSettings();
auto& audioZones = AudioMixer::getAudioZones();
AvatarAudioStream* stream = data.getAvatarAudioStream();
glm::vec3 streamPosition = stream->getPosition();
// find reverb properties
for (int i = 0; i < reverbSettings.size(); ++i) {
AABox box = audioZones[reverbSettings[i].zone];
if (box.contains(streamPosition)) {
hasReverb = true;
reverbTime = reverbSettings[i].reverbTime;
wetLevel = reverbSettings[i].wetLevel;
break;
}
}
// check if data changed
bool dataChanged = (stream->hasReverb() != hasReverb) ||
(stream->hasReverb() && (stream->getRevebTime() != reverbTime || stream->getWetLevel() != wetLevel));
if (dataChanged) {
// update stream
if (hasReverb) {
stream->setReverb(reverbTime, wetLevel);
} else {
stream->clearReverb();
}
}
// send packet at change or every so often
float CHANCE_OF_SEND = 0.01f;
bool sendData = dataChanged || (randFloat() < CHANCE_OF_SEND);
if (sendData) {
// size the packet
unsigned char bitset = 0;
int packetSize = sizeof(bitset);
if (hasReverb) {
packetSize += sizeof(reverbTime) + sizeof(wetLevel);
}
// write the packet
auto envPacket = NLPacket::create(PacketType::AudioEnvironment, packetSize);
if (hasReverb) {
setAtBit(bitset, HAS_REVERB_BIT);
}
envPacket->writePrimitive(bitset);
if (hasReverb) {
envPacket->writePrimitive(reverbTime);
envPacket->writePrimitive(wetLevel);
}
// send the packet
DependencyManager::get<NodeList>()->sendPacket(std::move(envPacket), *node);
}
}
示例2: sendAudioEnvironmentPacket
void AudioMixer::sendAudioEnvironmentPacket(SharedNodePointer node) {
// Send stream properties
bool hasReverb = false;
float reverbTime, wetLevel;
// find reverb properties
for (int i = 0; i < _zoneReverbSettings.size(); ++i) {
AudioMixerClientData* data = static_cast<AudioMixerClientData*>(node->getLinkedData());
glm::vec3 streamPosition = data->getAvatarAudioStream()->getPosition();
AABox box = _audioZones[_zoneReverbSettings[i].zone];
if (box.contains(streamPosition)) {
hasReverb = true;
reverbTime = _zoneReverbSettings[i].reverbTime;
wetLevel = _zoneReverbSettings[i].wetLevel;
// Modulate wet level with distance to wall
float MIN_ATTENUATION_DISTANCE = 2.0f;
float MAX_ATTENUATION = -12; // dB
glm::vec3 distanceToWalls = (box.getDimensions() / 2.0f) - glm::abs(streamPosition - box.calcCenter());
float distanceToClosestWall = glm::min(distanceToWalls.x, distanceToWalls.z);
if (distanceToClosestWall < MIN_ATTENUATION_DISTANCE) {
wetLevel += MAX_ATTENUATION * (1.0f - distanceToClosestWall / MIN_ATTENUATION_DISTANCE);
}
break;
}
}
AudioMixerClientData* nodeData = static_cast<AudioMixerClientData*>(node->getLinkedData());
AvatarAudioStream* stream = nodeData->getAvatarAudioStream();
bool dataChanged = (stream->hasReverb() != hasReverb) ||
(stream->hasReverb() && (stream->getRevebTime() != reverbTime ||
stream->getWetLevel() != wetLevel));
if (dataChanged) {
// Update stream
if (hasReverb) {
stream->setReverb(reverbTime, wetLevel);
} else {
stream->clearReverb();
}
}
// Send at change or every so often
float CHANCE_OF_SEND = 0.01f;
bool sendData = dataChanged || (randFloat() < CHANCE_OF_SEND);
if (sendData) {
auto nodeList = DependencyManager::get<NodeList>();
unsigned char bitset = 0;
int packetSize = sizeof(bitset);
if (hasReverb) {
packetSize += sizeof(reverbTime) + sizeof(wetLevel);
}
auto envPacket = NLPacket::create(PacketType::AudioEnvironment, packetSize);
if (hasReverb) {
setAtBit(bitset, HAS_REVERB_BIT);
}
envPacket->writePrimitive(bitset);
if (hasReverb) {
envPacket->writePrimitive(reverbTime);
envPacket->writePrimitive(wetLevel);
}
nodeList->sendPacket(std::move(envPacket), *node);
}
}
示例3: inf
/*
* Tries to load vmap and tilemap for a gridtile and creates a navmesh for it.
*
*/
bool
ModelContainerView::generateMoveMapForTile (int pMapId, int x, int y)
{
bool result = iVMapManager.loadMap (gVMapDataDir.c_str (), pMapId, x, y) == VMAP_LOAD_RESULT_OK;
if (result == VMAP_LOAD_RESULT_OK)
{
//VMap loaded. Add data from vmap to global Triangle-Array
parseVMap (pMapId, x, y);
}
// Add data from Height-Map to global Triangle-Array
generateHeightMap(pMapId,x,y);
// We will now add all triangles inside the given zone to the vectormap.
// We could also do additional checks here.
double x_max = (32-x)*SIZE_OF_GRIDS + 50;
double y_max = (32-y)*SIZE_OF_GRIDS + 50;
double x_min = x_max - SIZE_OF_GRIDS - 100;
double y_min = y_max - SIZE_OF_GRIDS - 100;
Vector3 low = Vector3(x_min,y_min,-inf());
Vector3 high = Vector3(x_max,y_max,inf());
AABox checkBox = AABox(low,high);
AABox check;
Triangle t;
//each triangle has mangos format.
for (int i = 0; i < globalTriangleArray.size(); i++) {
t = globalTriangleArray[i];
t.getBounds(check);
if (checkBox.contains(check)) {
// Write it down in detour format.
iGlobArray.append(t.vertex(0).y,t.vertex(0).z,t.vertex(0).x);
iGlobArray.append(t.vertex(1).y,t.vertex(1).z,t.vertex(1).x);
iGlobArray.append(t.vertex(2).y,t.vertex(2).z,t.vertex(2).x);
}
}
if (iGlobArray.size() == 0) {
printf("No models - check your mmap.datadir in your config");
return true;
}
if(gMakeObjFile)
debugGenerateObjFile(); // create obj file for Recast Demo viewer
//return true;
float bmin[3], bmax[3];
/*
* The format looks like this
* Verticle = float[3]
* Triangle = Verticle[3]
* So there are
* array.size() floats
* that means there are
* nverts = array.size()/3 Verticles
* that means there are
* ntris = nverts/3
*/
//array/3 verticles
const int nverts = iGlobArray.size()/3; // because 1 vert is 3 float.
// -> vert = float[3]
const float* verts = iGlobArray.getCArray();
rcCalcBounds(verts,nverts,bmin,bmax);
// nverts/3 triangles
// -> Triangle = vert[3] = float[9]
int* tris = new int[nverts];// because 1 triangle is 3 verts
for (int i = 0; i< nverts; i++)
tris[i] = i;
/* tris[i] = 1,2,3;4,5,6;7,8,9;
*
*/
const int ntris = (nverts/3);
rcConfig m_cfg;
//
// Step 1. Initialize build config.
//
// Init build configuration from GUI
memset(&m_cfg, 0, sizeof(m_cfg));
// Change config settings here!
m_cfg.cs = 0.3f;
m_cfg.ch = 0.2f;
m_cfg.walkableSlopeAngle = 50.0f;
m_cfg.walkableHeight = 10;
m_cfg.walkableClimb = 4;
m_cfg.walkableRadius = 2;
m_cfg.maxEdgeLen = (int)(12 / 0.3f);
m_cfg.maxSimplificationError = 1.3f;
m_cfg.minRegionSize = (int)rcSqr(50);
m_cfg.mergeRegionSize = (int)rcSqr(20);
m_cfg.maxVertsPerPoly = (int)6;
m_cfg.detailSampleDist = 1.8f;
m_cfg.detailSampleMaxError = 0.2f * 1;
bool m_keepInterResults = false;
printf("CellSize : %.2f\n",m_cfg.cs);
printf("CellHeight : %.2f\n",m_cfg.ch);
printf("WalkableSlope : %.2f\n",m_cfg.walkableSlopeAngle);
printf("WalkableHeight : %i\n",m_cfg.walkableHeight);
printf("walkableClimb : %i\n",m_cfg.walkableClimb);
printf("walkableRadius : %i\n",m_cfg.walkableRadius);
//.........这里部分代码省略.........