Esempio n. 1
0
Point *BiGraph::getPoint(unsigned int i)
{
		if (i >= point.size() || i<0 || getPointSize() == 0)
			return NULL;
		return &point.at(i);
	
};
Esempio n. 2
0
void DotTool::mouseDown(struct point2f p) {
	Tool::mouseDown(p);
	dots = new Dots();
	dots->setColor(getColor());
	dots->setPointSize(getPointSize());
	dots->addPoint(p.x, p.y);
	notifyIntermediatePaintableCreated(dots);
}
void ofxRParticleRenderer::draw()
{
    activateBlending(); 
    glPointSize(getPointSize());
    glBegin(GL_POINTS);
    vector<ofxRParticle *>::iterator it = (*particles).begin();
    vector<ofxRParticle *>::iterator eit = (*particles).end();
    for(; it != eit; ++it)
    {
        ofxRParticle *p = (*it);
        ofVec3f &pos = p->getPos();
        ofColor &clr = p->getColor();
        ofSetColor(clr);
        glNormal3f(p->getRadius()*(getPointSize())*10.0,0,0);
        glVertex3fv(pos.getPtr());
    }
    glEnd();
}
Esempio n. 4
0
	void ZMeshFilterManifold::updateRange()
	{
		output_.fill(0);
		for (int i=0; i<wki_Psi_blurs_.size(); i++)
		{
			float weight = rangeWeights_[i];
			output_.block(0, getSpatialDim(), getPointSize(), getRangeDim()) += wki_Psi_blurs_[i]*weight;
		}
	}
