本文整理汇总了C++中MyVector::GetY方法的典型用法代码示例。如果您正苦于以下问题:C++ MyVector::GetY方法的具体用法?C++ MyVector::GetY怎么用?C++ MyVector::GetY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyVector
的用法示例。
在下文中一共展示了MyVector::GetY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddEdgeToList
/**********************************************************
*
* AddEdgeToList
*
* parameters IN:
* VertexCell * vertex1
* VertexCell * vertex2
*
*********************************************************/
void AddEdgeToList (VertexCell * vertex1, VertexCell * vertex2)
{
VertexCell * tempVertex;
MyVector dw;
EdgeBox * edgeBox;
if (vertex1->screenPos.GetY() > vertex2->screenPos.GetY()) {
tempVertex = vertex1;
vertex1 = vertex2;
vertex2 = tempVertex;
}
int y1 = vertex1->screenPos.GetY();
int y2 = vertex2->screenPos.GetY();
if (y1 != y2) {
int dy = y2 - y1;
double currX = vertex1->screenPos.GetX();
double currZ = vertex1->screenPos.GetZ();
double currI = lightVector.DotProduct (vertex1->vertexNormal);
MyVector currW = vertex1->worldPos;
double dx = (vertex2->screenPos.GetX() - currX) / dy;
double dz = (vertex2->screenPos.GetZ() - currZ) / dy;
double di = (lightVector.DotProduct (vertex2->vertexNormal) - currI) / dy;
dw.SetX( (vertex2->worldPos.GetX() - currW.GetX()) / dy);
dw.SetY( (vertex2->worldPos.GetY() - currW.GetY()) / dy);
dw.SetZ( (vertex2->worldPos.GetZ() - currW.GetZ()) / dy);
for (int y = y1; y <= y2 - 1; y++) {
edgeBox = new EdgeBox;
edgeBox->x = currX;
edgeBox->z = (int)currZ;
edgeBox->i = currI;
edgeBox->w = currW;
edgeBox->next = edgeListAt[y];
edgeListAt[y] = edgeBox;
currX += dx;
currZ += dz;
currI += di;
currW.SetX( currW.GetX() + dw.GetX());
currW.SetY( currW.GetY() + dw.GetY());
currW.SetZ( currW.GetZ() + dw.GetZ());
}
}
}
示例2: RenderSpan
/**********************************************************
*
* RenderSpan
*
* parameters IN:
* int y
* EdgeBox ** edgeBox1
* EdgeBox ** edgeBox2
*
*********************************************************/
void RenderSpan (int y, EdgeBox ** edgeBox1, EdgeBox ** edgeBox2)
{
EdgeBox * tempEdgeBox;
int x, z;
double dz, di;
MyVector dw;
if ((*edgeBox1)->x > (*edgeBox2)->x) {
tempEdgeBox = *edgeBox1;
*edgeBox1 = *edgeBox2;
*edgeBox2 = tempEdgeBox;
}
int x1 = (int)(*edgeBox1)->x;
int x2 = (int)(*edgeBox2)->x;
if (x1 != x2) {
int dx = x2 - x1;
double currZ = (*edgeBox1)->z;
double currI = (*edgeBox1)->i;
MyVector currW = (*edgeBox1)->w;
dz = ((*edgeBox2)->z - currZ) / dx;
di = ((*edgeBox2)->i - currI) / dx;
dw.SetX( ((*edgeBox2)->w.GetX() - currW.GetX()) / dx);
dw.SetY( ((*edgeBox2)->w.GetY() - currW.GetY()) / dx);
dw.SetZ( ((*edgeBox2)->w.GetZ() - currW.GetZ()) / dx);
for (x = x1; x <= x2 - 1; x++) {
z = (int)currZ;
if (z < zBufferAt[x][y]) {
zBufferAt[x][y] = z;
RenderPixel (x, y, currI, currW);
}
currZ += dz;
currI += di;
currW.SetX( currW.GetX() + dw.GetX());
currW.SetY( currW.GetY() + dw.GetY());
currW.SetZ( currW.GetZ() + dw.GetZ());
}
}
}
示例3: woodGrain
/**********************************************************
*
* woodGrain
*
* parameters IN:
* MyVector w
*
* return value : double
*
*********************************************************/
double woodGrain (MyVector w)
{
double ang;
double rad = sqrt (w.GetX() * w.GetX() + w.GetZ() * w.GetZ());
if (w.GetZ() == 0) {
ang = Util::PI() / 2.;
} else {
ang = arcTangent (w.GetX(), w.GetZ());
}
rad += 2. * sin (20. * ang + w.GetY() / 150.);
int grain = (int)fmod(rad, 60); // return remainder
if (grain < 30) {
return 1.4;
} else {
return 0.25;
}
}