REVIEWED: models_yaw_pitch_roll

This commit is contained in:
raysan5 2021-10-19 14:58:04 +02:00
parent fec0ce34c5
commit 2e151408bb
10 changed files with 10939 additions and 443 deletions

View file

@ -881,8 +881,8 @@ models/models_skybox: models/models_skybox.c
models/models_yaw_pitch_roll: models/models_yaw_pitch_roll.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file models/resources/models/gltf/plane/plane.gltf@resources/models/gltf/plane/plane.gltf \
--preload-file models/resources/models/gltf/plane/plane_diffuse.png@resources/models/gltf/plane/plane_diffuse.png
--preload-file models/resources/models/obj/plane.gltf@resources/modelsobj/plane.gltf \
--preload-file models/resources/models/obj/plane_diffuse.png@resources/models/obj/plane_diffuse.png
models/models_heightmap: models/models_heightmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \

View file

@ -32,9 +32,9 @@ int main(void)
camera.fovy = 30.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera type
// Model loading
// NOTE: Diffuse map loaded automatically
Model model = LoadModel("resources/models/gltf/plane/plane.gltf");
Model model = LoadModel("resources/models/obj/plane.obj"); // Load model
Texture2D texture = LoadTexture("resources/models/obj/plane_diffuse.png"); // Load model texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
float pitch = 0.0f;
float roll = 0.0f;
@ -88,7 +88,7 @@ int main(void)
// Draw 3D model (recomended to draw 3D always before 2D)
BeginMode3D(camera);
DrawModel(model, (Vector3){ 0.0f, 0.0f, 15.0f }, 0.25f, WHITE); // Draw 3d model with texture
DrawModel(model, (Vector3){ 0.0f, -8.0f, 0.0f }, 1.0f, WHITE); // Draw 3d model with texture
DrawGrid(10, 10.0f);
EndMode3D();

View file

