Exemplo n.º 1
0
void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters) {
  my_render = (vsx_module_param_render*)in_parameters.create(VSX_MODULE_PARAM_ID_RENDER, "render_in",false,false);
  res_x = 512;

  support_feedback = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "support_feedback");
  support_feedback->set(1);

  float_texture = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "float_texture");
  float_texture->set(0);
  float_texture_int = 0;

  alpha_channel = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "alpha_channel");
  alpha_channel->set(1);
  alpha_channel_int = 1;

  clear_color = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "clear_color");
  clear_color->set(0,0);
  clear_color->set(0,1);
  clear_color->set(0,2);
  clear_color->set(1,3);


  texture_size = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "texture_size");
  texture_size->set(2);

  tex_size_internal = -1;

  texture_result = (vsx_module_param_texture*)out_parameters.create(VSX_MODULE_PARAM_ID_TEXTURE,"texture_out");
  allocate_second_texture = true;
  start();
}
Exemplo n.º 2
0
Arquivo: main.cpp Projeto: Who828/vsxu
	void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters)
	{
		last_updated = -1.0f;
	  loading_done = true;
	  pos = (vsx_module_param_float3*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT3, "pos");
	  pos->set(0,0);
	  pos->set(0,1);
	  pos->set(0,2);

	  color0 = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "color0");
	  color0->set(1.0f,0);
	  color0->set(1.0f,1);
	  color0->set(1.0f,2);
	  color0->set(0.3f,3);

	  color1 = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "color1");
	  color1->set(1.0f,0);
	  color1->set(1.0f,1);
	  color1->set(1.0f,2);
	  color1->set(1.0f,3);

	  // parameters for the effect
	  friction = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "friction");
	  friction->set(1);

	  step_length = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "step_length");
	  step_length->set(10);

	  render_result = (vsx_module_param_render*)out_parameters.create(VSX_MODULE_PARAM_ID_RENDER,"render_out");
	  render_result->set(0);
	  gr.init();
	}
Exemplo n.º 3
0
Arquivo: main.cpp Projeto: Who828/vsxu
	void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters)
	{
	  loading_done = true;
	  prev_num_particles = 0;
	  in_particlesystem = (vsx_module_param_particlesystem*)in_parameters.create(VSX_MODULE_PARAM_ID_PARTICLESYSTEM,"in_particlesystem");

	  color0 = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "color0");
	  color0->set(1.0f,0);
	  color0->set(1.0f,1);
	  color0->set(1.0f,2);
	  color0->set(0.3f,3);

	  color1 = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "color1");
	  color1->set(1.0f,0);
	  color1->set(1.0f,1);
	  color1->set(1.0f,2);
	  color1->set(1.0f,3);

	  // parameters for the effect
	  friction = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "friction");
	  friction->set(1);

	  step_length = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "step_length");
	  step_length->set(10);

	  ribbon_width = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "ribbon_width");
	  ribbon_width->set(0.2f);

		length = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "length");
		length->set(1.0f);

		render_result = (vsx_module_param_render*)out_parameters.create(VSX_MODULE_PARAM_ID_RENDER,"render_out");
		render_result->set(0);
	}
