Skip to content

Commit 44b2811

Browse files
author
jcteng
committed
add tutorial 0-4 implement
0 parents commit 44b2811

30 files changed

+3972
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.vscode
2+
*.pyc

3rdparty/FbxCommon.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from fbx import *
2+
import sys
3+
4+
def InitializeSdkObjects():
5+
# The first thing to do is to create the FBX SDK manager which is the
6+
# object allocator for almost all the classes in the SDK.
7+
lSdkManager = FbxManager.Create()
8+
if not lSdkManager:
9+
sys.exit(0)
10+
11+
# Create an IOSettings object
12+
ios = FbxIOSettings.Create(lSdkManager, IOSROOT)
13+
lSdkManager.SetIOSettings(ios)
14+
15+
# Create the entity that will hold the scene.
16+
lScene = FbxScene.Create(lSdkManager, "")
17+
18+
return (lSdkManager, lScene)
19+
20+
def SaveScene(pSdkManager, pScene, pFilename, pFileFormat = -1, pEmbedMedia = False):
21+
lExporter = FbxExporter.Create(pSdkManager, "")
22+
if pFileFormat < 0 or pFileFormat >= pSdkManager.GetIOPluginRegistry().GetWriterFormatCount():
23+
pFileFormat = pSdkManager.GetIOPluginRegistry().GetNativeWriterFormat()
24+
if not pEmbedMedia:
25+
lFormatCount = pSdkManager.GetIOPluginRegistry().GetWriterFormatCount()
26+
for lFormatIndex in range(lFormatCount):
27+
if pSdkManager.GetIOPluginRegistry().WriterIsFBX(lFormatIndex):
28+
lDesc = pSdkManager.GetIOPluginRegistry().GetWriterFormatDescription(lFormatIndex)
29+
if "ascii" in lDesc:
30+
pFileFormat = lFormatIndex
31+
break
32+
33+
if not pSdkManager.GetIOSettings():
34+
ios = FbxIOSettings.Create(pSdkManager, IOSROOT)
35+
pSdkManager.SetIOSettings(ios)
36+
37+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_MATERIAL, True)
38+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_TEXTURE, True)
39+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_EMBEDDED, pEmbedMedia)
40+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_SHAPE, True)
41+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GOBO, True)
42+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_ANIMATION, True)
43+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, True)
44+
45+
result = lExporter.Initialize(pFilename, pFileFormat, pSdkManager.GetIOSettings())
46+
if result == True:
47+
result = lExporter.Export(pScene)
48+
49+
lExporter.Destroy()
50+
return result
51+
52+
def LoadScene(pSdkManager, pScene, pFileName):
53+
lImporter = FbxImporter.Create(pSdkManager, "")
54+
result = lImporter.Initialize(pFileName, -1, pSdkManager.GetIOSettings())
55+
if not result:
56+
return False
57+
58+
if lImporter.IsFBX():
59+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_MATERIAL, True)
60+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_TEXTURE, True)
61+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_EMBEDDED, True)
62+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_SHAPE, True)
63+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GOBO, True)
64+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_ANIMATION, True)
65+
pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, True)
66+
67+
result = lImporter.Import(pScene)
68+
lImporter.Destroy()
69+
return result

3rdparty/fbx.pyd

12.9 MB
Binary file not shown.

3rdparty/fbxsip.pyd

65.5 KB
Binary file not shown.

glsl/tu01/fragment.glsl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#version 330 core
2+
3+
// Interpolated values from the vertex shaders
4+
in vec3 fragmentColor;
5+
6+
// Ouput data
7+
out vec3 color;
8+
9+
void main(){
10+
11+
// Output color = color specified in the vertex shader,
12+
// interpolated between all 3 surrounding vertices
13+
color = fragmentColor;
14+
15+
}

glsl/tu01/vertex.glsl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#version 330 core
2+
3+
// Input vertex data, different for all executions of this shader.
4+
layout(location = 0) in vec3 vertexPosition_modelspace;
5+
layout(location = 1) in vec3 vertexColor;
6+
7+
// Output data ; will be interpolated for each fragment.
8+
out vec3 fragmentColor;
9+
// Values that stay constant for the whole mesh.
10+
uniform mat4 MVP;
11+
void main(){
12+
13+
// Output position of the vertex, in clip space : MVP * position
14+
gl_Position = MVP * vec4(vertexPosition_modelspace,1);
15+
16+
// The color of each vertex will be interpolated
17+
// to produce the color of each fragment
18+
fragmentColor = vertexColor;
19+
}

glsl/tu02/fragment.glsl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#version 330 core
2+
3+
// Interpolated values from the vertex shaders
4+
in vec2 UV;
5+
6+
// Ouput data
7+
out vec3 color;
8+
9+
// Values that stay constant for the whole mesh.
10+
uniform sampler2D myTextureSampler;
11+
12+
void main(){
13+
14+
// Output color = color of the texture at the specified UV
15+
color = texture( myTextureSampler, UV ).rgb;
16+
}

glsl/tu02/vertex.glsl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#version 330 core
2+
3+
// Input vertex data, different for all executions of this shader.
4+
layout(location = 0) in vec3 vertexPosition_modelspace;
5+
layout(location = 1) in vec2 vertexUV;
6+
7+
// Output data ; will be interpolated for each fragment.
8+
out vec2 UV;
9+
10+
// Values that stay constant for the whole mesh.
11+
uniform mat4 MVP;
12+
13+
void main(){
14+
15+
// Output position of the vertex, in clip space : MVP * position
16+
gl_Position = MVP * vec4(vertexPosition_modelspace,1);
17+
18+
// UV of the vertex. No special space for this one.
19+
UV = vertexUV;
20+
}

glsl/tu04/fragment.glsl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#version 330 core
2+
3+
// Interpolated values from the vertex shaders
4+
in vec2 UV;
5+
6+
// Ouput data
7+
out vec3 color;
8+
9+
// Values that stay constant for the whole mesh.
10+
uniform sampler2D myTextureSampler;
11+
12+
void main(){
13+
14+
// Output color = color of the texture at the specified UV
15+
color = texture( myTextureSampler, UV ).rgb;
16+
}

glsl/tu04/vertex.glsl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#version 330 core
2+
3+
// Input vertex data, different for all executions of this shader.
4+
layout(location = 0) in vec3 vertexPosition_modelspace;
5+
layout(location = 1) in vec2 vertexUV;
6+
7+
// Output data ; will be interpolated for each fragment.
8+
out vec2 UV;
9+
10+
// Values that stay constant for the whole mesh.
11+
uniform mat4 MVP;
12+
13+
void main(){
14+
15+
// Output position of the vertex, in clip space : MVP * position
16+
gl_Position = MVP * vec4(vertexPosition_modelspace,1);
17+
18+
// UV of the vertex. No special space for this one.
19+
UV = vertexUV;
20+
}

0 commit comments

Comments
 (0)