本文整理汇总了C++中Vec3i函数的典型用法代码示例。如果您正苦于以下问题:C++ Vec3i函数的具体用法?C++ Vec3i怎么用?C++ Vec3i使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vec3i函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
size_t Volume::getVoxelIndex(const Vec3i& coords, BorderTreatment borderTreatment) const
{
Vec3i treatedCoords = coords;
switch (borderTreatment)
{
case TREAT_EXCEPTION:
if (!properties.getMemoryBoundingBox().isInside(coords))
{
std::stringstream ss;
ss << "Volume coordinates (" << coords << ") out of bounds (" << properties.getVolumeResolution() << ")!";
throw Exception( ss.str() );
}
break;
case TREAT_CLAMP:
treatedCoords = clamp(coords, Vec3i(0, 0, 0), (Vec3i)properties.getVolumeResolution());
break;
case TREAT_MIRROR:
throw Exception("Mirror border treatment not yet implemented!");
break;
case TREAT_REPEAT:
treatedCoords = Vec3i(coords.x % (int)properties.getVolumeResolution().x,
coords.y % (int)properties.getVolumeResolution().y,
coords.z % (int)properties.getVolumeResolution().z);
break;
default:
throw Exception("Illegal border treatment given!");
}
return calculateVoxelIndex((Vec3ui)treatedCoords);
}
示例2: p
uint32 ObjLoader::fetchVertex(int32 pos, int32 normal, int32 uv)
{
if (pos < 0)
pos += _pos.size() + 1;
if (normal < 0)
normal += _normal.size() + 1;
if (uv < 0)
uv += _uv.size() + 1;
auto iter = _indices.find(Vec3i(pos, normal, uv));
if (iter != _indices.end()) {
return iter->second;
} else {
Vec3f p(0.0f), n(0.0f, 1.0f, 0.0f);
Vec2f u(0.0f);
if (pos)
p = _pos[pos - 1];
if (normal)
n = _normal[normal - 1];
if (uv)
u = _uv[uv - 1];
_bounds.grow(p);
uint32 index = _verts.size();
_verts.emplace_back(p, n, u);
_indices.insert(std::make_pair(Vec3i(pos, normal, uv), index));
return index;
}
}
示例3: generate_data
static Data generate_data(DataType data_type, const Config &config)
{
Data data;
const int half_size = config.data_size/2;
for (int z = 0; z < config.data_size; z++) {
for (int y = 0; y < config.data_size; y++) {
for (int x = 0; x < config.data_size; x++) {
const Vec3i p = (Vec3i(x, y, z) - Vec3i(half_size)) * Vec3i(2);
data.spheres.pappend(ToVec3f(p), 1.0f);
}}}
for (int i = 0; i < data.spheres.length(); i++)
data.mapping.append(i);
data.results.resize((data.spheres.length() + 31) / 32);
fill<uint32_t>(data.results, 0);
// If random data is requested, shuffle the mapping and move the spheres.
if (data_type == Random) {
auto seed = std::chrono::system_clock::now().time_since_epoch().count();
std::shuffle(data.mapping.data(), data.mapping.data() + data.mapping.length(),
std::default_random_engine(seed));
Vector<Sphere> spheres_tmp(&sse_allocator);
spheres_tmp.resize(data.spheres.length());
for (int i = 0; i < data.spheres.length(); i++) {
spheres_tmp[data.mapping[i]] = data.spheres[i];
}
data.spheres = std::move(spheres_tmp);
}
return data;
}
示例4: getBlockIndexByBlockCoords
void Chunk::deleteBlock(Vec3i localCoords)
{
if(localCoords.x < 0)
localCoords.x += 16;
if(localCoords.y < 0)
localCoords.y += 16;
int index = getBlockIndexByBlockCoords(localCoords);
int topIndex = getBlockIndexByBlockCoords(Vec3i(localCoords.x,localCoords.y,localCoords.z+1));
if(m_block[index].m_type == PUMPKIN)
m_pumpkinCount--;
if((m_block[topIndex].m_flagsAndLighting & SKY_MASK) == SKY_MASK)
{
for(int z = localCoords.z; z > 0; z--)
{
m_block[getBlockIndexByBlockCoords(Vec3i(localCoords.x,localCoords.y,z))].m_flagsAndLighting |= SKY_MASK;
if((m_block[getBlockIndexByBlockCoords(Vec3i(localCoords.x,localCoords.y,z-1))].m_flagsAndLighting & SOLID_MASK) == SOLID_MASK)
break;
}
}
m_block[index].m_type = AIR;
m_block[index].m_flagsAndLighting &= ~SOLID_MASK;
m_block[index].m_flagsAndLighting |= DIRTY_MASK;
m_isDirty = true;
m_lightDirtyIndex.push_back(index);
markAdjacentBlockAsLightDirty(localCoords,m_lightDirtyIndex);
calculateLighting();
}
示例5: getHightestAdjacentLightLevel
int Chunk::getHightestAdjacentLightLevel(Vec3i blockCoords)
{
int lightValue[NUM_OF_FACES];
lightValue[TOP_SIDE] = blockCoords.z + 1 > 127 ? -1 : m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x , blockCoords.y , blockCoords.z+1))].m_flagsAndLighting & LIGHT_MASK;
lightValue[BOTTOM_SIDE] = blockCoords.z - 1 < 0 ? -1 : m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x , blockCoords.y , blockCoords.z-1))].m_flagsAndLighting & LIGHT_MASK;
lightValue[EAST_SIDE] = blockCoords.x + 1 > 15 ? -1 : m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x+1 , blockCoords.y , blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;
lightValue[WEST_SIDE] = blockCoords.x - 1 < 0 ? -1 : m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x-1 , blockCoords.y , blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;
lightValue[NORTH_SIDE] = blockCoords.y + 1 > 15 ? -1 : m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x , blockCoords.y+1, blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;
lightValue[SOUTH_SIDE] = blockCoords.y - 1 < 0 ? -1 : m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x , blockCoords.y-1, blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;
if(lightValue[TOP_SIDE] == -1)
lightValue[TOP_SIDE] = NIGHT_LIGHTING_LEVEL;
if(lightValue[BOTTOM_SIDE] == -1)
lightValue[BOTTOM_SIDE] = NIGHT_LIGHTING_LEVEL;
if(lightValue[EAST_SIDE] == -1 && m_eastChunk != nullptr)
lightValue[EAST_SIDE] = m_eastChunk->m_block[getBlockIndexByBlockCoords(Vec3i(0 , blockCoords.y , blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;
if(lightValue[WEST_SIDE] == -1 && m_westChunk != nullptr)
lightValue[WEST_SIDE] = m_westChunk->m_block[getBlockIndexByBlockCoords(Vec3i(15 , blockCoords.y , blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;
if(lightValue[NORTH_SIDE] == -1 && m_northChunk != nullptr)
lightValue[NORTH_SIDE] = m_northChunk->m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x , 0 , blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;;
if(lightValue[SOUTH_SIDE] == -1 && m_southChunk != nullptr)
lightValue[SOUTH_SIDE] = m_southChunk->m_block[getBlockIndexByBlockCoords(Vec3i(blockCoords.x , 15 , blockCoords.z ))].m_flagsAndLighting & LIGHT_MASK;
int highestValue = 0;
for(int index = 0; index < NUM_OF_FACES; index++)
{
if(lightValue[index] > highestValue)
highestValue = lightValue[index];
}
return highestValue;
}
示例6: n
GridTopology::GridTopology(int _nx, int _ny, int _nz)
: n(initData(&n,Vec3i(_nx,_ny,_nz),"n","grid resolution"))
, p_createTexCoords(initData(&p_createTexCoords, (bool)false, "createTexCoords", "If set to true, virtual texture coordinates will be generated using 3D interpolation."))
, m_texCoords(initData(&m_texCoords, "texcoords", "If createTexCoords is set to true, this data will store the virtual texture coordinates of the grid."))
{
nbPoints = _nx*_ny*_nz;
this->n.setValue(Vec3i(_nx,_ny,_nz));
}
示例7: Vec3f
void voxelSurfaceContruction::getSurface(voxelObject *s_obj, arrayInt vIdxs, arrayVec3f &point, arrayVec3i &faces)
{
s_hashTable = &s_obj->m_hashTable;
s_boxes = &s_obj->m_boxes;
// The point also need and hash table
pointHash hashPtf;
Vec3f basePointHash = s_hashTable->leftDown;
float voxelSize = s_hashTable->voxelSize;
hashPtf.basePt = basePointHash - Vec3f(voxelSize, voxelSize, voxelSize) / 2;
hashPtf.sizef = s_obj->m_voxelSizef;
hashPtf.NumXYZ = s_hashTable->NumXYZ + Vec3i(1, 1, 1);
mapii hashPtIdx;
// Loop through voxel
for (int i = 0; i < vIdxs.size(); i++)
{
int curIdx = vIdxs[i];
voxelBox curB = s_boxes->at(curIdx);
Vec3i posi = curB.xyzIndex;
int boneIdx = curB.boneIndex;
// Check every faces
for (int j = 0; j < DIRECT_TOTAL; j++)
{
Vec3i neighbori = getNeighborPos(posi, (direction)j);
int idx = s_hashTable->getBoxIndexFromVoxelCoord(neighbori);
if (idx == -1
|| (s_boxes->at(idx).boneIndex != boneIdx))
{
arrayVec3f pointQuad = getQuadFace(curB.leftDown, curB.rightUp, (direction)j);
mapii vertexIdxMap;
for (int k = 0; k < 4; k++)
{
int h = hashPtf.getHash(pointQuad[k]);
if (hashPtIdx.find(h) == hashPtIdx.end())
{
point.push_back(pointQuad[k]);
hashPtIdx.insert(pairii(h, point.size() - 1));
}
vertexIdxMap.insert(pairii(k, hashPtIdx[h]));
}
faces.push_back(Vec3i(vertexIdxMap[0], vertexIdxMap[1], vertexIdxMap[2]));
faces.push_back(Vec3i(vertexIdxMap[0], vertexIdxMap[2], vertexIdxMap[3]));
}
}
}
}
示例8: file
void VdbGrid::loadResources()
{
openvdb::io::File file(_path->absolute().asString());
try {
file.open();
} catch(const openvdb::IoError &e) {
FAIL("Failed to open vdb file at '%s': %s", *_path, e.what());
}
openvdb::GridBase::Ptr ptr = file.readGrid(_gridName);
if (!ptr)
FAIL("Failed to read grid '%s' from vdb file '%s'", _gridName, *_path);
file.close();
_grid = openvdb::gridPtrCast<openvdb::FloatGrid>(ptr);
if (!_grid)
FAIL("Failed to read grid '%s' from vdb file '%s': Grid is not a FloatGrid", _gridName, *_path);
openvdb::CoordBBox bbox = _grid->evalActiveVoxelBoundingBox();
Vec3i minP = Vec3i(bbox.min().x(), bbox.min().y(), bbox.min().z());
Vec3i maxP = Vec3i(bbox.max().x(), bbox.max().y(), bbox.max().z()) + 1;
Vec3f diag = Vec3f(maxP - minP);
float scale = 1.0f/diag.max();
diag *= scale;
Vec3f center = Vec3f(minP)*scale + Vec3f(diag.x(), 0.0f, diag.z())*0.5f;
std::cout << minP << " -> " << maxP << std::endl;
if (_integrationMethod == IntegrationMethod::ResidualRatio)
generateSuperGrid();
_transform = Mat4f::translate(-center)*Mat4f::scale(Vec3f(scale));
_invTransform = Mat4f::scale(Vec3f(1.0f/scale))*Mat4f::translate(center);
_bounds = Box3f(Vec3f(minP), Vec3f(maxP));
if (_sampleMethod == SampleMethod::ExactLinear || _integrationMethod == IntegrationMethod::ExactLinear) {
auto accessor = _grid->getAccessor();
for (openvdb::FloatGrid::ValueOnCIter iter = _grid->cbeginValueOn(); iter.test(); ++iter) {
if (*iter != 0.0f)
for (int z = -1; z <= 1; ++z)
for (int y = -1; y <= 1; ++y)
for (int x = -1; x <= 1; ++x)
accessor.setValueOn(iter.getCoord() + openvdb::Coord(x, y, z));
_bounds = Box3f(Vec3f(minP - 1), Vec3f(maxP + 1));
}
}
_invConfigTransform = _configTransform.invert();
}
示例9: cvtColor
Mat ColorDetect::process(const Mat& image)
{
Mat ImageLab=image.clone();
result.create(image.rows,image.cols,CV_8U);
//将image转换为Lab格式存储在ImageLab中
cvtColor(image,ImageLab,CV_BGR2Lab);
//将目标颜色由BGR转换为Lab
Mat temp(1,1,CV_8UC3);
temp.at<Vec3b>(0,0)=target;//创建了一张1*1的临时图像并用目标颜色填充
cvtColor(temp,temp,CV_BGR2Lab);
target=temp.at<Vec3b>(0,0);//再从临时图像的Lab格式中取出目标颜色
// 创建处理用的迭代器
Mat_<Vec3b>::iterator it=ImageLab.begin<Vec3b>();
Mat_<Vec3b>::iterator itend=ImageLab.end<Vec3b>();
Mat_<uchar>::iterator itout=result.begin<uchar>();
while(it!=itend)
{
//两个颜色值之间距离的计算
int dist=static_cast<int>(norm<int,3>(Vec3i((*it)[0]-target[0],
(*it)[1]-target[1],(*it)[2]-target[2])));
if(dist<minDist)
(*itout)=255;
else
(*itout)=0;
it++;
itout++;
}
return result;
}
示例10: Vec3f
Grid3dUtility::Grid3dUtility()
{
offset = Vec3f(0,0,0);
scale = Vec3f(0,0,0);
dimension = Vec3i(0,0,0);
h = 0.0;
}
示例11: Vec3i
void CudaGridMap::copyGridMapPadded(float *dst, const Vec3i &numGridPointsDst,
const float *src, const Vec3i &numGridPointsSrc,
cudaMemcpyKind kind)
{
Vec3i numGridPointsMin = Vec3i(Mathi::Min(numGridPointsDst.x, numGridPointsSrc.x),
Mathi::Min(numGridPointsDst.y, numGridPointsSrc.y),
Mathi::Min(numGridPointsDst.z, numGridPointsSrc.z));
int numGridPointsDstXMulY = numGridPointsDst.x * numGridPointsDst.y;
int numGridPointsSrcXMulY = numGridPointsSrc.x * numGridPointsSrc.y;
for (int z = 0; z < numGridPointsMin.z; z++)
{
// Set the base of output indices from z
int outputIndexZBaseDst = z * numGridPointsDstXMulY;
int outputIndexZBaseSrc = z * numGridPointsSrcXMulY;
for (int y = 0; y < numGridPointsMin.y; y++)
{
// Set the base of output indices from (z,y)
int outputIndexZYBaseDst = outputIndexZBaseDst + y * numGridPointsDst.x;
int outputIndexZYBaseSrc = outputIndexZBaseSrc + y * numGridPointsSrc.x;
// Copy one row in axis X
CUDA_SAFE_CALL(cudaMemcpyAsync(dst + outputIndexZYBaseDst, src + outputIndexZYBaseSrc, sizeof(float) * numGridPointsMin.x, kind, stream));
}
}
}
示例12: is
void CubeDocBase::loadMinText(const string& s)
{
istringstream is(s);
int fcn = 0, x, y, z, dr, sc, rt;
is >> fcn;
if (fcn == 0) {
cout << "unexpected fcn==0" << endl;
return;
}
OrderTemplate ort;
//vector<tuple<Vec3i, int>> faces;
for(int i = 0; i < fcn; ++i) {
is >> x >> y >> z >> dr;
if (!is.good()) {
cout << "unexpected end read faces " << i << endl;
return;
}
ort.faces.push_back(OrderTemplate::LoadedFace(Vec3i(x, y, z), (EPlane)dr));
}
vector<pair<int, int>> slv; // sc, dt
for(int i = 0; i < fcn; ++i) {
is >> sc;
if (!is.good()) {
cout << "unexpected end read solution " << i << endl;
return;
}
is >> rt; // avoid reporting error if reached end just after reading the number
slv.push_back(make_pair(sc, rt));
}
generateFromFaces(ort);
addSlvMin(slv);
}
示例13: Vec3i
void coordAsignDlg::init(std::vector<bone*> *boneFullArray, std::vector<bvhVoxel> *meshBoxFull)
{
s_boneFullArray = boneFullArray;
s_meshBoxFull = meshBoxFull;
coords.resize(s_meshBoxFull->size());
std::fill(coords.begin(), coords.end(), Vec3i(-1, -1, -1));
//
for (int i = 0; i < s_meshBoxFull->size(); i++)
{
boneComboBox.AddString((*s_meshBoxFull)[i].boneName);
}
comboMapX.AddString(_T("X"));
comboMapX.AddString(_T("Y"));
comboMapX.AddString(_T("Z"));
comboMapY.AddString(_T("X"));
comboMapY.AddString(_T("Y"));
comboMapY.AddString(_T("Z"));
boneComboBox.SetCurSel(0);
setCurBoneSlection(0);
}
示例14:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool BenchmarkPart5K::onInitialize()
{
PartCompoundGenerator gen;
gen.setPartDistribution(Vec3i(25, 20, 10));
gen.setUseShaders(true);
gen.setNumEffects(10);
gen.useRandomEffectAssignment(false);
gen.setExtent(Vec3f(3,3,3));
gen.setOrigin(Vec3f(-1.5f, -1.5f, -1.5f));
Collection<Part> parts;
gen.generateSpheres(22,23, &parts);
ref<ModelBasicList> myModel = new ModelBasicList;
size_t i;
for (i = 0; i < parts.size(); i++)
{
myModel->addPart(parts[i].p());
}
myModel->updateBoundingBoxesRecursive();
m_renderSequence->rendering(0)->scene()->addModel(myModel.p());
BoundingBox bb = myModel->boundingBox();
if (bb.isValid())
{
m_camera->fitView(bb, -Vec3d::Z_AXIS, Vec3d::Y_AXIS);
}
return true;
}
示例15: Vec3i
void GridUtility::get27Neighbors(std::vector<Vec3i>& neighbors, const Vec3i& p, const int radius) const
{
if(!isInside(p))
{
neighbors.clear();
return;
}
int kmin = std::max(p[2]-radius,0);
int kmax = std::min(p[2]+radius,dimension[2]-1);
int jmin = std::max(p[1]-radius,0);
int jmax = std::min(p[1]+radius,dimension[1]-1);
int imin = std::max(p[0]-radius,0);
int imax = std::min(p[0]+radius,dimension[0]-1);
int size = (kmax-kmin+1)*(jmax-jmin+1)*(imax-imin+1);
neighbors.resize(size);
int counter = 0;
for(int k = kmin; k<= kmax; ++k )
{
for(int j = jmin; j<= jmax; ++j )
{
for(int i = imin; i<= imax; ++i )
{
neighbors[counter] = Vec3i(i,j,k);
counter++;
}
}
}
}