Exemplo n.º 4
0
  void output(vsx_module_param_abs* param)
  {
    VSX_UNUSED(param);
    particles = in_particlesystem->get_addr();
    if (particles) {
      if (prev_num_particles != particles->particles->size())
      {
    	// remove all the old ones
    	/*for (unsigned long i = 0; i < gr.size(); i++)
    	{
    		delete gr[i];
    	}
        gr.reset_used(0);*/
        //printf("num particles: %d\n",particles->particles->size());
    	//printf("prev_num: %d\n",prev_num_particles);
        for (unsigned long i = prev_num_particles; i < particles->particles->size(); ++i) {
        	//if (i == prev_num_particles) printf("allocating again\n");
        	gr[i] = new gravity_strip;
          //printf("i: %d\n",i);
          gr[i]->init();
          gr[i]->init_strip();
        }
        prev_num_particles = particles->particles->size();
      }
      //printf("done alloc %d\n",particles->particles->size());

      for (unsigned long i = 0; i < particles->particles->size(); ++i) {
      	//gr[i].length = 0.0f;
      	gr[i]->width = ribbon_width->get();
				//gr[i].masses[1].mass = gr[i].masses[0].mass + ribbon_width->get();
				gr[i]->length = length->get();
				gr[i]->friction = friction->get();
        float tt = ((*particles->particles)[i].time/(*particles->particles)[i].lifetime);
        if (tt < 0.0f) tt = 0.0f;
        if (tt > 1.0f) tt = 1.0f;
			  gr[i]->color0[0] = color0->get(0)*tt;
			  gr[i]->color0[1] = color0->get(1)*tt;
			  gr[i]->color0[2] = color0->get(2)*tt;
			  gr[i]->color0[3] = color0->get(3)*tt;

			  gr[i]->color1[0] = color1->get(0);
			  gr[i]->color1[1] = color1->get(1);
			  gr[i]->color1[2] = color1->get(2);
			  gr[i]->step_freq = 10.0f * step_length->get();
		  	//if (last_update != engine->vtime) {
			  gr[i]->update(engine->dtime, (*(particles->particles))[i].pos.x, (*(particles->particles))[i].pos.y, (*(particles->particles))[i].pos.z);
					//last_upd ate = engine->vtime;
	  		//}
				//printf("%f, %f, %f\n", (*particles->particles)[i].pos.x, (*particles->particles)[i].pos.y, (*particles->particles)[i].pos.z);
			  gr[i]->render();
		//		printf("%d %d;;; %d\n",__LINE__,i, particles->particles->size());
        // add the delta-time to the time of the particle
        /*(*particles->particles)[i].pos.x += px*engine->dtime;
        (*particles->particles)[i].pos.y += py*engine->dtime;
        (*particles->particles)[i].pos.z += pz*engine->dtime;*/
      }
      //printf("done drawing\n");
    }
	render_result->set(1);
  }
Exemplo n.º 5
0
  // this is run for each connection to this in-param.
  void output(vsx_module_param_abs* param) 
  {
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    // translation
    glTranslatef(position->get(0),position->get(1),position->get(2));
    // rotation
    glRotatef(
      (float)angle->get()*360, 
      rotation_axis->get(0), 
      rotation_axis->get(1), 
      rotation_axis->get(2)
    );
    // scaling
    glScalef(size->get(0), size->get(1), size->get(2));
    // color
    glColor4f(
      color_rgb->get(0),
      color_rgb->get(1),
      color_rgb->get(2),
      color_rgb->get(3)
    );

    glBegin(GL_QUADS);
      glTexCoord2f(0.0f,0.0f);
      glVertex3f(-1.0f, -1.0f, 0.0f);
      glTexCoord2f(0.0f,1.0f);
      glVertex3f(-1.0f,  1.0f, 0.0f);
      glTexCoord2f(1.0f,1.0f);
      glVertex3f( 1.0f,  1.0f, 0.0f);
      glTexCoord2f(1.0f,0.0f);
      glVertex3f( 1.0f, -1.0f, 0.0f);
    glEnd();

    if (border->get()) 
    {
      glEnable(GL_LINE_SMOOTH);
      glLineWidth(1.5);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

      glBegin(GL_LINE_STRIP);
        glColor3f(0, 0, 0);
        glVertex3f(-2, -0.4f, 0);
        glVertex3f(-2, -0.2f, 0);
        glVertex3f( 2, -0.2f, 0);
        glVertex3f( 2, -0.4f, 0);
        glVertex3f(-2, -0.4f, 0);
      glEnd();
    }

    glPopMatrix();
    render_result->set(1);
    loading_done = true;
  }
Exemplo n.º 6
0
  // this method uses the engine's parameter holder to create data holders for 
  // each of the parameters also binding them to their name (string)
  void declare_params(
    vsx_module_param_list& in_parameters, 
    vsx_module_param_list& out_parameters
  )
  {
    loading_done = true;
    position = (vsx_module_param_float3*)in_parameters.create(
      VSX_MODULE_PARAM_ID_FLOAT3, 
      "position"
    );
    position->set(0.0f, 0);
    position->set(0.0f, 1);
    position->set(0.0f, 2);

    size = (vsx_module_param_float3*)in_parameters.create(
      VSX_MODULE_PARAM_ID_FLOAT3, 
      "size"
    );
    size->set(1.0f,0);
    size->set(0.3f,1);
    angle = (vsx_module_param_float*)in_parameters.create(
      VSX_MODULE_PARAM_ID_FLOAT, 
      "angle"
    );
    angle->set(0.0f);

    border = (vsx_module_param_int*)in_parameters.create(
      VSX_MODULE_PARAM_ID_INT, 
      "border"
    );

    rotation_axis = (vsx_module_param_float3*)in_parameters.create(
      VSX_MODULE_PARAM_ID_FLOAT3, 
      "rotation_axis"
    );
    rotation_axis->set(1.0f, 0);
    rotation_axis->set(1.0f, 1);
    rotation_axis->set(0.0f, 2);
    color_rgb = (vsx_module_param_float4*)in_parameters.create(
      VSX_MODULE_PARAM_ID_FLOAT4, 
      "color"
    );
    color_rgb->set(1.0,0);
    color_rgb->set(1.0,1);
    color_rgb->set(1.0,2);
    color_rgb->set(1.0,3);

    render_result = (vsx_module_param_render*)out_parameters.create(
      VSX_MODULE_PARAM_ID_RENDER,
      "render_out"
    );
    render_result->set(0);
  }
