Move collada viewer to extra/model-viewer
parent
e1223e056f
commit
03966e4fb2
|
@ -8,15 +8,15 @@ io io.encodings.ascii io.files io.files.temp kernel locals math
|
||||||
math.matrices math.vectors.simd math.parser math.vectors
|
math.matrices math.vectors.simd math.parser math.vectors
|
||||||
method-chains namespaces sequences splitting threads ui ui.gadgets
|
method-chains namespaces sequences splitting threads ui ui.gadgets
|
||||||
ui.gadgets.worlds ui.pixel-formats specialized-arrays
|
ui.gadgets.worlds ui.pixel-formats specialized-arrays
|
||||||
specialized-vectors literals game.models.collada fry xml
|
specialized-vectors literals fry xml
|
||||||
xml.traversal sequences.deep destructors math.bitwise opengl.gl
|
xml.traversal sequences.deep destructors math.bitwise opengl.gl
|
||||||
prettyprint game.models.obj game.models.loader ;
|
game.models.obj game.models.loader game.models.collada ;
|
||||||
FROM: alien.c-types => float ;
|
FROM: alien.c-types => float ;
|
||||||
SPECIALIZED-ARRAY: float
|
SPECIALIZED-ARRAY: float
|
||||||
SPECIALIZED-VECTOR: uint
|
SPECIALIZED-VECTOR: uint
|
||||||
IN: collada.viewer
|
IN: model-viewer
|
||||||
|
|
||||||
GLSL-SHADER: collada-vertex-shader vertex-shader
|
GLSL-SHADER: model-vertex-shader vertex-shader
|
||||||
uniform mat4 mv_matrix, p_matrix;
|
uniform mat4 mv_matrix, p_matrix;
|
||||||
uniform vec3 light_position;
|
uniform vec3 light_position;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ void main()
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
GLSL-SHADER: collada-fragment-shader fragment-shader
|
GLSL-SHADER: model-fragment-shader fragment-shader
|
||||||
varying vec2 texit;
|
varying vec2 texit;
|
||||||
varying vec3 norm;
|
varying vec3 norm;
|
||||||
void main()
|
void main()
|
||||||
|
@ -45,8 +45,8 @@ void main()
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
GLSL-PROGRAM: collada-program
|
GLSL-PROGRAM: model-program
|
||||||
collada-vertex-shader collada-fragment-shader ;
|
model-vertex-shader model-fragment-shader ;
|
||||||
|
|
||||||
GLSL-SHADER: debug-vertex-shader vertex-shader
|
GLSL-SHADER: debug-vertex-shader vertex-shader
|
||||||
uniform mat4 mv_matrix, p_matrix;
|
uniform mat4 mv_matrix, p_matrix;
|
||||||
|
@ -73,18 +73,18 @@ void main()
|
||||||
|
|
||||||
GLSL-PROGRAM: debug-program debug-vertex-shader debug-fragment-shader ;
|
GLSL-PROGRAM: debug-program debug-vertex-shader debug-fragment-shader ;
|
||||||
|
|
||||||
UNIFORM-TUPLE: collada-uniforms < mvp-uniforms
|
UNIFORM-TUPLE: model-uniforms < mvp-uniforms
|
||||||
{ "light-position" vec3-uniform f } ;
|
{ "light-position" vec3-uniform f } ;
|
||||||
|
|
||||||
TUPLE: collada-state
|
TUPLE: model-state
|
||||||
models
|
models
|
||||||
vertex-arrays
|
vertex-arrays
|
||||||
index-vectors ;
|
index-vectors ;
|
||||||
|
|
||||||
TUPLE: collada-world < wasd-world
|
TUPLE: model-world < wasd-world
|
||||||
{ collada collada-state } ;
|
{ model-state model-state } ;
|
||||||
|
|
||||||
VERTEX-FORMAT: collada-vertex
|
VERTEX-FORMAT: model-vertex
|
||||||
{ "POSITION" float-components 3 f }
|
{ "POSITION" float-components 3 f }
|
||||||
{ "NORMAL" float-components 3 f }
|
{ "NORMAL" float-components 3 f }
|
||||||
{ "TEXCOORD" float-components 2 f } ;
|
{ "TEXCOORD" float-components 2 f } ;
|
||||||
|
@ -95,7 +95,7 @@ VERTEX-FORMAT: debug-vertex
|
||||||
|
|
||||||
TUPLE: vbo vertex-buffer index-buffer index-count vertex-format ;
|
TUPLE: vbo vertex-buffer index-buffer index-count vertex-format ;
|
||||||
|
|
||||||
: <collada-buffers> ( models -- buffers )
|
: <model-buffers> ( models -- buffers )
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
[ attribute-buffer>> underlying>> static-upload draw-usage vertex-buffer byte-array>buffer ]
|
[ attribute-buffer>> underlying>> static-upload draw-usage vertex-buffer byte-array>buffer ]
|
||||||
|
@ -105,11 +105,11 @@ TUPLE: vbo vertex-buffer index-buffer index-count vertex-format ;
|
||||||
} cleave vbo boa
|
} cleave vbo boa
|
||||||
] map ;
|
] map ;
|
||||||
|
|
||||||
: fill-collada-state ( collada-state -- )
|
: fill-model-state ( model-state -- )
|
||||||
dup models>> <collada-buffers>
|
dup models>> <model-buffers>
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
[ vertex-buffer>> collada-program <program-instance> ]
|
[ vertex-buffer>> model-program <program-instance> ]
|
||||||
[ vertex-format>> ] bi buffer>vertex-array
|
[ vertex-format>> ] bi buffer>vertex-array
|
||||||
] map >>vertex-arrays drop
|
] map >>vertex-arrays drop
|
||||||
]
|
]
|
||||||
|
@ -124,19 +124,19 @@ TUPLE: vbo vertex-buffer index-buffer index-count vertex-format ;
|
||||||
{ "C:/Users/erikc/Downloads/test2.dae"
|
{ "C:/Users/erikc/Downloads/test2.dae"
|
||||||
"C:/Users/erikc/Downloads/Sponza.obj" } ;
|
"C:/Users/erikc/Downloads/Sponza.obj" } ;
|
||||||
|
|
||||||
: <collada-state> ( -- collada-state )
|
: <model-state> ( -- model-state )
|
||||||
collada-state new
|
model-state new
|
||||||
model-files [ load-models ] [ append ] map-reduce >>models ;
|
model-files [ load-models ] [ append ] map-reduce >>models ;
|
||||||
|
|
||||||
M: collada-world begin-game-world
|
M: model-world begin-game-world
|
||||||
init-gpu
|
init-gpu
|
||||||
{ 0.0 0.0 2.0 } 0 0 set-wasd-view
|
{ 0.0 0.0 2.0 } 0 0 set-wasd-view
|
||||||
<collada-state> [ fill-collada-state drop ] [ >>collada drop ] 2bi ;
|
<model-state> [ fill-model-state drop ] [ >>model-state drop ] 2bi ;
|
||||||
|
|
||||||
: <collada-uniforms> ( world -- uniforms )
|
: <model-uniforms> ( world -- uniforms )
|
||||||
[ wasd-mv-matrix ] [ wasd-p-matrix ] bi
|
[ wasd-mv-matrix ] [ wasd-p-matrix ] bi
|
||||||
{ -10000.0 10000.0 10000.0 } ! light position
|
{ -10000.0 10000.0 10000.0 } ! light position
|
||||||
collada-uniforms boa ;
|
model-uniforms boa ;
|
||||||
|
|
||||||
: draw-line ( world from to color -- )
|
: draw-line ( world from to color -- )
|
||||||
[ 3 head ] tri@ dup -rot append -rot append swap append >float-array
|
[ 3 head ] tri@ dup -rot append -rot append swap append >float-array
|
||||||
|
@ -146,7 +146,7 @@ M: collada-world begin-game-world
|
||||||
{ 0 1 } >uint-array stream-upload draw-usage index-buffer byte-array>buffer
|
{ 0 1 } >uint-array stream-upload draw-usage index-buffer byte-array>buffer
|
||||||
2 '[ _ 0 <buffer-ptr> _ uint-indexes <index-elements> ] call
|
2 '[ _ 0 <buffer-ptr> _ uint-indexes <index-elements> ] call
|
||||||
|
|
||||||
rot <collada-uniforms>
|
rot <model-uniforms>
|
||||||
|
|
||||||
{
|
{
|
||||||
{ "primitive-mode" [ 3drop lines-mode ] }
|
{ "primitive-mode" [ 3drop lines-mode ] }
|
||||||
|
@ -163,7 +163,7 @@ M: collada-world begin-game-world
|
||||||
{ 0 0 0 } { 0 1 0 } { 0 1 0 }
|
{ 0 0 0 } { 0 1 0 } { 0 1 0 }
|
||||||
{ 0 0 0 } { 0 0 1 } { 0 0 1 } } draw-lines ;
|
{ 0 0 0 } { 0 0 1 } { 0 0 1 } } draw-lines ;
|
||||||
|
|
||||||
: draw-collada ( world -- )
|
: draw-model ( world -- )
|
||||||
0 0 0 0 glClearColor
|
0 0 0 0 glClearColor
|
||||||
1 glClearDepth
|
1 glClearDepth
|
||||||
HEX: ffffffff glClearStencil
|
HEX: ffffffff glClearStencil
|
||||||
|
@ -174,9 +174,9 @@ M: collada-world begin-game-world
|
||||||
face-ccw cull-back <triangle-cull-state> set-gpu-state
|
face-ccw cull-back <triangle-cull-state> set-gpu-state
|
||||||
|
|
||||||
cmp-less <depth-state> set-gpu-state
|
cmp-less <depth-state> set-gpu-state
|
||||||
[ collada>> vertex-arrays>> ]
|
[ model-state>> vertex-arrays>> ]
|
||||||
[ collada>> index-vectors>> ]
|
[ model-state>> index-vectors>> ]
|
||||||
[ <collada-uniforms> ]
|
[ <model-uniforms> ]
|
||||||
tri
|
tri
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -193,16 +193,16 @@ M: collada-world begin-game-world
|
||||||
]
|
]
|
||||||
bi ;
|
bi ;
|
||||||
|
|
||||||
M: collada-world draw-world*
|
M: model-world draw-world*
|
||||||
draw-collada ;
|
draw-model ;
|
||||||
|
|
||||||
M: collada-world wasd-movement-speed drop 1/4. ;
|
M: model-world wasd-movement-speed drop 1/4. ;
|
||||||
M: collada-world wasd-near-plane drop 1/32. ;
|
M: model-world wasd-near-plane drop 1/32. ;
|
||||||
M: collada-world wasd-far-plane drop 1024.0 ;
|
M: model-world wasd-far-plane drop 1024.0 ;
|
||||||
|
|
||||||
GAME: collada-game {
|
GAME: model-viewer {
|
||||||
{ world-class collada-world }
|
{ world-class model-world }
|
||||||
{ title "Collada Viewer" }
|
{ title "Model Viewer" }
|
||||||
{ pixel-format-attributes { windowed double-buffered } }
|
{ pixel-format-attributes { windowed double-buffered } }
|
||||||
{ grab-input? t }
|
{ grab-input? t }
|
||||||
{ use-game-input? t }
|
{ use-game-input? t }
|
Loading…
Reference in New Issue