本文整理汇总了C++中StelPainter::drawFromArray方法的典型用法代码示例。如果您正苦于以下问题:C++ StelPainter::drawFromArray方法的具体用法?C++ StelPainter::drawFromArray怎么用?C++ StelPainter::drawFromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StelPainter
的用法示例。
在下文中一共展示了StelPainter::drawFromArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawComa
void Comet::drawComa(StelCore* core, StelProjector::ModelViewTranformP transfo)
{
// Find rotation matrix from 0/0/1 to viewdirection! crossproduct for axis (normal vector), dotproduct for angle.
Vec3d eclposNrm=eclipticPos - core->getObserverHeliocentricEclipticPos() ; eclposNrm.normalize();
Mat4d comarot=Mat4d::rotation(Vec3d(0.0, 0.0, 1.0)^(eclposNrm), std::acos(Vec3d(0.0, 0.0, 1.0).dot(eclposNrm)) );
StelProjector::ModelViewTranformP transfo2 = transfo->clone();
transfo2->combine(comarot);
StelPainter* sPainter = new StelPainter(core->getProjection(transfo2));
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glDisable(GL_CULL_FACE);
// GZ: For the coma, we can use extinction via atmosphere.
// In addition, light falloff is a bit reduced for better visibility. Power basis should be 0.4, we use 0.6.
float minSkyMag=core->getSkyDrawer()->getLimitMagnitude();
float mag100pct=minSkyMag-6.0f; // should be 5, but let us draw it a bit brighter.
float magDrop=getVMagnitudeWithExtinction(core)-mag100pct;
float magFactor=std::pow(0.6f , magDrop);
magFactor=qMin(magFactor, 2.0f); // Limit excessively bright display.
comaTexture->bind();
sPainter->setColor(magFactor,magFactor,0.6f*magFactor);
sPainter->setArrays((Vec3d*)comaVertexArr.constData(), (Vec2f*)comaTexCoordArr.constData());
sPainter->drawFromArray(StelPainter::Triangles, comaVertexArr.size()/3);
glDisable(GL_BLEND);
if (sPainter)
delete sPainter;
sPainter=NULL;
}
示例2: draw
// returns true if visible
// Assumes that we are in local frame
void MeteorStream::draw(const StelCore* core, StelPainter& sPainter)
{
if(!alive)
return;
Vec3d spos = position;
Vec3d epos = posTrain;
// convert to equ
spos.transfo4d(viewMatrix);
epos.transfo4d(viewMatrix);
// convert to local and correct for earth radius
//[since equ and local coordinates in stellarium use same 0 point!]
spos = core->j2000ToAltAz(spos);
epos = core->j2000ToAltAz(epos);
spos[2] -= EARTH_RADIUS;
epos[2] -= EARTH_RADIUS;
// 1216 is to scale down under 1 for desktop version
spos/=1216;
epos/=1216;
// connect this point with last drawn point
double tmag = mag*distMultiplier;
QVector<Vec4f> colorArray;
QVector<Vec3d> vertexArray;
// last point - dark
colorArray.push_back(Vec4f(0,0,0,0));
vertexArray.push_back(epos);
// compute intermediate points to curve along projection distortions
int segments = 10;
for (int i=1; i<segments; i++) {
Vec3d posi = posInternal;
posi[2] = posTrain[2] + i*(position[2] - posTrain[2])/segments;
posi.transfo4d(viewMatrix);
posi = core->j2000ToAltAz(posi);
posi[2] -= EARTH_RADIUS;
posi/=1216;
colorArray.push_back(Vec4f(1,1,1,i*tmag/segments));
vertexArray.push_back(posi);
}
// first point - light
colorArray.push_back(Vec4f(1,1,1,tmag));
vertexArray.push_back(spos);
sPainter.setColorPointer(4, GL_FLOAT, colorArray.constData());
sPainter.setVertexPointer(3, GL_DOUBLE, vertexArray.constData());
sPainter.enableClientStates(true, false, true);
sPainter.drawFromArray(StelPainter::LineStrip, vertexArray.size(), 0, true);
sPainter.enableClientStates(false);
}
示例3: draw
// returns true if visible
// Assumes that we are in local frame
void Meteor::draw(const StelCore* core, StelPainter& sPainter)
{
if (!alive)
return;
const StelProjectorP proj = sPainter.getProjector();
Vec3d spos = position;
Vec3d epos = posTrain;
// convert to equ
spos.transfo4d(mmat);
epos.transfo4d(mmat);
// convert to local and correct for earth radius [since equ and local coordinates in stellarium use same 0 point!]
spos = core->equinoxEquToAltAz( spos );
epos = core->equinoxEquToAltAz( epos );
spos[2] -= EARTH_RADIUS;
epos[2] -= EARTH_RADIUS;
// 1216 is to scale down under 1 for desktop version
spos/=1216;
epos/=1216;
// qDebug("[%f %f %f] (%d, %d) (%d, %d)\n", position[0], position[1], position[2], (int)start[0], (int)start[1], (int)end[0], (int)end[1]);
if (train)
{
// connect this point with last drawn point
double tmag = mag*distMultiplier;
// compute an intermediate point so can curve slightly along projection distortions
Vec3d posi = posInternal;
posi[2] = position[2] + (posTrain[2] - position[2])/2;
posi.transfo4d(mmat);
posi = core->equinoxEquToAltAz( posi );
posi[2] -= EARTH_RADIUS;
posi/=1216;
// draw dark to light
Vec4f colorArray[3];
colorArray[0].set(0,0,0,0);
colorArray[1].set(1,1,1,tmag*0.5);
colorArray[2].set(1,1,1,tmag);
Vec3d vertexArray[3];
vertexArray[0]=epos;
vertexArray[1]=posi;
vertexArray[2]=spos;
sPainter.setColorPointer(4, GL_FLOAT, colorArray);
sPainter.setVertexPointer(3, GL_DOUBLE, vertexArray);
// TODO the crash doesn't appear when the last true is set to false
sPainter.enableClientStates(true, false, true);
sPainter.drawFromArray(StelPainter::LineStrip, 3, 0, true);
sPainter.enableClientStates(false);
}
else
{
sPainter.setPointSize(1.f);
Vec3d start;
proj->project(spos, start);
sPainter.drawPoint2d(start[0],start[1]);
}
train = 1;
}
示例4: drawTail
void Comet::drawTail(StelCore* core, StelProjector::ModelViewTranformP transfo, bool gas)
{
// Find rotation matrix from 0/0/1 to eclipticPosition: crossproduct for axis (normal vector), dotproduct for angle.
Vec3d eclposNrm=eclipticPos; eclposNrm.normalize();
Mat4d tailrot=Mat4d::rotation(Vec3d(0.0, 0.0, 1.0)^(eclposNrm), std::acos(Vec3d(0.0, 0.0, 1.0).dot(eclposNrm)) );
StelProjector::ModelViewTranformP transfo2 = transfo->clone();
transfo2->combine(tailrot);
if (!gas) {
CometOrbit* orbit=(CometOrbit*)userDataPtr;
Vec3d velocity=orbit->getVelocity(); // [AU/d]
// This was a try to rotate a straight parabola somewhat away from the antisolar direction.
//Mat4d dustTailRot=Mat4d::rotation(eclposNrm^(-velocity), 0.15f*std::acos(eclposNrm.dot(-velocity))); // GZ: This scale factor of 0.15 is empirical from photos of Halley and Hale-Bopp.
// The curved tail is curved towards positive X. We first rotate around the Z axis into a direction opposite of the motion vector, then again the antisolar rotation applies.
Mat4d dustTailRot=Mat4d::zrotation(atan2(velocity[1], velocity[0]) + M_PI);
transfo2->combine(dustTailRot);
// In addition, we let the dust tail already start with a light tilt.
Mat4d dustTailYrot=Mat4d::yrotation(5.0f*velocity.length()); // again, this is pretty ad-hoc, feel free to improve!
transfo2->combine(dustTailYrot);
}
StelPainter* sPainter = new StelPainter(core->getProjection(transfo2));
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glDisable(GL_CULL_FACE);
// GZ: If we use getVMagnitudeWithExtinction(), a head extincted in the horizon mist can completely hide an otherwise frighteningly long tail.
// we must use unextincted mag, but mix/dim with atmosphere/sky brightness.
// In addition, light falloff is a bit reduced for better visibility. Power basis should be 0.4, we use 0.6.
//float magfactor=std::pow(0.4f , getVMagnitudeWithExtinction(core));
float magFactor=std::pow(0.6f , getVMagnitude(core));
if (core->getSkyDrawer()->getFlagHasAtmosphere())
{
// Mix with sky brightness and light pollution: This is very ad-hoc, if someone finds a better solution, please go ahead!
// Light pollution:
float bortleIndexFactor=0.1f * (11 - core->getSkyDrawer()->getBortleScaleIndex());
magFactor*= bortleIndexFactor*bortleIndexFactor; // GZ-Guesstimate for light pollution influence
// sky brightness: This is about 10 for twilight where bright comet tails should already be visible. Dark night is close to 0.
float avgAtmLum=GETSTELMODULE(LandscapeMgr)->getAtmosphereAverageLuminance();
float atmLumFactor=(15.0f-avgAtmLum)/15.0f; if (atmLumFactor<0.05f) atmLumFactor=0.05f; //atmLumFactor=std::sqrt(atmLumFactor);
magFactor*=atmLumFactor*atmLumFactor;
}
magFactor*=(gas? 0.9 : dustTailBrightnessFactor); // TBD: empirical adjustment for texture brightness.
magFactor=qMin(magFactor, 1.05f); // Limit excessively bright display.
gasTailTexture->bind();
if (gas) {
//gasTailTexture->bind();
sPainter->setColor(0.15f*magFactor,0.15f*magFactor,0.6f*magFactor);
sPainter->setArrays((Vec3d*)gastailVertexArr.constData(), (Vec2f*)gastailTexCoordArr.constData());
sPainter->drawFromArray(StelPainter::Triangles, gastailIndices.size(), 0, true, gastailIndices.constData());
} else {
//dustTailTexture->bind();
sPainter->setColor(magFactor, magFactor,0.6f*magFactor);
//sPainter->setArrays((Vec3d*)dusttailVertexArr.constData(), (Vec2f*)dusttailTexCoordArr.constData());
//sPainter->drawFromArray(StelPainter::Triangles, dusttailIndices.size(), 0, true, dusttailIndices.constData());
sPainter->setArrays((Vec3d*)dusttailVertexArr.constData(), (Vec2f*)gastailTexCoordArr.constData());
sPainter->drawFromArray(StelPainter::Triangles, gastailIndices.size(), 0, true, gastailIndices.constData());
}
glDisable(GL_BLEND);
if (sPainter)
delete sPainter;
sPainter=NULL;
}