Exemplo n.º 7
0
Arquivo: main.cpp Projeto: Who828/vsxu
  void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters)
  {
    loading_done = true;
    prev_num_vertices = 0;
    mesh_id_start = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "mesh_id_start");
    mesh_id_start->set(0.0f);
    mesh_id_count = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "mesh_id_count");
    mesh_id_count->set(0.0f);
    in_mesh = (vsx_module_param_mesh*)in_parameters.create(VSX_MODULE_PARAM_ID_MESH,"in_mesh");

    upvector = (vsx_module_param_float3*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT3, "upvector");
    upvector->set(0.0f);
    upvector->set(0.0f);
    upvector->set(1.0f);

    color0 = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "color0");
    color0->set(1.0f,0);
    color0->set(1.0f,1);
    color0->set(1.0f,2);
    color0->set(0.3f,3);

    color1 = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "color1");
    color1->set(1.0f,0);
    color1->set(1.0f,1);
    color1->set(1.0f,2);
    color1->set(1.0f,3);

    modelview_matrix = (vsx_module_param_matrix*)in_parameters.create(VSX_MODULE_PARAM_ID_MATRIX,"modelview_matrix");



    // parameters for the effect
    friction = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "friction");
    friction->set(1);

    step_length = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "step_length");
    step_length->set(10);

    ribbon_width = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "ribbon_width");
    ribbon_width->set(0.2f);

    length = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "length");
    length->set(1.0f);

    reset_pos = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "reset_pos");
    reset_pos->set(-1.0f);

    render_result = (vsx_module_param_render*)out_parameters.create(VSX_MODULE_PARAM_ID_RENDER,"render_out");
    render_result->set(0);

    mesh_result = (vsx_module_param_mesh*)out_parameters.create(VSX_MODULE_PARAM_ID_MESH,"mesh_out");
  }
Exemplo n.º 8
0
  void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters) {
    texture_info_param_in = (vsx_module_param_texture*)in_parameters.create(VSX_MODULE_PARAM_ID_TEXTURE, "texture_in");
    loading_done = true;

    wrap_t = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "wrap_s");
    wrap_s = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "wrap_t");
    min_filter = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "min_filter");
    mag_filter = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "mag_filter");
    anisotropic_filter = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT, "anisotropic_filtering");
    border_color = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "border_color");
    border_color->set(0,0);
    border_color->set(0,1);
    border_color->set(0,2);
    border_color->set(0,3);
    texture_result = (vsx_module_param_texture*)out_parameters.create(VSX_MODULE_PARAM_ID_TEXTURE,"texture_rotate_out");
  }
Exemplo n.º 9
0
  void run() {
    texture_out = texture_info_param_in->get_addr();
    if (texture_out)
    {
     if (param_updates)
     {
        (*texture_out)->bind();
  #ifdef VSXU_OPENGL_ES
        if (GL_EXT_texture_filter_anisotropic)
  #endif
  #ifndef VSXU_OPENGL_ES
          if (GLEW_EXT_texture_filter_anisotropic)
  #endif
          {
          float rMaxAniso;
          glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &rMaxAniso);
          if (anisotropic_filter->get())
          glTexParameterf((*texture_out)->texture_info.ogl_type, GL_TEXTURE_MAX_ANISOTROPY_EXT, rMaxAniso);
          else
          glTexParameterf((*texture_out)->texture_info.ogl_type, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
        }

        float vals[4];
        vals[0] = border_color->get(0);
        vals[1] = border_color->get(1);
        vals[2] = border_color->get(2);
        vals[3] = border_color->get(3);

        glTexParameteri((*texture_out)->texture_info.ogl_type,GL_TEXTURE_MIN_FILTER, tex_filter[min_filter->get()]);
        glTexParameteri((*texture_out)->texture_info.ogl_type,GL_TEXTURE_MAG_FILTER, tex_filter[mag_filter->get()]);
  #ifndef VSXU_OPENGL_ES
        glTexParameterfv((*texture_out)->texture_info.ogl_type, GL_TEXTURE_BORDER_COLOR, vals);
  #endif
        glTexParameteri((*texture_out)->texture_info.ogl_type, GL_TEXTURE_WRAP_T, tex_wrap[wrap_t->get()]);
        glTexParameteri((*texture_out)->texture_info.ogl_type, GL_TEXTURE_WRAP_S, tex_wrap[wrap_s->get()]);
        (*texture_out)->_bind();

        --param_updates;
      }
      ((vsx_module_param_texture*)texture_result)->set(*texture_out);

    }	else {
      texture_result->valid = false;
    }
  }
