when i rotate my model the lighting don't light the new part in front of its

Hi !
my lighting works when i load my model but if i rotate the model the nex part in front of the light isn’t lighted !
Do you know why ? what can i do ?

hard to tell - could you post a code snippet?
:regards:

What type of light

Does all you model have correct normals etc…

Are you rotating your light as well

Basically more information is needed

in fact it works with some files(i am making a .3ds loader)and my model have at least some good normals (i have checked it), do you think it’s possible that some others aren’t right. I don’t try to rotate the light, just the model.

I apologize but I do not see where you have lighting involved. as far as the normals go, as long as they are “normalized” appropriately in your myLoader->myObjects[i].perVertexNormals data object. also, what if you have a model that encompasses the light source? could that be possible?

:regards:

sorry i didn’t pay attention :
this is normals computation (the function “multiplyMatrix” multiply normals by the rotation part of the tranformation matrix of the .3ds in which i read)

 void loader3ds::loadIndices()
{
	float resultDp ;
	ofstream oFile2("sortie3ds2.txt");

	file.read((char*) &(myObjects[counterObj].nbPoly), sizeof (unsigned short int));	

	for (polyCounter = 0 ; polyCounter< myObjects[counterObj].nbPoly ; polyCounter++)
	{
	
		file.read((char*) &(myObjects[counterObj].myIndices[polyCounter][0]), sizeof (unsigned short int));
		file.read((char*) &(myObjects[counterObj].myIndices[polyCounter][1]), sizeof (unsigned short int));
		file.read((char*) &(myObjects[counterObj].myIndices[polyCounter][2]), sizeof (unsigned short int));
		file.read((char*) &(faceInfo), sizeof (short int));
	//	cout<<"face info "<<faceInfo<<endl ;

		int Va = myObjects[counterObj].myIndices[polyCounter][0] ;
		int Vb = myObjects[counterObj].myIndices[polyCounter][1] ;
		int Vc = myObjects[counterObj].myIndices[polyCounter][2] ;                                                                       
		
//on se sert de ab et ca pour le produit vectoriel, ça et le reste servent uniquement pour la normal weight
		float Vab[] = {(myObjects[counterObj].myVertices[Vb][0] - myObjects[counterObj].myVertices[Va][0]),
					(myObjects[counterObj].myVertices[Vb][1] - myObjects[counterObj].myVertices[Va][1]),
					(myObjects[counterObj].myVertices[Vb][2] - myObjects[counterObj].myVertices[Va][2])};

		float Vac[] = {(myObjects[counterObj].myVertices[Vc][0] - myObjects[counterObj].myVertices[Va][0]),
					(myObjects[counterObj].myVertices[Vc][1] - myObjects[counterObj].myVertices[Va][1]),
					(myObjects[counterObj].myVertices[Vc][2] - myObjects[counterObj].myVertices[Va][2])};
		
		float Vba[] = {(myObjects[counterObj].myVertices[Va][0] - myObjects[counterObj].myVertices[Vb][0]),
					(myObjects[counterObj].myVertices[Va][1] - myObjects[counterObj].myVertices[Vb][1]),
					(myObjects[counterObj].myVertices[Va][2] - myObjects[counterObj].myVertices[Vb][2])};

		float Vbc[] = {(myObjects[counterObj].myVertices[Vc][0] - myObjects[counterObj].myVertices[Vb][0]),
					(myObjects[counterObj].myVertices[Vc][1] - myObjects[counterObj].myVertices[Vb][1]),
					(myObjects[counterObj].myVertices[Vc][2] - myObjects[counterObj].myVertices[Vb][2])};

		float Vca[] = {(myObjects[counterObj].myVertices[Va][0] - myObjects[counterObj].myVertices[Vc][0]),
					(myObjects[counterObj].myVertices[Va][1] - myObjects[counterObj].myVertices[Vc][1]),
					(myObjects[counterObj].myVertices[Va][2] - myObjects[counterObj].myVertices[Vc][2])};

		float Vcb[] = {(myObjects[counterObj].myVertices[Vb][0] - myObjects[counterObj].myVertices[Vc][0]),
					(myObjects[counterObj].myVertices[Vb][1] - myObjects[counterObj].myVertices[Vc][1]),
					(myObjects[counterObj].myVertices[Vb][2] - myObjects[counterObj].myVertices[Vc][2])};
		
		normalize(Vab) ;
		normalize(Vac) ;
		dotProduct(Vab, Vac, &resultDp) ; 
		//oFile2<<dec<<"resultDp "<<resultDp<<endl ;
		angle[polyCounter][0]=acosf(resultDp) ;
		//oFile2<<"angle "<<dec<<angle[polyCounter][0]<<endl ;

		normalize(Vba) ;
		normalize(Vbc) ;
		dotProduct(Vba, Vbc, &resultDp) ;
		//cout<<"resultDp "<<resultDp<<endl ;
		angle[polyCounter][1]=acosf(resultDp) ;

		normalize(Vca) ;
		normalize(Vcb) ;
		dotProduct(Vca, Vcb, &resultDp) ;
		angle[polyCounter][2]=acosf(resultDp) ;
		//oFile2<<"angle "<<dec<<angle[polyCounter][0]<<" "<<angle[polyCounter][1]<<" "<<angle[polyCounter][2]<<endl ;
		switch (faceInfo)
		{
			case 0x3 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vac, Vbc) ;
				      break ;
			case 0x7 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vab, Vbc) ;
				      break ;
			case 0x6 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vab, Vbc) ;
				      break ;
			case 0x5 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vac, Vab) ;
				      break ;
			case 0x4 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vab, Vcb) ;
				      break ;
			case 0x2 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vca, Vbc) ;
				      break ;
			case 0x1 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vac, Vcb) ;
				      break ;
			case 0x0 :crossProduct(&myObjects[counterObj].perFaceNormals[polyCounter], Vba, Vcb) ;
				      break ;
		}
		normalize(&myObjects[counterObj].perFaceNormals[polyCounter]) ;
		
		//oFile2<<dec<<"angle "<<angle[polyCounter*3]<<" "<<angle[polyCounter*3+1]<<" "<<angle[polyCounter*3+2]<<endl ;
		
	}//fin de la boucle for
	
	cout<<"face info "<<hex<<faceInfo<<endl ;
