hi i got this weird glitch when moving with easy cam, can someone explain me why i get that dark line when moving the sphere
what i’m doing is creating a particle and position each on the vertices of a sphere like this:
vertices = sphere.getMesh().getVertices();
for (int i = 0; i < vertices.size(); i++)
{
glm::vec3 v = vertices[i];
if(ofGetFrameNum() % 70 ==0){
Particle pTemp;
pTemp.pos = v +ofPoint(0,0,0);
p.push_back(pTemp);
}
}
Hi, I don’t think that it has to do with ofEasyCam. How are you rendering the particles? Do these have color, or mateerial or there is some lights in the scene? or do you have a shader?
Hi , i have neither yet .
here is my code :
.h
#include "ofMain.h"
class Particle{
public:
Particle(){
pos = ofPoint(ofGetWindowWidth()/2,ofGetWindowHeight()/2);
vel = glm::vec3(ofRandom(-1,1),ofRandom(-1,1),ofRandom(-1,1));
age = 0;
rotate =0;
}
void update(){
pos+= vel;
age++;
}
void draw(){
ofSetColor(ofColor::white);
ofDrawRectangle(pos,10,10);
}
glm::vec3 vel;
ofPoint pos;
int age;
float rotate;
};
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
//sphere
ofSpherePrimitive sphere;
//cam
ofEasyCam cam;
//particle call should improve later;
vector<Particle> p;
//save vertices // maybe not needed here
vector<glm::vec3> vertices;
};
.cpp
//--------------------------------------------------------------
void ofApp::setup(){
ofSetBackgroundColor(15);
ofSetVerticalSync(true);
sphere.set(700,12);
ambient.setAmbientColor(ofFloatColor(ofColor::white));
ambient.setPosition(0,0,0);
time = ofGetElapsedTimeMillis();
//basig ambirement set
// ofEnableBlendMode(OF_BLENDMODE_ADD);
ofEnableAntiAliasing();
// ofEnableArbTex();
ofEnableSmoothing();
ofEnableDepthTest();
}
//--------------------------------------------------------------
void ofApp::update(){
for (int i = 0; i < p.size(); i++)
{
p[i].update();
}
}
//--------------------------------------------------------------
void ofApp::draw(){
cam.begin();
for (int i = 0; i < p.size(); i++)
{
p[i].draw();
// if (p.size()>5000)
// {
// p.erase(p.end());
// }
}
cam.end();
vertices = sphere.getMesh().getVertices();
for (int i = 0; i < vertices.size(); i++)
{
glm::vec3 v = vertices[i];
if(ofGetFrameNum() % 70 ==0){
Particle pTemp;
pTemp.pos = v +ofPoint(0,0,0);
pTemp.rotate +=10;
p.push_back(pTemp);
}
}
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if (key == 'f')
{
ofSetFullscreen(true);
}
}
Hi, so it is not a glitch. It is totally fine. What’s going on is that you are rendering just some flat rectangles, and what you see as a dark line is because you are looking at those rectangles from its side so you dont see them and what you see is simply the background. If you zoom in you can notice it. Does it make sense?
Yeah it makes sense now
some how it look it odd
thanks @roymacdonald