本文整理汇总了C++中ofVec2f::dot方法的典型用法代码示例。如果您正苦于以下问题:C++ ofVec2f::dot方法的具体用法?C++ ofVec2f::dot怎么用?C++ ofVec2f::dot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofVec2f
的用法示例。
在下文中一共展示了ofVec2f::dot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: waterFlowErosion
void WaterErosion::waterFlowErosion(int x, int y, ofVec2f directionVector, float water, float sediments, float lastSlope)
{
if ((x >= 0 && x < width) && (y >= 0 && y < height))
{
int aValue = flowMap.getPixels()[(y * width + x) * 4 + 3];
int bValue = flowMap.getPixels()[(y * width + x) * 4 + 2];
int gValue = flowMap.getPixels()[(y * width + x) * 4 + 1];
int rValue = flowMap.getPixels()[(y * width + x) * 4 + 0];
int hValue = heightMap.getPixels()[y * width + x];
ofVec2f newDir;
int slope = water ;
int step = 0;
int radius = 1;
for (int fy = -radius; fy <= radius; fy++) {
for (int fx = -radius; fx <= radius; fx++)
{
if (fy != 0 || fx != 0)
{
int nY = y + fy;
int nX = x + fx;
if ((nX >= 0 && nX < width) && (nY >= 0 && nY < height))
{
int localCell = heightMap.getPixels()[nY * width + nX];
int localSlope = localCell - hValue;
if (localSlope < slope)
{
ofVec2f localDir = ofVec2f(fx, fy);
float theDot = directionVector.dot(localDir);
if (lastSlope > -2) {
if (theDot > -0.1 && theDot < 1 && aValue != 0)
{
slope = localSlope;
newDir = ofVec2f(fx, fy);
}
}
else {
if (theDot >= 0 && aValue != 0)
{
slope = localSlope;
newDir = ofVec2f(fx, fy);
step = (localSlope > 0) ? localSlope : 0;
}
}
}
}
else {
return;
}
}
}
}
if (newDir != ofVec2f(0, 0))
{
flowMap.getPixels()[(y * width + x) * 4 + 3] = 0;
int tmpSlope = slope;
if (water > 0)
{
int step = slope;
if (slope >= 0)
{
if (rValue > 0)
{
water += rValue;
flowMap.getPixels()[(y * width + x) * 4 + 0] = 0;
}
water = water - slope;
slope = -water;
}
float saturation = sediments / water;
float force = water + abs(slope * 0.66 + lastSlope * 0.34 );
if (slope <= lastSlope && saturation < water/8.0f)
{
float carryingCap = (water * maxSaturation - saturation) / (water * maxSaturation);
float amount = (carryingCap > 0) ? (carryingCap * abs(force) ) * removeSoil: 0;
if (amount < 0) {
amount = 0;
}
else if (amount > 3) {
amount = 3;
}
//.........这里部分代码省略.........