//éventuellement supprimer l'initialisation, vu que (peut etre) tout les sommets y passent	
	for (polyCounter = 0 ; polyCounter< myObjects[counterObj].nbVertices ; polyCounter++)
	{
		myObjects[counterObj].perVertexNormals[polyCounter][0] = 0 ;
		myObjects[counterObj].perVertexNormals[polyCounter][1] = 0 ;
		myObjects[counterObj].perVertexNormals[polyCounter][2] = 0 ;
	}
		
	for(nIndice=0 ; nIndice < myObjects[counterObj].nbVertices ; nIndice++)
	{
		for(i=0 ; i < myObjects[counterObj].nbPoly ; i++)
		{
			for(j=0 ; j< 3; j++)
			{
				if(myObjects[counterObj].myIndices[i][j]==nIndice)
				{
					myObjects[counterObj].perVertexNormals[nIndice][0] += myObjects[counterObj].perFaceNormals[i].x*angle[i][j] ;
					myObjects[counterObj].perVertexNormals[nIndice][1] += myObjects[counterObj].perFaceNormals[i].y*angle[i][j] ;
					myObjects[counterObj].perVertexNormals[nIndice][2] += myObjects[counterObj].perFaceNormals[i].z*angle[i][j] ;
				}
			}
		}
	}
	
	/*multiplyMatrix(myObjects[counterObj].localAxisMatrix, 
				   &myObjects[counterObj].myVertices[0][0], 
				   &myObjects[counterObj].nbVertices) ;*/

	multiplyMatrix(myObjects[counterObj].localAxisMatrix, 
				   &myObjects[counterObj].perVertexNormals[0][0], 
				   &myObjects[counterObj].nbVertices) ;
	
/*	float tempSwap, tempSwap2 ;

	for(counter=0 ; counter < myObjects[counterObj].nbVertices ; counter++)
	{
		tempSwap = myObjects[counterObj].myVertices[counter][1] ;
		myObjects[counterObj].myVertices[counter][1]= myObjects[counterObj].myVertices[counter][2] ;
		myObjects[counterObj].myVertices[counter][2]= -tempSwap ;

		tempSwap2 = myObjects[counterObj].perVertexNormals[counter][1] ;
		myObjects[counterObj].perVertexNormals[counter][1]= myObjects[counterObj].perVertexNormals[counter][2] ;
		myObjects[counterObj].perVertexNormals[counter][2]= -tempSwap2 ;
	}*/

//on normalise
	for(counter=0 ; counter < myObjects[counterObj].nbVertices ; counter++)
	{
		normalize(&myObjects[counterObj].perVertexNormals[counter][0], 
				  &myObjects[counterObj].perVertexNormals[counter][1],
				  &myObjects[counterObj].perVertexNormals[counter][2]) ;
	}

	ofstream oFile("sortie3ds.txt");
	for(counter=0 ; counter < myObjects[counterObj].nbVertices ; counter++)
	{
		 oFile<<"par vertex "<<myObjects[counterObj].perVertexNormals[counter][0] <<" "
					<<myObjects[counterObj].perVertexNormals[counter][1] <<" "
					<<myObjects[counterObj].perVertexNormals[counter][2] <<endl ;
	}
	/*for(counter=0 ; counter < myObjects[counterObj].nbVertices ; counter++)
	{
		for(i=0 ; i<100 ; i++)
		{
			oFile2<<dec<<tableIndices[counter][i]<<" " ;
		}
	}*/
	cout.flush() ;
} 

Are you using a

Omni-directional light source ?

or

Directional light source ?

or

Spot Light source ?