Esempio n. 1
0
void 
Object3DS::createTexture(UINT textureArray[], LPSTR strFileName, int textureID) {
	
	AUX_RGBImageRec *pBitmap = NULL;
    TGAImage *tgaImage = NULL;

	FILE *pFile = NULL;					// The File Handle we will use to read the bitmap

	if(!strFileName)					// Return from the function if no file name was passed in
		return;
	
	pFile = fopen(strFileName,"r");		// Check To See If The File Exists

	setTextureType(strFileName);

	if(pFile) {
		if (textureType == TEXTURE_BMP) {
			pBitmap = auxDIBImageLoad(strFileName);	// Load the bitmap and store the data	
		}
		else if (textureType == TEXTURE_TGA) {
			tgaImage = new TGAImage();
			tgaImage->loadTGA(strFileName);
		}
		else {
			exit(0);
		}
	}
	else												// If we can't find the file, quit!
	{													// Prompt the error message
		printf("Couldn't find a texture!\n");
		exit(0);
	}
	
	glGenTextures(1, &textureArray[textureID]);
	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
	glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);

	if (textureType == TEXTURE_BMP) {
		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);
	}
	else if (textureType == TEXTURE_TGA) {
		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tgaImage->imageWidth, tgaImage->imageHeight, tgaImage->texFormat, GL_UNSIGNED_BYTE, tgaImage->imageData);				
	}

	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	
	
	if (pBitmap) {
		if (pBitmap->data)
			free(pBitmap->data);						// Free the texture data, we don't need it anymore		
		free(pBitmap);									// Free the bitmap structure
	}	
}
Esempio n. 2
0
void editParticles()
{
	do{
		int i,j;
		char t;
		
		system("clear");
		printf("Textures\n");

		for(i=0;i<header->nParticleEmitters;i++)
		{
			setTextureType(tex[i].type);
			
			printf("%d Flags: %02x Bone: %d Pos: %.2f %.2f %.2f Texture: %d Blend: %d Type: %d\n",i,particles[i].flags,particles[i].bone,particles[i].pos[0],particles[i].pos[1],particles[i].pos[2],particles[i].texture,particles[i].blend,particles[i].type);
			printf("\tColors %08x %08x %08x\n",particles[i].p.colors[0],particles[i].p.colors[1],particles[i].p.colors[2]);
			printf("\tSizes %.2f %.2f %.2f\n",particles[i].p.sizes[0],particles[i].p.sizes[1],particles[i].p.sizes[2]);
			printf("\tSlowdown %.2f Rotation %.2f\n",particles[i].p.slowdown,particles[i].p.rotation);
		}


		printf("\n f - Change Flags\n n - Change Bones\n p - Change Position\n r - Change Rotation\n t - Change Texture\n c - Change Colors\n b - Change Blending\n y - Change Emitter Type\n s - Change Sizes\n a - Edit Animation Block\n q - Return to Main Menu\n");
		t=getchar();
		if(t=='p')
		{
			i=-1;

			do{
				printf("\nChange a postion (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{
					float Pos[3];
					printf("New Position (format \"x y z\")\n");
					scanf ("%f %f %f",&Pos[0],&Pos[1],&Pos[2]);
					for(j=0;j<3;j++)
						particles[i].pos[j]=Pos[j];
					changed=true;
				}
			}while(i!=-1);
		}
		else if(t=='s')
		{
			i=-1;

			do{
				printf("\nChange the sizes (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{
					float Size[3];
					printf("New Sizes (format \"b m e\")\n");
					scanf ("%f %f %f",&Size[0],&Size[1],&Size[2]);
					for(j=0;j<3;j++)
						particles[i].p.sizes[j]=Size[j];
					changed=true;
				}
			}while(i!=-1);
		}
		else if(t=='a')
		{
			i=-1;
			printf("Animation Block Types\n");
			printf("0 - Emission Speed\n");
			printf("1 - Speed Variation (range 0 to 1)\n");
			printf("2 - Rotation\\Tumble Spread (range 0 to pi)\n");
			printf("3 - ? (range: 0 to 2pi)\n");
			printf("4 - Gravity\n");
			printf("5 - Lifespan\n");
			printf("6 - Emission Rate\n");
			printf("7 - Emission Area Length\n");
			printf("8 - Emission Area Width\n");
			printf("9 - Gravity? (much stronger)\n");

			do{
				printf("Edit Animation Block (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{
					float Pos[3];
					printf("Which Block(0-9)\n");
					scanf ("%d",&j);
					editAnimBlock(&(particles[i].params[j]));
				}
			}while(i!=-1);
		}
		if(t=='b')
		{
			i=-1;

			do{
				printf("\nChange a blend mode (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{
					printf("New Blend Mode (0 - Opaque, 1 - Alpha testing, 2 - Alpha Blending, 3 - Additive, 4 - Additive Alpha, 5 - Modulate, 6 - Deeprun Tram Glass\n");
					scanf ("%d",&j);
					particles[i].blend=j;
					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='f')
		{
			i=-1;

			do{
				printf("\nChange flags (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{				
					printf("New Flag\n");
					scanf ("%x",&j);
					particles[i].flags=j;
					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='r')
		{
			i=-1;

			do{
				printf("\nChange flags (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{				
					printf("New Rotation\n");
					scanf ("%f",&(particles[i].p.rotation));
					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='n')
		{
			i=-1;

			do{
				printf("\nChange Bones (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{				
					printf("New Bone\n");
					scanf ("%d",&j);
					particles[i].bone=j;
					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='y')
		{
			i=-1;

			do{
				printf("\nChange a emitter type (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{
					printf("New Emitter Type (1 - Plane 2 - Sphere 3 - Unknown\n");
					scanf ("%d",&j);
					particles[i].type=j;
					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='t')
		{
			printf("Textures\n");
			for(i=0;i<header->nTextures;i++)
				printf(" %d - %s\n",i,(char *)(f+tex[i].nameOfs));

			i=-1;

			do{
				printf("\nChange a texture (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{
					printf("New Texture\n");

					scanf ("%d",&j);
					particles[i].texture=j;
					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='c')
		{
			i=-1;

			do{
				printf("\nChange particle colors (number of particle or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nParticleEmitters))
				{
					printf("Current Colors %08x %08x %08x\n",particles[i].p.colors[0],particles[i].p.colors[1],particles[i].p.colors[2]);

					printf("New Start Color\n");
					scanf ("%x",&j);
					particles[i].p.colors[0]=j;

					printf("New Middle Color\n");
					scanf ("%x",&j);
					particles[i].p.colors[1]=j;

					printf("New End Color\n");
					scanf ("%x",&j);
					particles[i].p.colors[2]=j;

					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='q')
			return;


	}while(1);
}
Esempio n. 3
0
void editTextures()
{
	do{
		int i,j;
		char t;
		
		system("clear");
		printf("Textures\n");

		for(i=0;i<header->nTextures;i++)
		{
			setTextureType(tex[i].type);
			
			printf("%d Type: %s (%d) Unknown: 0x%04x Flags: 0x%04x\n",i,textureType,tex[i].type,tex[i].flags>>16,tex[i].flags&0xffff);
			if(tex[i].type==0)
				printf("\tTexture: %s\n",(char *)(f+tex[i].nameOfs));
		}


		printf("\n t - Change Texture Type\n n - Change Texture File Name\n f - Change Texture Flags\n q - Return to Main Menu\n");
		t=getchar();

		if(t=='t')
		{
			i=-1;

			do{
				printf("\nChange a texture type (number of texture or -1 to quit)\n\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nTextures))
				{
					printf("New texture type (currently %d)\n",tex[i].type);
					printf("0 - Hard Coded\n");	
					printf("1 - Player Skin\n");
					printf("2 - Cape\n");
					printf("6 - Hair\n");
					printf("8 - Tauren Fur\n");
					printf("11 - Creature Skin 1\n");
					printf("12 - Creature Skin 2\n");
					printf("13 - Creature Skin 3\n");
					scanf ("%d",&j);
					tex[i].type=j;
					changed=true;
				}
			}while(i!=-1);
		}
		if(t=='n')
		{
			i=-1;

			do{
				printf("\nChange a texture file name (number of texture or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nTextures))
				{
					char newName[255];
					printf("New texture file name (currently %s max new length 15)\n",(char *)(f+tex[i].nameOfs));
					scanf ("%s",newName);
					if(strlen(newName)<16)
					{
						strcpy((char *)(f+tex[i].nameOfs),newName);
						tex[i].nameLen=strlen(newName)+1;
						changed=true;
					}
					else
						printf("Length of %s too long (%d characters while max of 15)\n",newName,strlen(newName));
					
				}
			}while(i!=-1);
		}
		if(t=='f')
		{
			i=-1;

			do{
				printf("\nChange a texture flag (number of texture or -1 to quit)\n");
				scanf ("%d",&i);
				if((i>=0)&&(i<header->nTextures))
				{
					printf("New texture type (currently 0x%04x)\n",tex[i].flags&0xffff);
					printf("1 - Texture Wrap X\n");	
					printf("2 - Texture Wrap Y\n");
					scanf ("%d",&j);
					tex[i].flags=(tex[i].flags&0xffff0000)|(j&(0xffff));
					changed=true;
				}
			}while(i!=-1);
		}
		else if(t=='q')
			return;


	}while(1);
}