Compare commits

..

No commits in common. "fec67091a13e39136e0dd15bb3b1ba7f102b8275" and "03b02994153825896073a1aae30a0df89592cea4" have entirely different histories.

8 changed files with 1604 additions and 1024 deletions

580
collada/cube_material.py Normal file
View File

@ -0,0 +1,580 @@
collada.types.Collada(
library_animations=[],
library_controllers=[],
library_effects=[
collada.types.LibraryEffects(
id=None,
name=None,
effects=[
collada.types.Effect(
id='CubeMaterialTextured',
name=None,
profile_common=[
collada.types.ProfileCommon(
id=None,
newparam=[
collada.types.Newparam(
sid='troll_cleric29_max2010_jpg-surface',
parameter_type=collada.types.Surface(
type=collada.types.FxSurfaceType._2D,
init_from=collada.types.InitFrom(uri='troll_cleric29_max2010_jpg')
)
),
collada.types.Newparam(
sid='troll_cleric29_max2010_jpg-sampler',
parameter_type=collada.types.Sampler2D(
source=collada.types.SourceFX(sid='troll_cleric29_max2010_jpg-surface')
)
)
],
technique=collada.types.TechniqueFX(
id=None,
sid='common',
shader=collada.types.Blinn(
emission=collada.types.Color(value=(0.0, 0.0, 0.0, 1.0)),
ambient=collada.types.Color(
value=(0.8588236, 0.254902, 0.9137256, 1.0)
),
diffuse=collada.types.Texture(
texture='troll_cleric29_max2010_jpg-sampler',
texcoord='CHANNEL1'
),
specular=collada.types.Color(value=(0.0, 0.0, 0.0, 1.0)),
shininess=collada.types.Float(value=10.0),
reflective=collada.types.Color(value=(0.0, 0.0, 0.0, 1.0)),
reflectivity=None,
transparent=collada.types.Color(value=(1.0, 1.0, 1.0, 1.0)),
transparency=collada.types.Float(value=1.0),
index_of_refraction=None
)
)
)
]
)
]
)
],
library_materials=[
collada.types.LibraryMaterials(
id=None,
name=None,
materials=[
collada.types.Material(
id='CubeMaterialTextured-material',
name='CubeMaterialTextured',
instance_effect=collada.types.InstanceEffect(
sid=None,
name=None,
url='#CubeMaterialTextured'
)
)
]
)
],
library_geometries=[
collada.types.LibraryGeometries(
id=None,
name=None,
geometries=[
collada.types.Geometry(
id='geom-Cube',
name='Cube',
geometric_element=collada.types.Mesh(
sources=[
collada.types.SourceCore(
id='geom-Cube-positions',
name=None,
array_element=collada.types.FloatArray(
count=24,
id='geom-Cube-positions-array',
name=None,
digits=6,
magnitude=38,
floats=[
-0.5,
-0.5,
0.0,
0.5,
-0.5,
0.0,
-0.5,
0.5,
0.0,
0.5,
0.5,
0.0,
-0.5,
-0.5,
1.0,
0.5,
-0.5,
1.0,
-0.5,
0.5,
1.0,
0.5,
0.5,
1.0
]
),
technique_common=collada.types.TechniqueCommon_SourceCore(
accessor=collada.types.Accessor(
count=8,
offset=0,
source='#geom-Cube-positions-array',
stride=3,
params=[
collada.types.Param(name='X', sid=None, type='float', semantic=None),
collada.types.Param(name='Y', sid=None, type='float', semantic=None),
collada.types.Param(name='Z', sid=None, type='float', semantic=None)
]
)
)
),
collada.types.SourceCore(
id='geom-Cube-normals',
name=None,
array_element=collada.types.FloatArray(
count=72,
id='geom-Cube-normals-array',
name=None,
digits=6,
magnitude=38,
floats=[
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0
]
),
technique_common=collada.types.TechniqueCommon_SourceCore(
accessor=collada.types.Accessor(
count=24,
offset=0,
source='#geom-Cube-normals-array',
stride=3,
params=[
collada.types.Param(name='X', sid=None, type='float', semantic=None),
collada.types.Param(name='Y', sid=None, type='float', semantic=None),
collada.types.Param(name='Z', sid=None, type='float', semantic=None)
]
)
)
),
collada.types.SourceCore(
id='geom-Cube-map1',
name=None,
array_element=collada.types.FloatArray(
count=36,
id='geom-Cube-map1-array',
name=None,
digits=6,
magnitude=38,
floats=[
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
1.0,
1.0,
0.0
]
),
technique_common=collada.types.TechniqueCommon_SourceCore(
accessor=collada.types.Accessor(
count=12,
offset=0,
source='#geom-Cube-map1-array',
stride=3,
params=[
collada.types.Param(name='S', sid=None, type='float', semantic=None),
collada.types.Param(name='T', sid=None, type='float', semantic=None),
collada.types.Param(name='P', sid=None, type='float', semantic=None)
]
)
)
)
],
vertices=collada.types.Vertices(
id='geom-Cube-vertices',
name=None,
inputs=[
collada.types.InputUnshared(
semantic='POSITION',
source='#geom-Cube-positions'
)
]
),
primitive_elements=[
collada.types.Triangles(
name=None,
count=12,
material='CubeMaterialTextured',
inputs=[
collada.types.InputShared(
offset=0,
semantic='VERTEX',
source='#geom-Cube-vertices',
set=None
),
collada.types.InputShared(
offset=1,
semantic='NORMAL',
source='#geom-Cube-normals',
set=None
),
collada.types.InputShared(
offset=2,
semantic='TEXCOORD',
source='#geom-Cube-map1',
set=0
)
],
p=[
0,
0,
9,
2,
1,
11,
3,
2,
10,
3,
2,
10,
1,
3,
8,
0,
0,
9,
4,
4,
8,
5,
5,
9,
7,
6,
11,
7,
6,
11,
6,
7,
10,
4,
4,
8,
0,
8,
4,
1,
9,
5,
5,
10,
7,
5,
10,
7,
4,
11,
6,
0,
8,
4,
1,
12,
0,
3,
13,
1,
7,
14,
3,
7,
14,
3,
5,
15,
2,
1,
12,
0,
3,
16,
4,
2,
17,
5,
6,
18,
7,
6,
18,
7,
7,
19,
6,
3,
16,
4,
2,
20,
0,
0,
21,
1,
4,
22,
3,
4,
22,
3,
6,
23,
2,
2,
20,
0
]
)
]
)
)
]
)
],
library_lights=[
collada.types.LibraryLights(
id=None,
name=None,
lights=[
collada.types.Light(
id='EnvironmentAmbientLight',
name='EnvironmentAmbientLight',
technique_common=collada.types.TechniqueCommon_Light(
light=collada.types.Ambient(color=(0.0, 0.0, 0.0))
)
)
]
)
],
library_images=[
collada.types.LibraryImages(
id=None,
name=None,
images=[
collada.types.Image(
id='troll_cleric29_max2010_jpg',
name=None,
format=None,
height=None,
width=None,
depth=None,
image_source=collada.types.InitFrom(
uri='file:///C:/cygwin/home/bilbo/collada/images/0_troll_cleric29_max2010.'
'jpg'
)
)
]
)
],
library_visual_scenes=[
collada.types.LibraryVisualScenes(
id=None,
name=None,
visual_scenes=[
collada.types.VisualScene(
id='MaxScene',
name=None,
nodes=[
collada.types.Node(
id=None,
name='EnvironmentAmbientLight',
sid=None,
type=collada.types.NodeType.NODE,
layer=[],
transformation_elements=[],
instance_geometries=[],
instance_lights=[
collada.types.InstanceLight(
sid=None,
name=None,
url='#EnvironmentAmbientLight'
)
],
nodes=[]
),
collada.types.Node(
id='node-Cube',
name='Cube',
sid=None,
type=collada.types.NodeType.NODE,
layer=[],
transformation_elements=[],
instance_geometries=[],
instance_lights=[],
nodes=[
collada.types.Node(
id=None,
name=None,
sid=None,
type=collada.types.NodeType.NODE,
layer=[],
transformation_elements=[
collada.types.Matrix(
sid=None,
values=(
(1.0, 0.0, 0.0, 0.0),
(0.0, 1.0, -4.37114e-08, 2.18557e-08),
(0.0, 4.37114e-08, 1.0, -0.5),
(0.0, 0.0, 0.0, 1.0)
)
)
],
instance_geometries=[
collada.types.InstanceGeometry(
sid=None,
name=None,
url='#geom-Cube',
bind_material=collada.types.BindMaterial(
technique_common=collada.types.TechniqueCommon_BindMaterial(
materials=[
collada.types.InstanceMaterial(
sid=None,
name=None,
target='#CubeMaterialTextured-material',
symbol='CubeMaterialTextured',
bind_vertex_inputs=[
collada.types.BindVertexInput(
semantic='CHANNEL1',
input_semantic='TEXCOORD',
input_set='0'
)
]
)
]
)
)
)
],
instance_lights=[],
nodes=[]
)
]
)
]
)
]
)
],
scenes=[
collada.types.Scene(
instance_visual_scene=collada.types.InstanceVisualScene(
sid=None,
name=None,
url='#MaxScene'
)
)
]
)

