Пример #1
0
int  
SKY_BOX::DrawGradient(CVIEWptr &v)
{
   //DebugBreak();
   update_position(); //center at the eye position
   
      
   Patch* p = get_patch();
   assert(p);
   Skybox_Texture* tex = get_tex<Skybox_Texture>(p);
   assert(tex);

   glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT );
   glEnable(GL_DEPTH_TEST);

   // set xform:
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glMultMatrixd(xform().transpose().matrix());
 
   // draw the mesh normally:
   int ret= tex->draw(v);
          
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();

   glPopAttrib();

   GL_VIEW_PRINT_GL_ERRORS("(regular) : ");

   return ret;
}
Пример #2
0
//TEST(CTiling, tiling)
TEST(CTiling, DISABLED_tiling)
{
  vector<shared_ptr<Patch> > cooked_patches;
  //read_patches(cooked_patches, "hand_chicken");
  //read_patches(cooked_patches, "cooked_rawData_chicken_combi_3");  
  //read_patches(cooked_patches, "cooked_rawData_dance_combi_4");  
  //read_patches(cooked_patches, "cooked_rawData_Hello_combi_3");
  read_patches(cooked_patches, "cooked_rawData_dance_combi_3");
  //read_patches(cooked_patches, "cooked_rawData_catchMe_combi_7");
  vector<string> dNote;
  /*
  dNote.push_back("u3");
  dNote.push_back("2");*/
  remove_dangling_patch(cooked_patches, dNote);
  
  vector< shared_ptr<Patch> > patches;
  Env env;
  tiling_by_example(patches, env, cooked_patches, "general", 20);
  
  //if (false)
  {
	PatchesViewer * v = new PatchesViewer(patches, env);
	v->get_camera().distance += 2;

	vector<ml::Motion> view_m;
	convert_patch_to_motion(view_m, patches);
    DontSlip noslipfoot;
    for (auto it = view_m.begin(); it != view_m.end(); ++it) {
	  noslipfoot.hold_foot(*it);
	}
    MotionsViewer * mv = new MotionsViewer(view_m);
	mv->get_camera().distance += 2;
  }


  if (false)
  {
    map<string, Patch> *patch_type = new map<string, Patch>();
    get_patch(patch_type);
    vector< shared_ptr<Patch> > patch_type_vector;
    for (auto it = patch_type->begin(); it != patch_type->end(); ++it) {
	  patch_type_vector.push_back(shared_ptr<Patch>(new Patch(it->second)));
	}

    vector< shared_ptr<Patch> > result_patches;
    Env env;
    tiling_by_example(result_patches, env, patch_type_vector, "dance", 2);
    
    /*DontSlip noslipfoot(18, 19, 24, 3, 4, 20);
    for (auto it = patches.begin(); it != patches.end(); ++it) noslipfoot.hold_foot(**it);*/
    PatchesViewer * v = new PatchesViewer(result_patches, env);
    v->get_camera().distance += 2;
  }

  
  if (false)
  {
    double offset = 0.0;
    for (auto it = cooked_patches.begin(); it != cooked_patches.end(); ) {
      /*if ((*it)->motions.size() == 1) {
      it = cooked_patches.erase(it);
      } else */
      {
        (*it)->translate(cml::vector3(offset, 0., 0.));
        ++it;
        offset += 7.0;
      }
    }
    PatchesViewer * v = new PatchesViewer(cooked_patches);
    v->get_camera().distance += 2;
  }
}
Пример #3
0
/*
 * returns 0 on success, non-zero if not all textures were properly extracted.
 */
