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
|
||||
method-chains namespaces sequences splitting threads ui ui.gadgets
|
||||
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
|
||||
prettyprint game.models.obj game.models.loader ;
|
||||
game.models.obj game.models.loader game.models.collada ;
|
||||
FROM: alien.c-types => float ;
|
||||
SPECIALIZED-ARRAY: float
|
||||
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 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 vec3 norm;
|
||||
void main()
|
||||
|
@ -45,8 +45,8 @@ void main()
|
|||
}
|
||||
;
|
||||
|
||||
GLSL-PROGRAM: collada-program
|
||||
collada-vertex-shader collada-fragment-shader ;
|
||||
GLSL-PROGRAM: model-program
|
||||
model-vertex-shader model-fragment-shader ;
|
||||
|
||||
GLSL-SHADER: debug-vertex-shader vertex-shader
|
||||
uniform mat4 mv_matrix, p_matrix;
|
||||
|
@ -73,18 +73,18 @@ void main()
|
|||
|
||||
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 } ;
|
||||
|
||||
TUPLE: collada-state
|
||||
TUPLE: model-state
|
||||
models
|
||||
vertex-arrays
|
||||
index-vectors ;
|
||||
|
||||
TUPLE: collada-world < wasd-world
|
||||
{ collada collada-state } ;
|
||||
TUPLE: model-world < wasd-world
|
||||
{ model-state model-state } ;
|
||||
|
||||
VERTEX-FORMAT: collada-vertex
|
||||
VERTEX-FORMAT: model-vertex
|
||||
{ "POSITION" float-components 3 f }
|
||||
{ "NORMAL" float-components 3 f }
|
||||
{ "TEXCOORD" float-components 2 f } ;
|
||||
|
@ -95,7 +95,7 @@ VERTEX-FORMAT: debug-vertex
|
|||
|
||||
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 ]
|
||||
|
@ -105,11 +105,11 @@ TUPLE: vbo vertex-buffer index-buffer index-count vertex-format ;
|
|||
} cleave vbo boa
|
||||
] map ;
|
||||
|
||||
: fill-collada-state ( collada-state -- )
|
||||
dup models>> <collada-buffers>
|
||||
: fill-model-state ( model-state -- )
|
||||
dup models>> <model-buffers>
|
||||
[
|
||||
[
|
||||
[ vertex-buffer>> collada-program <program-instance> ]
|
||||
[ vertex-buffer>> model-program <program-instance> ]
|
||||
[ vertex-format>> ] bi buffer>vertex-array
|
||||
] 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/Sponza.obj" } ;
|
||||
|
||||
: <collada-state> ( -- collada-state )
|
||||
collada-state new
|
||||
: <model-state> ( -- model-state )
|
||||
model-state new
|
||||
model-files [ load-models ] [ append ] map-reduce >>models ;
|
||||
|
||||
M: collada-world begin-game-world
|
||||
M: model-world begin-game-world
|
||||
init-gpu
|
||||
{ 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
|
||||
{ -10000.0 10000.0 10000.0 } ! light position
|
||||
collada-uniforms boa ;
|
||||
model-uniforms boa ;
|
||||
|
||||
: draw-line ( world from to color -- )
|
||||
[ 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
|
||||
2 '[ _ 0 <buffer-ptr> _ uint-indexes <index-elements> ] call
|
||||
|
||||
rot <collada-uniforms>
|
||||
rot <model-uniforms>
|
||||
|
||||
{
|
||||
{ "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 0 1 } { 0 0 1 } } draw-lines ;
|
||||
|
||||
: draw-collada ( world -- )
|
||||
: draw-model ( world -- )
|
||||
0 0 0 0 glClearColor
|
||||
1 glClearDepth
|
||||
HEX: ffffffff glClearStencil
|
||||
|
@ -174,9 +174,9 @@ M: collada-world begin-game-world
|
|||
face-ccw cull-back <triangle-cull-state> set-gpu-state
|
||||
|
||||
cmp-less <depth-state> set-gpu-state
|
||||
[ collada>> vertex-arrays>> ]
|
||||
[ collada>> index-vectors>> ]
|
||||
[ <collada-uniforms> ]
|
||||
[ model-state>> vertex-arrays>> ]
|
||||
[ model-state>> index-vectors>> ]
|
||||
[ <model-uniforms> ]
|
||||
tri
|
||||
[
|
||||
{
|
||||
|
@ -193,16 +193,16 @@ M: collada-world begin-game-world
|
|||
]
|
||||
bi ;
|
||||
|
||||
M: collada-world draw-world*
|
||||
draw-collada ;
|
||||
M: model-world draw-world*
|
||||
draw-model ;
|
||||
|
||||
M: collada-world wasd-movement-speed drop 1/4. ;
|
||||
M: collada-world wasd-near-plane drop 1/32. ;
|
||||
M: collada-world wasd-far-plane drop 1024.0 ;
|
||||
M: model-world wasd-movement-speed drop 1/4. ;
|
||||
M: model-world wasd-near-plane drop 1/32. ;
|
||||
M: model-world wasd-far-plane drop 1024.0 ;
|
||||
|
||||
GAME: collada-game {
|
||||
{ world-class collada-world }
|
||||
{ title "Collada Viewer" }
|
||||
GAME: model-viewer {
|
||||
{ world-class model-world }
|
||||
{ title "Model Viewer" }
|
||||
{ pixel-format-attributes { windowed double-buffered } }
|
||||
{ grab-input? t }
|
||||
{ use-game-input? t }
|
Loading…
Reference in New Issue