View File

@ -1,12 +1,12 @@
#pragma once
#ifndef COLLADA_HPP_
#define COLLADA_HPP_
namespace collada {
HRESULT LoadEffect();
HRESULT LoadMesh();
void Render(float t);
}
#endif
#pragma once
#ifndef COLLADA_HPP_
#define COLLADA_HPP_
namespace collada {
HRESULT LoadEffect();
HRESULT LoadMesh();
void Render(float t);
}
#endif

View File

@ -1,239 +1,239 @@
#pragma once
namespace collada {
struct float3 {
float const x;
float const y;
float const z;
};
struct float4 {
float const x;
float const y;
float const z;
float const w;
};
struct float7 {
float const a;
float const b;
float const c;
float const d;
float const e;
float const f;
float const g;
};
//////////////////////////////////////////////////////////////////////
// animation
//////////////////////////////////////////////////////////////////////
enum class interpolation {
LINEAR,
BEZIER,
};
struct source {
union {
float const * const float_array;
enum interpolation const name_array;
};
int const count;
int const stride;
};
struct sampler {
source const input;
source const output;
source const intangent;
source const outangent;
source const interpolation;
};
//////////////////////////////////////////////////////////////////////
// geometry
//////////////////////////////////////////////////////////////////////
enum class input_format {
FLOAT3,
FLOAT4,
INT4,
};
struct input_element {
char const * const semantic;
int const semantic_index;
enum input_format const format;
};
// inputs uniqueness is by evaluted pointer
struct inputs {
input_element const * const elements;
int const elements_count;
};
struct triangles {
int const count;
int const index_offset;
inputs const inputs;
};
struct mesh {
// `triangles` must become a union if non-triangles are implemented.
// instance_geometry is an index into this array.
triangles const * triangles;
int const triangles_count;
int const vertex_buffer_offset;
int const vertex_buffer_size;
int const index_buffer_offset;
int const index_buffer_size;
};
struct geometry {
mesh mesh;
};
//////////////////////////////////////////////////////////////////////
// node
//////////////////////////////////////////////////////////////////////
struct lookat {
float3 const eye;
float3 const at;
float3 const up;
};
struct matrix {
float const _11, _12, _13, _14;
float const _21, _22, _23, _24;
float const _31, _32, _33, _34;
float const _41, _42, _43, _44;
};
enum class transform_type {
LOOKAT,
MATRIX,
ROTATE,
SCALE,
TRANSLATE,
};
struct transform {
transform_type const type;
union {
lookat const lookat;
matrix const matrix;
float4 const rotate;
float3 const scale;
float7 const skew;
float3 const translate;
};
};
enum class node_type {
JOINT,
NODE,
};
struct color_or_texture {
union {
float4 color;
};
};
struct blinn {
color_or_texture const emission;
color_or_texture const ambient;
color_or_texture const diffuse;
color_or_texture const specular;
float const shininess;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
struct lambert {
color_or_texture const emission;
color_or_texture const ambient;
color_or_texture const diffuse;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
struct phong {
color_or_texture const emission;
color_or_texture const ambient;
color_or_texture const diffuse;
color_or_texture const specular;
float const shininess;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
struct constant {
float4 const color;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
enum class effect_type {
BLINN,
LAMBERT,
PHONG,
CONSTANT,
};
struct effect {
effect_type const type;
union {
blinn const blinn;
lambert const lambert;
phong const phong;
constant const constant;
};
};
struct material {
effect const * const effect;
};
struct instance_material {
int element_index;
material const * const material;
};
struct instance_geometry {
geometry const * const geometry;
instance_material const * const instance_materials;
int const instance_materials_count;
};
struct node {
node_type const type;
transform const * const transforms;
int const transforms_count;
instance_geometry const * const instance_geometries;
int const instance_geometries_count;
node const * const nodes;
int const nodes_count;
};
}
#pragma once
namespace collada {
struct float3 {
float const x;
float const y;
float const z;
};
struct float4 {
float const x;
float const y;
float const z;
float const w;
};
struct float7 {
float const a;
float const b;
float const c;
float const d;
float const e;
float const f;
float const g;
};
//////////////////////////////////////////////////////////////////////
// animation
//////////////////////////////////////////////////////////////////////
enum class interpolation {
LINEAR,
BEZIER,
};
struct source {
union {
float const * const float_array;
enum interpolation const name_array;
};
int const count;
int const stride;
};
struct sampler {
source const input;
source const output;
source const intangent;
source const outangent;
source const interpolation;
};
//////////////////////////////////////////////////////////////////////
// geometry
//////////////////////////////////////////////////////////////////////
enum class input_format {
FLOAT3,
FLOAT4,
INT4,
};
struct input_element {
char const * const semantic;
int const semantic_index;
enum input_format const format;
};
// inputs uniqueness is by evaluted pointer
struct inputs {
input_element const * const elements;
int const elements_count;
};
struct triangles {
int const count;
int const index_offset;
inputs const inputs;
};
struct mesh {
// `triangles` must become a union if non-triangles are implemented.
// instance_geometry is an index into this array.
triangles const * triangles;
int const triangles_count;
int const vertex_buffer_offset;
int const vertex_buffer_size;
int const index_buffer_offset;
int const index_buffer_size;
};
struct geometry {
mesh mesh;
};
//////////////////////////////////////////////////////////////////////
// node
//////////////////////////////////////////////////////////////////////
struct lookat {
float3 const eye;
float3 const at;
float3 const up;
};
struct matrix {
float const _11, _12, _13, _14;
float const _21, _22, _23, _24;
float const _31, _32, _33, _34;
float const _41, _42, _43, _44;
};
enum class transform_type {
LOOKAT,
MATRIX,
ROTATE,
SCALE,
TRANSLATE,
};
struct transform {
transform_type const type;
union {
lookat const lookat;
matrix const matrix;
float4 const rotate;
float3 const scale;
float7 const skew;
float3 const translate;
};
};
enum class node_type {
JOINT,
NODE,
};
struct color_or_texture {
union {
float4 color;
};
};
struct blinn {
color_or_texture const emission;
color_or_texture const ambient;
color_or_texture const diffuse;
color_or_texture const specular;
float const shininess;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
struct lambert {
color_or_texture const emission;
color_or_texture const ambient;
color_or_texture const diffuse;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
struct phong {
color_or_texture const emission;
color_or_texture const ambient;
color_or_texture const diffuse;
color_or_texture const specular;
float const shininess;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
struct constant {
float4 const color;
color_or_texture const reflective;
float const reflectivity;
color_or_texture const transparent;
float const transparency;
float const index_of_refraction;
};
enum class effect_type {
BLINN,
LAMBERT,
PHONG,
CONSTANT,
};
struct effect {
effect_type const type;
union {
blinn const blinn;
lambert const lambert;
phong const phong;
constant const constant;
};
};
struct material {
effect const * const effect;
};
struct instance_material {
int element_index;
material const * const material;
};
struct instance_geometry {
geometry const * const geometry;
instance_material const * const instance_materials;
int const instance_materials_count;
};
struct node {
node_type const type;
transform const * const transforms;
int const transforms_count;
instance_geometry const * const instance_geometries;
int const instance_geometries_count;
node const * const nodes;
int const nodes_count;
};
}

View File

@ -1,362 +1,362 @@
#include <windows.h>
#include <d3d10.h>
#include "directxmath/directxmath.h"
#include "print.hpp"
#include "collada.hpp"
extern ID3D10Device * g_pd3dDevice;
extern XMMATRIX g_View;
extern XMMATRIX g_Projection;
namespace collada {
static const float vertex_buffer[] = {
-5.0, -5.0, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0,
-5.0, 5.0, 0.0, 0.0, 0.0, -1.0, 1.0, 1.0, 0.0,
5.0, 5.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0,
5.0, -5.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0,
-5.0, -5.0, 20.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
5.0, -5.0, 20.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0,
5.0, 5.0, 20.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0,
-5.0, 5.0, 20.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0,
-5.0, -5.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0,
5.0, -5.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0,
5.0, -5.0, 4.0, 0.0, -1.0, 0.0, 1.0, 0.2, 0.0,
-5.0, -5.0, 4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= {
0, 1, 2,
2, 3, 0,
4, 5, 6,
6, 7, 4,
8, 9, 10,
10, 11, 8,
11, 10, 12,
12, 13, 11,
13, 12, 14,
14, 15, 13,
15, 14, 16,
16, 17, 15,
17, 16, 18,
18, 19, 17,
20, 21, 22,
22, 23, 20,
23, 22, 24,
24, 25, 23,
25, 24, 26,
26, 27, 25,
27, 26, 28,
28, 29, 27,
29, 28, 30,
30, 31, 29,
32, 33, 34,
34, 35, 32,
35, 34, 36,
36, 37, 35,
37, 36, 38,
38, 39, 37,
39, 38, 40,
40, 41, 39,
41, 40, 42,
42, 43, 41,
44, 45, 46,
46, 47, 44,
47, 46, 48,
48, 49, 47,
49, 48, 50,
50, 51, 49,
51, 50, 52,
52, 53, 51,
53, 52, 54,
54, 55, 53,
};
static const float inverse_bind_matrices[] = {
0.0f, 0.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f, 0.0f,
-10.0f, 0.0f, 0.0f, 1.0f,
};
static const float joints_weights[] = {
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 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0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
};
ID3D10Effect * g_pEffect = NULL;
ID3D10EffectTechnique * g_pTechniqueRender = NULL;
ID3D10InputLayout * g_pVertexLayout = NULL;
ID3D10Buffer * g_pVertexBufferPNT;
ID3D10Buffer * g_pVertexBufferJW;
ID3D10Buffer * g_pIndexBuffer;
ID3D10EffectMatrixVariable * g_pJointVariable = NULL;
ID3D10EffectMatrixVariable * g_pWorldVariable = NULL;
ID3D10EffectMatrixVariable * g_pViewVariable = NULL;
ID3D10EffectMatrixVariable * g_pProjectionVariable = NULL;
HRESULT LoadEffect()
{
HRESULT hr;
HRSRC hRes = FindResource(NULL, L"RES_COLLADA_FXO", RT_RCDATA);
if (hRes == NULL) {
print("FindResource RES_COLLADA_FXO\n");
return E_FAIL;
}
DWORD dwResSize = SizeofResource(NULL, hRes);
HGLOBAL hData = LoadResource(NULL, hRes);
void * pData = LockResource(hData);
hr = D3D10CreateEffectFromMemory(pData,
dwResSize,
0,
g_pd3dDevice,
NULL,
&g_pEffect
);
if (FAILED(hr)) {
print("D3D10CreateEffectFromMemory\n");
return hr;
}
g_pTechniqueRender = g_pEffect->GetTechniqueByName("Render");
// variables
g_pJointVariable = g_pEffect->GetVariableByName("mJoint")->AsMatrix();
g_pWorldVariable = g_pEffect->GetVariableByName("World")->AsMatrix();
g_pViewVariable = g_pEffect->GetVariableByName("View")->AsMatrix();
g_pProjectionVariable = g_pEffect->GetVariableByName("Projection")->AsMatrix();
// layout
D3D10_INPUT_ELEMENT_DESC layout[] = {
{"POSITION" , 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0 , D3D10_INPUT_PER_VERTEX_DATA, 0},
{"NORMAL" , 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD" , 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"BLENDINDICES", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"BLENDWEIGHT" , 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D10_INPUT_PER_VERTEX_DATA, 0},
};
UINT numElements = (sizeof (layout)) / (sizeof (layout[0]));
D3D10_PASS_DESC passDesc;
g_pTechniqueRender->GetPassByIndex(0)->GetDesc(&passDesc);
hr = g_pd3dDevice->CreateInputLayout(layout, numElements,
passDesc.pIAInputSignature,
passDesc.IAInputSignatureSize,
&g_pVertexLayout);
if (FAILED(hr)) {
print("CreateInputLayout\n");
return hr;
}
return S_OK;
}
HRESULT LoadMesh()
{
HRESULT hr;
D3D10_BUFFER_DESC bd;
D3D10_SUBRESOURCE_DATA initData;
bd.Usage = D3D10_USAGE_IMMUTABLE;
bd.ByteWidth = (sizeof (vertex_buffer));
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
initData.pSysMem = vertex_buffer;
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferPNT);
if (FAILED(hr)) {
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
return hr;
}
bd.Usage = D3D10_USAGE_IMMUTABLE;
bd.ByteWidth = (sizeof (joints_weights));
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
initData.pSysMem = joints_weights;
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferJW);
if (FAILED(hr)) {
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
return hr;
}
bd.Usage = D3D10_USAGE_IMMUTABLE;
bd.ByteWidth = (sizeof (index_buffer));
bd.BindFlags = D3D10_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
initData.pSysMem = index_buffer;
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pIndexBuffer);
if (FAILED(hr)) {
print("CreateBuffer: D3D10_BIND_INDEX_BUFFER\n");
return hr;
}
return S_OK;
}
void Render(float t)
{
XMMATRIX World = XMMatrixScaling(1, 1, 1);
// XMMATRIX XM_CALLCONV XMMatrixRotationNormal(FXMVECTOR NormalAxis, float Angle) noexcept;
//XMConvertToRadians
XMVECTOR axis = XMVectorSet(0, 1, 0, 0);
XMVECTOR axisZ = XMVectorSet(0, 0, 1, 0);
XMMATRIX joint0
= XMMatrixRotationNormal(axis, XMConvertToRadians(-90))
;
XMMATRIX joint1
= XMMatrixRotationNormal(axisZ, sin(t))
* XMMatrixTranslation(10, 0, 0)
* joint0
;
XMMATRIX joint0ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[0 * 16]);
XMMATRIX joint1ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[1 * 16]);
XMMATRIX mJoints[2] = {
joint0ibm * joint0,
joint1ibm * joint1,
};
g_pJointVariable->SetMatrixArray((float *)mJoints, 0, 2);
g_pWorldVariable->SetMatrix((float *)&World);
g_pViewVariable->SetMatrix((float *)&g_View);
g_pProjectionVariable->SetMatrix((float *)&g_Projection);
UINT stride[] = {
3 * 3 * 4, // position normal texture
4 * 2 * 4, // joint weight
};
UINT offset[] = { 0, 0 };
ID3D10Buffer * vertex_buffers[] = {
g_pVertexBufferPNT,
g_pVertexBufferJW,
};
g_pd3dDevice->IASetInputLayout(g_pVertexLayout);
g_pd3dDevice->IASetVertexBuffers(0, 2, vertex_buffers, stride, offset);
g_pd3dDevice->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
g_pd3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
D3D10_TECHNIQUE_DESC techDesc;
g_pTechniqueRender->GetDesc(&techDesc);
int indices_length = (sizeof (index_buffer)) / (sizeof (int));
for (UINT p = 0; p < techDesc.Passes; p++) {
g_pTechniqueRender->GetPassByIndex(p)->Apply(0);
g_pd3dDevice->DrawIndexed(indices_length, 0, 0);
}
}
}
#include <windows.h>
#include <d3d10.h>
#include "directxmath/directxmath.h"
#include "print.hpp"
#include "collada.hpp"
extern ID3D10Device * g_pd3dDevice;
extern XMMATRIX g_View;
extern XMMATRIX g_Projection;
namespace collada {
static const float vertex_buffer[] = {
-5.0, -5.0, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0,
-5.0, 5.0, 0.0, 0.0, 0.0, -1.0, 1.0, 1.0, 0.0,
5.0, 5.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0,
5.0, -5.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0,
-5.0, -5.0, 20.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
5.0, -5.0, 20.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0,
5.0, 5.0, 20.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0,
-5.0, 5.0, 20.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0,
-5.0, -5.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0,
5.0, -5.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0,
5.0, -5.0, 4.0, 0.0, -1.0, 0.0, 1.0, 0.2, 0.0,
-5.0, -5.0, 4.0, 0.0, -1.0, 0.0, 0.0, 0.2, 0.0,
5.0, -5.0, 8.0, 0.0, -1.0, 0.0, 1.0, 0.4, 0.0,
-5.0, -5.0, 8.0, 0.0, -1.0, 0.0, 0.0, 0.4, 0.0,
5.0, -5.0, 12.0, 0.0, -1.0, 0.0, 1.0, 0.6, 0.0,
-5.0, -5.0, 12.0, 0.0, -1.0, 0.0, 0.0, 0.6, 0.0,
5.0, -5.0, 16.0, 0.0, -1.0, 0.0, 1.0, 0.8, 0.0,
-5.0, -5.0, 16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0.0,
-5.0, 5.0, 16.0, 0.0, 1.0, 0.0, 1.0, 0.8, 0.0,
5.0, 5.0, 16.0, 0.0, 1.0, 0.0, 0.0, 0.8, 0.0,
-5.0, 5.0, 20.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0,
5.0, 5.0, 20.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
-5.0, 5.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-5.0, -5.0, 0.0, -1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
-5.0, -5.0, 4.0, -1.0, 0.0, 0.0, 1.0, 0.2, 0.0,
-5.0, 5.0, 4.0, -1.0, 0.0, 0.0, 0.0, 0.2, 0.0,
-5.0, -5.0, 8.0, -1.0, 0.0, 0.0, 1.0, 0.4, 0.0,
-5.0, 5.0, 8.0, -1.0, 0.0, 0.0, 0.0, 0.4, 0.0,
-5.0, -5.0, 12.0, -1.0, 0.0, 0.0, 1.0, 0.6, 0.0,
-5.0, 5.0, 12.0, -1.0, 0.0, 0.0, 0.0, 0.6, 0.0,
-5.0, -5.0, 16.0, -1.0, 0.0, 0.0, 1.0, 0.8, 0.0,
-5.0, 5.0, 16.0, -1.0, 0.0, 0.0, 0.0, 0.8, 0.0,
-5.0, -5.0, 20.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0,
-5.0, 5.0, 20.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0,
};
static const int index_buffer[] = {
0, 1, 2,
2, 3, 0,
4, 5, 6,
6, 7, 4,
8, 9, 10,
10, 11, 8,
11, 10, 12,
12, 13, 11,
13, 12, 14,
14, 15, 13,
15, 14, 16,
16, 17, 15,
17, 16, 18,
18, 19, 17,
20, 21, 22,
22, 23, 20,
23, 22, 24,
24, 25, 23,
25, 24, 26,
26, 27, 25,
27, 26, 28,
28, 29, 27,
29, 28, 30,
30, 31, 29,
32, 33, 34,
34, 35, 32,
35, 34, 36,
36, 37, 35,
37, 36, 38,
38, 39, 37,
39, 38, 40,
40, 41, 39,
41, 40, 42,
42, 43, 41,
44, 45, 46,
46, 47, 44,
47, 46, 48,
48, 49, 47,
49, 48, 50,
50, 51, 49,
51, 50, 52,
52, 53, 51,
53, 52, 54,
54, 55, 53,
};
static const float inverse_bind_matrices[] = {
0.0f, 0.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f, 0.0f,
-10.0f, 0.0f, 0.0f, 1.0f,
};
static const float joints_weights[] = {
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
0, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.2, 0.8, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.4, 0.6, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.6, 0.4, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 0.8, 0.2, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
1, 0, 0, 0, 1.0, 0, 0, 0,
};
ID3D10Effect * g_pEffect = NULL;
ID3D10EffectTechnique * g_pTechniqueRender = NULL;
ID3D10InputLayout * g_pVertexLayout = NULL;
ID3D10Buffer * g_pVertexBufferPNT;
ID3D10Buffer * g_pVertexBufferJW;
ID3D10Buffer * g_pIndexBuffer;
ID3D10EffectMatrixVariable * g_pJointVariable = NULL;
ID3D10EffectMatrixVariable * g_pWorldVariable = NULL;
ID3D10EffectMatrixVariable * g_pViewVariable = NULL;
ID3D10EffectMatrixVariable * g_pProjectionVariable = NULL;
HRESULT LoadEffect()
{
HRESULT hr;
HRSRC hRes = FindResource(NULL, L"RES_COLLADA_FXO", RT_RCDATA);
if (hRes == NULL) {
print("FindResource RES_COLLADA_FXO\n");
return E_FAIL;
}
DWORD dwResSize = SizeofResource(NULL, hRes);
HGLOBAL hData = LoadResource(NULL, hRes);
void * pData = LockResource(hData);
hr = D3D10CreateEffectFromMemory(pData,
dwResSize,
0,
g_pd3dDevice,
NULL,
&g_pEffect
);
if (FAILED(hr)) {
print("D3D10CreateEffectFromMemory\n");
return hr;
}
g_pTechniqueRender = g_pEffect->GetTechniqueByName("Render");
// variables
g_pJointVariable = g_pEffect->GetVariableByName("mJoint")->AsMatrix();
g_pWorldVariable = g_pEffect->GetVariableByName("World")->AsMatrix();
g_pViewVariable = g_pEffect->GetVariableByName("View")->AsMatrix();
g_pProjectionVariable = g_pEffect->GetVariableByName("Projection")->AsMatrix();
// layout
D3D10_INPUT_ELEMENT_DESC layout[] = {
{"POSITION" , 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0 , D3D10_INPUT_PER_VERTEX_DATA, 0},
{"NORMAL" , 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD" , 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"BLENDINDICES", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"BLENDWEIGHT" , 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D10_INPUT_PER_VERTEX_DATA, 0},
};
UINT numElements = (sizeof (layout)) / (sizeof (layout[0]));
D3D10_PASS_DESC passDesc;
g_pTechniqueRender->GetPassByIndex(0)->GetDesc(&passDesc);
hr = g_pd3dDevice->CreateInputLayout(layout, numElements,
passDesc.pIAInputSignature,
passDesc.IAInputSignatureSize,
&g_pVertexLayout);
if (FAILED(hr)) {
print("CreateInputLayout\n");
return hr;
}
return S_OK;
}
HRESULT LoadMesh()
{
HRESULT hr;
D3D10_BUFFER_DESC bd;
D3D10_SUBRESOURCE_DATA initData;
bd.Usage = D3D10_USAGE_IMMUTABLE;
bd.ByteWidth = (sizeof (vertex_buffer));
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
initData.pSysMem = vertex_buffer;
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferPNT);
if (FAILED(hr)) {
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
return hr;
}
bd.Usage = D3D10_USAGE_IMMUTABLE;
bd.ByteWidth = (sizeof (joints_weights));
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
initData.pSysMem = joints_weights;
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferJW);
if (FAILED(hr)) {
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
return hr;
}
bd.Usage = D3D10_USAGE_IMMUTABLE;
bd.ByteWidth = (sizeof (index_buffer));
bd.BindFlags = D3D10_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
initData.pSysMem = index_buffer;
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pIndexBuffer);
if (FAILED(hr)) {
print("CreateBuffer: D3D10_BIND_INDEX_BUFFER\n");
return hr;
}
return S_OK;
}
void Render(float t)
{
XMMATRIX World = XMMatrixScaling(1, 1, 1);
// XMMATRIX XM_CALLCONV XMMatrixRotationNormal(FXMVECTOR NormalAxis, float Angle) noexcept;
//XMConvertToRadians
XMVECTOR axis = XMVectorSet(0, 1, 0, 0);
XMVECTOR axisZ = XMVectorSet(0, 0, 1, 0);
XMMATRIX joint0
= XMMatrixRotationNormal(axis, XMConvertToRadians(-90))
;
XMMATRIX joint1
= XMMatrixRotationNormal(axisZ, sin(t))
* XMMatrixTranslation(10, 0, 0)
* joint0
;
XMMATRIX joint0ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[0 * 16]);
XMMATRIX joint1ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[1 * 16]);
XMMATRIX mJoints[2] = {
joint0ibm * joint0,
joint1ibm * joint1,
};
g_pJointVariable->SetMatrixArray((float *)mJoints, 0, 2);
g_pWorldVariable->SetMatrix((float *)&World);
g_pViewVariable->SetMatrix((float *)&g_View);
g_pProjectionVariable->SetMatrix((float *)&g_Projection);
UINT stride[] = {
3 * 3 * 4, // position normal texture
4 * 2 * 4, // joint weight
};
UINT offset[] = { 0, 0 };
ID3D10Buffer * vertex_buffers[] = {
g_pVertexBufferPNT,
g_pVertexBufferJW,
};
g_pd3dDevice->IASetInputLayout(g_pVertexLayout);
g_pd3dDevice->IASetVertexBuffers(0, 2, vertex_buffers, stride, offset);
g_pd3dDevice->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
g_pd3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
D3D10_TECHNIQUE_DESC techDesc;
g_pTechniqueRender->GetDesc(&techDesc);
int indices_length = (sizeof (index_buffer)) / (sizeof (int));
for (UINT p = 0; p < techDesc.Passes; p++) {
g_pTechniqueRender->GetPassByIndex(p)->Apply(0);
g_pd3dDevice->DrawIndexed(indices_length, 0, 0);
}
}
}