Esempio n. 5
0
void renderStrokeText(RenderingContext* rctx, const char* text, const XV3& position, const XV3& scale, float thickness, float color[4])
{
	rctx->shaderMan->UseStockShader(GLT_SHADER_IDENTITY, color);
	if (glUseShaderProgramEXT) {
		// glUseProgram does not work sometimes. I don't know why.
		glUseShaderProgramEXT(GL_VERTEX_SHADER, 0);
	} else {
		glUseProgram(0);
	}
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(position.X, position.Y, position.Z);
	glScalef(scale.X, scale.Y, scale.Z);
	glLineWidth(getPointSize() * thickness);
	glPointSize(getPointSize() * thickness);
	for (const char* p = text; *p; p++) {
		glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
	}
	glPopMatrix();
}
Esempio n. 6
0
float ofxTextObject::getWidth()
{    
    int   currentWordID;
    
    float currX = 0.0f;
    float maxWidth  = 0.0f;
    
    if (words.size() > 0) {
        
        for(int l=0;l < lines.size(); l++)
        {
            for(int w=0;w < lines[l].wordsID.size(); w++)
            {
                currentWordID = lines[l].wordsID[w];
                currX += words[currentWordID].width;
            }
            maxWidth = MAX(maxWidth, currX);
            currX = 0.0f;
        }
        //return maxWidth * scale;
		return maxWidth/getPointSize();	
    }
    else return 0;
}
Esempio n. 7
0
void UltraEyeRenderer::drawHenshinInstruction()
{
	XuSkeletonJointInfo jrh, jh, jre;
	m_henshinDetector->getUserDetector()->getSkeletonJointInfo(XU_SKEL_RIGHT_HAND, &jrh);
	m_henshinDetector->getUserDetector()->getSkeletonJointInfo(XU_SKEL_HEAD, &jh);
	m_henshinDetector->getUserDetector()->getSkeletonJointInfo(XU_SKEL_RIGHT_ELBOW, &jre);

	if (!isConfident(jrh) || !isConfident(jh) || !isConfident(jre)) return;

	const float CIRCLE_RADIUS = 100;

	XV3 fv(m_henshinDetector->getUserDetector()->getForwardVector());
	XV3 uv(m_henshinDetector->getUserDetector()->getUpVector());
	XV3 armDirection((jrh.position - jre.position).normalize());
	XV3 adjustedRightHand(jrh.position + armDirection * 30); // slightly move to the fingertip side
	XV3 adjustedHead(jh.position + fv * 100); // slightly move forward
	XV3 arrowTip(adjustedRightHand.interpolate(adjustedHead, 0.95f));
	XV3 arrowBottom(adjustedRightHand.interpolate(adjustedHead, 0.0f));
	float len = (arrowTip - arrowBottom).magnitude();
	XV3 triangleBottom(arrowBottom.interpolate(arrowTip, 0.8f));
	XV3 triangleOpening = (arrowTip - arrowBottom).cross(armDirection).normalize() * len * 0.1f;
	XV3 arrowPlaneNorm = (arrowTip - arrowBottom).cross(triangleOpening).normalize();
	XV3 triangleEnd1(triangleBottom + triangleOpening);
	XV3 triangleEnd2(triangleBottom - triangleOpening);

	float maxAlpha = cramp((len - 50.0f) / 150.0f, 0, 1);
	float blinkSpeed = 1000.0f / std::max(len - 100.0f, 100.f);
	m_phase += m_ticker.tick() * blinkSpeed;
	float alpha = square(std::sin(m_phase)) * maxAlpha;

	M3DVector4f arrowColor = { 0.7f, 0.0f, 0.0f, alpha };
	m_rctx->shaderMan->UseStockShader(GLT_SHADER_FLAT, m_rctx->transform.GetModelViewProjectionMatrix(), arrowColor);

	const float THICKNESS = 2;
	glDisable(GL_DEPTH_TEST);
	glLineWidth(getPointSize() * THICKNESS);
	glPointSize(getPointSize() * THICKNESS);

	glBegin(GL_LINES);
	if (len > CIRCLE_RADIUS) {
		glVertex3fv(XV3toM3D(arrowBottom + (arrowTip - arrowBottom).normalize() * CIRCLE_RADIUS));
		glVertex3fv(XV3toM3D(arrowTip));
	}
	glVertex3fv(XV3toM3D(arrowTip));
	glVertex3fv(XV3toM3D(triangleEnd1));
	glVertex3fv(XV3toM3D(arrowTip));
	glVertex3fv(XV3toM3D(triangleEnd2));
	glEnd();

	glBegin(GL_LINE_LOOP);
	XV3 r0((arrowTip - arrowBottom).normalize() * CIRCLE_RADIUS);
	GLFrame f;
	f.SetForwardVector(0, 0, 1); // invert Z
	const int SEGMENTS = 24;
	const float STEP_ANGLE = float(M_PI * 2 / SEGMENTS);
	for (int i = 0; i < SEGMENTS; i++) {
		f.RotateLocal(STEP_ANGLE, arrowPlaneNorm.X, arrowPlaneNorm.Y, arrowPlaneNorm.Z);
		M3DVector3f r;
		f.TransformPoint(XV3toM3D(r0), r);
		glVertex3fv(XV3toM3D(arrowBottom + r));
	}
	glEnd();

	if (m_isNewUser) {
		XV3 p(-0.95f, 0.80f, 0.0f), s(0.001f, 0.0015f, 1.0f);
		renderStrokeText(m_rctx, "Put your Ultra Eye On! Now!", p, s, 3.0f, arrowColor);
	}

	glEnable(GL_DEPTH_TEST);
}
Esempio n. 8
0
 void changePointSize(float delta)
 {
     setPointSize(getPointSize()+delta);
 }
