コード例 #1
0
int 	setup(oscplug *info, port)
{
	int port = info->port_offset;
	const char port_str[50];
	sprintf(port_str, "%d",port );
	info->osc_server = veejay_new_osc_server( (void*)info, port_str );
	info->osc_namespace = vpn( VEVO_ANONYMOUS_PORT );
	veejay_osc_namespace_events( (void*) info, "/veejay");
	return 1;
}
コード例 #2
0
ファイル: value_test.cpp プロジェクト: aasfalcon/wexplorer
TEST(SharedValueTest, ctorPtr)
{
    void* p;
    const void* cp;
    int* pi;
    const int* cpi;
    bool* pb;
    const bool* cpb;
    TestStruct* pts;
    const TestStruct* cpts;
    void* pn = NULL;
    void* pnullptr = nullptr;

    EXPECT_NO_THROW(Value v(p));
    EXPECT_NO_THROW(Value v(cp));
    EXPECT_NO_THROW(Value v(pi));
    EXPECT_NO_THROW(Value v(cpi));
    EXPECT_NO_THROW(Value v(pb));
    EXPECT_NO_THROW(Value v(cpb));
    EXPECT_NO_THROW(Value v(pts));
    EXPECT_NO_THROW(Value v(cpts));
    EXPECT_NO_THROW(Value v(pn));
    EXPECT_NO_THROW(Value v(pnullptr));
    EXPECT_NO_THROW(Value v(nullptr));
    EXPECT_NO_THROW(Value v(NULL)); // probably will be int(0) or _null(0) (bad)

    Value vp(p);
    Value vcp(cp);
    Value vpi(pi);
    Value vcpi(cpi);
    Value vpb(pb);
    Value vcpb(cpb);
    Value vpts(pts);
    Value vcpts(cpts);
    Value vpn(pn);
    Value vnullptr(nullptr);
    Value vNULL(NULL);

    EXPECT_EQ(vp.type(), typeid(const void*));
    EXPECT_EQ(vcp.type(), typeid(const void*));
    EXPECT_EQ(vpi.type(), typeid(const int*));
    EXPECT_EQ(vcpi.type(), typeid(const int*));
    EXPECT_EQ(vpb.type(), typeid(const bool*));
    EXPECT_EQ(vcpb.type(), typeid(const bool*));
    EXPECT_EQ(vpts.type(), typeid(const TestStruct*));
    EXPECT_EQ(vcpts.type(), typeid(const TestStruct*));
    EXPECT_EQ(vpn.type(), typeid(const void*));
    EXPECT_EQ(vnullptr.type(), typeid(const void*));

    EXPECT_NE(vNULL.type(), typeid(const void*));
    EXPECT_EQ(vNULL.type(), typeid(NULL));
}
コード例 #3
0
ファイル: plugload.c プロジェクト: flv0/veejay
int	plug_sys_detect_plugins(void)
{
	index_map_ = (vevo_port_t**) vj_calloc(sizeof(vevo_port_t*) * 1024 );
	illegal_plugins_ = vpn( VEVO_ILLEGAL );

	char *lvd_path = get_livido_plug_path();
	if( lvd_path != NULL ) {
		add_to_plugin_list( lvd_path );
		free(lvd_path);
	}


	if(!scan_plugins())
	{
		veejay_msg(VEEJAY_MSG_WARNING,
				"No plugins found in $HOME/.veejay/plugins.cfg" );
	}

	veejay_msg(VEEJAY_MSG_INFO, "Looking for plugins in common locations ...");
	
	int i;
	for( i = 0; plugger_paths[i].path != NULL; i ++ ) {
		add_to_plugin_list( plugger_paths[i].path );
	}

	//@ the freeframe version we use is not compatible with 64 bit systems. So, lets see if long is size 4
	//@ For every time there is a void* passed as int a gremlin will be happy
	if( sizeof(long) == 4 ) {
		if( n_ff_ > 0 ) { 
			veejay_msg(VEEJAY_MSG_INFO, "FreeFrame - cross-platform real-time video effects (http://freeframe.sourceforge.net)");
			veejay_msg(VEEJAY_MSG_INFO, "            found %d FreeFrame %s",	n_ff_ , n_ff_ == 1 ? "plugin" : "plugins" );
		}
	}

	if( n_fr_ > 0 ) {
		veejay_msg(VEEJAY_MSG_INFO, "frei0r - a minimalistic plugin API for video effects (http://www.piksel.org/frei0r)");
		veejay_msg(VEEJAY_MSG_INFO, "         found %d frei0r %s",
			n_fr_ , n_fr_ == 1 ? "plugin" : "plugins" );
	}	

	if( n_lvd_ > 0 ) {
		veejay_msg(VEEJAY_MSG_INFO, "Livido - (Linux) Video Dynamic Objects" );
		veejay_msg(VEEJAY_MSG_INFO, "         found %d Livido %s",
			n_lvd_, n_lvd_ == 1 ? "plugin" :"plugins" );
	}
	
	plug_print_all();
	
	return index_;
}
コード例 #4
0
ファイル: Camera.cpp プロジェクト: Banbury/starshatter-open
void
Camera::LookAt(const Point& target)
{
    // No navel gazing:
    if (target == Pos())
    return;

    Point tgt, tmp = target - Pos();

    // Rotate into the view orientation:
    tgt.x = (tmp * vrt());
    tgt.y = (tmp * vup());
    tgt.z = (tmp * vpn());

    if (tgt.z == 0) {
        Pitch(0.5);
        Yaw(0.5);
        LookAt(target);
        return;
    }

    double az = atan(tgt.x/tgt.z);
    double el = atan(tgt.y/tgt.z);

    // if target is behind, offset by 180 degrees:
    if (tgt.z < 0)
    az -= PI;

    Pitch(-el);
    Yaw(az);

    // roll to upright position:
    double deflection = vrt().y;
    while  (fabs(deflection) > 0.001) {
        double theta = asin(deflection/vrt().length());
        Roll(-theta);

        deflection = vrt().y;
    }
}
コード例 #5
0
void	vj_midi_reset( void *vv )
{
	vmidi_t *v = (vmidi_t*)vv;

	int a = vj_midi_events(vv);
	if( a > 0 )
	{
		char warn[200];
		snprintf(warn,sizeof(warn), "This will clear %d MIDI events, Continue ?",a );
		if( prompt_dialog( "MIDI", warn ) == GTK_RESPONSE_REJECT )
			return;

	}

	char **items = vevo_list_properties(v->vims);
	if(!items) {
		vj_msg(VEEJAY_MSG_INFO,"No MIDI events to clear");
		return;
	}
	int i;
	for( i = 0; items[i] != NULL ; i ++ )
	{
		dvims_t *d = NULL;
		if( vevo_property_get( v->vims, items[i],0,&d ) == VEVO_NO_ERROR )
		{
			if(d->msg) free(d->msg);
			if(d->widget) free(d->widget);
			free(d);
		}
		free(items[i]);
	}
	free(items);
	
	vpf(v->vims);

	v->vims = vpn(VEVO_ANONYMOUS_PORT);

	vj_msg(VEEJAY_MSG_INFO, "Cleared %d MIDI events.",a);
}
コード例 #6
0
void	*vj_midi_new(void *mw)
{
	vmidi_t *v = (vmidi_t*) vj_calloc(sizeof(vmidi_t));
	int portid = 0;

	if( snd_seq_open( &(v->sequencer), "hw", SND_SEQ_OPEN_DUPLEX | SND_SEQ_NONBLOCK, 0 ) < 0 )
	{
		veejay_msg(0, "Error opening ALSA sequencer");
		return v;
	}

	snd_seq_set_client_name( v->sequencer, "Veejay" );

	if( (portid = snd_seq_create_simple_port( v->sequencer, "Reloaded",
			SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE ,
			SND_SEQ_PORT_TYPE_APPLICATION )) < 0 )
	{
		veejay_msg(0, "Error creating sequencer port");
		return v;
	}

	v->npfd = snd_seq_poll_descriptors_count( v->sequencer, POLLIN );
	if( v->npfd <= 0 )
	{
		veejay_msg(0,"Unable to poll in from sequencer");
		return v;
	}
	v->pfd     = (struct pollfd *) vj_calloc( v->npfd * sizeof( struct pollfd ));
	v->mw      = mw;
	v->learn   = 0;
	v->vims    = vpn(VEVO_ANONYMOUS_PORT);	
	v->active = 1;
	snd_seq_poll_descriptors( v->sequencer, v->pfd, v->npfd, POLLIN );

	veejay_msg(VEEJAY_MSG_INFO, "MIDI listener active! Type 'aconnect -o' to see where to connect to.");
	veejay_msg(VEEJAY_MSG_INFO, "For example: $ aconnect 128 129");

	return (void*) v;
}
コード例 #7
0
ファイル: Camera.cpp プロジェクト: Banbury/starshatter-open
bool
Camera::Padlock(const Point& target, double alimit, double e_lo, double e_hi)
{
    // No navel gazing:
    if (target == Pos())
    return false;

    Point tgt, tmp = target - Pos();

    // Rotate into the view orientation:
    tgt.x = (tmp * vrt());
    tgt.y = (tmp * vup());
    tgt.z = (tmp * vpn());

    if (tgt.z == 0) {
        Yaw(0.1);

        tgt.x = (tmp * vrt());
        tgt.y = (tmp * vup());
        tgt.z = (tmp * vpn());

        if (tgt.z == 0)
        return false;
    }

    bool   locked  = true;
    double az      = atan(tgt.x/tgt.z);
    double orig    = az;

    // if target is behind, offset by 180 degrees:
    if (tgt.z < 0)
    az -= PI;

    while (az >  PI) az -= 2*PI;
    while (az < -PI) az += 2*PI;

    if (alimit > 0) {
        if (az < -alimit) {
            az = -alimit;
            locked = false;
        }
        else if (az > alimit) {
            az = alimit;
            locked = false;
        }
    }

    Yaw(az);

    // Rotate into the new view orientation:
    tgt.x = (tmp * vrt());
    tgt.y = (tmp * vup());
    tgt.z = (tmp * vpn());

    double el      = atan(tgt.y/tgt.z);

    if (e_lo > 0 && el < -e_lo) {
        el = -e_lo;
        locked = false;
    }

    else if (e_hi > 0 && el > e_hi) {
        el = e_hi;
        locked = false;
    }

    Pitch(-el);

    return locked;
}
コード例 #8
0
double Camera::bbToDetection(const Vector<double>& bbox, Vector<double>& pos3D, double ConvertScale, double& dist)
{
//    pos3D.clearContent();
    pos3D.setSize(3);

    double x = bbox(0);
    double y = bbox(1);
    double w = bbox(2);
    double h = bbox(3);

    // bottom_left and bottom_right are the point of the BBOX
    Vector<double> bottom_left(3, 1.0);
    bottom_left(0) = x + w/2.0;
    bottom_left(1) = y + h;

    Vector<double> bottom_right(3, 1.0);
    bottom_right(0) = x + w;
    bottom_right(1) = y + h;

    Vector<double> ray_bot_left_1;
    Vector<double> ray_bot_left_2;

    Vector<double> ray_bot_right_1;
    Vector<double> ray_bot_right_2;

    // Backproject through base point
    getRay(bottom_left, ray_bot_left_1, ray_bot_left_2);
    getRay(bottom_right, ray_bot_right_1, ray_bot_right_2);

    Vector<double> gpPointLeft;
    Vector<double> gpPointRight;

    // Intersect with ground plane
    intersectPlane(GPN_, GPD_, ray_bot_left_1, ray_bot_left_2, gpPointLeft);
    intersectPlane(GPN_, GPD_, ray_bot_right_1, ray_bot_right_2, gpPointRight);

    // Find top point
    Vector<double> ray_top_1;
    Vector<double> ray_top_2;

    Vector<double> aux(3, 1.0);
    aux(0) = x;
    aux(1) = y;

    getRay(aux, ray_top_1, ray_top_2);

    // Vertical plane through base points + normal
    Vector<double> point3;
    point3 = gpPointLeft;
    point3 -= (GPN_);
    Vector<double> vpn(3,0.0);
    Vector<double> diffGpo1Point3;
    Vector<double> diffGpo2Point3;

    diffGpo1Point3 = gpPointLeft;
    diffGpo1Point3 -=(point3);

    diffGpo2Point3 = gpPointRight;
    diffGpo2Point3 -= point3;

    vpn = cross(diffGpo1Point3,diffGpo2Point3);
    double vpd = (-1.0)*DotProduct(vpn, point3);

    Vector<double> gpPointTop;
    intersectPlane(vpn, vpd, ray_top_1, ray_top_2, gpPointTop);

    // Results
    gpPointTop -= gpPointLeft;

    // Compute Size
    double dSize = gpPointTop.norm();

    // Compute Distance
    aux = t_;
    aux -= gpPointLeft;
    dist = aux.norm();

    dist = dist * ConvertScale;
    if(gpPointLeft(2) < t_(2)) dist = dist * (-1.0);
    // Compute 3D Position of BBOx
    double posX = gpPointLeft(0) * ConvertScale;
    double posY = gpPointLeft(1) * ConvertScale;
    double posZ = gpPointLeft(2) * ConvertScale;

    pos3D(0) = (posX);
    pos3D(1) = (posY);
    pos3D(2) = (posZ);

    return dSize * ConvertScale;

}
コード例 #9
0
ファイル: assignment-5.cpp プロジェクト: agmathiesen/Graphics
int main() 
{
    try {

    // Camera settings
	Camera camera;
	glm::vec3 vrp(0.0f, 0.0f, 10.0f);
	glm::vec3 vpn(0.0f, 0.0f, 1.0f);
	glm::vec3 vup(0.0f, 1.0f, 0.0f);
	glm::vec3 prp(0.0f, 0.0f, 100.0f);
	float F = 10.0f;
	float B = -80.0f;
	glm::vec2 lower_left(-20.0f, -20.0f);
	glm::vec2 upper_right(20.0f, 20.0f);
	camera = Camera(vrp, vpn, vup, prp, lower_left, upper_right, F, B);
	
	// Examples
	int curves = 4;    // Amount of examples
	BezierRow G[curves];
	G[0] = BezierRow(glm::vec3(-15.0f, -15.0f, 0.0f),
					 glm::vec3(-10.0f, 25.0f, 0.0f),
					 glm::vec3(10.0f, 25.0f, 0.0f),
					 glm::vec3(15.0f, -15.0f, 0.0f));
	G[1] = BezierRow(glm::vec3(-20.0f, 0.0f, 0.0f),
					 glm::vec3(-1.0f, 55.0f, 0.0f),
					 glm::vec3(1.0f, -55.0f, 0.0f),
					 glm::vec3(20.0f, 0.0f, 0.0f));
	G[2] = BezierRow(glm::vec3(-1.0f, -5.0f, 0.0f),
					 glm::vec3(-60.0f, 5.0f, 0.0f),
					 glm::vec3(60.0f,  5.0f, 0.0f),
					 glm::vec3(1.0f,  -5.0f, 0.0f));
	G[3] = BezierRow(glm::vec3(-10.0f, -5.0f, 0.0f),
					 glm::vec3(60.0f,   5.0f, 0.0f),
					 glm::vec3(-60.0f,  5.0f, 0.0f),
					 glm::vec3(10.0f,  -5.0f, 0.0f));

	int currentfigure = 3; // Set figure between 4 different examples

	// Decide whether to use sampling or subdivision
	int decider = 1;

	int Npoint = 0;
	std::vector<glm::vec3> points;

	// Sampling
	if(decider == 0){
	float t = 0.0f;
	float step = 12.0f;
	sampling(G[currentfigure], t, step, points);
	Npoint = step*2;
	}

	// Subdivision
	else if(decider == 1){
	DLB /= 8.0f;	
	DRB /= 8.0f;
	int n = 3; 				// Amount of curves (smoothness)
 	int npow = pow(2, n+1); // Amount of points
	subdivide(G[currentfigure], n, points);
	Npoint = npow;
	}
	else{
		printf("No method chosen\n"); return 1;
	}




	glm::mat4x4 CTM = camera.CurrentTransformationMatrix();
	std::cout << "CTM = " << std::endl << CTM << std::endl;


	// Initialize the graphics
	InitializeGLFW();
	GLFWwindow* Window = CreateWindow(WindowWidth, WindowHeight, WindowTitle.c_str());
	InitializeGLEW();
	InitializeOpenGL();
	glfwSwapBuffers(Window);

	// Read and Compile the vertex program vertextransform.vert
	GLuint vertexprogID = CreateGpuProgram("vertextransform.vert", GL_VERTEX_SHADER);

        // Read and Compile the fragment program linefragment.frag
	GLuint linefragmentprogID = CreateGpuProgram("linefragment.frag", GL_FRAGMENT_SHADER);

	// Create a lineshader program and Link it with the vertex and linefragment programs
	GLuint lineshaderID = CreateShaderProgram(vertexprogID, linefragmentprogID);
	
	// Now comes the OpenGL core part

	// This is where the curve is initialized
        // User data is in the global variable curveVertices, and the number of entries
	// is in Ncurvevertices

    // Make a VertexArrayObject - it is used by the VertexArrayBuffer, and it must be declared!
	GLuint CurveVertexArrayID;
	glGenVertexArrays(1, &CurveVertexArrayID);
	glBindVertexArray(CurveVertexArrayID);

	// Make a curvevertexbufferObject - it uses the previous VertexArrayBuffer!
	GLuint curvevertexbuffer;
	glGenBuffers(1, &curvevertexbuffer);
	glBindBuffer(GL_ARRAY_BUFFER, curvevertexbuffer);




	// Give our vertices to OpenGL.
	glBufferData(GL_ARRAY_BUFFER, Npoint * 3 * sizeof(float), &points[0], GL_STATIC_DRAW);
	

    // Validate the shader program
	ValidateShader(lineshaderID, "Validating the lineshader");

	// Get locations of Uniforms
	GLuint curvevertextransform   = glGetUniformLocation(lineshaderID, "CTM");
	GLuint curvefragmentcolor     = glGetUniformLocation(lineshaderID, "Color");	




	// Initialize Attributes
	GLuint curvevertexattribute = glGetAttribLocation(lineshaderID, "VertexPosition");
	glVertexAttribPointer(curvevertexattribute, 3, GL_FLOAT, GL_FALSE, 0, 0);

	// The main loop
	while (!glfwWindowShouldClose(Window)) {
	    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	    glUseProgram(lineshaderID);
		glm::mat4x4 CTM = camera.CurrentTransformationMatrix();
		glUniformMatrix4fv(curvevertextransform, 1, GL_FALSE, &CTM[0][0]);
		glUniform3f(curvefragmentcolor, 0.2f, 0.2f, 0.2f);

		glEnableVertexAttribArray(curvevertexattribute);
		glBindVertexArray(CurveVertexArrayID);  // This is very important! There are two "binds"!
		glDrawArrays(GL_LINES, 0, Npoint);

		glDisableVertexAttribArray(curvevertexattribute);
	    glUseProgram(0);

	    glfwSwapBuffers(Window);
	    std::stringstream errormessage;
	    errormessage << "End of loop: " << "assignment5.cpp" << ": " << __LINE__ << ": ";
	    ErrorCheck(errormessage.str());

	    glfwPollEvents();
	}
    }
    catch (std::exception const& exception) {
	std::cerr << "Exception: " << exception.what() << std::endl;
    }

    glfwTerminate();

    return 0;
}
コード例 #10
0
void Camera::updateFrustrum(void)
{
    // frustrum planes
    Vector r_origin( _frame->LTM._41, _frame->LTM._42, _frame->LTM._43 );
    Vector vpn( _frame->LTM._31, _frame->LTM._32, _frame->LTM._33 );
    Vector vright( _frame->LTM._11, _frame->LTM._12, _frame->LTM._13 );
    Vector vup( _frame->LTM._21, _frame->LTM._22, _frame->LTM._23 );

    //r_origin = Vector( 0,0,0 );
    //vright = Vector( 1,0,0 );
    //vup    = Vector( 0,1,0 );
    //vpn    = Vector( 0,0,1 );

    // for right-handed coordinate system
    vpn *= - 1, vright *= -1, vup *= -1;

	float orgOffset = D3DXVec3Dot( &r_origin, &vpn );
    
    // far plane
    frustrum[4].a = -vpn.x;
    frustrum[4].b = -vpn.y;
    frustrum[4].c = -vpn.z;
	frustrum[4].d = -_farClipPlane - orgOffset;
    
    // near plane
	frustrum[5].a = vpn.x;
    frustrum[5].b = vpn.y;
    frustrum[5].c = vpn.z;
	frustrum[5].d = _nearClipPlane + orgOffset;

    // (1.33) is reserve multiplier
    float fovx = _fov * 1.33f; 
    // (1.1) is reserve multiplier
	float fovy = fovx * _viewPort.Height/_viewPort.Width * 1.1f; 

	fovx *= 0.5f;
	fovy *= 0.5f;

	float tanx = tan( D3DXToRadian(fovx) );
	float tany = tan( D3DXToRadian(fovy) );

	// left plane
    Vector n = (vpn * tanx) + vright;
    D3DXVec3Normalize( &n, &n );
	frustrum[0].a = n.x;
    frustrum[0].b = n.y;
    frustrum[0].c = n.z;
	
    // right plane
    n = (vpn * tanx) - vright;
    D3DXVec3Normalize( &n, &n );
	frustrum[1].a = n.x;
    frustrum[1].b = n.y;
    frustrum[1].c = n.z;

    // bottom plane
    n = (vpn * tany) + vup;
    D3DXVec3Normalize( &n, &n );
	frustrum[2].a = n.x;
    frustrum[2].b = n.y;
    frustrum[2].c = n.z;

    // top plane
    n = (vpn * tany) - vup;
    D3DXVec3Normalize( &n, &n );
	frustrum[3].a = n.x;
    frustrum[3].b = n.y;
    frustrum[3].c = n.z;

	for( unsigned int i=0; i < 4; i++ )
	{
        n.x = frustrum[i].a;
        n.y = frustrum[i].b;
        n.z = frustrum[i].c;
		frustrum[i].d = D3DXVec3Dot( &n, &r_origin );
	}
}