Hi All,
I've fixed the last problem concerning cameras and object positionning by learning with some tutorials and making several tests :p
Now I can play with camera and objects easily with the commands set I've created for :)
But I encounter 3 new issues.
1/ 1 triangle is not drawn ... It seem to be the last one or the first one .... I've defined 36 triangles with each all correct coordinates :
INTERNAL_MakeTriangle( MemblockID, 0, -X, -Y, -Z, X, -Y, -Z, X, -Y, Z, 0 ); // Bottom 1/2
INTERNAL_MakeTriangle( MemblockID, 1, X, -Y, Z, -X, -Y, Z, -X, -Y, -Z, 1 ); // Bottom 2/2
INTERNAL_MakeTriangle( MemblockID, 2, -X, Y, -Z, -X, Y, Z, X, Y, Z, 0 ); // Top 1/2
INTERNAL_MakeTriangle( MemblockID, 3, X, Y, Z, X, Y, -Z, -X, Y, -Z, 1 ); // Top 2/2
INTERNAL_MakeTriangle( MemblockID, 4, -X, -Y, -Z, -X, Y, -Z, X, Y, -Z, 0 ); // South 1/2
INTERNAL_MakeTriangle( MemblockID, 5, X, Y, -Z, X, -Y, -Z, -X, -Y, -Z, 1 ); // South 2/2
INTERNAL_MakeTriangle( MemblockID, 6, X, -Y, Z, X, Y, Z, -X, Y, Z, 0 ); // North 1/2
INTERNAL_MakeTriangle( MemblockID, 7, -X, Y, Z,-X, -Y, Z, X, -Y, Z, 1 ); // North 2/2
INTERNAL_MakeTriangle( MemblockID, 8, X, -Y, -Z, X, Y, -Z, X, Y, Z, 0 ); // East 1/2
INTERNAL_MakeTriangle( MemblockID, 9, X, Y, Z, X, -Y, Z, X, -Y, -Z, 1 ); // East 2/2
INTERNAL_MakeTriangle( MemblockID,10, -X, -Y, -Z, -X, -Y, Z, -X, Y, Z, 0 ); // West 1/2
INTERNAL_MakeTriangle( MemblockID,11, -X, Y, Z, -X, Y, -Z, -X, -Y, -Z, 1 ); // West 2/2
last arg simply change the UV textures to define the triangle.
Here is the triangle function :
void INTERNAL_MakeTriangle( int MemblockID, int TriangleID, float XA, float YA, float ZA, float XB, float YB, float ZB, float XC, float YC, float ZC, int MODE ){
int VectorNumber = TriangleID * 3;
int RGBColor = DERgb( 255, 255, 255 );
if ( MODE == 0 ){
INTERNAL_MakeVector( MemblockID, VectorNumber, XA, YA, ZA, RGBColor, 1.0f, 1.0f );
INTERNAL_MakeVector( MemblockID, VectorNumber + 1, XB, YB, ZB, RGBColor, 1.0f, 0.0f );
INTERNAL_MakeVector( MemblockID, VectorNumber + 2, XC, YC, ZC, RGBColor, 0.0f, 0.0f );
}
if ( MODE == 1 ){
INTERNAL_MakeVector( MemblockID, VectorNumber, XA, YA, ZA, RGBColor, 0.0f, 0.0f );
INTERNAL_MakeVector( MemblockID, VectorNumber + 1, XB, YB, ZB, RGBColor, 0.0f, 1.0f );
INTERNAL_MakeVector( MemblockID, VectorNumber + 2, XC, YC, ZC, RGBColor, 1.0f, 1.0f );
}
}
Strange Issue .. I'm maybe wrong with something in the function that render the object ...
2/ Problem with normals.
I'm making now the object normals and object texturing but I encounter 2 problems.
My test concern a cube.
I've set normal to 1 axis to 1/-1 depending on the face:
Top : Y = 1.0
Bottom : Y = -1.0
Left : X=-1.0
Right : X= 1.0
Front : Z = -1.0
Rear : Z = 1.0
These values are the axis orientation of the face with object rotation set to 0.0, 0.0, 0.0
But lighting doesn't appear correctly.
3/ Problem with texturing.
Each face is 2 triangle. I've set textures coordinates to 0.0 or 1.0 depending on the position on the face
If I put the face on 2 axis:
top left : 0.0, 0.0
top right : 1.0, 0.0
bottom left : 0.0, 1.0
bottom right : 1.0, 1.0
All faces vertex follow this rule.
But I get this result :
http://files.odyssey-creators.com/MyCubev0_1.jpgHere is the code I use to trace my 3D Object on screen :
void INTERNAL_Trace3DObject( int ObjectID ){
Object3DPointer MyObject = NULL;
MyObject = GetObjectPTR( ObjectID );
if ( MyObject != 0 ){
int *ObjectMeshPTR = NULL;
ObjectMeshPTR = GetObjectMeshPTR( ObjectID );
// Gestion des faces cach?es de l'objet.
// Utilise les composantes de couleur de l'objet 3D.
glColor3f( MyObject->RGBRed, MyObject->RGBGreen, MyObject->RGBBlue );
// Valide la position sur X,Y,Z de l'objet ? tracer.
glTranslatef( MyObject->XPos, MyObject->YPos, MyObject->ZPos );
// Valide les angles de rotation appliqu?s ? l'objet ? tracer.
glRotatef( MyObject->XRot, 1.0, 0.0, 0.0 );
glRotatef( MyObject->YRot, 0.0, 1.0, 0.0 );
glRotatef( MyObject->ZRot, 0.0, 0.0, 1.0 );
// Redimensionnement de l'objet ? tracer.
// glScalef( MyObject->XScale, MyObject->YScale, MyObject->ZScale );
// Activation des modes de rendu n?cessaires.
int VertexAmount = ( MyObject->MeshMemorySize - 12 ) / 36;
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, ObjectMeshPTR + 12 );
glEnableClientState( GL_NORMAL_ARRAY );
int *ObjectNormalPTR = NULL;
ObjectNormalPTR = ObjectMeshPTR + 12 + ( 36 * 12 );
glNormalPointer( GL_FLOAT, 0, ObjectNormalPTR );
int *ObjectUVPTR = NULL;
ObjectUVPTR = ObjectMeshPTR + 12 + ( 36 * 24 );
if ( MyObject->ImageIndex != 0 ){
glActiveTexture( GL_TEXTURE0 );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, ImageTexture[ MyObject->ImageIndex ] );
glClientActiveTexture( GL_TEXTURE0 );
glEnableClientState( GL_TEXTURE_COORD_ARRAY_EXT );
glTexCoordPointer( 2, GL_FLOAT, 0, ObjectUVPTR );
}
if ( MyObject->Culling == 1 ){
glEnable( GL_CULL_FACE );
}else{
glDisable( GL_CULL_FACE );
}
// Trac? des ?l?ments.
glDrawArrays( GL_TRIANGLES, 0, VertexAmount );
//D?sactivation des composantes utilis?es pour le rendu de l'objet 3D.
if ( MyObject->ImageIndex != 0 ){
glDisable( GL_TEXTURE_2D );
}
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY_EXT );
glDisableClientState( GL_NORMAL_ARRAY );
}
}
I don't understand what can cause this issue.
I've rechecked the UV coordinates, the normals, the vertexes ...
If someone have an idea ... plz help :)
Thank you
Regards,
Freddix / AmiDARK