void PointsEventHandler::changePointSize(float delta)
{
    setPointSize(getPointSize() + delta);
}
Esempio n. 10
0
void WorldRenderer::drawBackground()
{
	m_rctx->orthoMatrix.PushMatrix();
	{
		//TODO: find out what this does
		//m_rctx->orthoMatrix.Translate(
		//	float(m_rng.gaussian(0.6)) * currentIntensity * 0.01f,
		//	float(m_rng.gaussian(0.6)) * currentIntensity * 0.01f,
		//	0);

		// setup shader
		m_rctx->shaderMan->UseStockShader(GLT_SHADER_SHADED, m_rctx->orthoMatrix.GetMatrix());

		// get depth buffer
		DepthMetaData dmd;
		m_depthGen->GetMetaData(dmd);
		const XnDepthPixel* dp = dmd.Data();

		// get image buffer
		ImageMetaData imd;
		m_imageGen->GetMetaData(imd);
		const XnRGB24Pixel* ip = imd.RGB24Data();

		// get working buffers
		M3DVector3f* vp = m_vertexBuf;
		M3DVector4f* cp = m_colorBuf;
		XnUInt32 numPoints = getNumPoints();

		// setup henshin-related information
		const float Z_SCALE = 10.0f;
		XnUserID userID = 0;
		const XnLabel* lp = NULL;
		XV3 headCenter, headDirection;
		getHenshinData(&userID, &lp, &headCenter, &headDirection);

		float lightRadius = 900.0f;

		bool isTracked = userID && lp;

		const int NUM_BALLS = 3;
		XV3 ball_centers[NUM_BALLS];
		bool ball_enabled_flags[NUM_BALLS];

		float ball_radius[3];
		float ball_core_radius[3];
		float ball_core_radius2[3];

		//get the ball centres and transform into projective coords
		//Also calculate an appropriate radius to make the ball scale as it moves away from the camera
		for (int j=0; j< NUM_BALLS; j++) {
			 m_ball_manager->GetBallInfo(j, &ball_enabled_flags[j],&ball_centers[j]);

			 if(!ball_enabled_flags[j]) continue;

			 XV3 ball_top(ball_centers[j]); //copy the ball center before transformation
			 
			 m_depthGen->ConvertRealWorldToProjective(1, &ball_centers[j], &ball_centers[j]);
			 normalizeProjective(&ball_centers[j]);
			 
			 //this is probably a clunky way to transform the radius into projectiev coods but it seems to work ok
			 ball_top.Y +=lightRadius;
			 m_depthGen->ConvertRealWorldToProjective(1, &ball_top, &ball_top);
			 normalizeProjective(&ball_top);
			 ball_radius[j] = fabs(ball_top.Y-ball_centers[j].Y);
			 ball_core_radius[j]  = ball_radius[j]*0.1f;
			 ball_core_radius2[j] = square(ball_core_radius[j]);
		}

		XnUInt32 ix = 0, iy = 0;
		float nearZ = PERSPECTIVE_Z_MIN + m_depthAdjustment;
		for (XnUInt32 i = 0; i < numPoints; i++, dp++, ip++, vp++, cp++, lp++, ix++) {

			if (ix == m_width) {
				ix = 0;
				iy++;
			}

			// (*vp)[0] (x) is already set
			// (*vp)[1] (y) is already set
			(*vp)[2] = (*dp) ? getNormalizedDepth(*dp, nearZ, PERSPECTIVE_Z_MAX) : Z_INFINITE;

			setRGB(cp, *ip);

			//highlight the tracked user
			if(isTracked) {
				if(*lp == userID) {
					(*cp)[0] *= 1.2f;
					(*cp)[1] *= 1.2f;
					(*cp)[2] *= 1.2f;
				}
			}

			// draw balls
			for(int j=0; j < NUM_BALLS; j++) {
				if(!ball_enabled_flags[j]) continue;

				XV3& lightCenter = ball_centers[j];
				//float ball_depth = (*dp) ? getNormalizedDepth(ball_radius[j], nearZ, PERSPECTIVE_Z_MAX) : 0;

				if((*vp)[2] < (lightCenter.Z - 0.001*ball_radius[j])) continue; //don't draw obscured pixels
				{
					// TODO: Should we use 3D object?
					XV3 flatCoords(*vp);
					flatCoords.Z = lightCenter.Z;
					float flatDistance2 = lightCenter.distance2(flatCoords);

					if (flatDistance2 < ball_core_radius2[j]) {
						float r = (1.0f - sqrt(flatDistance2) / ball_core_radius[j]) * (1.0f + 0.8f * ball_radius[j]);
						float r2 = r * r;
						float a = (r <= 1.0f) ? (2 * r2 - r2 * r2) : 1.0f;

						(*cp)[0] *= 1.2;
						(*cp)[1] *= 1.2;
						(*cp)[2] *= 1.2;

						//assuming we only have three balls cycle through red,green and blue for each one
						(*cp)[j] = interpolate((*cp)[j], 1.0f, a);
						//(*cp)[1] = interpolate((*cp)[1], 1.0f, a);
						//(*cp)[2] = interpolate((*cp)[2], 1.0f, a);
					}
				}
			}
		}

		glEnable(GL_POINT_SIZE);
		glPointSize(getPointSize());
		m_batch.draw(m_vertexBuf, m_colorBuf);
	}
	m_rctx->orthoMatrix.PopMatrix();
}