collada: normalize cpp/hpp/fx to dos line endings
This commit is contained in:
parent
03b0299415
commit
0d1a363790
@ -1,580 +0,0 @@
|
|||||||
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'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef COLLADA_HPP_
|
#ifndef COLLADA_HPP_
|
||||||
#define COLLADA_HPP_
|
#define COLLADA_HPP_
|
||||||
|
|
||||||
namespace collada {
|
namespace collada {
|
||||||
HRESULT LoadEffect();
|
HRESULT LoadEffect();
|
||||||
HRESULT LoadMesh();
|
HRESULT LoadMesh();
|
||||||
void Render(float t);
|
void Render(float t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,239 +1,239 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace collada {
|
namespace collada {
|
||||||
|
|
||||||
struct float3 {
|
struct float3 {
|
||||||
float const x;
|
float const x;
|
||||||
float const y;
|
float const y;
|
||||||
float const z;
|
float const z;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct float4 {
|
struct float4 {
|
||||||
float const x;
|
float const x;
|
||||||
float const y;
|
float const y;
|
||||||
float const z;
|
float const z;
|
||||||
float const w;
|
float const w;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct float7 {
|
struct float7 {
|
||||||
float const a;
|
float const a;
|
||||||
float const b;
|
float const b;
|
||||||
float const c;
|
float const c;
|
||||||
float const d;
|
float const d;
|
||||||
float const e;
|
float const e;
|
||||||
float const f;
|
float const f;
|
||||||
float const g;
|
float const g;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// animation
|
// animation
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
enum class interpolation {
|
enum class interpolation {
|
||||||
LINEAR,
|
LINEAR,
|
||||||
BEZIER,
|
BEZIER,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct source {
|
struct source {
|
||||||
union {
|
union {
|
||||||
float const * const float_array;
|
float const * const float_array;
|
||||||
enum interpolation const name_array;
|
enum interpolation const name_array;
|
||||||
};
|
};
|
||||||
int const count;
|
int const count;
|
||||||
int const stride;
|
int const stride;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sampler {
|
struct sampler {
|
||||||
source const input;
|
source const input;
|
||||||
source const output;
|
source const output;
|
||||||
source const intangent;
|
source const intangent;
|
||||||
source const outangent;
|
source const outangent;
|
||||||
source const interpolation;
|
source const interpolation;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// geometry
|
// geometry
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
enum class input_format {
|
enum class input_format {
|
||||||
FLOAT3,
|
FLOAT3,
|
||||||
FLOAT4,
|
FLOAT4,
|
||||||
INT4,
|
INT4,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct input_element {
|
struct input_element {
|
||||||
char const * const semantic;
|
char const * const semantic;
|
||||||
int const semantic_index;
|
int const semantic_index;
|
||||||
enum input_format const format;
|
enum input_format const format;
|
||||||
};
|
};
|
||||||
|
|
||||||
// inputs uniqueness is by evaluted pointer
|
// inputs uniqueness is by evaluted pointer
|
||||||
struct inputs {
|
struct inputs {
|
||||||
input_element const * const elements;
|
input_element const * const elements;
|
||||||
int const elements_count;
|
int const elements_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct triangles {
|
struct triangles {
|
||||||
int const count;
|
int const count;
|
||||||
int const index_offset;
|
int const index_offset;
|
||||||
inputs const inputs;
|
inputs const inputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mesh {
|
struct mesh {
|
||||||
// `triangles` must become a union if non-triangles are implemented.
|
// `triangles` must become a union if non-triangles are implemented.
|
||||||
// instance_geometry is an index into this array.
|
// instance_geometry is an index into this array.
|
||||||
triangles const * triangles;
|
triangles const * triangles;
|
||||||
int const triangles_count;
|
int const triangles_count;
|
||||||
|
|
||||||
int const vertex_buffer_offset;
|
int const vertex_buffer_offset;
|
||||||
int const vertex_buffer_size;
|
int const vertex_buffer_size;
|
||||||
|
|
||||||
int const index_buffer_offset;
|
int const index_buffer_offset;
|
||||||
int const index_buffer_size;
|
int const index_buffer_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct geometry {
|
struct geometry {
|
||||||
mesh mesh;
|
mesh mesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// node
|
// node
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct lookat {
|
struct lookat {
|
||||||
float3 const eye;
|
float3 const eye;
|
||||||
float3 const at;
|
float3 const at;
|
||||||
float3 const up;
|
float3 const up;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct matrix {
|
struct matrix {
|
||||||
float const _11, _12, _13, _14;
|
float const _11, _12, _13, _14;
|
||||||
float const _21, _22, _23, _24;
|
float const _21, _22, _23, _24;
|
||||||
float const _31, _32, _33, _34;
|
float const _31, _32, _33, _34;
|
||||||
float const _41, _42, _43, _44;
|
float const _41, _42, _43, _44;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class transform_type {
|
enum class transform_type {
|
||||||
LOOKAT,
|
LOOKAT,
|
||||||
MATRIX,
|
MATRIX,
|
||||||
ROTATE,
|
ROTATE,
|
||||||
SCALE,
|
SCALE,
|
||||||
TRANSLATE,
|
TRANSLATE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct transform {
|
struct transform {
|
||||||
transform_type const type;
|
transform_type const type;
|
||||||
union {
|
union {
|
||||||
lookat const lookat;
|
lookat const lookat;
|
||||||
matrix const matrix;
|
matrix const matrix;
|
||||||
float4 const rotate;
|
float4 const rotate;
|
||||||
float3 const scale;
|
float3 const scale;
|
||||||
float7 const skew;
|
float7 const skew;
|
||||||
float3 const translate;
|
float3 const translate;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class node_type {
|
enum class node_type {
|
||||||
JOINT,
|
JOINT,
|
||||||
NODE,
|
NODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct color_or_texture {
|
struct color_or_texture {
|
||||||
union {
|
union {
|
||||||
float4 color;
|
float4 color;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct blinn {
|
struct blinn {
|
||||||
color_or_texture const emission;
|
color_or_texture const emission;
|
||||||
color_or_texture const ambient;
|
color_or_texture const ambient;
|
||||||
color_or_texture const diffuse;
|
color_or_texture const diffuse;
|
||||||
color_or_texture const specular;
|
color_or_texture const specular;
|
||||||
float const shininess;
|
float const shininess;
|
||||||
color_or_texture const reflective;
|
color_or_texture const reflective;
|
||||||
float const reflectivity;
|
float const reflectivity;
|
||||||
color_or_texture const transparent;
|
color_or_texture const transparent;
|
||||||
float const transparency;
|
float const transparency;
|
||||||
float const index_of_refraction;
|
float const index_of_refraction;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lambert {
|
struct lambert {
|
||||||
color_or_texture const emission;
|
color_or_texture const emission;
|
||||||
color_or_texture const ambient;
|
color_or_texture const ambient;
|
||||||
color_or_texture const diffuse;
|
color_or_texture const diffuse;
|
||||||
color_or_texture const reflective;
|
color_or_texture const reflective;
|
||||||
float const reflectivity;
|
float const reflectivity;
|
||||||
color_or_texture const transparent;
|
color_or_texture const transparent;
|
||||||
float const transparency;
|
float const transparency;
|
||||||
float const index_of_refraction;
|
float const index_of_refraction;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct phong {
|
struct phong {
|
||||||
color_or_texture const emission;
|
color_or_texture const emission;
|
||||||
color_or_texture const ambient;
|
color_or_texture const ambient;
|
||||||
color_or_texture const diffuse;
|
color_or_texture const diffuse;
|
||||||
color_or_texture const specular;
|
color_or_texture const specular;
|
||||||
float const shininess;
|
float const shininess;
|
||||||
color_or_texture const reflective;
|
color_or_texture const reflective;
|
||||||
float const reflectivity;
|
float const reflectivity;
|
||||||
color_or_texture const transparent;
|
color_or_texture const transparent;
|
||||||
float const transparency;
|
float const transparency;
|
||||||
float const index_of_refraction;
|
float const index_of_refraction;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct constant {
|
struct constant {
|
||||||
float4 const color;
|
float4 const color;
|
||||||
color_or_texture const reflective;
|
color_or_texture const reflective;
|
||||||
float const reflectivity;
|
float const reflectivity;
|
||||||
color_or_texture const transparent;
|
color_or_texture const transparent;
|
||||||
float const transparency;
|
float const transparency;
|
||||||
float const index_of_refraction;
|
float const index_of_refraction;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class effect_type {
|
enum class effect_type {
|
||||||
BLINN,
|
BLINN,
|
||||||
LAMBERT,
|
LAMBERT,
|
||||||
PHONG,
|
PHONG,
|
||||||
CONSTANT,
|
CONSTANT,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct effect {
|
struct effect {
|
||||||
effect_type const type;
|
effect_type const type;
|
||||||
union {
|
union {
|
||||||
blinn const blinn;
|
blinn const blinn;
|
||||||
lambert const lambert;
|
lambert const lambert;
|
||||||
phong const phong;
|
phong const phong;
|
||||||
constant const constant;
|
constant const constant;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct material {
|
struct material {
|
||||||
effect const * const effect;
|
effect const * const effect;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct instance_material {
|
struct instance_material {
|
||||||
int element_index;
|
int element_index;
|
||||||
material const * const material;
|
material const * const material;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct instance_geometry {
|
struct instance_geometry {
|
||||||
geometry const * const geometry;
|
geometry const * const geometry;
|
||||||
|
|
||||||
instance_material const * const instance_materials;
|
instance_material const * const instance_materials;
|
||||||
int const instance_materials_count;
|
int const instance_materials_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct node {
|
struct node {
|
||||||
node_type const type;
|
node_type const type;
|
||||||
|
|
||||||
transform const * const transforms;
|
transform const * const transforms;
|
||||||
int const transforms_count;
|
int const transforms_count;
|
||||||
|
|
||||||
instance_geometry const * const instance_geometries;
|
instance_geometry const * const instance_geometries;
|
||||||
int const instance_geometries_count;
|
int const instance_geometries_count;
|
||||||
|
|
||||||
node const * const nodes;
|
node const * const nodes;
|
||||||
int const nodes_count;
|
int const nodes_count;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
724
src/collada.cpp
724
src/collada.cpp
@ -1,362 +1,362 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <d3d10.h>
|
#include <d3d10.h>
|
||||||
|
|
||||||
#include "directxmath/directxmath.h"
|
#include "directxmath/directxmath.h"
|
||||||
|
|
||||||
#include "print.hpp"
|
#include "print.hpp"
|
||||||
#include "collada.hpp"
|
#include "collada.hpp"
|
||||||
|
|
||||||
extern ID3D10Device * g_pd3dDevice;
|
extern ID3D10Device * g_pd3dDevice;
|
||||||
extern XMMATRIX g_View;
|
extern XMMATRIX g_View;
|
||||||
extern XMMATRIX g_Projection;
|
extern XMMATRIX g_Projection;
|
||||||
|
|
||||||
namespace collada {
|
namespace collada {
|
||||||
static const float vertex_buffer[] = {
|
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, 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, 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, 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, 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, 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, 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, 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, 20.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0,
|
||||||
-5.0, -5.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, 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, 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, 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, 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, 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, 1.0, 1.0, 0.0,
|
||||||
-5.0, 5.0, 20.0, -1.0, 0.0, 0.0, 0.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[] = {
|
static const int index_buffer[] = {
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
2, 3, 0,
|
2, 3, 0,
|
||||||
4, 5, 6,
|
4, 5, 6,
|
||||||
6, 7, 4,
|
6, 7, 4,
|
||||||
8, 9, 10,
|
8, 9, 10,
|
||||||
10, 11, 8,
|
10, 11, 8,
|
||||||
11, 10, 12,
|
11, 10, 12,
|
||||||
12, 13, 11,
|
12, 13, 11,
|
||||||
13, 12, 14,
|
13, 12, 14,
|
||||||
14, 15, 13,
|
14, 15, 13,
|
||||||
15, 14, 16,
|
15, 14, 16,
|
||||||
16, 17, 15,
|
16, 17, 15,
|
||||||
17, 16, 18,
|
17, 16, 18,
|
||||||
18, 19, 17,
|
18, 19, 17,
|
||||||
20, 21, 22,
|
20, 21, 22,
|
||||||
22, 23, 20,
|
22, 23, 20,
|
||||||
23, 22, 24,
|
23, 22, 24,
|
||||||
24, 25, 23,
|
24, 25, 23,
|
||||||
25, 24, 26,
|
25, 24, 26,
|
||||||
26, 27, 25,
|
26, 27, 25,
|
||||||
27, 26, 28,
|
27, 26, 28,
|
||||||
28, 29, 27,
|
28, 29, 27,
|
||||||
29, 28, 30,
|
29, 28, 30,
|
||||||
30, 31, 29,
|
30, 31, 29,
|
||||||
32, 33, 34,
|
32, 33, 34,
|
||||||
34, 35, 32,
|
34, 35, 32,
|
||||||
35, 34, 36,
|
35, 34, 36,
|
||||||
36, 37, 35,
|
36, 37, 35,
|
||||||
37, 36, 38,
|
37, 36, 38,
|
||||||
38, 39, 37,
|
38, 39, 37,
|
||||||
39, 38, 40,
|
39, 38, 40,
|
||||||
40, 41, 39,
|
40, 41, 39,
|
||||||
41, 40, 42,
|
41, 40, 42,
|
||||||
42, 43, 41,
|
42, 43, 41,
|
||||||
44, 45, 46,
|
44, 45, 46,
|
||||||
46, 47, 44,
|
46, 47, 44,
|
||||||
47, 46, 48,
|
47, 46, 48,
|
||||||
48, 49, 47,
|
48, 49, 47,
|
||||||
49, 48, 50,
|
49, 48, 50,
|
||||||
50, 51, 49,
|
50, 51, 49,
|
||||||
51, 50, 52,
|
51, 50, 52,
|
||||||
52, 53, 51,
|
52, 53, 51,
|
||||||
53, 52, 54,
|
53, 52, 54,
|
||||||
54, 55, 53,
|
54, 55, 53,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float inverse_bind_matrices[] = {
|
static const float inverse_bind_matrices[] = {
|
||||||
0.0f, 0.0f, -1.0f, 0.0f,
|
0.0f, 0.0f, -1.0f, 0.0f,
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
1.0f, 0.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, 0.0f, 1.0f,
|
||||||
|
|
||||||
0.0f, 0.0f, -1.0f, 0.0f,
|
0.0f, 0.0f, -1.0f, 0.0f,
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
1.0f, 0.0f, 0.0f, 0.0f,
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
-10.0f, 0.0f, 0.0f, 1.0f,
|
-10.0f, 0.0f, 0.0f, 1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float joints_weights[] = {
|
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,
|
||||||
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,
|
||||||
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,
|
||||||
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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 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,
|
||||||
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.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.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.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, 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,
|
||||||
1, 0, 0, 0, 1.0, 0, 0, 0,
|
1, 0, 0, 0, 1.0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
ID3D10Effect * g_pEffect = NULL;
|
ID3D10Effect * g_pEffect = NULL;
|
||||||
ID3D10EffectTechnique * g_pTechniqueRender = NULL;
|
ID3D10EffectTechnique * g_pTechniqueRender = NULL;
|
||||||
ID3D10InputLayout * g_pVertexLayout = NULL;
|
ID3D10InputLayout * g_pVertexLayout = NULL;
|
||||||
|
|
||||||
ID3D10Buffer * g_pVertexBufferPNT;
|
ID3D10Buffer * g_pVertexBufferPNT;
|
||||||
ID3D10Buffer * g_pVertexBufferJW;
|
ID3D10Buffer * g_pVertexBufferJW;
|
||||||
ID3D10Buffer * g_pIndexBuffer;
|
ID3D10Buffer * g_pIndexBuffer;
|
||||||
|
|
||||||
ID3D10EffectMatrixVariable * g_pJointVariable = NULL;
|
ID3D10EffectMatrixVariable * g_pJointVariable = NULL;
|
||||||
|
|
||||||
ID3D10EffectMatrixVariable * g_pWorldVariable = NULL;
|
ID3D10EffectMatrixVariable * g_pWorldVariable = NULL;
|
||||||
ID3D10EffectMatrixVariable * g_pViewVariable = NULL;
|
ID3D10EffectMatrixVariable * g_pViewVariable = NULL;
|
||||||
ID3D10EffectMatrixVariable * g_pProjectionVariable = NULL;
|
ID3D10EffectMatrixVariable * g_pProjectionVariable = NULL;
|
||||||
|
|
||||||
HRESULT LoadEffect()
|
HRESULT LoadEffect()
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
HRSRC hRes = FindResource(NULL, L"RES_COLLADA_FXO", RT_RCDATA);
|
HRSRC hRes = FindResource(NULL, L"RES_COLLADA_FXO", RT_RCDATA);
|
||||||
if (hRes == NULL) {
|
if (hRes == NULL) {
|
||||||
print("FindResource RES_COLLADA_FXO\n");
|
print("FindResource RES_COLLADA_FXO\n");
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
DWORD dwResSize = SizeofResource(NULL, hRes);
|
DWORD dwResSize = SizeofResource(NULL, hRes);
|
||||||
HGLOBAL hData = LoadResource(NULL, hRes);
|
HGLOBAL hData = LoadResource(NULL, hRes);
|
||||||
void * pData = LockResource(hData);
|
void * pData = LockResource(hData);
|
||||||
hr = D3D10CreateEffectFromMemory(pData,
|
hr = D3D10CreateEffectFromMemory(pData,
|
||||||
dwResSize,
|
dwResSize,
|
||||||
0,
|
0,
|
||||||
g_pd3dDevice,
|
g_pd3dDevice,
|
||||||
NULL,
|
NULL,
|
||||||
&g_pEffect
|
&g_pEffect
|
||||||
);
|
);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("D3D10CreateEffectFromMemory\n");
|
print("D3D10CreateEffectFromMemory\n");
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
g_pTechniqueRender = g_pEffect->GetTechniqueByName("Render");
|
g_pTechniqueRender = g_pEffect->GetTechniqueByName("Render");
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
g_pJointVariable = g_pEffect->GetVariableByName("mJoint")->AsMatrix();
|
g_pJointVariable = g_pEffect->GetVariableByName("mJoint")->AsMatrix();
|
||||||
|
|
||||||
g_pWorldVariable = g_pEffect->GetVariableByName("World")->AsMatrix();
|
g_pWorldVariable = g_pEffect->GetVariableByName("World")->AsMatrix();
|
||||||
g_pViewVariable = g_pEffect->GetVariableByName("View")->AsMatrix();
|
g_pViewVariable = g_pEffect->GetVariableByName("View")->AsMatrix();
|
||||||
g_pProjectionVariable = g_pEffect->GetVariableByName("Projection")->AsMatrix();
|
g_pProjectionVariable = g_pEffect->GetVariableByName("Projection")->AsMatrix();
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
D3D10_INPUT_ELEMENT_DESC layout[] = {
|
D3D10_INPUT_ELEMENT_DESC layout[] = {
|
||||||
{"POSITION" , 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0 , D3D10_INPUT_PER_VERTEX_DATA, 0},
|
{"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},
|
{"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},
|
{"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},
|
{"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},
|
{"BLENDWEIGHT" , 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D10_INPUT_PER_VERTEX_DATA, 0},
|
||||||
};
|
};
|
||||||
UINT numElements = (sizeof (layout)) / (sizeof (layout[0]));
|
UINT numElements = (sizeof (layout)) / (sizeof (layout[0]));
|
||||||
|
|
||||||
D3D10_PASS_DESC passDesc;
|
D3D10_PASS_DESC passDesc;
|
||||||
g_pTechniqueRender->GetPassByIndex(0)->GetDesc(&passDesc);
|
g_pTechniqueRender->GetPassByIndex(0)->GetDesc(&passDesc);
|
||||||
|
|
||||||
hr = g_pd3dDevice->CreateInputLayout(layout, numElements,
|
hr = g_pd3dDevice->CreateInputLayout(layout, numElements,
|
||||||
passDesc.pIAInputSignature,
|
passDesc.pIAInputSignature,
|
||||||
passDesc.IAInputSignatureSize,
|
passDesc.IAInputSignatureSize,
|
||||||
&g_pVertexLayout);
|
&g_pVertexLayout);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("CreateInputLayout\n");
|
print("CreateInputLayout\n");
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT LoadMesh()
|
HRESULT LoadMesh()
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
D3D10_BUFFER_DESC bd;
|
D3D10_BUFFER_DESC bd;
|
||||||
D3D10_SUBRESOURCE_DATA initData;
|
D3D10_SUBRESOURCE_DATA initData;
|
||||||
|
|
||||||
bd.Usage = D3D10_USAGE_IMMUTABLE;
|
bd.Usage = D3D10_USAGE_IMMUTABLE;
|
||||||
bd.ByteWidth = (sizeof (vertex_buffer));
|
bd.ByteWidth = (sizeof (vertex_buffer));
|
||||||
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
||||||
bd.CPUAccessFlags = 0;
|
bd.CPUAccessFlags = 0;
|
||||||
bd.MiscFlags = 0;
|
bd.MiscFlags = 0;
|
||||||
initData.pSysMem = vertex_buffer;
|
initData.pSysMem = vertex_buffer;
|
||||||
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferPNT);
|
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferPNT);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
|
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bd.Usage = D3D10_USAGE_IMMUTABLE;
|
bd.Usage = D3D10_USAGE_IMMUTABLE;
|
||||||
bd.ByteWidth = (sizeof (joints_weights));
|
bd.ByteWidth = (sizeof (joints_weights));
|
||||||
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
||||||
bd.CPUAccessFlags = 0;
|
bd.CPUAccessFlags = 0;
|
||||||
bd.MiscFlags = 0;
|
bd.MiscFlags = 0;
|
||||||
initData.pSysMem = joints_weights;
|
initData.pSysMem = joints_weights;
|
||||||
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferJW);
|
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pVertexBufferJW);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
|
print("CreateBuffer: D3D10_BIND_VERTEX_BUFFER\n");
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bd.Usage = D3D10_USAGE_IMMUTABLE;
|
bd.Usage = D3D10_USAGE_IMMUTABLE;
|
||||||
bd.ByteWidth = (sizeof (index_buffer));
|
bd.ByteWidth = (sizeof (index_buffer));
|
||||||
bd.BindFlags = D3D10_BIND_INDEX_BUFFER;
|
bd.BindFlags = D3D10_BIND_INDEX_BUFFER;
|
||||||
bd.CPUAccessFlags = 0;
|
bd.CPUAccessFlags = 0;
|
||||||
bd.MiscFlags = 0;
|
bd.MiscFlags = 0;
|
||||||
initData.pSysMem = index_buffer;
|
initData.pSysMem = index_buffer;
|
||||||
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pIndexBuffer);
|
hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &g_pIndexBuffer);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("CreateBuffer: D3D10_BIND_INDEX_BUFFER\n");
|
print("CreateBuffer: D3D10_BIND_INDEX_BUFFER\n");
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render(float t)
|
void Render(float t)
|
||||||
{
|
{
|
||||||
XMMATRIX World = XMMatrixScaling(1, 1, 1);
|
XMMATRIX World = XMMatrixScaling(1, 1, 1);
|
||||||
|
|
||||||
// XMMATRIX XM_CALLCONV XMMatrixRotationNormal(FXMVECTOR NormalAxis, float Angle) noexcept;
|
// XMMATRIX XM_CALLCONV XMMatrixRotationNormal(FXMVECTOR NormalAxis, float Angle) noexcept;
|
||||||
//XMConvertToRadians
|
//XMConvertToRadians
|
||||||
XMVECTOR axis = XMVectorSet(0, 1, 0, 0);
|
XMVECTOR axis = XMVectorSet(0, 1, 0, 0);
|
||||||
XMVECTOR axisZ = XMVectorSet(0, 0, 1, 0);
|
XMVECTOR axisZ = XMVectorSet(0, 0, 1, 0);
|
||||||
XMMATRIX joint0
|
XMMATRIX joint0
|
||||||
= XMMatrixRotationNormal(axis, XMConvertToRadians(-90))
|
= XMMatrixRotationNormal(axis, XMConvertToRadians(-90))
|
||||||
;
|
;
|
||||||
XMMATRIX joint1
|
XMMATRIX joint1
|
||||||
= XMMatrixRotationNormal(axisZ, sin(t))
|
= XMMatrixRotationNormal(axisZ, sin(t))
|
||||||
* XMMatrixTranslation(10, 0, 0)
|
* XMMatrixTranslation(10, 0, 0)
|
||||||
* joint0
|
* joint0
|
||||||
;
|
;
|
||||||
|
|
||||||
XMMATRIX joint0ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[0 * 16]);
|
XMMATRIX joint0ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[0 * 16]);
|
||||||
XMMATRIX joint1ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[1 * 16]);
|
XMMATRIX joint1ibm = XMLoadFloat4x4((XMFLOAT4X4*)&inverse_bind_matrices[1 * 16]);
|
||||||
XMMATRIX mJoints[2] = {
|
XMMATRIX mJoints[2] = {
|
||||||
joint0ibm * joint0,
|
joint0ibm * joint0,
|
||||||
joint1ibm * joint1,
|
joint1ibm * joint1,
|
||||||
};
|
};
|
||||||
|
|
||||||
g_pJointVariable->SetMatrixArray((float *)mJoints, 0, 2);
|
g_pJointVariable->SetMatrixArray((float *)mJoints, 0, 2);
|
||||||
|
|
||||||
g_pWorldVariable->SetMatrix((float *)&World);
|
g_pWorldVariable->SetMatrix((float *)&World);
|
||||||
g_pViewVariable->SetMatrix((float *)&g_View);
|
g_pViewVariable->SetMatrix((float *)&g_View);
|
||||||
g_pProjectionVariable->SetMatrix((float *)&g_Projection);
|
g_pProjectionVariable->SetMatrix((float *)&g_Projection);
|
||||||
|
|
||||||
UINT stride[] = {
|
UINT stride[] = {
|
||||||
3 * 3 * 4, // position normal texture
|
3 * 3 * 4, // position normal texture
|
||||||
4 * 2 * 4, // joint weight
|
4 * 2 * 4, // joint weight
|
||||||
};
|
};
|
||||||
UINT offset[] = { 0, 0 };
|
UINT offset[] = { 0, 0 };
|
||||||
ID3D10Buffer * vertex_buffers[] = {
|
ID3D10Buffer * vertex_buffers[] = {
|
||||||
g_pVertexBufferPNT,
|
g_pVertexBufferPNT,
|
||||||
g_pVertexBufferJW,
|
g_pVertexBufferJW,
|
||||||
};
|
};
|
||||||
|
|
||||||
g_pd3dDevice->IASetInputLayout(g_pVertexLayout);
|
g_pd3dDevice->IASetInputLayout(g_pVertexLayout);
|
||||||
g_pd3dDevice->IASetVertexBuffers(0, 2, vertex_buffers, stride, offset);
|
g_pd3dDevice->IASetVertexBuffers(0, 2, vertex_buffers, stride, offset);
|
||||||
g_pd3dDevice->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
g_pd3dDevice->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
g_pd3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
g_pd3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
D3D10_TECHNIQUE_DESC techDesc;
|
D3D10_TECHNIQUE_DESC techDesc;
|
||||||
g_pTechniqueRender->GetDesc(&techDesc);
|
g_pTechniqueRender->GetDesc(&techDesc);
|
||||||
|
|
||||||
int indices_length = (sizeof (index_buffer)) / (sizeof (int));
|
int indices_length = (sizeof (index_buffer)) / (sizeof (int));
|
||||||
for (UINT p = 0; p < techDesc.Passes; p++) {
|
for (UINT p = 0; p < techDesc.Passes; p++) {
|
||||||
g_pTechniqueRender->GetPassByIndex(p)->Apply(0);
|
g_pTechniqueRender->GetPassByIndex(p)->Apply(0);
|
||||||
g_pd3dDevice->DrawIndexed(indices_length, 0, 0);
|
g_pd3dDevice->DrawIndexed(indices_length, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,72 +1,72 @@
|
|||||||
matrix World;
|
matrix World;
|
||||||
matrix View;
|
matrix View;
|
||||||
matrix Projection;
|
matrix Projection;
|
||||||
|
|
||||||
matrix mJoint[2];
|
matrix mJoint[2];
|
||||||
|
|
||||||
struct VS_INPUT
|
struct VS_INPUT
|
||||||
{
|
{
|
||||||
float4 Pos : POSITION;
|
float4 Pos : POSITION;
|
||||||
float3 Normal : NORMAL;
|
float3 Normal : NORMAL;
|
||||||
float2 Tex : TEXCOORD0;
|
float2 Tex : TEXCOORD0;
|
||||||
float4 Joint : BLENDINDICES0;
|
float4 Joint : BLENDINDICES0;
|
||||||
float4 Weight : BLENDWEIGHT0;
|
float4 Weight : BLENDWEIGHT0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
{
|
{
|
||||||
float4 Pos : SV_POSITION;
|
float4 Pos : SV_POSITION;
|
||||||
float3 Normal : NORMAL;
|
float3 Normal : NORMAL;
|
||||||
float2 Tex : TEXCOORD0;
|
float2 Tex : TEXCOORD0;
|
||||||
};
|
};
|
||||||
|
|
||||||
PS_INPUT VS(VS_INPUT input)
|
PS_INPUT VS(VS_INPUT input)
|
||||||
{
|
{
|
||||||
PS_INPUT output;
|
PS_INPUT output;
|
||||||
|
|
||||||
matrix mSkin
|
matrix mSkin
|
||||||
= input.Weight.x * mJoint[int(input.Joint.x)]
|
= input.Weight.x * mJoint[int(input.Joint.x)]
|
||||||
+ input.Weight.y * mJoint[int(input.Joint.y)]
|
+ input.Weight.y * mJoint[int(input.Joint.y)]
|
||||||
+ input.Weight.z * mJoint[int(input.Joint.z)]
|
+ input.Weight.z * mJoint[int(input.Joint.z)]
|
||||||
+ input.Weight.w * mJoint[int(input.Joint.w)]
|
+ input.Weight.w * mJoint[int(input.Joint.w)]
|
||||||
;
|
;
|
||||||
|
|
||||||
output.Pos = mul(input.Pos, mSkin);
|
output.Pos = mul(input.Pos, mSkin);
|
||||||
output.Pos = mul(output.Pos, World);
|
output.Pos = mul(output.Pos, World);
|
||||||
output.Pos = mul(output.Pos, View);
|
output.Pos = mul(output.Pos, View);
|
||||||
output.Pos = mul(output.Pos, Projection);
|
output.Pos = mul(output.Pos, Projection);
|
||||||
|
|
||||||
output.Normal = input.Normal;
|
output.Normal = input.Normal;
|
||||||
output.Tex = input.Tex;
|
output.Tex = input.Tex;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 PS(PS_INPUT input) : SV_Target
|
float4 PS(PS_INPUT input) : SV_Target
|
||||||
{
|
{
|
||||||
//return float4(input.Normal * 0.5 + 0.5, 1);
|
//return float4(input.Normal * 0.5 + 0.5, 1);
|
||||||
return float4(input.Tex.xy, 0, 1);
|
return float4(input.Tex.xy, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendState DisableBlending
|
BlendState DisableBlending
|
||||||
{
|
{
|
||||||
BlendEnable[0] = FALSE;
|
BlendEnable[0] = FALSE;
|
||||||
};
|
};
|
||||||
|
|
||||||
DepthStencilState EnableDepth
|
DepthStencilState EnableDepth
|
||||||
{
|
{
|
||||||
DepthEnable = TRUE;
|
DepthEnable = TRUE;
|
||||||
DepthWriteMask = ALL;
|
DepthWriteMask = ALL;
|
||||||
};
|
};
|
||||||
|
|
||||||
technique10 Render
|
technique10 Render
|
||||||
{
|
{
|
||||||
pass P0
|
pass P0
|
||||||
{
|
{
|
||||||
SetVertexShader(CompileShader(vs_4_0, VS()));
|
SetVertexShader(CompileShader(vs_4_0, VS()));
|
||||||
SetGeometryShader(NULL);
|
SetGeometryShader(NULL);
|
||||||
SetPixelShader(CompileShader(ps_4_0, PS()));
|
SetPixelShader(CompileShader(ps_4_0, PS()));
|
||||||
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
|
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
|
||||||
SetDepthStencilState(EnableDepth, 0);
|
SetDepthStencilState(EnableDepth, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user