Exemplo n.º 10
0
Arquivo: main.cpp Projeto: Who828/vsxu
	void output(vsx_module_param_abs* param) {
		gr.friction = friction->get();
	  gr.color0[0] = color0->get(0);
	  gr.color0[1] = color0->get(1);
	  gr.color0[2] = color0->get(2);
	  gr.color0[3] = color0->get(3);

	  gr.color1[0] = color1->get(0);
	  gr.color1[1] = color1->get(1);
	  gr.color1[2] = color1->get(2);
	  gr.step_freq = 10.0f * step_length->get();
	  if (last_updated != engine->vtime)
	  {
			gr.update(engine->dtime, pos->get(0), pos->get(1), pos->get(2));
			last_updated = engine->vtime;
	  }
		gr.render();
	  render_result->set(1);
	}
Exemplo n.º 11
0
bool activate_offscreen() {
  //printf("ac1\n");
  //printf("activate offscreen\n");
  //glGetIntegerv(GL_VIEWPORT, viewport);
  //printf("old viewport is %d %d %d %d\n",viewport[0],viewport[1],viewport[2],viewport[3]);
#if defined(VSXU_OPENGL_ES) || defined (__APPLE__)
  glGetIntegerv (GL_VIEWPORT, viewport);
#endif

  bool rebuild = false;

  if (alpha_channel->get() != alpha_channel_int)
  {
    alpha_channel_int = alpha_channel->get();
    rebuild = true;
  }

  if (float_texture->get() != float_texture_int)
  {
    float_texture_int = float_texture->get();
    rebuild = true;
  }

  if (texture_size->get() >= 10)
  {
    glGetIntegerv (GL_VIEWPORT, viewport);
    int t_res_x = abs(viewport[2] - viewport[0]);
    int t_res_y = abs(viewport[3] - viewport[1]);

    if (texture_size->get() == 10) {
      if (t_res_x != res_x || t_res_y != res_y) rebuild = true;
    }

    if (texture_size->get() == 11) {
      if (t_res_x / 2 != res_x || t_res_y / 2 != res_y) rebuild = true;
    }

    if (texture_size->get() == 12) {
      if (t_res_x / 4 != res_x || t_res_y / 4 != res_y) rebuild = true;
    }

    if (texture_size->get() == 13) {
      if (t_res_x * 2 != res_x || t_res_y * 2 != res_y) rebuild = true;
    }

    if (texture_size->get() == 14) {
      if (t_res_x * 4 != res_x || t_res_y * 4 != res_y) rebuild = true;
    }
  }


  if (texture_size->get() != tex_size_internal || rebuild) {
    //printf("generating new framebuffer\n");
    tex_size_internal = texture_size->get();
    switch (tex_size_internal) {
      case 0: res_y = res_x = 2048; break;
      case 1: res_y = res_x = 1024; break;
      case 2: res_y = res_x = 512; break;
      case 3: res_y = res_x = 256; break;
      case 4: res_y = res_x = 128; break;
      case 5: res_y = res_x = 64; break;
      case 6: res_y = res_x = 32; break;
      case 7: res_y = res_x = 16; break;
      case 8: res_y = res_x = 8; break;
      case 9: res_y = res_x = 4; break;
      case 10: res_x = abs(viewport[2] - viewport[0]); res_y = abs(viewport[3] - viewport[1]); break;
      case 11: res_x = abs(viewport[2] - viewport[0]) / 2; res_y = abs(viewport[3] - viewport[1]) / 2; break;
      case 12: res_x = abs(viewport[2] - viewport[0]) / 4; res_y = abs(viewport[3] - viewport[1]) / 4; break;
      case 13: res_x = abs(viewport[2] - viewport[0]) * 2; res_y = abs(viewport[3] - viewport[1]) * 2; break;
      case 14: res_x = abs(viewport[2] - viewport[0]) * 4; res_y = abs(viewport[3] - viewport[1]) * 4; break;
    };

    texture->reinit_buffer(res_x, res_y,float_texture->get(),alpha_channel->get());
    if (support_feedback->get())
    texture2->reinit_buffer(res_x, res_y, float_texture->get(),alpha_channel->get());
  }

  if (!which_buffer || support_feedback->get() == 0)
    texture->begin_capture();
  else
    texture2->begin_capture();

  //printf("changing viewport to %d\n",res_x);
	glViewport(0,0,res_x,res_y);
	glDepthMask(GL_TRUE);
	//glDisable(GL_DEPTH_TEST);
	glClearColor(clear_color->get(0),clear_color->get(1),clear_color->get(2),clear_color->get(3));
  //printf("clear buffer\n");
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
//#ifdef __APPLE__
	glEnable(GL_BLEND);
//#endif
  glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&glsl_prog);
  glUseProgram(0);
  //glBlendFunc(GL_SRC_ALPHA,GL_ONE);
  loading_done = true;
  return true;
};
Exemplo n.º 12
0
Arquivo: main.cpp Projeto: Who828/vsxu
  void output(vsx_module_param_abs* param) {
    mesh = in_mesh->get_addr();

    if (mesh && (*mesh)->data->vertices.size())
    {
      if (prev_num_vertices != (unsigned long)mesh_id_count->get())
      {
        // remove all the old ones
        for (unsigned long i = prev_num_vertices; i < (unsigned long)mesh_id_count->get(); ++i)
        {
          //printf("allocating %d\n", i);
          //if (i == prev_num_vertices)
            //printf("allocating again\n");
          gr[i] = new gravity_strip;
          gr[i]->init();
          gr[i]->init_strip();
        }
        prev_num_vertices = (int)mesh_id_count->get();
      }
      //printf("mesh_id_start: %d\n", (int)mesh_id_start->get());
      size_t mesh_index = (size_t)mesh_id_start->get() % (*mesh)->data->vertices.size();

      vsx_matrix* matrix_result = modelview_matrix->get_addr();
      if (!matrix_result)
      {
        matrix_result = &modelview_matrix_no_connection;
        glGetFloatv(GL_MODELVIEW_MATRIX, modelview_matrix_no_connection.m);
      }


      //printf("in-mesh vertex count: %d\n", mesh->data->vertices.size());
      if (param == render_result)
      {
        for (unsigned long i = 0; i < prev_num_vertices; ++i)
        {
          //gr[i].length = 0.0f;
          gr[i]->width = ribbon_width->get();
          //gr[i].masses[1].mass = gr[i].masses[0].mass + ribbon_width->get();
          gr[i]->length = length->get();
          gr[i]->friction = friction->get();
          //float tt = ((*particles->particles)[i].time/(*particles->particles)[i].lifetime);
          //if (tt < 0.0f) tt = 0.0f;
          //if (tt > 1.0f) tt = 1.0f;
          gr[i]->color0[0] = color0->get(0);
          gr[i]->color0[1] = color0->get(1);
          gr[i]->color0[2] = color0->get(2);
          gr[i]->color0[3] = color0->get(3);

          gr[i]->color1[0] = color1->get(0);
          gr[i]->color1[1] = color1->get(1);
          gr[i]->color1[2] = color1->get(2);
          gr[i]->step_freq = 10.0f * step_length->get();
          //if (last_update != engine->vtime) {
          if (reset_pos->get() > 0.0f)
          {
            gr[i]->reset_pos(
              (*mesh)->data->vertices[mesh_index].x,
              (*mesh)->data->vertices[mesh_index].y,
              (*mesh)->data->vertices[mesh_index].z
            );
          } else
          {
            gr[i]->update(
              engine->dtime,
              (*mesh)->data->vertices[mesh_index].x,
              (*mesh)->data->vertices[mesh_index].y,
              (*mesh)->data->vertices[mesh_index].z
            );
          }
          gr[i]->render();
              //(*(particles->particles))[i].pos.x, (*(particles->particles))[i].pos.y, (*(particles->particles))[i].pos.z);
            //last_upd ate = engine->vtime;
          //}
          //printf("%f, %f, %f\n", (*particles->particles)[i].pos.x, (*particles->particles)[i].pos.y, (*particles->particles)[i].pos.z);
      //    printf("%d %d;;; %d\n",__LINE__,i, particles->particles->size());
          // add the delta-time to the time of the particle
          /*(*particles->particles)[i].pos.x += px*engine->dtime;
          (*particles->particles)[i].pos.y += py*engine->dtime;
          (*particles->particles)[i].pos.z += pz*engine->dtime;*/
          mesh_index++;
          mesh_index = mesh_index % (*mesh)->data->vertices.size();
        }
      }
      else
      {
        float ilength = length->get();
        if (ilength > 1.0f) ilength = 1.0f;
        if (ilength < 0.01f) ilength = 0.01f;

        int num2 = BUFF_LEN * (int)(ilength * 8.0f * (float)prev_num_vertices);

        //printf("num2: %d\n", num2);
        // allocate mesh memory for all parts
        mesh_out->data->faces.allocate(num2);
        mesh_out->data->vertices.allocate(num2);
        mesh_out->data->vertex_normals.allocate(num2);
        mesh_out->data->vertex_tex_coords.allocate(num2);
        //printf("mesh: %d\n", __LINE__);
        mesh_out->data->faces.reset_used(num2);
        mesh_out->data->vertices.reset_used(num2);
        mesh_out->data->vertex_normals.reset_used(num2);
        mesh_out->data->vertex_tex_coords.reset_used(num2);
        //printf("mesh: %d\n", __LINE__);

        vsx_face*      fs_d = mesh_out->data->faces.get_pointer();
        vsx_vector*    vs_d = mesh_out->data->vertices.get_pointer();
        vsx_vector*    ns_d = mesh_out->data->vertex_normals.get_pointer();
        vsx_tex_coord* ts_d = mesh_out->data->vertex_tex_coords.get_pointer();
        int generated_vertices = 0;
        int generated_faces = 0;
        //printf("mesh: %d\n", __LINE__);

        generated_faces = 0;
        generated_vertices = 0;
        generated_vertices = 0;
        generated_vertices = 0;
        vsx_vector upv;
        upv.x = upvector->get(0);
        upv.y = upvector->get(1);
        upv.z = upvector->get(2);
        for (unsigned long i = 0; i < prev_num_vertices; ++i)
        {
          gr[i]->width = ribbon_width->get();
          gr[i]->length = length->get();
          gr[i]->friction = friction->get();
          gr[i]->color0[0] = color0->get(0);
          gr[i]->color0[1] = color0->get(1);
          gr[i]->color0[2] = color0->get(2);
          gr[i]->color0[3] = color0->get(3);

          gr[i]->color1[0] = color1->get(0);
          gr[i]->color1[1] = color1->get(1);
          gr[i]->color1[2] = color1->get(2);
          gr[i]->step_freq = 10.0f * step_length->get();

          //printf("mesh: %d %d\n", __LINE__, mesh_index);
          if (reset_pos->get() > 0.0f)
          {
            gr[i]->reset_pos(
              (*mesh)->data->vertices[mesh_index].x,
              (*mesh)->data->vertices[mesh_index].y,
              (*mesh)->data->vertices[mesh_index].z
            );
          } else
          {
            gr[i]->update(
              engine->dtime,
              (*mesh)->data->vertices[mesh_index].x,
              (*mesh)->data->vertices[mesh_index].y,
              (*mesh)->data->vertices[mesh_index].z
            );
          }
          //printf("%d\n", (int)i);

          gr[i]->generate_mesh(*mesh_out,fs_d, vs_d, ns_d, ts_d, matrix_result, &upv, generated_vertices, generated_faces);
          mesh_index++;
          mesh_index = mesh_index % (*mesh)->data->vertices.size();
        }

//        printf("generated faces: %d\n", generated_faces);
        //printf("generated vertices: %d\n", generated_vertices);
        mesh_out->data->faces.reset_used(generated_faces);
        mesh_out->data->vertices.reset_used(generated_vertices);
        mesh_out->data->vertex_normals.reset_used(generated_vertices);
        mesh_out->data->vertex_tex_coords.reset_used(generated_vertices);
        //printf("mesh: %d\n", __LINE__);

        mesh_result->set_p(mesh_out);
      }
      //printf("done drawing\n");
    }
  render_result->set(1);
  }