View File

@ -1,72 +1,72 @@
matrix World;
matrix View;
matrix Projection;
matrix mJoint[2];
struct VS_INPUT
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
float4 Joint : BLENDINDICES0;
float4 Weight : BLENDWEIGHT0;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
};
PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output;
matrix mSkin
= input.Weight.x * mJoint[int(input.Joint.x)]
+ input.Weight.y * mJoint[int(input.Joint.y)]
+ input.Weight.z * mJoint[int(input.Joint.z)]
+ input.Weight.w * mJoint[int(input.Joint.w)]
;
output.Pos = mul(input.Pos, mSkin);
output.Pos = mul(output.Pos, World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
output.Normal = input.Normal;
output.Tex = input.Tex;
return output;
}
float4 PS(PS_INPUT input) : SV_Target
{
//return float4(input.Normal * 0.5 + 0.5, 1);
return float4(input.Tex.xy, 0, 1);
}
BlendState DisableBlending
{
BlendEnable[0] = FALSE;
};
DepthStencilState EnableDepth
{
DepthEnable = TRUE;
DepthWriteMask = ALL;
};
technique10 Render
{
pass P0
{
SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PS()));
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(EnableDepth, 0);
}
}
matrix World;
matrix View;
matrix Projection;
matrix mJoint[2];
struct VS_INPUT
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
float4 Joint : BLENDINDICES0;
float4 Weight : BLENDWEIGHT0;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
};
PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output;
matrix mSkin
= input.Weight.x * mJoint[int(input.Joint.x)]
+ input.Weight.y * mJoint[int(input.Joint.y)]
+ input.Weight.z * mJoint[int(input.Joint.z)]
+ input.Weight.w * mJoint[int(input.Joint.w)]
;
output.Pos = mul(input.Pos, mSkin);
output.Pos = mul(output.Pos, World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
output.Normal = input.Normal;
output.Tex = input.Tex;
return output;
}
float4 PS(PS_INPUT input) : SV_Target
{
//return float4(input.Normal * 0.5 + 0.5, 1);
return float4(input.Tex.xy, 0, 1);
}
BlendState DisableBlending
{
BlendEnable[0] = FALSE;
};
DepthStencilState EnableDepth
{
DepthEnable = TRUE;
DepthWriteMask = ALL;
};
technique10 Render
{
pass P0
{
SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PS()));
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(EnableDepth, 0);
}
}