int decompile(listitem_t *wadlist, char *section, void *texture, void *pnames)
{
	int	rc = 0;
	int	i, j;
	int	patches_found;
	int	*p1;
	char	*p2;
	short	*p3;
	int	num_tex;
	int	off_tex;
	short	dummy;
	short	width, height, num_pat;
	short	xoff, yoff, pnum;
	char	tname[9];
	FILE	*fp = NULL;
	char	fn[50];

	/* initialize */
	memset(&tname[0], 0, sizeof tname);

	/* get number of textures in texture lump */
	p1 = (int *) texture;
	num_tex = *p1;
	swaplong(&num_tex);
	printf("  found %d textures\n", num_tex);

	/* loop over all textures */
	for (i = 0; i < num_tex; i++) {
 
		/* offset for texture in lump */
		p1 = (int *) texture + i + 1;
		off_tex = *p1;
		swaplong(&off_tex);
		p2 = (char *) texture + off_tex;

		/* get name of texture */
		strncpy(&tname[0], p2, 8);
		{
		  int n;
		  for (n = 0; n < sizeof tname; n++)
			  tname[n] = toupper(((unsigned char *) tname)[n]);
		}
		if (wildcard != NULL && fnmatch(wildcard, tname, 0) != 0)
			continue;

		/* get texture composition */
		p3 = (short *) (p2 + 8);
		dummy = *p3++;		/* always 0 */
		dummy = *p3++;		/* always 0 */
		width = *p3++;
		swapint(&width);
		height = *p3++;
		swapint(&height);
		dummy = *p3++;		/* always 0 */
		dummy = *p3++;		/* always 0 */
		num_pat = *p3++;
		swapint(&num_pat);

		printf("  decompiling texture %s, %d patches, %dx%d\n",
		  &tname[0], num_pat, width, height);

		/* grow the texture buffer if necessary */
		{
		  unsigned long newsize = width * height;
		  if ((size_t) newsize != newsize) {
		    err("Texture too big, size_t overflow (%hd x %hd). Skipping.",
			width, height);
		    rc = 1;
		    continue;
		  }
		  if (newsize > img_buf_sz) {
		    unsigned char *newbuf = realloc(img_buf, newsize);
		    if (newbuf == NULL) {
		      err("Texture too big, not enough memory (%d x %d). Skipping.",
			  width, height);
		      rc = 1;
		      continue;
		    }
		    img_buf_sz = newsize;
		    img_buf    = newbuf;
		  }
		}

		/* want text file too? */
		if (tflag) {
		  strcpy(&fn[0], "textures/");
		  if (preserve_case)
		    strcat(&fn[0], &tname[0]);
		  else
		    strlcat(&fn[0], &tname[0]);
		  strcat(&fn[0], ".wgc");
		  if ((fp = fopen(&fn[0], "w")) == NULL) {
		    err("can't open %s for writing", &fn[0]);
		    exit(1);
		  }
		  fprintf(fp, "%s_START\n", section);
		  fprintf(fp, "  %s %d %d %d\n", &tname[0], width, height,
		      num_pat);
		}

		/* clear pixel buffer */
		memset(img_buf, 255, img_buf_sz);

		/* loop over all patches for the texture */
		patches_found = 0;
		for (j = 0; j < num_pat; j++) {
		  const char *patchname = NULL;
		  listitem_t *wad;

		  xoff = *p3++;
		  swapint(&xoff);
		  yoff = *p3++;
		  swapint(&yoff);
		  if (yoff < 0)
                    yoff = 0;
		  pnum = *p3++;
		  swapint(&pnum);
		  dummy = *p3++;	/* always 1, stepdir? what is that?? */
		  dummy = *p3++;	/* always 0 for colormap 0 */
		  for (wad = wadlist; wad != NULL; wad = wad->next) {
		    if (get_patch(wad->wf, fp, pnames, width, height,
			  xoff, yoff, pnum, &patchname) == 0) {
		      patches_found++;
		      break;
		    }
		  }
		  if (wad == NULL)
		    printf("    Warning: patch \"%.8s\" is missing\n",
			patchname);
		}

		if (patches_found == 0 && mpatch_policy != OIT_ALWAYS) {
		  printf("    Warning: skipping void texture \"%s\".\n", tname);
		  rc = 1;
		}
		else if (patches_found < num_pat && mpatch_policy == OIT_IF_ALL) {
		  printf("    Warning: skipping incomplete texture \"%s\".\n", tname);
		  rc = 1;
		}
		else
		  if (extract)
		    write_ppm(&tname[0], width, height);

		/* terminate and close the text file too */
		if (tflag) {
		  fprintf(fp, "%s_END\n", section);
		  if (fclose(fp)) {
		    err("%s: %s", fn, strerror(errno));
		    exit(1);
		  }
		}
	}
	return rc;
}