Exemplo n.º 13
0
  void output(vsx_module_param_abs* param)
  {
    VSX_UNUSED(param);
    if (text_in->updates)
    {
      if (process_lines())
      text_in->updates = 0;
    }
    if (text_alpha->get() <= 0)
      return;

    if (!ftfont)
    {
      user_message = "module||error loading font "+cur_font;
      return;
    }

    if (text_in->get() == "_")
      return;


    float obj_size = size->get();

    gl_state->matrix_mode (VSX_GL_MODELVIEW_MATRIX );
    gl_state->matrix_push();

    gl_state->matrix_rotate_f( (float)angle->get()*360, rotation_axis->get(0), rotation_axis->get(1), rotation_axis->get(2) );

    if (obj_size < 0)
      obj_size = 0;

    gl_state->matrix_scale_f( obj_size*0.8*0.01, obj_size*0.01, obj_size*0.01 );

    int l_align = align->get();
    float l_leading = leading->get();
    float ypos = 0;

    if (cur_render_type == 0)
      glEnable(GL_TEXTURE_2D);

    glColor4f(red->get(),green->get(),blue->get(),text_alpha->get());

    for (unsigned long i = 0; i < lines.size(); ++i)
    {
      float ll = limit_line->get();
      if (ll != -1.0f)
      {
        if (trunc(ll) != i) continue;
      }
      gl_state->matrix_push();
      if (l_align == 0)
      {
        gl_state->matrix_translate_f( 0, ypos, 0 );
      } else
      if (l_align == 1)
      {
        gl_state->matrix_translate_f( -lines[i].size_x*0.5f,ypos,0 );
      }
      if (l_align == 2)
      {
        gl_state->matrix_translate_f( -lines[i].size_x,ypos,0 );
      }

      if (cur_render_type == 1)
      {
        if (outline_alpha->get() > 0.0f && ftfont2) {
          float pre_linew;
          pre_linew = gl_state->line_width_get();
          gl_state->line_width_set( outline_thickness->get() );
          glColor4f(outline_color->get(0),outline_color->get(1),outline_color->get(2),outline_alpha->get()*outline_color->get(3));
          ftfont2->Render(lines[i].string.c_str());
          gl_state->line_width_set( pre_linew );
        }
        glColor4f(red->get(),green->get(),blue->get(),text_alpha->get());
      }

      ftfont->Render(lines[i].string.c_str());
      gl_state->matrix_pop();
      ypos += l_leading;
    }

    if (cur_render_type == 0)
      glDisable(GL_TEXTURE_2D);


    gl_state->matrix_pop();

    render_result->set(1);
    loading_done = true;
  }