View File

@ -1,50 +1,50 @@
#include <windows.h>
#include <strsafe.h>
#include "print.hpp"
void print(LPCSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
char buf[512];
STRSAFE_LPSTR end = NULL;
StringCbVPrintfExA(buf,
(sizeof (buf)),
&end,
NULL,
STRSAFE_NULL_ON_FAILURE,
fmt,
args);
va_end(args);
#ifdef _DEBUG
OutputDebugStringA(buf);
//size_t length = end - &buf[0];
//HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
//WriteConsoleA(hOutput, buf, (DWORD)length, NULL, NULL);
#endif
}
void printW(LPCWSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
WCHAR buf[512];
STRSAFE_LPWSTR end = NULL;
StringCbVPrintfExW(buf,
(sizeof (buf)),
&end,
NULL,
STRSAFE_NULL_ON_FAILURE,
fmt,
args);
va_end(args);
#ifdef _DEBUG
OutputDebugStringW(buf);
//size_t length = end - &buf[0];
//HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
//WriteConsoleW(hOutput, buf, (DWORD)length, NULL, NULL);
#endif
}
#include <windows.h>
#include <strsafe.h>
#include "print.hpp"
void print(LPCSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
char buf[512];
STRSAFE_LPSTR end = NULL;
StringCbVPrintfExA(buf,
(sizeof (buf)),
&end,
NULL,
STRSAFE_NULL_ON_FAILURE,
fmt,
args);
va_end(args);
#ifdef _DEBUG
OutputDebugStringA(buf);
//size_t length = end - &buf[0];
//HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
//WriteConsoleA(hOutput, buf, (DWORD)length, NULL, NULL);
#endif
}
void printW(LPCWSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
WCHAR buf[512];
STRSAFE_LPWSTR end = NULL;
StringCbVPrintfExW(buf,
(sizeof (buf)),
&end,
NULL,
STRSAFE_NULL_ON_FAILURE,
fmt,
args);
va_end(args);
#ifdef _DEBUG
OutputDebugStringW(buf);
//size_t length = end - &buf[0];
//HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
//WriteConsoleW(hOutput, buf, (DWORD)length, NULL, NULL);
#endif
}

