Ejemplo n.º 1
0
void Init(HWND hWnd)
{
	g_hWnd = hWnd;										// Assign the window handle to a global window handle
	GetClientRect(g_hWnd, &g_rRect);					// Assign the windows rectangle to a global RECT
	InitializeOpenGL(g_rRect.right, g_rRect.bottom);	// Init OpenGL with the global rect

	g_Load3ds.Import3DS(&g_3DModel, FILE_NAME);			// Load our .3DS file into our model structure

	// Go through all the materials
	for(int i = 0; i < g_3DModel.numOfMaterials; i++)
	{
		// Check to see if there is a file name to load in this material
		if(strlen(g_3DModel.pMaterials[i].strFile) > 0)
		{
			// Use the name of the texture file to load the bitmap, with a texture ID (i).
			// We pass in our global texture array, the name of the texture, and an ID to reference it.	
			CreateTexture(g_Texture, g_3DModel.pMaterials[i].strFile, i);			
		}

		// Set the texture ID for this material
		g_3DModel.pMaterials[i].texureId = i;
	}

	glEnable(GL_LIGHT0);								// Turn on a light with defaults set
	glEnable(GL_LIGHTING);								// Turn on lighting
	glEnable(GL_COLOR_MATERIAL);						// Allow color
}
Ejemplo n.º 2
0
Liquidmanager::Liquidmanager(int wid,int hei,struct winampVisModule *this_mod)
{
	Generated_textures	= new TextGeneration();
	Generated_Meshes	= new MeshGeneration();	

	char *ini_file=new char[70];
	char *help=new char[70];
	char *p;
	GetModuleFileName(this_mod->hDllInstance,ini_file,MAX_PATH);
	p=ini_file+strlen(ini_file);
	while (p >= ini_file && *p != '\\') p--;
	if (++p >= ini_file) 
		*p = 0;
	strcpy(help,ini_file);
	strcat(help,FILE_NAME);

	g_Load3ds.Import3DS(&liquidmodel, help);
	
	width				= wid;
	height				= hei;

	textures			= new loadall(this_mod);
	
	liquid1				= new scene1(40.0f,(float)width,(float)height);
	/*liquid2				= new scene2(40.0f,4,(float)width,(float)height,0);
	liquid3				= new scene3(40.0f,Generated_textures,(float)width,(float)height);
	liquid6				= new scene6(40.0f,(float)width,(float)height);
	liquid7				= new scene7(40.0f,(float)width,(float)height);
	liquid8				= new scene8(40.0f,(float)width,(float)height);
	liquid9				= new scene9(40.0f,(float)width,(float)height);
	liquid10			= new scene10(40.0f,(float)width,(float)height);
	liquid11			= new scene11(40.0f,(float)width,(float)height);
	liquid12			= new scene12(40.0f,(float)width,(float)height);
	liquid13			= new scene13(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid14			= new scene14(40.0f,(float)width,(float)height);
	liquid15			= new scene15(40.0f,(float)width,(float)height);
	liquid16			= new scene16(40.0f,0,(float)width,(float)height);
	liquid17			= new scene17(40.0f,(float)width,(float)height);
	liquid18			= new scene18(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid19			= new scene19(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid20			= new scene20(40.0f,(float)width,(float)height);
	liquid21			= new scene21(40.0f,(float)width,(float)height);
	liquid22			= new scene22(40.0f,(float)width,(float)height);
	liquid23			= new scene23(40.0f,(float)width,(float)height);
	liquid24			= new scene24(40.0f,(float)width,(float)height);
	liquid25			= new scene25(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid26			= new scene26(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid27			= new scene27(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid28			= new scene28(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid29			= new scene29(40.0f,Generated_textures,Generated_Meshes,(float)width,(float)height);
	liquid30			= new scene30(40.0f,(float)width,(float)height);
	liquid31			= new scene31(40.0f,Generated_textures,Generated_Meshes,&liquidmodel,(float)width,(float)height);
	//liquid34			= new scene34(40.0f,(float)width,(float)height);*/
	g_pFrameTime		= new liqTime();
	liquid1->Init(textures);

	lockscene		= FALSE;
}
Ejemplo n.º 3
0
void init3DTexTest()
{
//	Test3DS();
	Model3DsTest1.Loadfile("Data/Model/Test3dsModel.3DS");
	Model3DsTest1.LoadToVRAM();
	for(int i=0;i<32;i++)
	{
		for(int j=0;j<32;j++)
		{
			for(int k=0;k<4;k++)
			{
				Tex3DData[i][j][k][0]=rand()%256;
				Tex3DData[i][j][k][1]=rand()%256;
				Tex3DData[i][j][k][2]=rand()%256;
				Tex3DData[i][j][k][3]=rand()%256;
			}
		}
	}
    glGenTextures( 1, &Tex3DID );
	glBindTexture( GL_TEXTURE_3D, Tex3DID ); 
	glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexImage3D(GL_TEXTURE_3D,0,GL_RGBA,32,32,4,0,GL_RGBA,GL_UNSIGNED_BYTE,Tex3DData);
}
Ejemplo n.º 4
0
/*
void Test3DS()
{
	Model3ds=lib3ds_file_open("Data/Model/3ds.3DS");

	Lib3dsMeshInstanceNode *MeshData=0;
	
	Node=Model3ds->nodes;

	while((Node->type!=LIB3DS_NODE_MESH_INSTANCE)||(strcmp(Node->name,"$$$DUMMY")==0))
	{
		Node=Node->next;
		if(!Node)
			return;
	}
	Node=Node->next;
	Node=Node->next;
	Mesh=lib3ds_file_mesh_for_node(Model3ds,Node);
	if(!Mesh)
		return;
		
	//for(Mesh=Model3ds->meshes;Mesh!=NULL;Mesh=Model3ds->)
}*/
void DrawTest3DS()
{

	GLfloat LightPos[]={10000.0f,0.0f,0.0f,0.0f};
	glLightfv(GL_LIGHT0,GL_POSITION,LightPos);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	//float tmpxxx=0.0f;
	glColor4f(1.0f,1.0f,1.0f,1.0f);
	glBindTexture(GL_TEXTURE_2D, Test3DsTexID);
	//glBindTexture(GL_TEXTURE_2D, 0);
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(TestPos[0],TestPos[1],-150.0f+TestPos[2]);				// Move Right 1.5 Units And Into The Screen 6.0
	glRotatef(-turn2*2,0.0f,1.0f,0.0f);			// Rotate The Quad On The X axis
	glRotatef(TestRot[0],1.0f,0.0f,0.0f);
	glRotatef(TestRot[1],0.0f,1.0f,0.0f);
	TestRotSNYC=TestRotSNYC+1;
	if(TestRotSNYC>=100.0f)
		TestRotSNYC=0.0f;
	//frametest=TestRotSNYC;
	Model3DsTest1.Render(frametest);
	//float * pvertices = new float[Mesh->nvertices*3*3*4];
	/*glBegin(GL_TRIANGLES);
	for(int i=0;i<Mesh->nfaces;i++)
	{
		
		Face=&(Mesh->faces[i]);


		//glVertex3fv(Mesh->vertices[Face->index[j]]);
		glTexCoord2f(Mesh->texcos[Face->index[0]][0],Mesh->texcos[Face->index[0]][1]);glVertex3f(Mesh->vertices[Face->index[0]][0],Mesh->vertices[Face->index[0]][2],Mesh->vertices[Face->index[0]][1]);
		glTexCoord2f(Mesh->texcos[Face->index[1]][0],Mesh->texcos[Face->index[1]][1]);glVertex3f(Mesh->vertices[Face->index[1]][0],Mesh->vertices[Face->index[1]][2],Mesh->vertices[Face->index[1]][1]);
		glTexCoord2f(Mesh->texcos[Face->index[2]][0],Mesh->texcos[Face->index[2]][1]);glVertex3f(Mesh->vertices[Face->index[2]][0],Mesh->vertices[Face->index[2]][2],Mesh->vertices[Face->index[2]][1]);
		//tmpxxx=pvertices[(i*3+j)*3+0]=Mesh->vertices[Face->index[j]][0]*0.01f;
		//tmpxxx=pvertices[(i*3+j)*3+1]=Mesh->vertices[Face->index[j]][1]*0.01f;
		//tmpxxx=pvertices[(i*3+j)*3+2]=Mesh->vertices[Face->index[j]][2]*0.01f;
		
		
	}
	glEnd();*/
	glPopMatrix();
	glDisable(GL_LIGHTING);
}
Ejemplo n.º 5
0
void Init(HWND hWnd)
{
	g_hWnd = hWnd;										// Assign the window handle to a global window handle
	GetClientRect(g_hWnd, &g_rRect);					// Assign the windows rectangle to a global RECT
	InitializeOpenGL(g_rRect.right, g_rRect.bottom);	// Init OpenGL with the global rect

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	// First we need to actually load the .3DS file.  We just pass in an address to
	// our t3DModel structure and the file name string we want to load ("face.3ds").

	g_Load3ds.Import3DS(&g_3DModel, FILE_NAME);			// Load our .3DS file into our model structure

	// Depending on how many textures we found, load each one (Assuming .BMP)
	// If you want to load other files than bitmaps, you will need to adjust CreateTexture().
	// Below, we go through all of the materials and check if they have a texture map to load.
	// Otherwise, the material just holds the color information and we don't need to load a texture.

	// Go through all the materials
	for(int i = 0; i < g_3DModel.numOfMaterials; i++)
	{
		// Check to see if there is a file name to load in this material
		if(strlen(g_3DModel.pMaterials[i].strFile) > 0)
		{
			// Use the name of the texture file to load the bitmap, with a texture ID (i).
			// We pass in our global texture array, the name of the texture, and an ID to reference it.	
			CreateTexture(g_3DModel.pMaterials[i].strFile, g_Texture[i]);			
		}

		// Set the texture ID for this material
		g_3DModel.pMaterials[i].texureId = i;
	}

	// Here, we turn on a lighting and enable lighting.  We don't need to
	// set anything else for lighting because we will just take the defaults.
	// We also want color, so we turn that on

	glEnable(GL_LIGHT0);								// Turn on a light with defaults set
	glEnable(GL_LIGHTING);								// Turn on lighting
	glEnable(GL_COLOR_MATERIAL);						// Allow color

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

}
Ejemplo n.º 6
0
void Init(HWND hWnd)
{
	g_hWnd = hWnd;										// Assign the window handle to a global window handle
	GetClientRect(g_hWnd, &g_rRect);					// Assign the windows rectangle to a global RECT
	InitializeOpenGL(g_rRect.right, g_rRect.bottom);	// Init OpenGL with the global rect


/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
	
	// Initialize the camera position
	g_Camera.PositionCamera(0, 3.5f, 30,	0, 0, 0,	0, 1, 0);

	// Here we load the world from a .3ds file
	g_Load3DS.Import3DS(&g_World, FILE_NAME);

	// Go through all the materials
	for(int i = 0; i < g_World.numOfMaterials; i++)
	{
		// Check to see if there is a file name to load in this material
		if(strlen(g_World.pMaterials[i].strFile) > 0)
		{
			// Use the name of the texture file to load the bitmap, with a texture ID (i).
			// We pass in our global texture array, the name of the texture, and an ID to reference it.	
			CreateTexture(g_Texture[i], g_World.pMaterials[i].strFile);			
		}

		// Set the texture ID for this material
		g_World.pMaterials[i].texureId = i;
	}

	// The first thing that needs to happen before creating our octree is to find
	// the total width of the initial root node.  Now we pass in our t3DModel object
	// to GetSceneDimensions(), instead of vertices and a vertex count, as done
	// in the last octree tutorials.  This will store the initial root node cube width.
	g_Octree.GetSceneDimensions(&g_World);

	// Since our model structures stores multiple objects, we can't easily access the
	// total triangle count in the scene with out manually going through and counting the total.
	// This is what we do below.  With the result, we pass this into our CreateNode() function.
	int TotalTriangleCount = g_Octree.GetSceneTriangleCount(&g_World);

	// To create the first node we need the world data, the total triangle count in the scene,
	// along with the initial root node center and width.  This function will then recursively
	// subdivide the rest of the world, according to the global restrictions.
	g_Octree.CreateNode(&g_World, TotalTriangleCount, g_Octree.GetCenter(), g_Octree.GetWidth());

	// The octree should be created by now.  To better increase our efficiency we use display
	// lists for every end node.  This way, we just have to call a display list ID to draw
	// a node, verses the slow loops we normal had.  Vertex arrays are also used to optimize
	// our rendering of the octree.

	// Below we get the display list base ID and store it in the root node.  This should return 1
	// since we don't use display lists anywhere before this.  Notice that we use our global
	// variable that stores our end node count to pass in the total amount of list ID's needed.
	// If you are unfamiliar with displays, basically what you do is section off a certain
	// amount of ID's, and then you are returns a base pointer to the start of those ID's.
	// You can use the ID's from the base pointer to the base pointer ID + the number of
	// ID's that were saved off for that base pointer.  Each of the ID's correspond to a
	// bunch of OpenGL commands.  That means that each end node has it's own ID that
	// corresponds to a bunch of OpenGL commands.  So, for instance, if pass in a bunch
	// of vertices to OpenGL, we can assign this action to a display list.  That way we
	// just call a display list ID to perform that action.  Think of it as a function.
	// You just need to call a function to do a bunch of tasks, which eliminates extra
	// code, and also is saved on the video card for faster processing.  
	g_Octree.SetDisplayListID( glGenLists(g_EndNodeCount) );

	// Now we go through every single end node and create a display list for them all.
	// That way, when we draw the end node, we just use it's display list ID to render
	// the node, instead of looping through all the objects and manually give the verts to opengl.
	// The parameters for this function is the node (starting with the root node), 
	// the world data and current display list base ID.  The base ID is stored in the root
	// node's ID, so we just pass that in.  The reason we do this is because, if you create
	// other display lists before you create the octree, you don't want to assume the octree
	// ID's go from 1 to the end node count.  By passing in the base ID, we then will add
	// this ID to other nodes.  Right now, when they are created they are assigned the
	// end node count at the time upon creating them.  This will make more sense when looking
	// at the octree code.
	g_Octree.CreateDisplayList(&g_Octree, &g_World, g_Octree.GetDisplayListID());

	// Hide our cursor since we are using first person camera mode
	ShowCursor(FALSE);

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	glEnable(GL_LIGHT0);								// Turn on a light with defaults set
	glEnable(GL_LIGHTING);								// Turn on lighting
	glEnable(GL_COLOR_MATERIAL);						// Allow color
}