Exemplo n.º 14
0
void declare_params(vsx_module_param_list& in_parameters, vsx_module_param_list& out_parameters)
{
  declare_run = false;
  size = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "size");
  size->set(1.0f);
  angle = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "angle");
  angle->set(0.0f);

  text_in = (vsx_module_param_string*)in_parameters.create(VSX_MODULE_PARAM_ID_STRING, "text_in");
  text_in->set("Vovoid VSX Ultra");
  text_in->updates = 1;
  font_in = (vsx_module_param_resource*)in_parameters.create(VSX_MODULE_PARAM_ID_RESOURCE, "font_in");
  font_in->set("resources/fonts/pala.ttf");
  cur_font = "";

  limit_line = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "limit_line");
  limit_line->set(-1.0f);


  leading = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "leading");
  leading->set(1.0f);

  glyph_size = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "glyph_size");
  glyph_size->set(24.0f);
  cur_glyph_size = 24.0f;
  render_type = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT,"render_type");
  render_type->set(0);
  align = (vsx_module_param_int*)in_parameters.create(VSX_MODULE_PARAM_ID_INT,"align");
  align->set(0);
  cur_render_type = 0;

  ftfont = 0;
  ftfont2 = 0;

  rotation_axis = (vsx_module_param_float3*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT3, "rotation_axis");
  rotation_axis->set(0.0f, 0);
  rotation_axis->set(1.0f, 1);
  rotation_axis->set(0.0f, 2);
  red = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "red");
  red->set(1.0f);
  green = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "green");
  green->set(1.0f);
  blue = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "blue");
  blue->set(1.0f);

  text_alpha = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "text_alpha");
  text_alpha->set(1.0);
  outline_alpha = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "outline_alpha");
  outline_alpha->set(0.5);
  outline_thickness = (vsx_module_param_float*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT, "outline_thickness");
  outline_thickness->set(3.0);
  outline_color = (vsx_module_param_float4*)in_parameters.create(VSX_MODULE_PARAM_ID_FLOAT4, "outline_color");
  outline_color->set(0.0f, 0);
  outline_color->set(0.0f, 1);
  outline_color->set(0.0f, 2);
  outline_color->set(0.0f, 3);

  render_result = (vsx_module_param_render*)out_parameters.create(VSX_MODULE_PARAM_ID_RENDER,"render_out");
  render_result->set(0);
  declare_run = true;

  gl_state = vsx_gl_state::get();
}
Exemplo n.º 15
0
bool activate_offscreen() {
  #if defined(VSXU_OPENGL_ES) || defined (__APPLE__)
    glGetIntegerv (GL_VIEWPORT, viewport);
  #endif

  bool rebuild = false;

  if (support_feedback->get() != support_feedback_int)
  {
    support_feedback_int = support_feedback->get();
    rebuild = true;
  }

  if (alpha_channel->get() != alpha_channel_int)
  {
    alpha_channel_int = alpha_channel->get();
    rebuild = true;
  }

  if (float_texture->get() != float_texture_int)
  {
    float_texture_int = float_texture->get();
    rebuild = true;
  }

  if (multisample->get() != multisample_int)
  {
    multisample_int = multisample->get();
    rebuild = true;
  }

  if (multisample->get() != multisample_int)
  {
    multisample_int = multisample->get();
    rebuild = true;
  }

  if (texture_size->get() >= 10)
  {
    glGetIntegerv (GL_VIEWPORT, viewport);
    int t_res_x = abs(viewport[2] - viewport[0]);
    int t_res_y = abs(viewport[3] - viewport[1]);

    if (texture_size->get() == 10) {
      if (t_res_x != res_x || t_res_y != res_y) rebuild = true;
    }

    if (texture_size->get() == 11) {
      if (t_res_x / 2 != res_x || t_res_y / 2 != res_y) rebuild = true;
    }

    if (texture_size->get() == 12) {
      if (t_res_x / 4 != res_x || t_res_y / 4 != res_y) rebuild = true;
    }

    if (texture_size->get() == 13) {
      if (t_res_x * 2 != res_x || t_res_y * 2 != res_y) rebuild = true;
    }

    if (texture_size->get() == 14) {
      if (t_res_x * 4 != res_x || t_res_y * 4 != res_y) rebuild = true;
    }
  }


  if (texture_size->get() != tex_size_internal || rebuild) {
    //printf("generating new framebuffer\n");
    tex_size_internal = texture_size->get();
    switch (tex_size_internal) {
      case 0: res_y = res_x = 2048; break;
      case 1: res_y = res_x = 1024; break;
      case 2: res_y = res_x = 512; break;
      case 3: res_y = res_x = 256; break;
      case 4: res_y = res_x = 128; break;
      case 5: res_y = res_x = 64; break;
      case 6: res_y = res_x = 32; break;
      case 7: res_y = res_x = 16; break;
      case 8: res_y = res_x = 8; break;
      case 9: res_y = res_x = 4; break;
      case 10: res_x = abs(viewport[2] - viewport[0]); res_y = abs(viewport[3] - viewport[1]); break;
      case 11: res_x = abs(viewport[2] - viewport[0]) / 2; res_y = abs(viewport[3] - viewport[1]) / 2; break;
      case 12: res_x = abs(viewport[2] - viewport[0]) / 4; res_y = abs(viewport[3] - viewport[1]) / 4; break;
      case 13: res_x = abs(viewport[2] - viewport[0]) * 2; res_y = abs(viewport[3] - viewport[1]) * 2; break;
      case 14: res_x = abs(viewport[2] - viewport[0]) * 4; res_y = abs(viewport[3] - viewport[1]) * 4; break;
    };

    if (0 == support_feedback_int)
    {
      texture->reinit_color_depth_buffer
      (
        res_x,
        res_y,
        float_texture_int,
        alpha_channel_int,
        multisample_int
      );
      texture->bind();
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL,0);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      texture->_bind();

    }
    if (1 == support_feedback_int)
    {
      // feedback textures ignores foreign depth buffer...
      texture->reinit_color_depth_buffer
      (
        res_x,
        res_y,
        float_texture_int,
        alpha_channel_int,
        multisample_int
      );
      texture->bind();
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL,0);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      texture->_bind();
      texture2->reinit_color_depth_buffer
      (
        res_x,
        res_y,
        float_texture_int,
        alpha_channel_int,
        multisample_int
      );
      texture2->bind();
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL,0);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      texture2->_bind();
    }
  }

  if (!which_buffer || support_feedback->get() == 0)
    texture->begin_capture_to_buffer();
  else
    texture2->begin_capture_to_buffer();

  //printf("changing viewport to %d\n",res_x);
	glViewport(0,0,res_x,res_y);
	glDepthMask(GL_TRUE);
	glClearColor(clear_color->get(0),clear_color->get(1),clear_color->get(2),clear_color->get(3));
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
	glEnable(GL_BLEND);
  glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&glsl_prog);
  if ( atof((char*)glGetString(GL_VERSION)) >= 2.0 )
    glUseProgram(0);
  else
    glUseProgramObjectARB(0);

  loading_done = true;
  return true;
}