View File

@ -1,172 +1,172 @@
#include <windows.h>
#include <assert.h>
#include <d3d10.h>
#include "globals.hpp"
#include "print.hpp"
#include "render_state.hpp"
HRESULT LoadTexture2D(const wchar_t * resourceName,
const int width,
const int height,
const int pitch,
const DXGI_FORMAT format,
ID3D10ShaderResourceView ** pTextureShaderResourceView)
{
HRESULT hr;
// texture
HRSRC hRes = FindResource(NULL, resourceName, RT_RCDATA);
if (hRes == NULL) {
print("FindResource %s\n", resourceName);
return -1;
}
DWORD dwResourceSize = SizeofResource(NULL, hRes);
assert(pitch >= width);
assert(pitch * height == (int)dwResourceSize);
HGLOBAL hData = LoadResource(NULL, hRes);
D3D10_SUBRESOURCE_DATA subresourceData;
subresourceData.pSysMem = LockResource(hData);
subresourceData.SysMemPitch = pitch;
D3D10_TEXTURE2D_DESC textureDesc;
textureDesc.Width = width;
textureDesc.Height = height;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = format;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D10_USAGE_IMMUTABLE;
textureDesc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D10Texture2D * pTexture;
hr = g_pd3dDevice->CreateTexture2D(&textureDesc, &subresourceData, &pTexture);
if (FAILED(hr)) {
print("CreateTexture2D\n");
return hr;
}
D3D10_SHADER_RESOURCE_VIEW_DESC descSRV;
descSRV.Format = textureDesc.Format;
descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
descSRV.Texture2D.MostDetailedMip = 0;
descSRV.Texture2D.MipLevels = 1;
hr = g_pd3dDevice->CreateShaderResourceView(pTexture, &descSRV, pTextureShaderResourceView);
if (FAILED(hr)) {
print("CreateShaderResourceView\n");
return hr;
}
return S_OK;
}
HRESULT LoadTexture3D(const wchar_t * resourceName,
const int width,
const int height,
const int depth,
const int pitch,
const int slicePitch,
const DXGI_FORMAT format,
ID3D10ShaderResourceView ** pTextureShaderResourceView)
{
HRESULT hr;
HRSRC hRes = FindResource(NULL, resourceName, RT_RCDATA);
if (hRes == NULL) {
print("FindResource %s\n", resourceName);
return -1;
}
DWORD dwResourceSize = SizeofResource(NULL, hRes);
assert(pitch >= width);
assert(slicePitch >= depth);
assert(slicePitch * depth == (int)dwResourceSize);
HGLOBAL hData = LoadResource(NULL, hRes);
D3D10_SUBRESOURCE_DATA subresourceData;
subresourceData.pSysMem = LockResource(hData);
subresourceData.SysMemPitch = pitch;
subresourceData.SysMemSlicePitch = slicePitch;
D3D10_TEXTURE3D_DESC textureDesc;
textureDesc.Width = width;
textureDesc.Height = height;
textureDesc.Depth = depth;
textureDesc.MipLevels = 1;
textureDesc.Format = format;
textureDesc.Usage = D3D10_USAGE_IMMUTABLE;
textureDesc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D10Texture3D * pTexture;
hr = g_pd3dDevice->CreateTexture3D(&textureDesc, &subresourceData, &pTexture);
if (FAILED(hr)) {
print("CreateTexture3D\n");
return hr;
}
D3D10_SHADER_RESOURCE_VIEW_DESC descSRV;
descSRV.Format = textureDesc.Format;
descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE3D;
descSRV.Texture3D.MostDetailedMip = 0;
descSRV.Texture3D.MipLevels = 1;
hr = g_pd3dDevice->CreateShaderResourceView(pTexture, &descSRV, pTextureShaderResourceView);
if (FAILED(hr)) {
print("CreateShaderResourceView\n");
return hr;
}
return S_OK;
}
HRESULT CreateTextureRenderTargetView(const int width,
const int height,
ID3D10RenderTargetView ** pRenderTargetView,
ID3D10ShaderResourceView ** pTextureShaderResourceView)
{
HRESULT hr;
D3D10_TEXTURE2D_DESC textureDesc;
textureDesc.Width = width;
textureDesc.Height = height;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D10_USAGE_DEFAULT;
textureDesc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D10Texture2D * pTexture;
hr = g_pd3dDevice->CreateTexture2D(&textureDesc, NULL, &pTexture);
if (FAILED(hr)) {
print("CreateTexture2D\n");
return hr;
}
hr = g_pd3dDevice->CreateRenderTargetView(pTexture, NULL, pRenderTargetView);
if (FAILED(hr)) {
print("g_pd3dDevice->CreateRenderTargetView(pTexture)\n");
return hr;
}
D3D10_SHADER_RESOURCE_VIEW_DESC descSRV;
descSRV.Format = textureDesc.Format;
descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
descSRV.Texture2D.MostDetailedMip = 0;
descSRV.Texture2D.MipLevels = 1;
hr = g_pd3dDevice->CreateShaderResourceView(pTexture, &descSRV, pTextureShaderResourceView);
if (FAILED(hr)) {
print("CreateShaderResourceView\n");
return hr;
}
return S_OK;
}
#include <windows.h>
#include <assert.h>
#include <d3d10.h>
#include "globals.hpp"
#include "print.hpp"
#include "render_state.hpp"
HRESULT LoadTexture2D(const wchar_t * resourceName,
const int width,
const int height,
const int pitch,
const DXGI_FORMAT format,
ID3D10ShaderResourceView ** pTextureShaderResourceView)
{
HRESULT hr;
// texture
HRSRC hRes = FindResource(NULL, resourceName, RT_RCDATA);
if (hRes == NULL) {
print("FindResource %s\n", resourceName);
return -1;
}
DWORD dwResourceSize = SizeofResource(NULL, hRes);
assert(pitch >= width);
assert(pitch * height == (int)dwResourceSize);
HGLOBAL hData = LoadResource(NULL, hRes);
D3D10_SUBRESOURCE_DATA subresourceData;
subresourceData.pSysMem = LockResource(hData);
subresourceData.SysMemPitch = pitch;
D3D10_TEXTURE2D_DESC textureDesc;
textureDesc.Width = width;
textureDesc.Height = height;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = format;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D10_USAGE_IMMUTABLE;
textureDesc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D10Texture2D * pTexture;
hr = g_pd3dDevice->CreateTexture2D(&textureDesc, &subresourceData, &pTexture);
if (FAILED(hr)) {
print("CreateTexture2D\n");
return hr;
}
D3D10_SHADER_RESOURCE_VIEW_DESC descSRV;
descSRV.Format = textureDesc.Format;
descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
descSRV.Texture2D.MostDetailedMip = 0;
descSRV.Texture2D.MipLevels = 1;
hr = g_pd3dDevice->CreateShaderResourceView(pTexture, &descSRV, pTextureShaderResourceView);
if (FAILED(hr)) {
print("CreateShaderResourceView\n");
return hr;
}
return S_OK;
}
HRESULT LoadTexture3D(const wchar_t * resourceName,
const int width,
const int height,
const int depth,
const int pitch,
const int slicePitch,
const DXGI_FORMAT format,
ID3D10ShaderResourceView ** pTextureShaderResourceView)
{
HRESULT hr;
HRSRC hRes = FindResource(NULL, resourceName, RT_RCDATA);
if (hRes == NULL) {
print("FindResource %s\n", resourceName);
return -1;
}
DWORD dwResourceSize = SizeofResource(NULL, hRes);
assert(pitch >= width);
assert(slicePitch >= depth);
assert(slicePitch * depth == (int)dwResourceSize);
HGLOBAL hData = LoadResource(NULL, hRes);
D3D10_SUBRESOURCE_DATA subresourceData;
subresourceData.pSysMem = LockResource(hData);
subresourceData.SysMemPitch = pitch;
subresourceData.SysMemSlicePitch = slicePitch;
D3D10_TEXTURE3D_DESC textureDesc;
textureDesc.Width = width;
textureDesc.Height = height;
textureDesc.Depth = depth;
textureDesc.MipLevels = 1;
textureDesc.Format = format;
textureDesc.Usage = D3D10_USAGE_IMMUTABLE;
textureDesc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D10Texture3D * pTexture;
hr = g_pd3dDevice->CreateTexture3D(&textureDesc, &subresourceData, &pTexture);
if (FAILED(hr)) {
print("CreateTexture3D\n");
return hr;
}
D3D10_SHADER_RESOURCE_VIEW_DESC descSRV;
descSRV.Format = textureDesc.Format;
descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE3D;
descSRV.Texture3D.MostDetailedMip = 0;
descSRV.Texture3D.MipLevels = 1;
hr = g_pd3dDevice->CreateShaderResourceView(pTexture, &descSRV, pTextureShaderResourceView);
if (FAILED(hr)) {
print("CreateShaderResourceView\n");
return hr;
}
return S_OK;
}
HRESULT CreateTextureRenderTargetView(const int width,
const int height,
ID3D10RenderTargetView ** pRenderTargetView,
ID3D10ShaderResourceView ** pTextureShaderResourceView)
{
HRESULT hr;
D3D10_TEXTURE2D_DESC textureDesc;
textureDesc.Width = width;
textureDesc.Height = height;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D10_USAGE_DEFAULT;
textureDesc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D10Texture2D * pTexture;
hr = g_pd3dDevice->CreateTexture2D(&textureDesc, NULL, &pTexture);
if (FAILED(hr)) {
print("CreateTexture2D\n");
return hr;
}
hr = g_pd3dDevice->CreateRenderTargetView(pTexture, NULL, pRenderTargetView);
if (FAILED(hr)) {
print("g_pd3dDevice->CreateRenderTargetView(pTexture)\n");
return hr;
}
D3D10_SHADER_RESOURCE_VIEW_DESC descSRV;
descSRV.Format = textureDesc.Format;
descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
descSRV.Texture2D.MostDetailedMip = 0;
descSRV.Texture2D.MipLevels = 1;
hr = g_pd3dDevice->CreateShaderResourceView(pTexture, &descSRV, pTextureShaderResourceView);
if (FAILED(hr)) {
print("CreateShaderResourceView\n");
return hr;
}
return S_OK;
}

