本文整理汇总了C++中Pixel::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixel::getPosition方法的具体用法?C++ Pixel::getPosition怎么用?C++ Pixel::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixel
的用法示例。
在下文中一共展示了Pixel::getPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void ServerClientProxy::draw(float x, float y, float w, float h){ //not used anymore since Clients do not render on the server UI
if(drawEnabled){
glViewport(x, ofGetHeight()-y-h, w-1, h-1);
// all the matrix setup is copied from the ofGraphics.cpp::void ofSetupScreen() method.
float halfFov, theTan, screenFov, aspect;
screenFov = 60.0f;
float eyeX = (float)w / 2.0;
float eyeY = (float)h / 2.0;
halfFov = PI * screenFov / 360.0;
theTan = tanf(halfFov);
float dist = eyeY / theTan;
float nearDist = dist / 10.0; // near / far clip plane
float farDist = dist * 10.0;
aspect = (float)w/(float)h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(screenFov, aspect, nearDist, farDist);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyeX, eyeY, dist, eyeX, eyeY, 0.0, 0.0, 1.0, 0.0);
glClear(GL_DEPTH_BUFFER_BIT);
glScalef(1, -1, 1); // invert Y axis so increasing Y goes down.
glTranslatef(10, -y-h+10, 0); // shift origin up to upper-left corner.
// draw the pixels
//ofTranslate(translation.x, translation.y, translation.z);
ofTranslate(centroid.x, centroid.y, centroid.z);
ofRotateX(this->rotX);
ofRotateZ(this->rotY);
ofTranslate(-centroid.x, -centroid.y, -centroid.z);
glScalef(scale, scale, scale);
vector<Pixel*>::iterator it = this->pixelsFast.begin();
while (it!=this->pixelsFast.end())
{
Pixel* px = *it;
ofVec3f position = px->getPosition();
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
ofSetColor(px->getR(),px->getG(), px->getB());
glCallList(this->displayList);
glPopMatrix();
it++;
}
// reset viewport back to main screen
glFlush();
}
}
示例2: drawPixel
void Screen::drawPixel(Pixel pixel) {
Point position = (pixel.getPosition());
if (position.x>= width || position.x < 0 || position.y >=height || position.y <0 )
return;
int location = (position.x+vinfo.xoffset) * (vinfo.bits_per_pixel/8)
+ (position.y+vinfo.yoffset) * finfo.line_length;
Color color = (pixel.getColor());
*(pseudoFrame+location) = color.blue;
*(pseudoFrame+location+1) = color.green;
*(pseudoFrame+location+2) = color.red;
*(pseudoFrame+location+3) = color.alpha;
}
示例3: updateParticulas
void Recuerdo::updateParticulas(double tiempoSeg, double tiempoMil){
// a que recuerdo llamo con tiempo en segundo.
bool* pixelBool = new bool[(int)this->pixels->size()];
std::fill_n( pixelBool, (int)this->pixels->size(), 0 );
vector<Particula*>::iterator it = this->particulas->begin();
vector<Pixel*>::iterator itpixels;
Pixel *pixel;
Particula* particula;
Punto *ptoAnt = NULL;
Punto *ptoSig = NULL;
Punto *ptoAct = NULL;
long a;// = ofGetElapsedTimeMillis() % 1000;
bool recTienePar=false;
while (it!=this->particulas->end())
{
particula = *it;
// a = fmod(tiempoMil,particula->frecuencia);
a = fmod(tiempoMil - (particula->tiempoini),particula->frecuencia );//+ particula->tiempoini*1000;
itpixels = pixels->begin();
//if (particula->tiempoini <= tiempoSeg && particula->tiempofin >= tiempoSeg){
if (particula->tiempoini <= tiempoMil && particula->tiempofin >= tiempoMil){
ptoAnt = anterior(particula, a);
ptoSig = siguiente(particula,a);
if (ptoAnt != NULL && ptoSig != NULL){
ptoAct = ptoActual(ptoAnt,ptoSig,a);
//Gonzalo
//ptoAct->draw(ptoAct);
//ofPushMatrix();
//particula->draw(ptoAct);
//ofPopMatrix();
cout << particula->id;
while (itpixels != pixels->end()){
pixel = *itpixels;
ofVec3f pos = pixel->getPosition();
int dis = sqrt((pos.x - ptoAct->x)*(pos.x - ptoAct->x) + (pos.z - ptoAct->z)* (pos.z - ptoAct->z));
if (dis <= ptoAct->intensidad){
//Aca va el decaimiento del color
ofVec3f colores(ptoAct->r, ptoAct->g,ptoAct->b);
ofVec3f retColores = decaimiento (colores,dis,ptoAct->intensidad);
pixel->blendRGBA(retColores.x, retColores.y, retColores.z,0,0.4f);
//pixel->blendRGBA(ptoAct->r,ptoAct->g,ptoAct->b,0,0.4f);
pixelBool[(int)pixel->getId()] = true;
}
itpixels++;
}
}
}
it++;
}// Busco
itpixels = pixels->begin();
if (recTienePar) {
while (itpixels != pixels->end()){
Pixel* px = *itpixels;
if (!pixelBool[(int)px->getId()]){
px->blendRGBA(0, 0, 0, 255, 0.4f);
}
itpixels++;
}
}
delete[] pixelBool;
this->draw();
};
示例4: transmitFrame
void GenericClientManager::transmitFrame() {
//construyo DTFrame en base a los pixels mezclados
if(this->waitForReceiver==0) { // envio solo si el server no me pidio esperarpor error
vector<DTPixel*>* newVector = new vector<DTPixel*>;
map<int,Pixel*>::iterator it = this->pixels->begin();
while (it!=this->pixels->end())
{
Pixel* px = it->second;
ofVec3f position = px->getPosition();
ofVec3f front = px->getFront();
ofVec3f up = px->getUp();
string modelName = px->getModelName();
DTPixel* dtPix = new DTPixel(px->getId(), px->getR(), px->getG(), px->getB(), px->getA(), position.x, position.y, position.z, front, up, modelName);
newVector->push_back(dtPix);
it++;
}
DTFrame * newFrame = new DTFrame(0, newVector, this->pixels->size() , this->sequenceNumber);
// slice the DTFrame and transmit by piece.
int pixelQuantity = newVector->size();
int minId=0;
int maxId=pixelQuantity-1;
while(pixelQuantity>0) {
celebra_packet_t toTransmit;
int headerSize =18;
if (pixelQuantity<=341) {
toTransmit=newFrame->getBinaryPacketFromFrame(minId, maxId, this->sequenceNumber, 1);
int sent = this->udpManager.SendAll((char *)&toTransmit, headerSize+((maxId-minId+1)*3));
pixelQuantity=0;
}
else {
toTransmit=newFrame->getBinaryPacketFromFrame(minId, minId+340, this->sequenceNumber, 0);
int sent = this->udpManager.SendAll((char *)&toTransmit, headerSize+(341*3));
pixelQuantity=pixelQuantity-341;
minId = minId + 341;
}
// must increment sequence number.
if (this->sequenceNumber==65535) {
this->sequenceNumber=0;
}
else {
this->sequenceNumber++;
}
}
delete newFrame;
}
else {
this->waitForReceiver-=1;
}
}