本文整理汇总了C++中ColorNode::getColor方法的典型用法代码示例。如果您正苦于以下问题:C++ ColorNode::getColor方法的具体用法?C++ ColorNode::getColor怎么用?C++ ColorNode::getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColorNode
的用法示例。
在下文中一共展示了ColorNode::getColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawIdxLineSet
static void DrawIdxLineSet(IndexedLineSetNode *idxLineSet)
{
CoordinateNode *coordinate = idxLineSet->getCoordinateNodes();
if (!coordinate)
return;
NormalNode *normal = idxLineSet->getNormalNodes();
ColorNode *color = idxLineSet->getColorNodes();
int bColorPerVertex =idxLineSet->getColorPerVertex();
bool bLineBegin = true;
bool bLineClose = true;
int nLine = 0;
float vpoint[3];
float pcolor[3];
glColor3f(1.0f, 1.0f, 1.0f);
int nCoordIndexes = idxLineSet->getNCoordIndexes();
for (int nCoordIndex=0; nCoordIndex<nCoordIndexes; nCoordIndex++) {
int coordIndex = idxLineSet->getCoordIndex(nCoordIndex);
if (bLineBegin) {
glBegin(GL_LINE_STRIP);
bLineBegin = false;
bLineClose = false;
if (color && !bColorPerVertex) {
color->getColor(nLine, pcolor);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pcolor);
// glColor3fv(pcolor);
}
nLine++;
}
if (coordIndex != -1) {
coordinate->getPoint(coordIndex, vpoint);
glVertex3fv(vpoint);
if (color && bColorPerVertex) {
color->getColor(coordIndex, pcolor);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pcolor);
// glColor3fv(pcolor);
}
}
else {
glEnd();
bLineBegin = true;
bLineClose = true;
}
}
if (bLineClose == false)
glEnd();
}
示例2: DrawPointSet
static void DrawPointSet(PointSetNode *pointSet)
{
CoordinateNode *coordinate = pointSet->getCoordinateNodes();
if (!coordinate)
return;
NormalNode *normal = pointSet->getNormalNodes();
ColorNode *color = pointSet->getColorNodes();
float vpoint[3];
float pcolor[3];
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_POINTS);
int nCoordinatePoint = coordinate->getNPoints();
for (int n=0; n<nCoordinatePoint; n++) {
if (color) {
color->getColor(n, pcolor);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pcolor);
// glColor3fv(pcolor);
}
coordinate->getPoint(n, vpoint);
glVertex3fv(vpoint);
}
glEnd();
}
示例3: DrawIdxFaceSet
static void DrawIdxFaceSet(IndexedFaceSetNode *idxFaceSet)
{
CoordinateNode *coordinateNode = idxFaceSet->getCoordinateNodes();
if (!coordinateNode)
return;
TextureCoordinateNode *texCoordNode = idxFaceSet->getTextureCoordinateNodes();
NormalNode *normalNode = idxFaceSet->getNormalNodes();
ColorNode *colorNode = idxFaceSet->getColorNodes();
bool colorPerVertex =idxFaceSet->getColorPerVertex();
bool normalPerVertex =idxFaceSet->getNormalPerVertex();
bool ccw = idxFaceSet->getCCW();
if (ccw == true)
glFrontFace(GL_CCW);
else
glFrontFace(GL_CW);
bool solid = idxFaceSet->getSolid();
if (solid == false)
glDisable(GL_CULL_FACE);
else
glEnable(GL_CULL_FACE);
bool convex = idxFaceSet->getConvex();
GLUtriangulatorObj *tessObj = NULL;
if (convex == false) {
tessObj = gluNewTess();
gluTessCallback(tessObj, GLU_BEGIN, (GLUtessCallBackFunc)glBegin);
gluTessCallback(tessObj, GLU_VERTEX, (GLUtessCallBackFunc)glVertex3dv);
gluTessCallback(tessObj, GLU_END, (GLUtessCallBackFunc)glEnd);
}
bool bPolygonBegin = true;
bool bPolygonClose = true;
int nPolygon = 0;
int nVertex = 0;
float point[3];
float vector[3];
float color[4]; color[3] = 1.0f;
float coord[2];
double (*tessPoint)[3];
if ((idxFaceSet->getColorPerVertex() && idxFaceSet->getColorNodes()) || (idxFaceSet->getNormalPerVertex() && idxFaceSet->getNormalNodes()))
glShadeModel (GL_SMOOTH);
else
glShadeModel (GL_FLAT);
int nColorIndexes = idxFaceSet->getNColorIndexes();
int nNormalIndexes = idxFaceSet->getNNormalIndexes();
int nTexCoordIndexes = idxFaceSet->getNTexCoordIndexes();
int nCoordIndexes = idxFaceSet->getNCoordIndexes();
for (int nCoordIndex=0; nCoordIndex<nCoordIndexes; nCoordIndex++) {
int coordIndex = idxFaceSet->getCoordIndex(nCoordIndex);
if (bPolygonBegin) {
if (convex == false)
gluBeginPolygon(tessObj);
else
glBegin(GL_POLYGON);
bPolygonBegin = false;
bPolygonClose = false;
int nVertices = 0;
int index = coordIndex;
while (index != -1) {
nVertices++;
int nIndex = nCoordIndex + nVertices;
if (nIndex < nCoordIndexes)
index = idxFaceSet->getCoordIndex(nIndex);
else
break;
}
if (convex == false)
tessPoint = new double[nVertices][3];
// dafault color
//glColor3f(1.0f, 1.0f, 1.0f);
// default normal
if ((nCoordIndex + 2) < nCoordIndexes) {
float point[3][3];
float normal[3];
for (int n=0; n<3; n++) {
int index = idxFaceSet->getCoordIndex(nCoordIndex+n);
coordinateNode->getPoint(index, point[n]);
}
GetNormalFromVertices(point, normal);
glNormal3fv(normal);
}
//.........这里部分代码省略.........
示例4: DrawElevationGrid
static void DrawElevationGrid(ElevationGridNode *eg)
{
int xDimension = eg->getXDimension();
int zDimension = eg->getZDimension();
int nPoints = xDimension * zDimension;
float xSpacing = eg->getXSpacing();
float zSpacing = eg->getZSpacing();
int x, z;
SFVec3f *point = new SFVec3f[nPoints];
for (x=0; x<xDimension; x++) {
for (z=0; z<zDimension; z++) {
float xpos = xSpacing * x;
float ypos = eg->getHeight(x + z*zDimension);
float zpos = zSpacing * z;
point[x + z*xDimension].setValue(xpos, ypos, zpos);
}
}
ColorNode *color = eg->getColorNodes();
NormalNode *normal = eg->getNormalNodes();
TextureCoordinateNode *texCoord = eg->getTextureCoordinateNodes();
bool bColorPerVertex = eg->getColorPerVertex();
bool bNormalPerVertex = eg->getNormalPerVertex();
bool ccw = eg->getCCW();
if (ccw == true)
glFrontFace(GL_CCW);
else
glFrontFace(GL_CW);
bool solid = eg->getSolid();
if (solid == false)
glDisable(GL_CULL_FACE);
else
glEnable(GL_CULL_FACE);
glNormal3f(0.0f, 1.0f, 0.0f);
for (x=0; x<xDimension-1; x++) {
for (z=0; z<zDimension-1; z++) {
int n;
if (bColorPerVertex == false && color) {
float egColor[4]; egColor[3] = 1.0f;
color->getColor(x + z*zDimension, egColor);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, egColor);
// glColor3fv(egColor);
}
if (bNormalPerVertex == false && normal) {
float egNormal[3];
normal->getVector(x + z*zDimension, egNormal);
glNormal3fv(egNormal);
}
float egPoint[4][3];
float egColor[4][4];
float egNormal[4][3];
float egTexCoord[4][2];
egColor[0][3] = egColor[1][3] = egColor[2][3] = egColor[3][3] = 1.0f;
for (n=0; n<4; n++) {
int xIndex = x + ((n < 2) ? 0 : 1);
int zIndex = z + (n%2);
int index = xIndex + zIndex*xDimension;
if (bColorPerVertex == true && color)
color->getColor(index, egColor[n]);
if (bNormalPerVertex == true && normal)
normal->getVector(index, egNormal[n]);
if (texCoord)
texCoord->getPoint(index, egTexCoord[n]);
else {
egTexCoord[n][0] = (float)xIndex / (float)(xDimension-1);
egTexCoord[n][1] = (float)zIndex / (float)(zDimension-1);
}
point[index].getValue(egPoint[n]);
}
glBegin(GL_POLYGON);
// Tanks for Joerg Scheurich aka MUFTI
if (!normal) {
float point[3][3];
float normal[3];
for (n=0; n<3; n++)
memcpy(point[n] , egPoint[n], sizeof(float)*3);
GetNormalFromVertices(point, normal);
glNormal3fv(normal);
}
for (n=0; n<3; n++) {
if (bColorPerVertex == true && color) {
//.........这里部分代码省略.........