View File

@ -4540,161 +4540,161 @@ const int accessor_8[] = {
};
const XMMATRIX accessor_9[] = {
XMMATRIX( 1.0000000f, -0.0000000f, -0.0000000f, -0.0000000f,
-0.0000000f, 1.0000000f, 0.0000001f, 0.0000000f,
0.0000000f, -0.0000001f, 1.0000000f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000000f, -0.0000000f, -0.0000000f,
-0.0000000f, 1.0000000f, 0.0000001f, 0.0000000f,
0.0000000f, -0.0000001f, 1.0000000f, -0.0000000f,
0.0020865f, -0.6493472f, 0.0044682f, 1.0000000f),
XMMATRIX( 0.9999925f, 0.0038494f, 0.0002189f, -0.0000000f,
0.0038556f, -0.9983662f, -0.0570068f, 0.0000000f,
-0.0000005f, 0.0570072f, -0.9983711f, -0.0000000f,
XMMATRIX( 0.9999925f, 0.0038494f, 0.0002189f, -0.0000000f,
0.0038556f, -0.9983662f, -0.0570068f, 0.0000000f,
-0.0000005f, 0.0570072f, -0.9983711f, -0.0000000f,
0.1011884f, 0.6297937f, 0.0216967f, 1.0000000f),
XMMATRIX( 0.9999585f, -0.0091070f, 0.0003901f, -0.0000000f,
-0.0091151f, -0.9993415f, 0.0351207f, 0.0000000f,
0.0000704f, -0.0351225f, -0.9993804f, -0.0000000f,
XMMATRIX( 0.9999585f, -0.0091070f, 0.0003901f, -0.0000000f,
-0.0091151f, -0.9993415f, 0.0351207f, 0.0000000f,
0.0000704f, -0.0351225f, -0.9993804f, -0.0000000f,
0.1061165f, 0.3790198f, -0.0133131f, 1.0000000f),
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 1.0000000f, -0.0000001f, 0.0000000f,
-0.0000000f, 0.0000001f, 1.0000000f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 1.0000000f, -0.0000001f, 0.0000000f,
-0.0000000f, 0.0000001f, 1.0000000f, -0.0000000f,
0.0020865f, -0.7840567f, 0.0044684f, 1.0000000f),
XMMATRIX( 0.9999975f, 0.0022573f, 0.0000000f, -0.0000000f,
-0.0022573f, 0.9999975f, -0.0000001f, 0.0000000f,
-0.0000000f, 0.0000001f, 1.0000000f, -0.0000000f,
XMMATRIX( 0.9999975f, 0.0022573f, 0.0000000f, -0.0000000f,
-0.0022573f, 0.9999975f, -0.0000001f, 0.0000000f,
-0.0000000f, 0.0000001f, 1.0000000f, -0.0000000f,
0.0041084f, -0.8957252f, 0.0044684f, 1.0000000f),
XMMATRIX( 0.9999950f, 0.0031200f, -0.0002015f, -0.0000000f,
0.0031265f, -0.9978876f, 0.0648890f, 0.0000000f,
0.0000006f, -0.0648893f, -0.9978877f, -0.0000000f,
XMMATRIX( 0.9999950f, 0.0031200f, -0.0002015f, -0.0000000f,
0.0031265f, -0.9978876f, 0.0648890f, 0.0000000f,
0.0000006f, -0.0648893f, -0.9978877f, -0.0000000f,
0.2384893f, 1.1499825f, -0.0747788f, 1.0000000f),
XMMATRIX( 1.0000000f, -0.0000001f, 0.0000014f, -0.0000000f,
0.0000000f, -0.9978564f, -0.0654442f, 0.0000000f,
0.0000007f, 0.0654436f, -0.9978516f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000001f, 0.0000014f, -0.0000000f,
0.0000000f, -0.9978564f, -0.0654442f, 0.0000000f,
0.0000007f, 0.0654436f, -0.9978516f, -0.0000000f,
0.2411296f, 0.8435937f, 0.0352844f, 1.0000000f),
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000014f, -0.0000000f,
-0.0000000f, -1.0000001f, -0.0000000f, 0.0000000f,
0.0000007f, -0.0000003f, -0.9999953f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000014f, -0.0000000f,
-0.0000000f, -1.0000001f, -0.0000000f, 0.0000000f,
0.0000007f, -0.0000003f, -0.9999953f, -0.0000000f,
0.2411296f, 0.5391477f, 0.0000003f, 1.0000000f),
XMMATRIX( 1.0000001f, 0.0000000f, -0.0000000f, -0.0000000f,
0.0000000f, 1.0000001f, 0.0000000f, -0.0000000f,
0.0000000f, -0.0000000f, 1.0000000f, -0.0000000f,
XMMATRIX( 1.0000001f, 0.0000000f, -0.0000000f, -0.0000000f,
0.0000000f, 1.0000001f, 0.0000000f, -0.0000000f,
0.0000000f, -0.0000000f, 1.0000000f, -0.0000000f,
-0.0000000f, -1.2420585f, -0.0000000f, 1.0000000f),
XMMATRIX( 1.0000001f, 0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 0.9582973f, 0.2857734f, 0.0000000f,
0.0000000f, -0.2857733f, 0.9582972f, -0.0000000f,
XMMATRIX( 1.0000001f, 0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 0.9582973f, 0.2857734f, 0.0000000f,
0.0000000f, -0.2857733f, 0.9582972f, -0.0000000f,
-0.2488541f, -1.3979810f, -0.3699030f, 1.0000000f),
XMMATRIX(-1.0000001f, 0.0000001f, 0.0000000f, -0.0000000f,
-0.0000001f, -0.9963848f, -0.0849537f, 0.0000000f,
0.0000007f, -0.0849559f, 0.9963719f, -0.0000000f,
XMMATRIX(-1.0000001f, 0.0000001f, 0.0000000f, -0.0000000f,
-0.0000001f, -0.9963848f, -0.0849537f, 0.0000000f,
0.0000007f, -0.0849559f, 0.9963719f, -0.0000000f,
-0.2411295f, 1.1474965f, 0.0978378f, 1.0000000f),
XMMATRIX(-1.0000001f, -0.0000000f, -0.0000001f, -0.0000000f,
-0.0000000f, -0.9980612f, -0.0622333f, 0.0000000f,
0.0000006f, -0.0622358f, 0.9980485f, -0.0000000f,
XMMATRIX(-1.0000001f, -0.0000000f, -0.0000001f, -0.0000000f,
-0.0000000f, -0.9980612f, -0.0622333f, 0.0000000f,
0.0000006f, -0.0622358f, 0.9980485f, -0.0000000f,
-0.2411295f, 1.0469925f, 0.0740057f, 1.0000000f),
XMMATRIX(-1.0000001f, -0.0000001f, -0.0000862f, -0.0000000f,
0.0000029f, -0.9994135f, -0.0342350f, 0.0000000f,
-0.0000855f, -0.0342378f, 0.9994007f, 0.0000000f,
XMMATRIX(-1.0000001f, -0.0000001f, -0.0000862f, -0.0000000f,
0.0000029f, -0.9994135f, -0.0342350f, 0.0000000f,
-0.0000855f, -0.0342378f, 0.9994007f, 0.0000000f,
-0.2411336f, 0.9460898f, 0.0474864f, 1.0000000f),
XMMATRIX(-0.9999998f, 0.0000001f, -0.0007542f, 0.0000000f,
-0.0000017f, -0.9999976f, 0.0020114f, 0.0000000f,
-0.0007535f, 0.0020081f, 0.9999847f, -0.0000000f,
XMMATRIX(-0.9999998f, 0.0000001f, -0.0007542f, 0.0000000f,
-0.0000017f, -0.9999976f, 0.0020114f, 0.0000000f,
-0.0007535f, 0.0020081f, 0.9999847f, -0.0000000f,
-0.2411421f, 0.8438913f, 0.0167495f, 1.0000000f),
XMMATRIX(-1.0000001f, -0.0000001f, 0.0000955f, -0.0000000f,
0.0000050f, -0.9986384f, 0.0521609f, -0.0000000f,
0.0000961f, 0.0521570f, 0.9986261f, -0.0000000f,
XMMATRIX(-1.0000001f, -0.0000001f, 0.0000955f, -0.0000000f,
0.0000050f, -0.9986384f, 0.0521609f, -0.0000000f,
0.0000961f, 0.0521570f, 0.9986261f, -0.0000000f,
-0.2411315f, 0.7425256f, -0.0203104f, 1.0000000f),
XMMATRIX(-0.9999996f, -0.0000002f, -0.0008393f, 0.0000000f,
-0.0001079f, -0.9916946f, 0.1286122f, 0.0000000f,
-0.0008317f, 0.1286074f, 0.9916822f, -0.0000000f,
XMMATRIX(-0.9999996f, -0.0000002f, -0.0008393f, 0.0000000f,
-0.0001079f, -0.9916946f, 0.1286122f, 0.0000000f,
-0.0008317f, 0.1286074f, 0.9916822f, -0.0000000f,
-0.2410713f, 0.6366479f, -0.0695772f, 1.0000000f),
XMMATRIX( 0.9999952f, -0.0031200f, 0.0002028f, -0.0000000f,
-0.0031266f, -0.9978875f, 0.0648890f, 0.0000000f,
0.0000000f, -0.0648893f, -0.9978880f, -0.0000000f,
XMMATRIX( 0.9999952f, -0.0031200f, 0.0002028f, -0.0000000f,
-0.0031266f, -0.9978875f, 0.0648890f, 0.0000000f,
0.0000000f, -0.0648893f, -0.9978880f, -0.0000000f,
-0.2384892f, 1.1499823f, -0.0747791f, 1.0000000f),
XMMATRIX( 1.0000001f, 0.0000000f, -0.0000001f, -0.0000000f,
-0.0000000f, -0.9978563f, -0.0654443f, 0.0000000f,
-0.0000000f, 0.0654437f, -0.9978519f, -0.0000000f,
XMMATRIX( 1.0000001f, 0.0000000f, -0.0000001f, -0.0000000f,
-0.0000000f, -0.9978563f, -0.0654443f, 0.0000000f,
-0.0000000f, 0.0654437f, -0.9978519f, -0.0000000f,
-0.2411296f, 0.8435934f, 0.0352841f, 1.0000000f),
XMMATRIX( 1.0000001f, 0.0000000f, -0.0000001f, -0.0000000f,
-0.0000000f, -1.0000000f, -0.0000000f, 0.0000000f,
-0.0000000f, -0.0000003f, -0.9999956f, 0.0000000f,
XMMATRIX( 1.0000001f, 0.0000000f, -0.0000001f, -0.0000000f,
-0.0000000f, -1.0000000f, -0.0000000f, 0.0000000f,
-0.0000000f, -0.0000003f, -0.9999956f, 0.0000000f,
-0.2411296f, 0.5391475f, -0.0000000f, 1.0000000f),
XMMATRIX(-1.0000001f, 0.0000001f, -0.0000021f, -0.0000000f,
0.0000000f, -0.9963848f, -0.0849539f, 0.0000000f,
-0.0000014f, -0.0849561f, 0.9963719f, 0.0000000f,
XMMATRIX(-1.0000001f, 0.0000001f, -0.0000021f, -0.0000000f,
0.0000000f, -0.9963848f, -0.0849539f, 0.0000000f,
-0.0000014f, -0.0849561f, 0.9963719f, 0.0000000f,
0.2411296f, 1.1474965f, 0.0978385f, 1.0000000f),
XMMATRIX(-1.0000001f, -0.0000000f, -0.0000018f, -0.0000000f,
0.0000001f, -0.9980614f, -0.0622338f, 0.0000000f,
-0.0000011f, -0.0622363f, 0.9980485f, 0.0000000f,
XMMATRIX(-1.0000001f, -0.0000000f, -0.0000018f, -0.0000000f,
0.0000001f, -0.9980614f, -0.0622338f, 0.0000000f,
-0.0000011f, -0.0622363f, 0.9980485f, 0.0000000f,
0.2411295f, 1.0469943f, 0.0740067f, 1.0000000f),
XMMATRIX(-1.0000001f, -0.0000001f, 0.0000870f, -0.0000000f,
-0.0000030f, -0.9994135f, -0.0342354f, 0.0000000f,
0.0000876f, -0.0342383f, 0.9994008f, -0.0000000f,
XMMATRIX(-1.0000001f, -0.0000001f, 0.0000870f, -0.0000000f,
-0.0000030f, -0.9994135f, -0.0342354f, 0.0000000f,
0.0000876f, -0.0342383f, 0.9994008f, -0.0000000f,
0.2411337f, 0.9460909f, 0.0474867f, 1.0000000f),
XMMATRIX(-0.9999999f, -0.0000002f, 0.0007523f, -0.0000000f,
0.0000017f, -0.9999979f, 0.0020110f, 0.0000000f,
0.0007530f, 0.0020077f, 0.9999850f, -0.0000000f,
XMMATRIX(-0.9999999f, -0.0000002f, 0.0007523f, -0.0000000f,
0.0000017f, -0.9999979f, 0.0020110f, 0.0000000f,
0.0007530f, 0.0020077f, 0.9999850f, -0.0000000f,
0.2411422f, 0.8438926f, 0.0167503f, 1.0000000f),
XMMATRIX(-1.0000001f, -0.0000001f, -0.0000976f, 0.0000000f,
-0.0000051f, -0.9986385f, 0.0521605f, 0.0000000f,
-0.0000968f, 0.0521566f, 0.9986261f, -0.0000000f,
XMMATRIX(-1.0000001f, -0.0000001f, -0.0000976f, 0.0000000f,
-0.0000051f, -0.9986385f, 0.0521605f, 0.0000000f,
-0.0000968f, 0.0521566f, 0.9986261f, -0.0000000f,
0.2411316f, 0.7425266f, -0.0203097f, 1.0000000f),
XMMATRIX(-0.9999998f, -0.0000000f, 0.0008371f, -0.0000000f,
0.0001073f, -0.9917392f, 0.1282703f, -0.0000000f,
0.0008309f, 0.1282655f, 0.9917267f, -0.0000000f,
XMMATRIX(-0.9999998f, -0.0000000f, 0.0008371f, -0.0000000f,
0.0001073f, -0.9917392f, 0.1282703f, -0.0000000f,
0.0008309f, 0.1282655f, 0.9917267f, -0.0000000f,
0.2410717f, 0.6366724f, -0.0693572f, 1.0000000f),
XMMATRIX( 0.9999633f, -0.0042382f, 0.0074449f, -0.0000000f,
-0.0038072f, -0.9983676f, -0.0569888f, 0.0000000f,
0.0076739f, 0.0569584f, -0.9983445f, -0.0000000f,
XMMATRIX( 0.9999633f, -0.0042382f, 0.0074449f, -0.0000000f,
-0.0038072f, -0.9983676f, -0.0569888f, 0.0000000f,
0.0076739f, 0.0569584f, -0.9983445f, -0.0000000f,
-0.1011066f, 0.6298342f, 0.0208916f, 1.0000000f),
XMMATRIX( 0.9999292f, 0.0094264f, 0.0072769f, -0.0000000f,
0.0091650f, -0.9993400f, 0.0351520f, 0.0000000f,
0.0076031f, -0.0350826f, -0.9993530f, -0.0000000f,
XMMATRIX( 0.9999292f, 0.0094264f, 0.0072769f, -0.0000000f,
0.0091650f, -0.9993400f, 0.0351520f, 0.0000000f,
0.0076031f, -0.0350826f, -0.9993530f, -0.0000000f,
-0.1060352f, 0.3789865f, -0.0141235f, 1.0000000f),
XMMATRIX(-0.0000005f, -0.0000000f, -1.0000001f, 0.0000000f,
1.0000001f, 0.0000000f, -0.0000005f, 0.0000000f,
0.0000000f, -1.0000002f, 0.0000000f, -0.0000000f,
XMMATRIX(-0.0000005f, -0.0000000f, -1.0000001f, 0.0000000f,
1.0000001f, 0.0000000f, -0.0000005f, 0.0000000f,
0.0000000f, -1.0000002f, 0.0000000f, -0.0000000f,
-0.5391478f, -0.0000001f, -0.2411293f, 1.0000000f),
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f,
0.0000000f, -1.0000000f, 0.0000000f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f,
0.0000000f, -1.0000000f, 0.0000000f, -0.0000000f,
0.2411295f, -0.0870393f, -0.8440942f, 1.0000000f),
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000010f, -0.0000000f,
0.0000010f, -0.0039314f, -0.9999923f, 0.0000000f,
0.0000000f, 0.9999923f, -0.0039314f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000010f, -0.0000000f,
0.0000010f, -0.0039314f, -0.9999923f, 0.0000000f,
0.0000000f, 0.9999923f, -0.0039314f, -0.0000000f,
0.1054246f, 0.0106810f, -0.0000419f, 1.0000000f),
XMMATRIX(-0.0475822f, -0.0000003f, -0.9988677f, -0.0000000f,
0.7671170f, 0.6404657f, -0.0365425f, -0.0000000f,
0.6397402f, -0.7679867f, -0.0304748f, -0.0000000f,
XMMATRIX(-0.0475822f, -0.0000003f, -0.9988677f, -0.0000000f,
0.7671170f, 0.6404657f, -0.0365425f, -0.0000000f,
0.6397402f, -0.7679867f, -0.0304748f, -0.0000000f,
-0.0567143f, 0.0626259f, -0.1028425f, 1.0000000f),
XMMATRIX(-0.0475822f, -0.0000002f, -0.9988677f, -0.0000000f,
0.9988673f, -0.0000001f, -0.0475821f, 0.0000000f,
-0.0000000f, -0.9999999f, -0.0000000f, 0.0000000f,
XMMATRIX(-0.0475822f, -0.0000002f, -0.9988677f, -0.0000000f,
0.9988673f, -0.0000001f, -0.0475821f, 0.0000000f,
-0.0000000f, -0.9999999f, -0.0000000f, 0.0000000f,
-0.0812300f, -0.0106811f, -0.1016747f, 1.0000000f),
XMMATRIX( 0.9999926f, -0.0000000f, 0.0038554f, -0.0000000f,
0.0038554f, 0.0000000f, -0.9999926f, 0.0000000f,
-0.0000000f, 1.0000000f, 0.0000000f, -0.0000000f,
XMMATRIX( 0.9999926f, -0.0000000f, 0.0038554f, -0.0000000f,
0.0038554f, 0.0000000f, -0.9999926f, 0.0000000f,
-0.0000000f, 1.0000000f, 0.0000000f, -0.0000000f,
0.1011885f, -0.2318209f, 0.3805980f, 1.0000000f),
XMMATRIX(-0.0000005f, -0.0000000f, 1.0000001f, -0.0000000f,
-1.0000001f, -0.0000000f, -0.0000005f, 0.0000000f,
0.0000000f, -1.0000002f, 0.0000000f, -0.0000000f,
XMMATRIX(-0.0000005f, -0.0000000f, 1.0000001f, -0.0000000f,
-1.0000001f, -0.0000000f, -0.0000005f, 0.0000000f,
0.0000000f, -1.0000002f, 0.0000000f, -0.0000000f,
0.5391478f, -0.0000001f, -0.2411293f, 1.0000000f),
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f,
0.0000000f, -1.0000000f, 0.0000000f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000000f, 0.0000000f, -0.0000000f,
-0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f,
0.0000000f, -1.0000000f, 0.0000000f, -0.0000000f,
-0.2411295f, -0.0870393f, -0.8440942f, 1.0000000f),
XMMATRIX( 1.0000000f, -0.0000000f, -0.0000010f, -0.0000000f,
-0.0000010f, -0.0039314f, -0.9999923f, 0.0000000f,
-0.0000000f, 0.9999923f, -0.0039314f, -0.0000000f,
XMMATRIX( 1.0000000f, -0.0000000f, -0.0000010f, -0.0000000f,
-0.0000010f, -0.0039314f, -0.9999923f, 0.0000000f,
-0.0000000f, 0.9999923f, -0.0039314f, -0.0000000f,
-0.1054246f, 0.0106810f, -0.0000419f, 1.0000000f),
XMMATRIX(-0.0475822f, 0.0000003f, 0.9988677f, -0.0000000f,
-0.7671170f, 0.6404657f, -0.0365425f, 0.0000000f,
-0.6397402f, -0.7679867f, -0.0304748f, 0.0000000f,
XMMATRIX(-0.0475822f, 0.0000003f, 0.9988677f, -0.0000000f,
-0.7671170f, 0.6404657f, -0.0365425f, 0.0000000f,
-0.6397402f, -0.7679867f, -0.0304748f, 0.0000000f,
0.0567143f, 0.0626259f, -0.1028425f, 1.0000000f),
XMMATRIX(-0.0475822f, 0.0000002f, 0.9988677f, -0.0000000f,
-0.9988673f, -0.0000001f, -0.0475821f, 0.0000000f,
0.0000000f, -0.9999999f, -0.0000000f, -0.0000000f,
XMMATRIX(-0.0475822f, 0.0000002f, 0.9988677f, -0.0000000f,
-0.9988673f, -0.0000001f, -0.0475821f, 0.0000000f,
0.0000000f, -0.9999999f, -0.0000000f, -0.0000000f,
0.0812300f, -0.0106811f, -0.1016747f, 1.0000000f),
XMMATRIX( 0.9999926f, -0.0000000f, -0.0038554f, -0.0000000f,
-0.0038554f, 0.0000000f, -0.9999926f, 0.0000000f,
0.0000000f, 1.0000000f, 0.0000000f, -0.0000000f,
XMMATRIX( 0.9999926f, -0.0000000f, -0.0038554f, -0.0000000f,
-0.0038554f, 0.0000000f, -0.9999926f, 0.0000000f,
0.0000000f, 1.0000000f, 0.0000000f, -0.0000000f,
-0.1011885f, -0.2318209f, 0.3805980f, 1.0000000f),
};