@ -7,9 +7,9 @@
| models/obj/turret.obj,<br>models/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
| models/obj/well.obj,<br>models/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
| models/obj/cube.obj,<br>models/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
| models/obj/plane.gltf,<br>models/gltf/plane/plane.bin,<br>models/gltf/plane/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c)
| models/iqm/guy.iqm,<br>models/iqm/guyanim.iqm,<br>models/iqm/guytex.png,<br>models/iqm/guy.blend | [@culacant](https://github.com/culacant) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
| models/iqm/vertex_colored_object.iqm | ❔ | ❔ | - |
| models/gltf/plane/plane.gltf,<br>models/gltf/plane/plane.bin,<br>models/gltf/plane/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c)
| models/gltf/... | _various_ | Check [LICENSE](https://github.com/raysan5/raylib/blob/master/examples/models/resources/models/gltf/LICENSE) | - |
| models/vox/chr_knight.vox | ❔ | ❔ | - |
| models/vox/chr_sword.vox | ❔ | ❔ | - |

View file

@ -1,9 +0,0 @@
WWI Plane Model created by GiaHanLam (https://sketchfab.com/GiaHanLam)
This model is free to use, licensed as Creative Commons Attribution (CC-BY 4.0)
License details: https://creativecommons.org/licenses/by/4.0/
As per the license, author must be credited and commercial use is allowed.
This model was donwload from author Sketchfab account: https://sketchfab.com/3d-models/wwi-plane-model-f0d39a6daacd4925a8922db193886715

View file

@ -1,327 +0,0 @@
{
"accessors": [
{
"bufferView": 2,
"componentType": 5126,
"count": 3446,
"max": [
143.99604797363281,
168.74668884277344,
75.31597900390625
],
"min": [
-143.99604797363281,
-43.94732666015625,
-49.556678771972656
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 41352,
"componentType": 5126,
"count": 3446,
"max": [
1,
0.99916732311248779,
0.99978786706924438
],
"min": [
-1,
-0.99928808212280273,
-0.99977350234985352
],
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 3446,
"max": [
1,
1,
1,
1
],
"min": [
0,
0,
0,
0
],
"type": "VEC4"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 3446,
"max": [
4.8965663909912109,
0.99786919355392456
],
"min": [
0.0036561768501996994,
0.0083234198391437531
],
"type": "VEC2"
},
{
"bufferView": 0,
"componentType": 5125,
"count": 7692,
"max": [
3445
],
"min": [
0
],
"type": "SCALAR"
}
],
"asset": {
"extras": {
"author": "GiaHanLam (https://sketchfab.com/GiaHanLam)",
"license": "CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)",
"source": "https://sketchfab.com/3d-models/wwi-plane-model-f0d39a6daacd4925a8922db193886715",
"title": "WWI Plane Model"
},
"generator": "Sketchfab-8.25.0",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 30768,
"byteOffset": 0,
"name": "floatBufferViews",
"target": 34963
},
{
"buffer": 0,
"byteLength": 27568,
"byteOffset": 30768,
"byteStride": 8,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 82704,
"byteOffset": 58336,
"byteStride": 12,
"name": "floatBufferViews",
"target": 34962
},
{
"buffer": 0,
"byteLength": 55136,
"byteOffset": 141040,
"byteStride": 16,
"name": "floatBufferViews",
"target": 34962
}
],
"buffers": [
{
"byteLength": 196176,
"uri": "plane.bin"
}
],
"images": [
{
"uri": "plane_diffuse.png"
}
],
"materials": [
{
"doubleSided": true,
"name": "Material_24",
"pbrMetallicRoughness": {
"baseColorFactor": [
1,
1,
1,
1
],
"baseColorTexture": {
"index": 0,
"texCoord": 0
},
"metallicFactor": 0,
"roughnessFactor": 0.59999999999999998
}
}
],
"meshes": [
{
"name": "BODY_Material #24_0",
"primitives": [
{
"attributes": {
"COLOR_0": 2,
"NORMAL": 1,
"POSITION": 0,
"TEXCOORD_0": 3
},
"indices": 4,
"material": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"children": [
1
],
"name": "RootNode (gltf orientation matrix)",
"rotation": [
-0.70710678118654746,
-0,
-0,
0.70710678118654757
]
},
{
"children": [
2
],
"name": "RootNode (model correction matrix)"
},
{
"children": [
3
],
"matrix": [
1,
0,
0,
0,
0,
0,
1,
0,
0,
-1,
0,
0,
0,
0,
0,
1
],
"name": "base"
},
{
"children": [
4,
6
],
"name": "RootNode"
},
{
"children": [
5
],
"matrix": [
1,
0,
0,
0,
0,
2.2204460492503131e-16,
-1,
0,
0,
1,
2.2204460492503131e-16,
0,
0,
0,
0,
1
],
"name": "BODY"
},
{
"mesh": 0,
"name": "BODY_Material #24_0"
},
{
"children": [
7
],
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
-680,
0,
90,
1
],
"name": "Sky001"
},
{
"children": [
8
],
"matrix": [
1,
0,
0,
0,
0,
2.2204460492503131e-16,
1,
0,
0,
-1,
2.2204460492503131e-16,
0,
0,
0,
0,
1
],
"name": ""
},
{
"name": ""
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9987,
"wrapS": 10497,
"wrapT": 10497
}
],
"scene": 0,
"scenes": [
{
"name": "OSG_Scene",
"nodes": [
0
]
}
],
"textures": [
{
"sampler": 0,
"source": 0
}
]
}

File diff suppressed because it is too large Load diff

View file

Before

Width:  |  Height:  |  Size: 804 KiB

After

Width:  |  Height:  |  Size: 804 KiB

Before After
Before After

View file

@ -6,10 +6,11 @@ attribute vec2 vertexTexCoord;
attribute vec3 vertexNormal;
attribute vec4 vertexColor;
attribute mat4 instance;
attribute mat4 instanceTransform;
// Input uniform values
uniform mat4 mvp;
uniform mat4 matNormal;
// Output vertex attributes (to fragment shader)
varying vec3 fragPosition;
@ -19,43 +20,16 @@ varying vec3 fragNormal;
// NOTE: Add here your custom variables
// https://github.com/glslify/glsl-inverse
mat3 inverse(mat3 m)
{
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
float b01 = a22*a11 - a12*a21;
float b11 = -a22*a10 + a12*a20;
float b21 = a21*a10 - a11*a20;
float det = a00*b01 + a01*b11 + a02*b21;
return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
}
// https://github.com/glslify/glsl-transpose
mat3 transpose(mat3 m)
{
return mat3(m[0][0], m[1][0], m[2][0],
m[0][1], m[1][1], m[2][1],
m[0][2], m[1][2], m[2][2]);
}
void main()
{
// Compute MVP for current instance
mat4 mvpi = mvp*instanceTransform;
// Send vertex attributes to fragment shader
fragPosition = vec3(instance*vec4(vertexPosition, 1.0));
fragPosition = vec3(mvpi*vec4(vertexPosition, 1.0));
fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
mat3 normalMatrix = transpose(inverse(mat3(instance)));
fragNormal = normalize(normalMatrix*vertexNormal);
mat4 mvpi = mvp*instance;
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
// Calculate final vertex position
gl_Position = mvpi*vec4(vertexPosition, 1.0);