working on model lighthing/texture mapping

This commit is contained in:
Chris Danford
2003-04-27 05:14:27 +00:00
parent d1db01ecfe
commit 8e96af518a
7 changed files with 350 additions and 189 deletions
+184 -170
View File
@@ -4,7 +4,7 @@ Frames: 30
Frame: 1
Meshes: 1
"Cylinder01" 0 -1
"Cylinder01" 0 0
91
0 4.500000 -33.250000 0.000000 0.000000 1.000000 6
0 4.500000 -23.666668 0.000000 0.000000 0.833333 5
@@ -69,13 +69,13 @@ Meshes: 1
0 -2.250000 5.083332 -3.897114 0.666667 0.333333 2
0 -2.250000 14.666668 -3.897114 0.666667 0.166667 1
0 -2.250000 24.250000 -3.897114 0.666667 0.000000 0
0 -0.000000 -23.666668 -4.500000 0.750000 0.833333 5
0 -0.000000 -33.250000 -4.500000 0.750000 1.000000 6
0 -0.000000 -14.083334 -4.500000 0.750000 0.666667 4
0 -0.000000 -4.500000 -4.500000 0.750000 0.500000 3
0 -0.000000 5.083332 -4.500000 0.750000 0.333333 2
0 -0.000000 14.666668 -4.500000 0.750000 0.166667 1
0 -0.000000 24.250000 -4.500000 0.750000 0.000000 0
0 0.000000 -23.666668 -4.500000 0.750000 0.833333 5
0 0.000000 -33.250000 -4.500000 0.750000 1.000000 6
0 0.000000 -14.083334 -4.500000 0.750000 0.666667 4
0 0.000000 -4.500000 -4.500000 0.750000 0.500000 3
0 0.000000 5.083332 -4.500000 0.750000 0.333333 2
0 0.000000 14.666668 -4.500000 0.750000 0.166667 1
0 0.000000 24.250000 -4.500000 0.750000 0.000000 0
0 2.250000 -33.250000 -3.897114 0.833333 1.000000 6
0 2.250000 -23.666668 -3.897114 0.833333 0.833333 5
0 2.250000 -14.083334 -3.897114 0.833333 0.666667 4
@@ -97,171 +97,185 @@ Meshes: 1
0 4.500000 5.083332 0.000000 1.000000 0.333333 2
0 4.500000 14.666668 0.000000 1.000000 0.166667 1
0 4.500000 24.250000 0.000000 1.000000 0.000000 0
12
1.000000 0.000000 0.000000
17
0.965926 0.000000 0.258819
0.866025 0.000000 0.500000
0.866025 0.000000 0.500000
0.500000 0.000000 0.866025
0.000000 0.000000 1.000000
-0.500000 0.000000 0.866025
-0.500000 0.000000 0.866025
-0.866025 0.000000 0.500000
-1.000000 0.000000 0.000000
-0.866025 0.000000 -0.500000
-0.866025 0.000000 -0.500000
-0.500000 0.000000 -0.866025
0.000000 0.000000 -1.000000
0.500000 0.000000 -0.866025
0.500000 0.000000 -0.866025
0.866025 0.000000 -0.500000
0.965926 0.000000 -0.258819
144
0 0 1 2 0 0 1 1
0 0 2 3 0 1 1 1
0 0 2 3 0 1 2 1
0 1 4 2 0 0 1 1
0 4 5 2 0 1 1 1
0 4 5 2 0 2 1 1
0 4 6 7 0 0 1 1
0 4 7 5 0 1 1 1
0 4 7 5 0 1 2 1
0 6 8 7 0 0 1 1
0 8 9 7 0 1 1 1
0 8 9 7 0 2 1 1
0 8 10 11 0 0 1 1
0 8 11 9 0 1 1 1
0 8 11 9 0 1 2 1
0 10 12 11 0 0 1 1
0 12 13 11 0 1 1 1
0 3 2 14 1 1 2 1
0 2 15 14 1 2 2 1
0 2 5 16 1 1 2 1
0 2 16 15 1 2 2 1
0 5 7 16 1 1 2 1
0 7 17 16 1 2 2 1
0 7 9 18 1 1 2 1
0 7 18 17 1 2 2 1
0 9 11 18 1 1 2 1
0 11 19 18 1 2 2 1
0 11 13 20 1 1 2 1
0 11 20 19 1 2 2 1
0 14 15 21 2 2 3 1
0 14 21 22 2 3 3 1
0 15 16 21 2 2 3 1
0 16 23 21 2 3 3 1
0 16 17 24 2 2 3 1
0 16 24 23 2 3 3 1
0 17 18 24 2 2 3 1
0 18 25 24 2 3 3 1
0 18 19 26 2 2 3 1
0 18 26 25 2 3 3 1
0 19 20 26 2 2 3 1
0 20 27 26 2 3 3 1
0 22 21 28 3 3 4 1
0 21 29 28 3 4 4 1
0 21 23 30 3 3 4 1
0 21 30 29 3 4 4 1
0 23 24 30 3 3 4 1
0 24 31 30 3 4 4 1
0 24 25 32 3 3 4 1
0 24 32 31 3 4 4 1
0 25 26 32 3 3 4 1
0 26 33 32 3 4 4 1
0 26 27 34 3 3 4 1
0 26 34 33 3 4 4 1
0 28 29 35 4 4 5 1
0 28 35 36 4 5 5 1
0 29 30 35 4 4 5 1
0 30 37 35 4 5 5 1
0 30 31 38 4 4 5 1
0 30 38 37 4 5 5 1
0 31 32 38 4 4 5 1
0 32 39 38 4 5 5 1
0 32 33 40 4 4 5 1
0 32 40 39 4 5 5 1
0 33 34 40 4 4 5 1
0 34 41 40 4 5 5 1
0 36 35 42 5 5 6 1
0 35 43 42 5 6 6 1
0 35 37 44 5 5 6 1
0 35 44 43 5 6 6 1
0 37 38 44 5 5 6 1
0 38 45 44 5 6 6 1
0 38 39 46 5 5 6 1
0 38 46 45 5 6 6 1
0 39 40 46 5 5 6 1
0 40 47 46 5 6 6 1
0 40 41 48 5 5 6 1
0 40 48 47 5 6 6 1
0 42 43 49 6 6 7 1
0 42 49 50 6 7 7 1
0 43 44 49 6 6 7 1
0 44 51 49 6 7 7 1
0 44 45 52 6 6 7 1
0 44 52 51 6 7 7 1
0 45 46 52 6 6 7 1
0 46 53 52 6 7 7 1
0 46 47 54 6 6 7 1
0 46 54 53 6 7 7 1
0 47 48 54 6 6 7 1
0 48 55 54 6 7 7 1
0 50 49 56 7 7 8 1
0 49 57 56 7 8 8 1
0 49 51 58 7 7 8 1
0 49 58 57 7 8 8 1
0 51 52 58 7 7 8 1
0 52 59 58 7 8 8 1
0 52 53 60 7 7 8 1
0 52 60 59 7 8 8 1
0 53 54 60 7 7 8 1
0 54 61 60 7 8 8 1
0 54 55 62 7 7 8 1
0 54 62 61 7 8 8 1
0 56 57 63 8 8 9 1
0 56 63 64 8 9 9 1
0 57 58 63 8 8 9 1
0 58 65 63 8 9 9 1
0 58 59 66 8 8 9 1
0 58 66 65 8 9 9 1
0 59 60 66 8 8 9 1
0 60 67 66 8 9 9 1
0 60 61 68 8 8 9 1
0 60 68 67 8 9 9 1
0 61 62 68 8 8 9 1
0 62 69 68 8 9 9 1
0 64 63 70 9 9 10 1
0 63 71 70 9 10 10 1
0 63 65 72 9 9 10 1
0 63 72 71 9 10 10 1
0 65 66 72 9 9 10 1
0 66 73 72 9 10 10 1
0 66 67 74 9 9 10 1
0 66 74 73 9 10 10 1
0 67 68 74 9 9 10 1
0 68 75 74 9 10 10 1
0 68 69 76 9 9 10 1
0 68 76 75 9 10 10 1
0 70 71 77 10 10 11 1
0 70 77 78 10 11 11 1
0 71 72 77 10 10 11 1
0 72 79 77 10 11 11 1
0 72 73 80 10 10 11 1
0 72 80 79 10 11 11 1
0 73 74 80 10 10 11 1
0 74 81 80 10 11 11 1
0 74 75 82 10 10 11 1
0 74 82 81 10 11 11 1
0 75 76 82 10 10 11 1
0 76 83 82 10 11 11 1
0 78 77 84 11 11 0 1
0 77 85 84 11 0 0 1
0 77 79 86 11 11 0 1
0 77 86 85 11 0 0 1
0 79 80 86 11 11 0 1
0 80 87 86 11 0 0 1
0 80 81 88 11 11 0 1
0 80 88 87 11 0 0 1
0 81 82 88 11 11 0 1
0 82 89 88 11 0 0 1
0 82 83 90 11 11 0 1
0 82 90 89 11 0 0 1
0 12 13 11 0 2 1 1
0 3 2 14 2 1 3 1
0 2 15 14 1 3 3 1
0 2 5 16 1 2 3 1
0 2 16 15 1 3 3 1
0 5 7 16 2 1 3 1
0 7 17 16 1 3 3 1
0 7 9 18 1 2 3 1
0 7 18 17 1 3 3 1
0 9 11 18 2 1 3 1
0 11 19 18 1 3 3 1
0 11 13 20 1 2 3 1
0 11 20 19 1 3 3 1
0 14 15 21 3 3 4 1
0 14 21 22 3 4 4 1
0 15 16 21 3 3 4 1
0 16 23 21 3 4 4 1
0 16 17 24 3 3 4 1
0 16 24 23 3 4 4 1
0 17 18 24 3 3 4 1
0 18 25 24 3 4 4 1
0 18 19 26 3 3 4 1
0 18 26 25 3 4 4 1
0 19 20 26 3 3 4 1
0 20 27 26 3 4 4 1
0 22 21 28 4 4 5 1
0 21 29 28 4 5 5 1
0 21 23 30 4 4 6 1
0 21 30 29 4 6 5 1
0 23 24 30 4 4 6 1
0 24 31 30 4 5 6 1
0 24 25 32 4 4 6 1
0 24 32 31 4 6 5 1
0 25 26 32 4 4 6 1
0 26 33 32 4 5 6 1
0 26 27 34 4 4 5 1
0 26 34 33 4 5 5 1
0 28 29 35 5 5 7 1
0 28 35 36 5 7 7 1
0 29 30 35 5 6 7 1
0 30 37 35 6 7 7 1
0 30 31 38 6 5 7 1
0 30 38 37 6 7 7 1
0 31 32 38 5 6 7 1
0 32 39 38 6 7 7 1
0 32 33 40 6 5 7 1
0 32 40 39 6 7 7 1
0 33 34 40 5 5 7 1
0 34 41 40 5 7 7 1
0 36 35 42 7 7 8 1
0 35 43 42 7 8 8 1
0 35 37 44 7 7 8 1
0 35 44 43 7 8 8 1
0 37 38 44 7 7 8 1
0 38 45 44 7 8 8 1
0 38 39 46 7 7 8 1
0 38 46 45 7 8 8 1
0 39 40 46 7 7 8 1
0 40 47 46 7 8 8 1
0 40 41 48 7 7 8 1
0 40 48 47 7 8 8 1
0 42 43 49 8 8 9 1
0 42 49 50 8 9 10 1
0 43 44 49 8 8 9 1
0 44 51 49 8 10 9 1
0 44 45 52 8 8 9 1
0 44 52 51 8 9 10 1
0 45 46 52 8 8 9 1
0 46 53 52 8 10 9 1
0 46 47 54 8 8 9 1
0 46 54 53 8 9 10 1
0 47 48 54 8 8 9 1
0 48 55 54 8 10 9 1
0 50 49 56 10 9 11 1
0 49 57 56 9 11 11 1
0 49 51 58 9 10 11 1
0 49 58 57 9 11 11 1
0 51 52 58 10 9 11 1
0 52 59 58 9 11 11 1
0 52 53 60 9 10 11 1
0 52 60 59 9 11 11 1
0 53 54 60 10 9 11 1
0 54 61 60 9 11 11 1
0 54 55 62 9 10 11 1
0 54 62 61 9 11 11 1
0 56 57 63 11 11 12 1
0 56 63 64 11 12 12 1
0 57 58 63 11 11 12 1
0 58 65 63 11 12 12 1
0 58 59 66 11 11 12 1
0 58 66 65 11 12 12 1
0 59 60 66 11 11 12 1
0 60 67 66 11 12 12 1
0 60 61 68 11 11 12 1
0 60 68 67 11 12 12 1
0 61 62 68 11 11 12 1
0 62 69 68 11 12 12 1
0 64 63 70 12 12 13 1
0 63 71 70 12 13 13 1
0 63 65 72 12 12 14 1
0 63 72 71 12 14 13 1
0 65 66 72 12 12 14 1
0 66 73 72 12 13 14 1
0 66 67 74 12 12 14 1
0 66 74 73 12 14 13 1
0 67 68 74 12 12 14 1
0 68 75 74 12 13 14 1
0 68 69 76 12 12 13 1
0 68 76 75 12 13 13 1
0 70 71 77 13 13 15 1
0 70 77 78 13 15 15 1
0 71 72 77 13 14 15 1
0 72 79 77 14 15 15 1
0 72 73 80 14 13 15 1
0 72 80 79 14 15 15 1
0 73 74 80 13 14 15 1
0 74 81 80 14 15 15 1
0 74 75 82 14 13 15 1
0 74 82 81 14 15 15 1
0 75 76 82 13 13 15 1
0 76 83 82 13 15 15 1
0 78 77 84 15 15 16 1
0 77 85 84 15 16 16 1
0 77 79 86 15 15 16 1
0 77 86 85 15 16 16 1
0 79 80 86 15 15 16 1
0 80 87 86 15 16 16 1
0 80 81 88 15 15 16 1
0 80 88 87 15 16 16 1
0 81 82 88 15 15 16 1
0 82 89 88 15 16 16 1
0 82 83 90 15 15 16 1
0 82 90 89 15 16 16 1
Materials: 0
Materials: 1
"Material03"
1.000000 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000
0.000000 0.000000 0.000000 1.000000
0.000000 0.000000 0.000000 1.000000
16384.000000
1.000000
".\loading.bmp"
""
Bones: 7
"joint1"
""
0 0.000000 24.250000 0.000000 1.545162 1.570796 0.000000
8 0.000000 24.250000 0.000000 1.545162 1.570796 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.000000 0.000000 0.000000
@@ -272,40 +286,40 @@ Bones: 7
30.000000 0.000000 0.000000 0.000000
"joint2"
"joint1"
0 0.000000 0.000000 9.753204 0.106538 0.000000 0.000000
8 0.000000 0.000000 9.753204 0.106538 0.000000 0.000000
3
1.000000 0.000000 -0.000000 -0.000000
15.000000 0.000000 0.000000 -0.000000
30.000000 0.000000 0.000000 -0.000000
1.000000 0.000000 0.000000 0.000000
15.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 -0.401426 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
"joint3"
"joint2"
0 0.000000 0.000000 9.280355 0.134906 -0.000000 3.141593
3
1.000000 -0.000000 -0.000000 0.000000
15.000000 -0.000000 -0.000000 0.000000
30.000000 -0.000000 -0.000000 0.000000
8 0.000000 0.000000 9.280355 0.134906 0.000000 -3.141592
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.366519 0.000000 -0.000000
15.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.366519 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
"joint4"
"joint3"
0 0.000000 0.000000 9.263503 -0.054002 0.000000 0.000000
8 0.000000 0.000000 9.263503 -0.054002 0.000000 0.000000
3
1.000000 0.000000 -0.000000 0.000000
15.000000 0.000000 -0.000000 0.000000
30.000000 0.000000 -0.000000 0.000000
1.000000 0.000000 0.000000 0.000000
15.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.523599 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
"joint5"
"joint4"
0 0.000000 0.000000 10.000000 0.000000 0.000000 0.000000
8 0.000000 0.000000 10.000000 0.000000 0.000000 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.000000 0.000000 0.000000
@@ -316,18 +330,18 @@ Bones: 7
30.000000 0.000000 0.000000 0.000000
"joint6"
"joint5"
0 0.000000 0.000000 10.000000 0.026310 0.000259 0.000000
8 0.000000 0.000000 10.000000 0.026310 0.000259 0.000000
3
1.000000 0.000000 -0.000000 -0.000000
15.000000 0.000000 0.000000 -0.000000
30.000000 0.000000 0.000000 -0.000000
1.000000 0.000000 0.000000 0.000000
15.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.383972 -0.000016 0.000097
30.000000 0.000000 0.000000 0.000000
"joint7"
"joint6"
5 0.000000 0.000000 9.503289 0.000000 0.000000 0.000000
8 0.000000 0.000000 9.503289 0.000000 0.000000 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.000000 0.000000 0.000000
+5 -2
View File
@@ -93,6 +93,8 @@ typedef struct msMesh
} msMesh;
/* msMaterial */
class RageTexture;
typedef struct msMaterial
{
int nFlags;
@@ -104,8 +106,9 @@ typedef struct msMaterial
float fShininess;
float fTransparency;
char szDiffuseTexture[MS_MAX_PATH];
char szAlphaTexture[MS_MAX_PATH];
int nName;
char szAlphaTexture[MS_MAX_PATH]; // not used in SM. Use alpha in diffuse texture instead
int nName; // not used in SM. What is this for?
RageTexture* pTexture;
} msMaterial;
/* msPositionKey */
+90 -12
View File
@@ -13,6 +13,8 @@
#include "Milkshape.h"
#include "mathlib.h"
#include "RageDisplay.h"
#include "RageUtil.h"
#include "RageTextureManager.h"
Model::Model ()
@@ -42,9 +44,12 @@ void Model::Clear ()
}
}
bool Model::Load (const char *szFilename)
bool Model::Load( CString sPath )
{
FILE *file = fopen (szFilename, "rt");
CString sDir, sThrowAway;
splitrelpath( sPath, sDir, sThrowAway, sThrowAway );
FILE *file = fopen (sPath, "rt");
if (!file)
return false;
@@ -252,7 +257,7 @@ bool Model::Load (const char *szFilename)
for (i = 0; i < nNumMaterials && !bError; i++)
{
m_pModel->Materials.resize( m_pModel->Materials.size() );
m_pModel->Materials.resize( m_pModel->Materials.size()+1 );
msMaterial& Material = m_pModel->Materials.back();
// name
@@ -358,11 +363,8 @@ bool Model::Load (const char *szFilename)
bError = true;
break;
}
if (sscanf (szLine, "\"%[^\"]\"", szName) != 1)
{
bError = true;
break;
}
strcpy (szName, "");
sscanf (szLine, "\"%[^\"]\"", szName);
strcpy( Material.szDiffuseTexture, szName );
// alpha texture
@@ -373,8 +375,17 @@ bool Model::Load (const char *szFilename)
}
strcpy (szName, "");
sscanf (szLine, "\"%[^\"]\"", szName);
strcpy( Material.szAlphaTexture, szName );
Material.pTexture = NULL;
if( strcmp(Material.szDiffuseTexture, "")!=0 )
{
RageTextureID ID;
ID.filename = sDir+Material.szDiffuseTexture;
ID.bStretch = true;
if( DoesFileExist(ID.filename) )
Material.pTexture = TEXTUREMAN->LoadTexture( ID );
}
}
}
@@ -507,17 +518,59 @@ bool Model::Load (const char *szFilename)
return true;
}
#include "SDL_opengl.h"
#include "RageTimer.h"
void Model::DrawPrimitives()
{
if (!m_pModel)
return;
DISPLAY->SetTexture( NULL );
DISPLAY->SetBlendModeNormal();
DISPLAY->EnableLighting( true );
DISPLAY->EnableZBuffer();
DISPLAY->SetLightDirectional(
0,
RageColor(0.2f,0.2f,0.2f,1),
RageColor(1,1,1,1),
RageColor(1,1,1,1),
RageVector3(0, 0, +1) );
for (int i = 0; i < (int)m_pModel->Meshes.size(); i++)
{
msMesh *pMesh = &m_pModel->Meshes[i];
// apply material
if( pMesh->nMaterialIndex != -1 )
{
msMaterial& mat = m_pModel->Materials[ pMesh->nMaterialIndex ];
DISPLAY->SetMaterial(
mat.Emissive,
mat.Ambient,
mat.Diffuse,
mat.Specular,
mat.fShininess );
DISPLAY->SetTexture( mat.pTexture );
}
else
{
float emissive[4] = {0,0,0,0};
float ambient[4] = {0.2f,0.2f,0.2f,1};
float diffuse[4] = {0.7f,0.7f,0.7f,1};
float specular[4] = {0.2f,0.2f,0.2f,1};
float shininess = 1;
DISPLAY->SetMaterial(
emissive,
ambient,
diffuse,
specular,
shininess );
DISPLAY->SetTexture( NULL );
}
glBegin( GL_TRIANGLES );
for (int j = 0; j < (int)pMesh->Triangles.size(); j++)
{
RageVertex verts[3];
@@ -528,14 +581,31 @@ void Model::DrawPrimitives()
memcpy( nNormalIndices, pTriangle->nNormalIndices, sizeof(nNormalIndices) );
for (int k = 0; k < 3; k++)
{
msVertex *pVertex = &pMesh->Vertices[ nIndices[k] ];
RageVertex& v = verts[k];
msVec3 *normal = &pMesh->Normals[ nNormalIndices[k] ];
v.n.x = normal->v[0];
v.n.y = normal->v[1];
v.n.z = normal->v[2];
glNormal3fv( normal->v );
msVertex *pVertex = &pMesh->Vertices[ nIndices[k] ];
v.c = RageColor(1,1,1,1);
v.t.x = pVertex->uv[0];
v.t.y = pVertex->uv[1];
glTexCoord2f( pVertex->uv[0], pVertex->uv[1] );
float white[4] = {1,1,0,1};
glColor4fv( white );
if (pVertex->nBoneIndex == -1)
{
v.p.x = pVertex->Vertex[0];
v.p.y = pVertex->Vertex[1];
v.p.z = pVertex->Vertex[2];
glVertex3fv( pVertex->Vertex );
}
else
{
@@ -547,11 +617,18 @@ void Model::DrawPrimitives()
v.p.x = Vertex[0];
v.p.y = Vertex[1];
v.p.z = Vertex[2];
glVertex3fv( Vertex );
}
}
DISPLAY->DrawTriangles( verts, 3 );
// DISPLAY->DrawTriangles( verts, 3 );
}
glEnd();
}
DISPLAY->SetLightOff( 0 );
DISPLAY->EnableLighting( false );
}
float
@@ -748,5 +825,6 @@ Model::AdvanceFrame (float dt)
void Model::Update( float fDelta )
{
Actor::Update( fDelta );
AdvanceFrame( fDelta );
}
+1 -1
View File
@@ -34,7 +34,7 @@ public:
public:
void Clear ();
bool Load(const char *szFilename);
bool Load( CString sPath );
virtual void Update( float fDelta );
virtual void DrawPrimitives();
+49 -2
View File
@@ -943,9 +943,56 @@ void RageDisplay::DisableZBuffer()
{
glDisable( GL_DEPTH_TEST );
}
void RageDisplay::EnableTextureWrapping(bool yes)
void RageDisplay::EnableTextureWrapping(bool b)
{
GLenum mode = yes? GL_REPEAT:GL_CLAMP;
GLenum mode = b? GL_REPEAT:GL_CLAMP;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode );
}
void RageDisplay::SetMaterial(
float emissive[4],
float ambient[4],
float diffuse[4],
float specular[4],
float shininess
)
{
glMaterialfv( GL_FRONT, GL_EMISSION, emissive );
glMaterialfv( GL_FRONT, GL_AMBIENT, ambient );
glMaterialfv( GL_FRONT, GL_DIFFUSE, diffuse );
glMaterialfv( GL_FRONT, GL_SPECULAR, specular );
glMaterialf( GL_FRONT, GL_SHININESS, shininess );
}
void RageDisplay::EnableLighting(bool b)
{
if( b ) glEnable( GL_LIGHTING );
else glDisable( GL_LIGHTING );
}
void RageDisplay::SetLightOff( int index )
{
glDisable( GL_LIGHT0+index );
}
void RageDisplay::SetLightDirectional(
int index,
RageColor ambient,
RageColor diffuse,
RageColor specular,
RageVector3 dir )
{
// Light coordinates are transformed by the modelview matrix, but
// we are being passed in world-space coords.
glPushMatrix();
glLoadIdentity();
glEnable( GL_LIGHT0+index );
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
float position[4] = {dir.x, dir.y, dir.z, 0};
glLightfv(GL_LIGHT0, GL_POSITION, position);
glPopMatrix();
}
+18 -1
View File
@@ -66,7 +66,24 @@ public:
bool ZBufferEnabled() const;
void EnableZBuffer();
void DisableZBuffer();
void EnableTextureWrapping(bool yes=true);
void EnableTextureWrapping(bool b=true);
void SetMaterial(
float emissive[4],
float ambient[4],
float diffuse[4],
float specular[4],
float shininess
);
void EnableLighting(bool b=true);
void SetLightOff( int index );
void SetLightDirectional(
int index,
RageColor ambient,
RageColor diffuse,
RageColor specular,
RageVector3 dir );
void DrawQuad( const RageVertex v[4] ); // upper-left, upper-right, lower-left, lower-right
void DrawQuads( const RageVertex v[], int iNumVerts );
+3 -1
View File
@@ -31,9 +31,11 @@ ScreenSandbox::ScreenSandbox() : Screen("ScreenSandbox")
// this->AddChild( &m_sprite );
m_model.SetXY(CENTER_X, CENTER_Y);
m_model.SetZoom(10);
m_model.SetZoomX(5);
m_model.SetZoomY(5);
m_model.Load( "bend.txt" );
this->AddChild(&m_model);
m_model.SetEffectSpin( RageVector3(0,90,0) );
this->AddChild( &m_In );