[osg-users] How do I render a.ive model with shader?
OpenSceneGraph Users
osg-users at lists.openscenegraph.org
Tue Nov 24 19:16:39 PST 2020
system Win10& GTX1660 ,osg 3.6.4, osgearth 2.10.0
[image: QQ图片20201125102145.jpg]
static const char* gl3_VertexShader = {
"#version " GLSL_VERSION_STR "\n"
"// gl3_VertexShader\n"
"#ifdef GL_ES\n"
" precision highp float;\n"
"#endif\n"
"in vec4 osg_Vertex;\n"
"in vec4 osg_MultiTexCoord0;\n"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"out vec2 texCoord;\n"
"void main(void)\n"
"{\n"
" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
" texCoord = osg_MultiTexCoord0.xy;\n"
"}\n"
};
static const char* gl3_FragmentShader = {
"#version " GLSL_VERSION_STR "\n"
"// gl3_FragmentShader\n"
"#ifdef GL_ES\n"
" precision highp float;\n"
"#endif\n"
"uniform sampler2D baseTexture;\n"
"in vec2 texCoord;\n"
"out vec4 color;\n"
"void main(void)\n"
"{\n"
" color = texture(baseTexture, texCoord);\n"
"}\n"
};
//
osg::ref_ptr<osg::Program> program = new osg::Program;
program->addShader(new osg::Shader(osg::Shader::VERTEX,
gl2_VertexShader));
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
gl2_FragmentShader));
stateSet->addUniform( new osg::Uniform( " baseTexture ", 0) );
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
osg::BlendFunc *fn = new osg::BlendFunc();
fn->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::DST_ALPHA);
stateSet->setAttributeAndModes(fn, osg::StateAttribute::ON);
stateSet->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
//the follow code is .ive model file data
Group {
UniqueID Group_0
DataVariance DYNAMIC
name "db"
nodeMask 0xffffffff
cullingActive TRUE
num_children 1
Group {
DataVariance DYNAMIC
name "g2"
nodeMask 0xffffffff
cullingActive TRUE
num_children 3
Group {
DataVariance DYNAMIC
name "dianqi"
nodeMask 0xffffffff
cullingActive TRUE
num_children 7
Group {
DataVariance DYNAMIC
name "ping_3"
nodeMask 0xffffffff
cullingActive TRUE
num_children 2
Geode {
DataVariance DYNAMIC
nodeMask 0xffffffff
cullingActive TRUE
num_drawables 2
Geometry {
DataVariance DYNAMIC
StateSet {
UniqueID StateSet_1
DataVariance STATIC
rendering_hint DEFAULT_BIN
renderBinMode INHERIT
GL_CULL_FACE ON
GL_LIGHTING OFF
CullFace {
UniqueID CullFace_2
DataVariance STATIC
mode BACK
}
textureUnit 0 {
GL_TEXTURE_2D ON
Texture2D {
DataVariance STATIC
file "F:/flt/VRProject/NewZZuCampus/CEEP/yazi.rgb"
wrap_s REPEAT
wrap_t REPEAT
wrap_r CLAMP
min_filter LINEAR_MIPMAP_LINEAR
mag_filter LINEAR
maxAnisotropy 1
borderColor 0 0 0 0
borderWidth 0
useHardwareMipMapGeneration TRUE
unRefImageDataAfterApply TRUE
internalFormatMode USE_IMAGE_DATA_FORMAT
resizeNonPowerOfTwo TRUE
shadowComparison FALSE
shadowCompareFunc GL_LEQUAL
shadowTextureMode GL_LUMINANCE
}
TexEnv {
UniqueID TexEnv_3
DataVariance STATIC
mode REPLACE
}
}
}
useDisplayList TRUE
useVertexBufferObjects FALSE
PrimitiveSets 1
{
DrawArrays QUADS 0 216
}
VertexArray Vec3Array 216
{
-51.957 8.26928 0
-51.8407 8.23223 0.2
-51.6568 8.25002 0.2
-51.6568 8.25002 0
-51.8476 -33.2592 0
-51.8476 -33.2592 0.2
-51.8407 8.23223 0.2
-51.957 8.26928 0
-52.4713 -38.0013 0
-52.4713 -38.0013 0.2
-51.8476 -33.2592 0.2
-51.8476 -33.2592 0
-54.3721 -41.199 0
-54.3721 -41.199 0.2
-52.4713 -38.0013 0.2
-52.4713 -38.0013 0
-57.0649 -43.3869 0
-57.0649 -43.3869 0.2
-54.3721 -41.199 0.2
-54.3721 -41.199 0
-60.0052 -44.3868 0
-60.0052 -44.3868 0.2
-57.0649 -43.3869 0.2
-57.0649 -43.3869 0
-63.787 -44.5947 0
-63.787 -44.5947 0.2
-60.0052 -44.3868 0.2
-60.0052 -44.3868 0
-67.0342 -43.4265 0
-67.0342 -43.4265 0.2
-63.787 -44.5947 0.2
-63.787 -44.5947 0
-70.2913 -40.605 0
-70.2913 -40.605 0.2
-67.0342 -43.4265 0.2
-67.0342 -43.4265 0
-71.5288 -38.3082 0
-71.5288 -38.3082 0.2
-70.2913 -40.605 0.2
-70.2913 -40.605 0
-72.0139 -35.4669 0
-72.0139 -35.4669 0.2
-71.5288 -38.3082 0.2
-71.5288 -38.3082 0
-72.103 -31.7643 0
-72.103 -31.7643 0.2
-72.0139 -35.4669 0.2
-72.0139 -35.4669 0
-72.0733 36.6843 0
-72.0733 36.6843 0.2
-72.103 -31.7643 0.2
-72.103 -31.7643 0
-64.1929 41.367 0
-64.1929 41.367 0.2
-72.0733 36.6843 0.2
-72.0733 36.6843 0
-64.1137 56.4645 0
-64.1137 56.4645 0.2
-64.1929 41.367 0.2
-64.1929 41.367 0
-64.9354 58.5336 0
-64.9354 58.5336 0.2
-64.1137 56.4645 0.2
-64.1137 56.4645 0
-66.6481 59.4741 0
-66.6481 59.4741 0.2
-64.9354 58.5336 0.2
-64.9354 58.5336 0
-115.524 59.484 0
-115.524 59.484 0.2
-66.6481 59.4741 0.2
-66.6481 59.4741 0
-116.772 59.3652 0
-116.772 59.3652 0.2
-115.524 59.484 0.2
-115.524 59.484 0
-117.693 58.0386 0
-117.693 58.0386 0.2
-116.772 59.3652 0.2
-116.772 59.3652 0
-146.997 -79.9674 0
-146.997 -79.9674 0.2
-117.693 58.0386 0.2
-117.693 58.0386 0
-146.828 -85.2639 0
-146.828 -85.2639 0.2
-146.997 -79.9674 0.2
-146.997 -79.9674 0
-145.294 -90.0456 0
-145.294 -90.0456 0.2
-146.828 -85.2639 0.2
-146.828 -85.2639 0
-142.353 -93.7482 0
-142.353 -93.7482 0.2
-145.294 -90.0456 0.2
-145.294 -90.0456 0
-137.572 -96.6192 0
-137.572 -96.6192 0.2
-142.353 -93.7482 0.2
-142.353 -93.7482 0
-132.493 -97.8171 0
-132.493 -97.8171 0.2
-137.572 -96.6192 0.2
-137.572 -96.6192 0
102.315 -97.4013 0
102.315 -97.4013 0.2
-132.493 -97.8171 0.2
-132.493 -97.8171 0
105.028 -96.1242 0
105.028 -96.1242 0.2
102.315 -97.4013 0.2
102.315 -97.4013 0
107.562 -92.8374 0
107.562 -92.8374 0.2
105.028 -96.1242 0.2
105.028 -96.1242 0
107.849 -89.6892 0
107.849 -89.6892 0.2
107.562 -92.8374 0.2
107.562 -92.8374 0
107.81 44.3865 0
107.81 44.3865 0.2
107.849 -89.6892 0.2
107.849 -89.6892 0
107.117 45.9903 0
107.117 45.9903 0.2
107.81 44.3865 0.2
107.81 44.3865 0
106.057 47.2674 0
106.057 47.2674 0.2
107.117 45.9903 0.2
107.117 45.9903 0
83.03 47.7228 0
83.03 47.7228 0.2
106.057 47.2674 0.2
106.057 47.2674 0
68.9225 33.843 0
68.9225 33.843 0.2
83.03 47.7228 0.2
83.03 47.7228 0
62.1806 40.773 0
62.1806 40.773 0.2
68.9225 33.843 0.2
68.9225 33.843 0
62.0816 55.9398 0
62.0816 55.9398 0.2
62.1806 40.773 0.2
62.1806 40.773 0
61.646 57.702 0
61.646 57.702 0.2
62.0816 55.9398 0.2
62.0816 55.9398 0
59.7155 59.5137 0
59.7155 59.5137 0.2
61.646 57.702 0.2
61.646 57.702 0
-53.6197 59.3256 0
-53.6197 59.3256 0.2
59.7155 59.5137 0.2
59.7155 59.5137 0
-55.1443 58.5732 0
-55.1443 58.5732 0.2
-53.6197 59.3256 0.2
-53.6197 59.3256 0
-56.2135 56.6625 0
-56.2135 56.6625 0.2
-55.1443 58.5732 0.2
-55.1443 58.5732 0
-56.1046 16.9734 0
-56.1046 16.9734 0.2
-56.2135 56.6625 0.2
-56.2135 56.6625 0
-55.5007 15.528 0
-55.5007 15.528 0.2
-56.1046 16.9734 0.2
-56.1046 16.9734 0
-54.4414 14.6568 0
-54.4414 14.6568 0.2
-55.5007 15.528 0.2
-55.5007 15.528 0
0.820385 14.6568 0
0.820385 14.6568 0.2
-54.4414 14.6568 0.2
-54.4414 14.6568 0
1.94898 14.4291 0
1.94898 14.4291 0.2
0.820385 14.6568 0.2
0.820385 14.6568 0
2.66179 14.1123 0
2.66179 14.1123 0.2
1.94898 14.4291 0.2
1.94898 14.4291 0
10.5169 6.16984 0.2
10.7365 6.11495 0.2
2.66179 14.1123 0.2
2.66179 14.1123 0
1.04808 9.22169 0
1.04808 9.22169 0.2
6.75638 3.71245 0.2
6.71205 3.72909 0.2
-0.0112153 9.90479 0
-0.0112153 9.90479 0.2
1.04808 9.22169 0.2
1.04808 9.22169 0
-0.714115 10.1127 0
-0.714115 10.1127 0.2
-0.0112153 9.90479 0.2
-0.0112153 9.90479 0
-2.34762 10.1325 0
-2.34762 10.1325 0.2
-0.714115 10.1127 0.2
-0.714115 10.1127 0
-51.6568 8.25002 0
-51.6568 8.25002 0.2
-2.34762 10.1325 0.2
-2.34762 10.1325 0
}
ColorBinding OVERALL
ColorArray Vec4Array 1
{
1 1 1 1
}
TexCoordArray 0 Vec2Array 216
{
0.60364 -0.0619931
0.407567 0.368093
0.0406936 0.397053
-0.000106866 5.52509e-05
2.97628 -83.7138
3.37944 -83.6994
0.407022 -0.0611529
0.00118523 -0.00018089
1.62904 -9.6733
2.02671 -9.60548
0.404695 -0.0952584
0.00702198 -0.163083
4.08738 -6.48016
4.42604 -6.26095
0.348709 0.0380833
0.0100501 -0.181129
5.61375 -4.39601
5.85601 -4.07344
0.259994 0.129324
0.0177324 -0.193249
6.03267 -1.99089
6.14789 -1.60428
0.144468 0.184855
0.0292507 -0.201757
7.67906 -0.333196
7.68583 0.0701631
0.0472013 0.198218
0.0404394 -0.205141
6.51048 -2.80981
6.66143 -2.4357
0.206218 0.1688
0.0552735 -0.205312
6.41597 -6.13802
6.69155 -5.84341
0.343631 0.0942742
0.0680519 -0.200345
2.39794 -4.9134
2.76012 -4.73573
0.442542 -0.011059
0.0803548 -0.188722
0.843997 -5.9438
1.24396 -5.89113
0.484841 -0.126833
0.0848792 -0.179505
-0.0189433 -7.63854
0.384432 -7.64422
0.489737 -0.174391
0.0863617 -0.168705
-5.24081 -138.117
-4.8377 -138.133
0.489282 -0.169255
0.0861672 -0.15369
-16.1685 -8.71764
-15.9758 -9.07206
0.268361 -0.239941
0.0756608 0.114475
-1.27719 -30.2932
-0.874155 -30.3107
0.447219 0.113899
0.0441837 0.131403
1.53878 -4.0432
1.91912 -3.90871
0.422109 0.324998
0.0417706 0.190513
3.42437 -1.82837
3.6319 -1.48242
0.252159 0.545041
0.0446322 0.199098
98.5656 -3.57789
98.5811 -3.17477
0.0663008 0.606228
0.0508291 0.203109
2.76622 0.0669786
2.78912 0.469744
0.265692 0.613217
0.242792 0.210452
2.20556 -2.39292
2.52796 -2.15043
0.570104 0.45262
0.247703 0.21013
69.9363 -275.706
70.3275 -275.607
0.642572 0.304057
0.251438 0.205271
0.4554 -11.0206
0.858807 -11.0181
0.790451 -0.329442
0.387043 -0.332022
-2.33783 -10.1086
-1.94929 -10.2171
0.775716 -0.460961
0.387172 -0.352435
-5.25969 -8.06064
-4.93443 -8.29928
0.707146 -0.610033
0.381886 -0.371391
-9.04614 -6.54108
-8.82543 -6.87877
0.591678 -0.724006
0.370974 -0.386317
-9.79187 -3.20361
-9.68435 -3.59243
0.460163 -0.787146
0.352641 -0.398323
-472.981 -17.6343
-472.966 -18.0375
0.347363 -0.806951
0.332687 -0.403803
-6.15339 -2.80254
-5.9956 -3.17382
-0.429752 -0.808432
-0.587539 -0.437154
-5.96022 -6.86278
-5.65038 -7.12113
-0.28909 -0.691279
-0.598929 -0.432931
-1.43009 -6.7436
-1.03003 -6.79553
-0.209113 -0.472081
-0.609171 -0.420145
-10.848 -270.655
-10.4449 -270.67
-0.207649 -0.423155
-0.610775 -0.407884
0.642909 -3.16847
1.01906 -3.02269
-0.25439 0.263224
-0.630545 0.117446
1.40847 -2.53128
1.72858 -2.28577
-0.308242 0.369902
-0.628348 0.12439
45.7546 -2.56048
45.7779 -2.15774
-0.601273 0.532142
-0.624631 0.129403
28.9689 -26.7557
29.2406 -26.4575
-0.262683 0.433139
-0.534434 0.134985
12.5794 -14.405
12.8791 -14.1349
-0.176663 0.352047
-0.476339 0.0819765
-1.41878 -30.4673
-1.01557 -30.48
-0.0480158 0.0978886
-0.451229 0.110647
0.289155 -3.41478
0.684191 -3.33298
-0.0582243 0.252458
-0.45326 0.170661
3.29986 -3.62306
3.58695 -3.33964
-0.164814 0.460593
-0.451897 0.177172
228.01 -8.15777
228.025 -7.75462
-0.429308 0.587471
-0.444029 0.184325
3.13108 -1.19869
3.29567 -0.830382
0.164789 0.568812
0.000191656 0.200503
2.30793 -3.57058
2.65221 -3.3603
0.35009 0.408661
0.00581693 0.198376
2.84518 -79.8153
3.24834 -79.801
0.413771 0.205123
0.0106087 0.19084
-1.09003 -2.92538
-0.712132 -3.06658
0.393865 -0.106777
0.0159706 0.034432
-2.05412 -1.80841
-1.78617 -2.10998
0.281922 -0.272471
0.0139711 0.0291024
-111.376 -4.22687
-111.361 -4.62999
0.0253651 -0.377583
0.00997504 0.0255389
-2.46418 -0.528584
-2.36937 -0.9207
-0.112069 -0.374887
-0.206882 0.0172283
-1.62373 -0.677325
-1.44594 -1.03945
-0.0335921 -0.346051
-0.21138 0.0160753
-12.9229 -14.1394
-12.6227 -14.4089
0.0860677 -0.254931
-0.214102 0.014591
9.07576 -9.75034
9.36734 -9.47155
0.0666309 0.255842
-0.22495 -0.0229493
1.87592 -1.46258
2.10733 -1.13214
0.0247671 0.326251
-0.20664 -0.00419568
1.19809 -0.474402
1.32718 -0.0922002
-0.0735813 0.380933
-0.202677 -0.00126873
3.09074 -0.1659
3.11101 0.237006
-0.179961 0.402594
-0.200234 -0.000311847
-8.06019e-05 -0.40263
-8.06019e-05 0.000784932
-99.5329 0.000784932
-99.5329 -0.40263
}
}
Geometry {
DataVariance DYNAMIC
Use StateSet_1
useDisplayList TRUE
useVertexBufferObjects FALSE
PrimitiveSets 13
{
DrawElementsUShort TRIANGLE_FAN 4
{
5 7 3 4
}
DrawElementsUShort TRIANGLES 6
{
6 0 1 7 2 6
}
DrawElementsUShort TRIANGLE_FAN 6
{
33 34 29 30 31 32
}
DrawElementsUShort TRIANGLE_FAN 20
{
35 36 55 56 57 58 59 60 62 8
9 10 11 12 13 26 27 28 29 34
}
DrawElementsUShort TRIANGLE_FAN 5
{
26 13 23 24 25
}
DrawElementsUShort TRIANGLE_FAN 7
{
44 45 49 50 51 52 43
}
DrawElementsUShort TRIANGLE_FAN 9
{
42 43 52 36 37 38 39 40 41
}
DrawElementsUShort TRIANGLE_FAN 5
{
36 52 53 54 55
}
DrawElementsUShort TRIANGLE_FAN 6
{
23 13 14 15 16 22
}
DrawElementsUShort TRIANGLE_FAN 5
{
17 18 21 22 16
}
DrawElementsUShort TRIANGLE_FAN 4
{
19 20 21 18
}
DrawElementsUShort TRIANGLE_FAN 5
{
48 49 45 46 47
}
DrawElementsUShort TRIANGLES 3
{
62 60 61
}
}
VertexArray Vec3Array 63
{
6.71205 3.72909 0.2
6.75638 3.71245 0.2
8.00897 4.5622 0.2
9.34326 5.38358 0.2
10.7365 6.11495 0.2
10.5169 6.16984 0.2
7.97746 4.54082 0.2
8.05392 4.58987 0.2
-2.34762 10.1325 0
-0.714115 10.1127 0
-0.0112153 9.90479 0
1.04808 9.22169 0
6.71205 3.72909 0.2
10.5169 6.16984 0.2
2.66179 14.1123 0
1.94898 14.4291 0
0.820385 14.6568 0
-54.4414 14.6568 0
-55.5007 15.528 0
-56.1046 16.9734 0
-56.2135 56.6625 0
-55.1443 58.5732 0
-53.6197 59.3256 0
59.7155 59.5137 0
61.646 57.702 0
62.0816 55.9398 0
62.1806 40.773 0
68.9225 33.843 0
83.03 47.7228 0
106.057 47.2674 0
107.117 45.9903 0
107.81 44.3865 0
107.849 -89.6892 0
107.562 -92.8374 0
105.028 -96.1242 0
102.315 -97.4013 0
-132.493 -97.8171 0
-137.572 -96.6192 0
-142.353 -93.7482 0
-145.294 -90.0456 0
-146.828 -85.2639 0
-146.997 -79.9674 0
-117.693 58.0386 0
-116.772 59.3652 0
-115.524 59.484 0
-66.6481 59.4741 0
-64.9354 58.5336 0
-64.1137 56.4645 0
-64.1929 41.367 0
-72.0733 36.6843 0
-72.103 -31.7643 0
-72.0139 -35.4669 0
-71.5288 -38.3082 0
-70.2913 -40.605 0
-67.0342 -43.4265 0
-63.787 -44.5947 0
-60.0052 -44.3868 0
-57.0649 -43.3869 0
-54.3721 -41.199 0
-52.4713 -38.0013 0
-51.8476 -33.2592 0
-51.957 8.26928 0
-51.6568 8.25002 0
}
ColorBinding PER_PRIMITIVE_SET
ColorArray Vec4Array 13
{
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
}
TexCoordArray 0 Vec2Array 63
{
6.79803 -5.31917
7.04093 -4.99707
4.69526 -3.22815
2.3496 -1.45922
0.00393093 0.3097
-0.238968 -0.0123933
4.60599 -3.41346
4.53818 -3.23981
-0.193884 -0.000146975
-3.48489 -0.165157
-4.88573 -0.638046
-6.96855 -2.09607
-16.271 -11.8218
-23.3071 -6.5138
-10.5958 7.63792
-9.18331 8.33107
-6.92592 8.87649
104.461 13.1093
106.529 14.9465
107.636 17.9061
104.815 97.9127
102.514 101.682
99.3833 103.082
-129.072 94.7799
-132.824 90.9803
-133.567 87.395
-132.605 56.8169
-145.664 42.3323
-175.162 69.2281
-221.542 66.5464
-223.579 63.8911
-224.853 60.6054
-214.663 -209.644
-213.843 -215.967
-208.483 -222.398
-202.918 -224.764
270.399 -207.617
280.544 -204.814
289.962 -198.661
295.605 -190.972
298.331 -181.217
298.265 -170.528
228.628 105.395
226.671 107.999
224.148 108.143
125.632 104.379
122.252 102.352
120.754 98.1187
122.07 67.6939
138.313 58.859
143.616 -79.1053
143.72 -86.5751
142.96 -92.3393
140.641 -97.0636
134.292 -103
127.837 -105.604
120.198 -105.474
114.195 -103.684
108.6 -99.4802
104.523 -93.1804
102.903 -83.6699
99.9427 0.044184
99.3389 -0.0176301
}
}
}
--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/93092df2-3076-44a7-bf19-4914c99fe961n%40googlegroups.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20201124/8b059846/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QQ??20201125102145.jpg
Type: image/jpeg
Size: 533045 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20201124/8b059846/attachment-0001.jpg>
More information about the osg-users
mailing list