Compare commits
968 Commits
OpenSceneG
...
OpenSceneG
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f2eaa4339 | ||
|
|
789d435abe | ||
|
|
6b8db67c91 | ||
|
|
2975f9c20a | ||
|
|
ebc855cf50 | ||
|
|
c9547497cc | ||
|
|
75d32b3af6 | ||
|
|
a844a278ab | ||
|
|
94dcfb4ec2 | ||
|
|
8528449dff | ||
|
|
8d7fd88d5f | ||
|
|
28dd1cf8a8 | ||
|
|
14de2266ba | ||
|
|
cc02695822 | ||
|
|
2c442c9e9a | ||
|
|
ca44b9cbce | ||
|
|
0483912e32 | ||
|
|
21b5109089 | ||
|
|
549e20fbe7 | ||
|
|
b4b7a13063 | ||
|
|
8b58890975 | ||
|
|
871521cfea | ||
|
|
f19018a03d | ||
|
|
2709a5e946 | ||
|
|
52d5d80508 | ||
|
|
86e465d5d8 | ||
|
|
50ed5ebd1c | ||
|
|
9416ef4791 | ||
|
|
95a5f3ed0f | ||
|
|
8184798d40 | ||
|
|
170cbb9018 | ||
|
|
a1bda7d39e | ||
|
|
e7b86099d1 | ||
|
|
2f1d3626de | ||
|
|
a270a7635e | ||
|
|
0175c820af | ||
|
|
5255884fec | ||
|
|
bbf00cef01 | ||
|
|
82f7031ab5 | ||
|
|
2507c3974f | ||
|
|
ca4e840155 | ||
|
|
62374833dd | ||
|
|
330de18eba | ||
|
|
8420b158c1 | ||
|
|
095b64dc41 | ||
|
|
08f741bcd9 | ||
|
|
d3c2896651 | ||
|
|
0abbef71e1 | ||
|
|
50f3b4a539 | ||
|
|
ff3a6f4eb1 | ||
|
|
2768c1b170 | ||
|
|
5e89121152 | ||
|
|
0289b05cd5 | ||
|
|
a64b412885 | ||
|
|
e876e0bad3 | ||
|
|
9eba9df292 | ||
|
|
88a8423802 | ||
|
|
d4e1a8d6a3 | ||
|
|
2e41e3f656 | ||
|
|
4493cc817d | ||
|
|
5db57cfa34 | ||
|
|
353b18b27b | ||
|
|
b2c838033d | ||
|
|
097aedf23c | ||
|
|
d82768417d | ||
|
|
db1f2c5eb1 | ||
|
|
4fd6566e00 | ||
|
|
f2c1a7597c | ||
|
|
775c1443eb | ||
|
|
9f13e2fcb9 | ||
|
|
57947ea75c | ||
|
|
90ceb88c12 | ||
|
|
dfc1a899db | ||
|
|
092dd93be8 | ||
|
|
592c580721 | ||
|
|
87add5f508 | ||
|
|
4b9aa1fd24 | ||
|
|
c1ebc3ac0c | ||
|
|
38bb71460a | ||
|
|
8e65ab7e45 | ||
|
|
5a25a93bdd | ||
|
|
9f0bbbf831 | ||
|
|
7ee05a345a | ||
|
|
55416d83b3 | ||
|
|
a459033eff | ||
|
|
bead0740f2 | ||
|
|
831a552dfa | ||
|
|
ea2cbee347 | ||
|
|
71c1fc87bb | ||
|
|
6377e37e88 | ||
|
|
b70dfd40aa | ||
|
|
36f48f2227 | ||
|
|
3de0ec1904 | ||
|
|
1793466442 | ||
|
|
ceb97fe230 | ||
|
|
00acf55571 | ||
|
|
ba9ccd91a1 | ||
|
|
84d7d9a056 | ||
|
|
addf8b1d2d | ||
|
|
1e715b6877 | ||
|
|
ba2242decb | ||
|
|
6331a54a68 | ||
|
|
0896bd17bd | ||
|
|
ca2688b046 | ||
|
|
864e5cb6f0 | ||
|
|
261db64a9e | ||
|
|
3c1a89604b | ||
|
|
70ae69648d | ||
|
|
48020eed9e | ||
|
|
4044fd5a74 | ||
|
|
b3f0479118 | ||
|
|
340a47dc66 | ||
|
|
db4b7584fb | ||
|
|
0a4bf71fbb | ||
|
|
b40c3fc0aa | ||
|
|
df3626be27 | ||
|
|
d707983905 | ||
|
|
717c4f785c | ||
|
|
59d53b40a1 | ||
|
|
9d9543ca0a | ||
|
|
da134aa8ed | ||
|
|
cb09fff797 | ||
|
|
18d6d298bf | ||
|
|
deb074120e | ||
|
|
25f0d2ccde | ||
|
|
5a93c9100b | ||
|
|
6eabca211b | ||
|
|
15fea448d8 | ||
|
|
d82c62a03b | ||
|
|
d0f4086a57 | ||
|
|
c3f28a52e4 | ||
|
|
4738a2607b | ||
|
|
fe461c77fc | ||
|
|
715dd4e930 | ||
|
|
a2b2ba5860 | ||
|
|
603c280b62 | ||
|
|
64b0e1afd0 | ||
|
|
eaa3afcd21 | ||
|
|
04bd10ab92 | ||
|
|
7d2f9f3a0d | ||
|
|
bab56f9854 | ||
|
|
9b095b2936 | ||
|
|
2ab3a1e316 | ||
|
|
47c4c7c389 | ||
|
|
083c0f97d2 | ||
|
|
df075ef9bb | ||
|
|
9c127c2bca | ||
|
|
935b4de15d | ||
|
|
002ea7ebdd | ||
|
|
c8fa3244c2 | ||
|
|
744960bbf2 | ||
|
|
297a8a221b | ||
|
|
b2fa36f02b | ||
|
|
de1eb14f8d | ||
|
|
1d1cfda1d7 | ||
|
|
55ae5b1c5f | ||
|
|
635993038a | ||
|
|
f5496ea3c5 | ||
|
|
390316e579 | ||
|
|
7d40c7258f | ||
|
|
05b72e9b4c | ||
|
|
b4bfc3a451 | ||
|
|
1a7f2fcb3e | ||
|
|
4623c251bb | ||
|
|
b0a28a5b2c | ||
|
|
bdfd18dc03 | ||
|
|
8cf9600e2c | ||
|
|
eb556797e2 | ||
|
|
a6e57026b2 | ||
|
|
d66ee2c698 | ||
|
|
49cfece9d4 | ||
|
|
4f1e6b28e8 | ||
|
|
eb693f6a92 | ||
|
|
cbea97009c | ||
|
|
a70318fbd5 | ||
|
|
c0c5fc13b1 | ||
|
|
bab251fc59 | ||
|
|
caa3a06c70 | ||
|
|
4cca5c1d1c | ||
|
|
2dc53ceabb | ||
|
|
9b67578c47 | ||
|
|
82ecbe98da | ||
|
|
375e7c2d57 | ||
|
|
05a1084e5c | ||
|
|
ae2b6669ea | ||
|
|
2244f6a371 | ||
|
|
4697b3c68b | ||
|
|
efe52842fa | ||
|
|
56dc8fee01 | ||
|
|
9921c77136 | ||
|
|
b6579c5c4a | ||
|
|
ae4d87a3be | ||
|
|
6cb9115170 | ||
|
|
3722f46aff | ||
|
|
4b223c770b | ||
|
|
fed4d91ecc | ||
|
|
f730396f0a | ||
|
|
382c3322c9 | ||
|
|
47f574429a | ||
|
|
d024444140 | ||
|
|
492459e4dc | ||
|
|
53fd801088 | ||
|
|
39b9351153 | ||
|
|
81b6c82d9a | ||
|
|
d7931e3024 | ||
|
|
aa33d213dd | ||
|
|
267802c928 | ||
|
|
f5508d35f9 | ||
|
|
ac77a1e224 | ||
|
|
02e4aef5cb | ||
|
|
18c37d14cd | ||
|
|
29f3393275 | ||
|
|
ab69c1f9d4 | ||
|
|
f3d21bd285 | ||
|
|
0eb95f01d8 | ||
|
|
2923c8014a | ||
|
|
88bbcaecd2 | ||
|
|
fb3178106a | ||
|
|
1cd73f0238 | ||
|
|
5de095cb1d | ||
|
|
2a32bcaca6 | ||
|
|
5e14865877 | ||
|
|
71874c2dc5 | ||
|
|
448c93dbe9 | ||
|
|
544ef8be5a | ||
|
|
b72faed804 | ||
|
|
1284a0dd40 | ||
|
|
7bd050e431 | ||
|
|
9b77e757f2 | ||
|
|
94fe9b5fd5 | ||
|
|
2daff56860 | ||
|
|
255432f76b | ||
|
|
9f66a10aa2 | ||
|
|
455ebbc5f1 | ||
|
|
acb4ba8554 | ||
|
|
086ffd1672 | ||
|
|
482581feb0 | ||
|
|
6926cec135 | ||
|
|
f54f4e40ed | ||
|
|
6cb26321a9 | ||
|
|
79ec0e863d | ||
|
|
3b6c2b636a | ||
|
|
e3ed763c15 | ||
|
|
625821a91a | ||
|
|
9552567cd4 | ||
|
|
bcbaaefa02 | ||
|
|
07499f6658 | ||
|
|
c238a7cca2 | ||
|
|
0b2c3a9ddb | ||
|
|
1a683e2f83 | ||
|
|
93eb471d99 | ||
|
|
f1d5ba4278 | ||
|
|
191cf8f5aa | ||
|
|
1b599fc5ae | ||
|
|
127f3f6396 | ||
|
|
7b9cace094 | ||
|
|
01e8287b7d | ||
|
|
9249a59db2 | ||
|
|
e9388d5ad8 | ||
|
|
4e34cadee2 | ||
|
|
9402efe38e | ||
|
|
5dd07e4d1c | ||
|
|
9eb5465ff5 | ||
|
|
9c1c34d765 | ||
|
|
e545627571 | ||
|
|
046c3fca7a | ||
|
|
8810d27f7c | ||
|
|
9bb4ed08e1 | ||
|
|
f30160a5a4 | ||
|
|
668d351765 | ||
|
|
63088ab63e | ||
|
|
a2615388db | ||
|
|
adea6c9329 | ||
|
|
65f23ba9af | ||
|
|
5ce1ba67fb | ||
|
|
34a6b38983 | ||
|
|
bc288d23dc | ||
|
|
efbf05cd59 | ||
|
|
835a80ae90 | ||
|
|
f79d89e0ce | ||
|
|
7ff4be954b | ||
|
|
830d21471b | ||
|
|
18d14065a5 | ||
|
|
3cccecb79d | ||
|
|
6a4741cf54 | ||
|
|
b1c342c027 | ||
|
|
a5cea75d47 | ||
|
|
dd8d7c2839 | ||
|
|
ed35a0a07a | ||
|
|
6c723df2d6 | ||
|
|
bc3cff2406 | ||
|
|
7aad7dfd78 | ||
|
|
1dba64ac6c | ||
|
|
890ecb6abb | ||
|
|
ab55668ff3 | ||
|
|
93e6a59c9a | ||
|
|
5d7049dd9c | ||
|
|
68fdae5761 | ||
|
|
3efcc51d76 | ||
|
|
63cd217c77 | ||
|
|
21676c4db0 | ||
|
|
bce2e7d71d | ||
|
|
f549a9cb38 | ||
|
|
b7ccf3f377 | ||
|
|
2700c9d5e5 | ||
|
|
3d4aaacd14 | ||
|
|
0e9d969c84 | ||
|
|
00c7e5e552 | ||
|
|
c89d1968fd | ||
|
|
29eb65c77d | ||
|
|
19bfa92c91 | ||
|
|
0b3da415ef | ||
|
|
09f42e1411 | ||
|
|
8ed0780967 | ||
|
|
f9356603cf | ||
|
|
5297502a38 | ||
|
|
aa6ace649b | ||
|
|
796bced555 | ||
|
|
f64feb783f | ||
|
|
39a3227397 | ||
|
|
df6e752077 | ||
|
|
0781685b6c | ||
|
|
63575f53e1 | ||
|
|
6ec15736cd | ||
|
|
9bc3b3316a | ||
|
|
5339864c17 | ||
|
|
f5bd6b0487 | ||
|
|
1937cc6f14 | ||
|
|
366fcbf59b | ||
|
|
84c857d24d | ||
|
|
45585b78fb | ||
|
|
0e7ae7319b | ||
|
|
26a8f63212 | ||
|
|
f6450a1123 | ||
|
|
a9fff529c7 | ||
|
|
390b546389 | ||
|
|
5aa1234fa4 | ||
|
|
bada884342 | ||
|
|
d3e9b61f2b | ||
|
|
cd34312ea3 | ||
|
|
0b1605ed08 | ||
|
|
233a0a1782 | ||
|
|
6f7570d4ac | ||
|
|
9a7c9b2a50 | ||
|
|
e5ce3489a2 | ||
|
|
44002e77d2 | ||
|
|
128eeb9b30 | ||
|
|
9b08c37373 | ||
|
|
83f9d0f3e6 | ||
|
|
5fb8cd6a9c | ||
|
|
a0980734ac | ||
|
|
e7e517f2d0 | ||
|
|
7129fce278 | ||
|
|
dd189f22e5 | ||
|
|
1fcadcf514 | ||
|
|
b8b8365c06 | ||
|
|
81008c24df | ||
|
|
93334e7df0 | ||
|
|
4f8847dd50 | ||
|
|
e569671d13 | ||
|
|
c367e0771a | ||
|
|
2391b42000 | ||
|
|
f9736c4cf0 | ||
|
|
7cc88c6e06 | ||
|
|
da2efd5feb | ||
|
|
04ae78ac9b | ||
|
|
e76e3a7b1b | ||
|
|
521625b343 | ||
|
|
6d0e1bd50b | ||
|
|
0aef0c2f20 | ||
|
|
16e54a00fb | ||
|
|
9f0906984b | ||
|
|
634f597feb | ||
|
|
c15d07caa1 | ||
|
|
f7bee82e99 | ||
|
|
d200ef90a7 | ||
|
|
4a0ce866c0 | ||
|
|
32c0bc3b39 | ||
|
|
c4b83d2b0c | ||
|
|
a00c5e3a20 | ||
|
|
68c1360c96 | ||
|
|
d86849fc35 | ||
|
|
84d8eeb7cb | ||
|
|
e57e6c5409 | ||
|
|
8d999a07cf | ||
|
|
22868bce4f | ||
|
|
e64d5e5eca | ||
|
|
8df5440a26 | ||
|
|
ccdca3d9bf | ||
|
|
aa3634979a | ||
|
|
363633a81d | ||
|
|
6fa6de8593 | ||
|
|
9ebf35cf05 | ||
|
|
d4c9ecf370 | ||
|
|
66a11037ae | ||
|
|
4cb5d59d35 | ||
|
|
eed71f647d | ||
|
|
ce0f928f6f | ||
|
|
5a88734598 | ||
|
|
ea00708026 | ||
|
|
761229f8f4 | ||
|
|
32cffe2094 | ||
|
|
b4af638af9 | ||
|
|
9363aa5a89 | ||
|
|
b6d19d1052 | ||
|
|
cbf6745da5 | ||
|
|
24c612a2bd | ||
|
|
35d17d4654 | ||
|
|
7d947d79ff | ||
|
|
e4a42fa65c | ||
|
|
e6141b984d | ||
|
|
9a2f7c7d8e | ||
|
|
3e32d9c8af | ||
|
|
d831f1b538 | ||
|
|
6eb3b2f091 | ||
|
|
236e75b2be | ||
|
|
7ffde8abce | ||
|
|
8b231ba8e3 | ||
|
|
694e603d15 | ||
|
|
42529ca415 | ||
|
|
a31d603f9a | ||
|
|
1f50f23f86 | ||
|
|
9ef448c7b1 | ||
|
|
56bc0b14bc | ||
|
|
f0b3a47735 | ||
|
|
4b4327aaae | ||
|
|
3a67eefd9f | ||
|
|
ea9e13a0c6 | ||
|
|
7e67ac7a34 | ||
|
|
f3e9967f47 | ||
|
|
8b30807ef1 | ||
|
|
e2ee774705 | ||
|
|
c005e6997c | ||
|
|
10c43a3052 | ||
|
|
c48335baf7 | ||
|
|
e70ece8f10 | ||
|
|
057f8a8b3b | ||
|
|
0c02ef358f | ||
|
|
933baf5db4 | ||
|
|
92975a01fd | ||
|
|
e72af02c2b | ||
|
|
ad1cec1b2e | ||
|
|
bf4daf11ff | ||
|
|
79ae9cd8a3 | ||
|
|
e9a7b2a6e5 | ||
|
|
e8b86dc4ec | ||
|
|
ff476e9c15 | ||
|
|
fd4126dc59 | ||
|
|
36f6ef7242 | ||
|
|
1b871a822d | ||
|
|
b6c6885a97 | ||
|
|
b51bbaa406 | ||
|
|
014f13f774 | ||
|
|
17b372ec38 | ||
|
|
679956e79a | ||
|
|
4fa32ee0b8 | ||
|
|
f09b9576c6 | ||
|
|
7cb6e103f4 | ||
|
|
d7ce523529 | ||
|
|
18d66619b0 | ||
|
|
e45bdb60d7 | ||
|
|
2e1f90f7e8 | ||
|
|
9271b53c56 | ||
|
|
98e9f187b3 | ||
|
|
a6f3e0af78 | ||
|
|
fa2fb07609 | ||
|
|
d879cd7715 | ||
|
|
ce623c697e | ||
|
|
cebb9f6103 | ||
|
|
f9fd4342ba | ||
|
|
1591fe09f3 | ||
|
|
f9ad1e5673 | ||
|
|
1872137d88 | ||
|
|
ad926d7265 | ||
|
|
9fab99ddd9 | ||
|
|
16de7e9f33 | ||
|
|
94e8c42569 | ||
|
|
03a9786b11 | ||
|
|
7244e97850 | ||
|
|
4235169d41 | ||
|
|
232bda3828 | ||
|
|
b742a9e71a | ||
|
|
740f660ef1 | ||
|
|
47c5ddbce5 | ||
|
|
77bd6cbfe9 | ||
|
|
2e79a0e2d4 | ||
|
|
23786604c6 | ||
|
|
1796d55bea | ||
|
|
0dbafcc316 | ||
|
|
4896edda56 | ||
|
|
03047f3e7f | ||
|
|
86a37616f7 | ||
|
|
0e8bcc9027 | ||
|
|
ea631c777d | ||
|
|
b3f8679b69 | ||
|
|
f804d7dd81 | ||
|
|
01c7d87b1a | ||
|
|
d511288718 | ||
|
|
b32cf216a7 | ||
|
|
67abc66d8a | ||
|
|
5d5cf26138 | ||
|
|
cfe36876d4 | ||
|
|
7fe5db073b | ||
|
|
7233b2117c | ||
|
|
f288f9e996 | ||
|
|
55d03d5b34 | ||
|
|
53405c118a | ||
|
|
0b778533c8 | ||
|
|
46104008c7 | ||
|
|
3b8802c5aa | ||
|
|
5a99e4672e | ||
|
|
39dcea9ebb | ||
|
|
63444f648f | ||
|
|
f5a3c40934 | ||
|
|
3c9a0cdfd7 | ||
|
|
e8c4a6785c | ||
|
|
a5478cf910 | ||
|
|
fd2ee19b62 | ||
|
|
5c9a302beb | ||
|
|
e93a838222 | ||
|
|
bc533022ae | ||
|
|
0172bacdf4 | ||
|
|
568aeef975 | ||
|
|
30c35cb407 | ||
|
|
0ce9407c69 | ||
|
|
f13dd3d75d | ||
|
|
8961d45ebf | ||
|
|
794e0e71f4 | ||
|
|
e489767f71 | ||
|
|
583401970a | ||
|
|
58b66be7b7 | ||
|
|
284f410436 | ||
|
|
52861ecbb0 | ||
|
|
fb83c2b061 | ||
|
|
35816e6b25 | ||
|
|
42cb311f41 | ||
|
|
2e611be9c9 | ||
|
|
0a746faa2d | ||
|
|
2f86ac1896 | ||
|
|
283c2d3ed0 | ||
|
|
86db687bce | ||
|
|
269d360484 | ||
|
|
ec3ad89041 | ||
|
|
b4d397cfd7 | ||
|
|
4b220d4fd7 | ||
|
|
65ab874143 | ||
|
|
f784884fd1 | ||
|
|
a821a1cbbc | ||
|
|
fc4aeac75b | ||
|
|
59133b43d3 | ||
|
|
1dc215a1da | ||
|
|
4ab8cdb746 | ||
|
|
c1a3ab2a5b | ||
|
|
2faeaf553b | ||
|
|
c39ee015d6 | ||
|
|
5d3cb4f754 | ||
|
|
4d86f8dc79 | ||
|
|
9282a367e9 | ||
|
|
2200ebfbe1 | ||
|
|
1dbb0a7a82 | ||
|
|
c21f1f488f | ||
|
|
a28907a67f | ||
|
|
759a889468 | ||
|
|
aea3d6855b | ||
|
|
476dbf1c33 | ||
|
|
d32160abde | ||
|
|
b86c87d1a8 | ||
|
|
45c6ba0b73 | ||
|
|
18b5e2a9b8 | ||
|
|
d37eff5c2b | ||
|
|
b0c510ab08 | ||
|
|
de05dd22a8 | ||
|
|
a5cd9c0630 | ||
|
|
c3bfa67576 | ||
|
|
9f93b005cc | ||
|
|
9045813aab | ||
|
|
c6a4fde917 | ||
|
|
97e4ad473b | ||
|
|
01beb82041 | ||
|
|
25989e73f5 | ||
|
|
b882467217 | ||
|
|
96effb3690 | ||
|
|
95cac0b549 | ||
|
|
5e315d5fab | ||
|
|
28a9a235b6 | ||
|
|
bac5e760da | ||
|
|
6a40df7b7d | ||
|
|
c0bd5cda99 | ||
|
|
ba2432ca45 | ||
|
|
68412a1784 | ||
|
|
aab27e106c | ||
|
|
59d6931b59 | ||
|
|
055e1258ea | ||
|
|
695e08ec8c | ||
|
|
eb9f545d67 | ||
|
|
1feea279a5 | ||
|
|
1227f3f620 | ||
|
|
5fc6f0a796 | ||
|
|
c2ae14f94d | ||
|
|
14a563dc9f | ||
|
|
1e35f8975d | ||
|
|
f551c3dcec | ||
|
|
c3a0a8ddc3 | ||
|
|
cee53f6adc | ||
|
|
2f2908b7eb | ||
|
|
f51bb8bc70 | ||
|
|
41863ecbb6 | ||
|
|
9c04527cbe | ||
|
|
e5b5494fe1 | ||
|
|
7977b31577 | ||
|
|
df82754203 | ||
|
|
d546f95412 | ||
|
|
5e105d2fc4 | ||
|
|
fc6fdeaa2c | ||
|
|
fef2628d00 | ||
|
|
71893c46e5 | ||
|
|
17ba6f0a24 | ||
|
|
ecbe4b1058 | ||
|
|
7c278ce5d6 | ||
|
|
fd97a9a800 | ||
|
|
8d3790d594 | ||
|
|
f59f4d2929 | ||
|
|
51f3a02f73 | ||
|
|
ac2be18fbc | ||
|
|
2c7b82b401 | ||
|
|
2907284d00 | ||
|
|
1744617988 | ||
|
|
9c5774defb | ||
|
|
7bcf5e3b36 | ||
|
|
33e7857af9 | ||
|
|
84ca21655e | ||
|
|
11c9ec4f7d | ||
|
|
1a080dfa6a | ||
|
|
e8ac276451 | ||
|
|
c3fb8dc714 | ||
|
|
3ca30736b4 | ||
|
|
f86efdcd31 | ||
|
|
b4155dd817 | ||
|
|
6d351ba237 | ||
|
|
949c635d5d | ||
|
|
caceb94db8 | ||
|
|
da44e4f4b6 | ||
|
|
0b88ad24b2 | ||
|
|
f56ab3a04e | ||
|
|
aea4d1a261 | ||
|
|
67ce0d5244 | ||
|
|
ec89769e6b | ||
|
|
b213f6030e | ||
|
|
5ac0181cdc | ||
|
|
acb48db89e | ||
|
|
041dd7a871 | ||
|
|
2a97715239 | ||
|
|
48b9b25805 | ||
|
|
981182fb01 | ||
|
|
5a396c91e6 | ||
|
|
2f5e19447c | ||
|
|
d393604846 | ||
|
|
4457d2a145 | ||
|
|
d507a54456 | ||
|
|
bd81dd5ff8 | ||
|
|
06e88f3b91 | ||
|
|
9b6e10ddf0 | ||
|
|
0b73ee7933 | ||
|
|
2dbd24b52d | ||
|
|
5743d30dc1 | ||
|
|
9244ea7603 | ||
|
|
0a78919807 | ||
|
|
359fc46757 | ||
|
|
4935efc1a9 | ||
|
|
5f4c155d6b | ||
|
|
89cf88f2a9 | ||
|
|
ba4dde81bb | ||
|
|
c533c33457 | ||
|
|
e867f6bcd7 | ||
|
|
f537ece404 | ||
|
|
ce4890fa7a | ||
|
|
1432d4d54b | ||
|
|
a9baf19f32 | ||
|
|
4d69577228 | ||
|
|
2a36e51eed | ||
|
|
06f7fd4f48 | ||
|
|
52270c9656 | ||
|
|
0775483b7c | ||
|
|
3ae53557b1 | ||
|
|
1454e9c760 | ||
|
|
89417ee47f | ||
|
|
7d5d742070 | ||
|
|
251827c994 | ||
|
|
5d50913722 | ||
|
|
af01a9e984 | ||
|
|
ec08c4dfea | ||
|
|
2298cc520c | ||
|
|
55c4f9b401 | ||
|
|
d21280785c | ||
|
|
38b17bc5fa | ||
|
|
6ebe48d6bb | ||
|
|
db49c23944 | ||
|
|
3b4333ec9a | ||
|
|
ae27f1e210 | ||
|
|
0e3de701d9 | ||
|
|
85bce8b8ad | ||
|
|
e5a16de7d4 | ||
|
|
1ed3833556 | ||
|
|
fe61dcac69 | ||
|
|
43f9a76169 | ||
|
|
95f93e3bf5 | ||
|
|
c3b7f6debe | ||
|
|
487ee0f8e7 | ||
|
|
7664d90504 | ||
|
|
0381914b42 | ||
|
|
ad0872a783 | ||
|
|
a0df35b580 | ||
|
|
eb2e4d313a | ||
|
|
167b6e69e4 | ||
|
|
8ecd0dea87 | ||
|
|
45998e9ce1 | ||
|
|
5feb203d79 | ||
|
|
b20abdb819 | ||
|
|
737da5f23a | ||
|
|
7fc23467f1 | ||
|
|
3c414c7962 | ||
|
|
68f776e2cc | ||
|
|
9da901e11b | ||
|
|
d350ea5395 | ||
|
|
b0b98d49b8 | ||
|
|
884f480202 | ||
|
|
6d66e1abaa | ||
|
|
6aa6e9a38c | ||
|
|
76b1c8e20e | ||
|
|
fa5100cc2c | ||
|
|
329f98c83b | ||
|
|
b828f5c083 | ||
|
|
d9fd29d996 | ||
|
|
3aab31f198 | ||
|
|
a53308f7e8 | ||
|
|
c7698c1334 | ||
|
|
50c7a31d62 | ||
|
|
f3ce66aa8b | ||
|
|
dc55068db1 | ||
|
|
fa2e8b22c5 | ||
|
|
4e834dfc73 | ||
|
|
f6ace4a7d0 | ||
|
|
c9d19d7bff | ||
|
|
0af31eff5d | ||
|
|
c86e2361d2 | ||
|
|
c225f2758c | ||
|
|
74fb1f42d9 | ||
|
|
22e309e8fb | ||
|
|
22ef706e32 | ||
|
|
16c2bb5a2f | ||
|
|
2b2c1b5671 | ||
|
|
92ed903a7f | ||
|
|
116b9a978c | ||
|
|
c7542d5cd8 | ||
|
|
ce021df661 | ||
|
|
862c1c4af3 | ||
|
|
d13bfb522b | ||
|
|
85418bf7ba | ||
|
|
a548daa4be | ||
|
|
693d79c638 | ||
|
|
e8bae33143 | ||
|
|
0329ca5cea | ||
|
|
747654fb6d | ||
|
|
3c461dd706 | ||
|
|
04f9341161 | ||
|
|
1bcd36f5ed | ||
|
|
76396d0c12 | ||
|
|
215512647c | ||
|
|
3cad9d0962 | ||
|
|
14a4aa9a19 | ||
|
|
ca582c708d | ||
|
|
d95801f6a8 | ||
|
|
bbf081695b | ||
|
|
3e7900c39e | ||
|
|
20ffed1fa1 | ||
|
|
24ff8796d5 | ||
|
|
98d50250ff | ||
|
|
3a64805d20 | ||
|
|
7bcfb3c130 | ||
|
|
c403c052db | ||
|
|
881078289d | ||
|
|
5d26d16fd3 | ||
|
|
9995cb70a9 | ||
|
|
b9d7989b44 | ||
|
|
2dc271d85f | ||
|
|
4b655d9c46 | ||
|
|
9b380c8d49 | ||
|
|
1538ecf113 | ||
|
|
e04ca06fc8 | ||
|
|
9e903861a2 | ||
|
|
d7cba048f5 | ||
|
|
d3cebab9a3 | ||
|
|
088d00c651 | ||
|
|
6607b373d5 | ||
|
|
affe0b4a6d | ||
|
|
62888dba38 | ||
|
|
aa14f603d1 | ||
|
|
3fd407a60e | ||
|
|
2c4eb8d181 | ||
|
|
61b2659fab | ||
|
|
33479c7768 | ||
|
|
bdb0dfe27d | ||
|
|
0fc0c642bf | ||
|
|
4992f798d7 | ||
|
|
d9dbff18a2 | ||
|
|
e8e25e82a9 | ||
|
|
78ad56f76c | ||
|
|
951a437c0c | ||
|
|
bb48cef38c | ||
|
|
db329cf943 | ||
|
|
b32d8e0151 | ||
|
|
12e8d09ed1 | ||
|
|
0b7dbc68c9 | ||
|
|
845d33b353 | ||
|
|
2c1b6789db | ||
|
|
e557d4f28b | ||
|
|
8a230d42ed | ||
|
|
6e01f05853 | ||
|
|
f9dffdba2c | ||
|
|
3279e9a5f5 | ||
|
|
420d8f6acf | ||
|
|
8345c85c3c | ||
|
|
0f30c08701 | ||
|
|
c1af863f78 | ||
|
|
6c46956918 | ||
|
|
41924dfc14 | ||
|
|
64fa6aec43 | ||
|
|
098bc6df5e | ||
|
|
408c2a2267 | ||
|
|
c35fdf7333 | ||
|
|
698a284da8 | ||
|
|
abb7228d56 | ||
|
|
6d1ba5b06d | ||
|
|
43483408f3 | ||
|
|
757d00c3c8 | ||
|
|
cd6e174a5c | ||
|
|
cc37579392 | ||
|
|
140a04aebc | ||
|
|
6e6dafcd3e | ||
|
|
ca51a1113b | ||
|
|
22dd9df78b | ||
|
|
4b6593b211 | ||
|
|
796ccd14c8 | ||
|
|
19b8b1f474 | ||
|
|
edd83a03fe | ||
|
|
9be4a1a1c8 | ||
|
|
5162fcc108 | ||
|
|
c8de3b70ca | ||
|
|
94777c4ef5 | ||
|
|
83524f958e | ||
|
|
b2fd8f4059 | ||
|
|
3a79bc343d | ||
|
|
772c7d75c5 | ||
|
|
f26ef2d9e0 | ||
|
|
f95f43dbc6 | ||
|
|
ecbca83c01 | ||
|
|
f83722d62b | ||
|
|
15ad6eda63 | ||
|
|
454ccad3b9 | ||
|
|
52c2bc3ff5 | ||
|
|
f476406ae1 | ||
|
|
ec3b2ba2d3 | ||
|
|
1fd3c84287 | ||
|
|
b21d206d3a | ||
|
|
47db350da1 | ||
|
|
2d71a390d3 | ||
|
|
771075084b | ||
|
|
ef91a87e23 | ||
|
|
0f14f53698 | ||
|
|
966981f100 | ||
|
|
1ad9979cea | ||
|
|
0d3169f645 | ||
|
|
26e2106636 | ||
|
|
622cfb524c | ||
|
|
3db0557ed5 | ||
|
|
3a70830e89 | ||
|
|
7c4fb17298 | ||
|
|
36fea2bd60 | ||
|
|
c71a0c72e4 | ||
|
|
1d54065646 | ||
|
|
04ffdf1801 | ||
|
|
1625f61812 | ||
|
|
b15317481c | ||
|
|
6b7175baac | ||
|
|
675a61ea87 | ||
|
|
c14516d5f6 | ||
|
|
4aa16bc8e3 | ||
|
|
e4a73d121e | ||
|
|
4238629ebf | ||
|
|
31cb490c75 | ||
|
|
cbb6f1c92c | ||
|
|
ceb8d62636 | ||
|
|
164cd6e9b9 | ||
|
|
ed27e55b60 | ||
|
|
3abbba693c | ||
|
|
dcaf9b02ce | ||
|
|
27cc718251 | ||
|
|
302c5a7e92 | ||
|
|
35ccc1efa5 | ||
|
|
8d77126e2e | ||
|
|
6128300bc5 | ||
|
|
5efea79689 | ||
|
|
9f4fee5fd3 | ||
|
|
eb72bd6556 | ||
|
|
f07a1a91c8 | ||
|
|
1838707627 | ||
|
|
695fcda726 | ||
|
|
09b5e95d65 | ||
|
|
b59ab789a3 | ||
|
|
9c876964a5 | ||
|
|
f0bdbea926 | ||
|
|
147455866f | ||
|
|
0da1daca15 | ||
|
|
fb29f83255 | ||
|
|
5bfa112183 | ||
|
|
a53dd7d744 | ||
|
|
b6fa087fe2 | ||
|
|
9133a4c36a | ||
|
|
ae2b8c4130 | ||
|
|
2de3f08fd3 | ||
|
|
e1bae2701a | ||
|
|
0f9f891f72 | ||
|
|
26375c38ef | ||
|
|
d3d536f0a5 | ||
|
|
7b97a70c22 | ||
|
|
3979eb7755 | ||
|
|
eed9e9f7e1 | ||
|
|
913e159114 | ||
|
|
8620c4af7e | ||
|
|
a9658dbd4d | ||
|
|
d6a3ac647b | ||
|
|
f68c2246fc | ||
|
|
5fd1ece440 | ||
|
|
0a48e99a25 | ||
|
|
41a6d949c2 | ||
|
|
e79d51713f | ||
|
|
8e2857905f | ||
|
|
fa40366ae4 | ||
|
|
c617ea0163 | ||
|
|
ee7668fe6c | ||
|
|
00cf10be35 | ||
|
|
97e4451b16 | ||
|
|
fe0232ffba | ||
|
|
58291f986c | ||
|
|
7455f6265c | ||
|
|
8570c37ed5 | ||
|
|
5ee864ff25 | ||
|
|
fa26facba9 | ||
|
|
c34fe4255b | ||
|
|
30becd5ed3 | ||
|
|
6783dcff17 | ||
|
|
99b9eff9f4 | ||
|
|
aab458da93 | ||
|
|
1b7b0b8cd2 | ||
|
|
111a4a9274 | ||
|
|
e3c89d7f60 | ||
|
|
f38a855a73 | ||
|
|
dc123461c7 | ||
|
|
90a88488d3 | ||
|
|
7f9e1c5a6f | ||
|
|
20f334b6f8 | ||
|
|
9781fe55ea | ||
|
|
0392efafea | ||
|
|
0ff97d1350 | ||
|
|
47146017ae | ||
|
|
8c37336fdc | ||
|
|
058eef0555 | ||
|
|
389c2e6407 |
175
AUTHORS.txt
175
AUTHORS.txt
@@ -1,6 +1,6 @@
|
||||
OpenSceneGraph Library 3.0.0
|
||||
OpenSceneGraph Library 3.2.0
|
||||
|
||||
464 Contributors:
|
||||
511 Contributors:
|
||||
|
||||
Firstname Surname
|
||||
-----------------
|
||||
@@ -8,118 +8,127 @@ Robert Osfield
|
||||
Don Burns
|
||||
Stephan Huber
|
||||
Paul Martz
|
||||
Marco Jez
|
||||
Mathias Fr<46>hlich
|
||||
Mike Weiblen
|
||||
Jean-S<>bastien Guay
|
||||
Marco Jez
|
||||
Farshid Lashkari
|
||||
Eric Wing
|
||||
Ulrich Hertlein
|
||||
Cedric Pinson
|
||||
Wang Rui
|
||||
Brede Johansen
|
||||
Jean-S<>bastien Guay
|
||||
Mike Weiblen
|
||||
Ulrich Hertlein
|
||||
Eric Wing
|
||||
Sukender
|
||||
Michael Platings
|
||||
Cedric Pinson
|
||||
Brede Johansen
|
||||
Bob Kuehne
|
||||
Michael Platings
|
||||
Geoff Michel
|
||||
Eric Sokolowsky
|
||||
Wojciech Lewandowski
|
||||
Eric Sokolowsky
|
||||
David Callu
|
||||
Trajce Nikolov
|
||||
Colin McDonald
|
||||
Tim Moore
|
||||
Martin Lavery
|
||||
Colin McDonald
|
||||
Laurens Voerman
|
||||
Tree
|
||||
Luigi Calori
|
||||
Mike Wittman
|
||||
Chris Hanson
|
||||
Roland Smeenk
|
||||
Roger James
|
||||
Jeremy Moles
|
||||
Chris Hanson
|
||||
Mattias Helsing
|
||||
Jason Beverage
|
||||
Jan Peciva
|
||||
J.P. Delport
|
||||
Mattias Helsing
|
||||
Magnus Kessler
|
||||
David Fries
|
||||
Andy Skinner
|
||||
Paul Melis
|
||||
J.P. Delport
|
||||
David Fries
|
||||
Alberto Luaces
|
||||
Luc Frauciel
|
||||
Tom Jolley
|
||||
Pavel Moloshtan
|
||||
Brad Christiansen
|
||||
Olaf Flebbe
|
||||
Mathieu Marache
|
||||
Jason Daly
|
||||
Art Tevs
|
||||
Philip Lowman
|
||||
Per Fahlberg
|
||||
Norman Vine
|
||||
Art Tevs
|
||||
Alberto Luaces
|
||||
Serge Lages
|
||||
Magnus Kessler
|
||||
Laurens Voerman
|
||||
Alberto Farre
|
||||
Terry Welsh
|
||||
Serge Lages
|
||||
Lionel Lagarde
|
||||
Chris Denham
|
||||
Alberto Farre
|
||||
Sherman Wilcox
|
||||
Robert Milharcic
|
||||
Olaf Flebbe
|
||||
Mathieu Marache
|
||||
Robert Michael
|
||||
Mourad Boufarguine
|
||||
Andr<EFBFBD> Garneau
|
||||
Adrian Egli
|
||||
Ruben Lopez
|
||||
Randall Hopper
|
||||
Mourad Boufarguine
|
||||
Brad Christiansen
|
||||
Jan Ciger
|
||||
Torben Dannhauer
|
||||
Glenn Waldron
|
||||
Gideon May
|
||||
Don Tidrow
|
||||
Chris Denham
|
||||
Aurelien Albert
|
||||
Stephane Lamoliatte
|
||||
Romano Jos<6F> Magacho da Silva
|
||||
Michael Gronager
|
||||
Martin Naylor
|
||||
Joakim Simonsson
|
||||
David Spilling
|
||||
Daniel Sj<53>lie
|
||||
Bryan Thrall
|
||||
Glenn Waldron
|
||||
Fabien Lavignotte
|
||||
Torben Dannhauer
|
||||
Andreas Ekstrand
|
||||
Mike Connell
|
||||
Melchior Franz
|
||||
Lionel Lagarde
|
||||
Jan Ciger
|
||||
Johannes Baeuerle
|
||||
Riccardo Corsi
|
||||
Rafa Gaitan
|
||||
Neil Hughes
|
||||
Mike Connell
|
||||
Martin Beckett
|
||||
Joran Jessurun
|
||||
Gino van den Bergen
|
||||
Frederic Marmond
|
||||
David Guthrie
|
||||
Csaba Halasz
|
||||
Cory Riddell
|
||||
Chuck Seberino
|
||||
Boris Bralo
|
||||
Andreas Ekstrand
|
||||
Yefei He
|
||||
Thomas Hogarth
|
||||
Sondra Iverson
|
||||
Simon Julier
|
||||
Rune Schmidt Jensen
|
||||
Rainer Oder
|
||||
Martin Naylor
|
||||
Nico Kruithof
|
||||
Martin Aumueller
|
||||
Mario Valle
|
||||
Luc Frauciel
|
||||
Lukasz Izdebski
|
||||
Jorge Izquierdo Ciges
|
||||
Gordon Tomlinson
|
||||
Cory Riddell
|
||||
Frederic Bouvier
|
||||
Carlo Camporesi
|
||||
Ben Discoe
|
||||
Thibault Genessay
|
||||
Sasa Bistrovic
|
||||
Ravi Mathur
|
||||
Ralf Habacker
|
||||
Pjotr Svetachov
|
||||
Neil Groves
|
||||
Markus Trenkwalder
|
||||
Loic Dachary
|
||||
Joseph Steel
|
||||
Jorge Izquierdo
|
||||
John Shue
|
||||
Chuck Seberino
|
||||
Brad Colbert
|
||||
Vivek Rajan
|
||||
Uwe Woessner
|
||||
Tony Horrobin
|
||||
Thom DeCarlo
|
||||
Tatsuhiro Nishioka
|
||||
Tanguy Fautr<74>
|
||||
@@ -133,30 +142,32 @@ Mihai Radu
|
||||
Michael Hartman
|
||||
Martins Innus
|
||||
Maciej Krol
|
||||
Johannes Baeuerle
|
||||
Lilin Xiong
|
||||
Leandro Motta Barros
|
||||
Jordi Torres
|
||||
Johan Nouvel
|
||||
Hartwig Wiesmann
|
||||
Frederic Bouvier
|
||||
Donn Mielcarek
|
||||
Corbin Holtz
|
||||
Blasius Czink
|
||||
Alexander Sinditskiy
|
||||
Alexander Irion
|
||||
Toshiyuki Takahei
|
||||
Tony Horrobin
|
||||
Sebastien Grignard
|
||||
Ryan Kawicki
|
||||
Rudolf Wiedemann
|
||||
Romano Magacho
|
||||
Riccardo Corsi
|
||||
Nico Kruithof
|
||||
Mikhail Izmestev
|
||||
Maria Ten
|
||||
Liang Aibin
|
||||
Leandro Motta Barros
|
||||
Katharina Plugge
|
||||
John Vidar Larring
|
||||
John Kelso
|
||||
John Ivar
|
||||
Gustav Haapalahti
|
||||
Erik den Dekker
|
||||
Emmanuel Roche
|
||||
Domenico Mangieri
|
||||
Daniel Larimer
|
||||
Colin Dunlop
|
||||
Bruce Clay
|
||||
@@ -168,35 +179,39 @@ Alan Dickinson
|
||||
Vladimir Shabanov
|
||||
Tugkan Calapoglu
|
||||
Tim Daoust
|
||||
Thomas Hogarth
|
||||
Sohey Yamamoto
|
||||
Sergey Leontyev
|
||||
Sebastian Messerschmidt
|
||||
Santosh Gaikwad
|
||||
Rudolf Wiedemann
|
||||
Ryan Pavlik
|
||||
Robert Milharcic
|
||||
Rene Molenaar
|
||||
Piotr Domagalski
|
||||
Phil Atkin
|
||||
Nathan Monteleone
|
||||
Miguel Escriva
|
||||
Mattias Linde
|
||||
Mark Sciabica
|
||||
Lilin Xiong
|
||||
Marcin Prus
|
||||
Lee Butler
|
||||
Konstantin Sinitsyn
|
||||
Ken Sewell
|
||||
Julian Ortiz
|
||||
John Kaniarz
|
||||
Jim Vaughan
|
||||
Jeremy Bell
|
||||
Jaromir Vitek
|
||||
James French
|
||||
Guillaume Millet
|
||||
Gary Quinn
|
||||
Garrett Potts
|
||||
Gabor Dorka
|
||||
Fabio Mierlo
|
||||
Erik den Dekker
|
||||
Doug McCorkle
|
||||
Donald Cipperly
|
||||
Don Leich
|
||||
Domenico Mangieri
|
||||
Dietmar Funck
|
||||
Christian Buchner
|
||||
Charles Cole
|
||||
Blake Williams
|
||||
Antoine Hue
|
||||
@@ -204,10 +219,12 @@ Andrew Bettison
|
||||
Anders Backman
|
||||
Ali Botorabi
|
||||
Alexander Wiebel
|
||||
Alexander Irion
|
||||
Alessandro Terenzi
|
||||
Zach Deedler
|
||||
Yuzhong Shen
|
||||
Wee See
|
||||
Warren Macchi
|
||||
Vladimir Chebaev
|
||||
Vincent Bourdier
|
||||
Terrex
|
||||
Tassilo Glander
|
||||
@@ -216,16 +233,18 @@ Steve Lunsford
|
||||
Stephane Simon
|
||||
Stephan Eilemann
|
||||
Stanislav Blinov
|
||||
Sebastian Messerschmidt
|
||||
Ryan Pavlik
|
||||
Sergey Polischuk
|
||||
Raymond de Vries
|
||||
Ralf Kern
|
||||
Piotr Gwiazdowski
|
||||
Pierre Haritchabalet
|
||||
Perry Miller
|
||||
Pawel Ksiezopolski
|
||||
Paul Palumbo
|
||||
Paul Obermeier
|
||||
Nguyen Van Truong
|
||||
Nathan Cournia
|
||||
Morten Haukness
|
||||
Morn<EFBFBD> Pistorius
|
||||
Michael Henheffer
|
||||
Michael Guerrero
|
||||
@@ -233,22 +252,26 @@ Maya Leonard
|
||||
Max Bandazian
|
||||
Mathias Fiedler
|
||||
Mathew May
|
||||
Martin von Gargern
|
||||
Martin Spott
|
||||
Martin Lambers
|
||||
Martijn Kragtwijk
|
||||
Marius Heise
|
||||
Marcin Hajder
|
||||
Lukasz Izdebski
|
||||
Lilith Bryant
|
||||
Lars Nilsson
|
||||
Kristofer Tingdahl
|
||||
Kevin Moiule
|
||||
Keith Steffen
|
||||
Julen Garcia
|
||||
Joseph Winston
|
||||
John Aughey
|
||||
Johannes Scholz
|
||||
Joachim Pouderoux
|
||||
Jean-Christophe Lombardo
|
||||
Javier Taibo
|
||||
James Moliere
|
||||
Jaap Glas
|
||||
Igor Kravtchenko
|
||||
Himar Carmona
|
||||
He Sicong
|
||||
@@ -256,6 +279,7 @@ Guy Volckaert
|
||||
Gustavo Wagner
|
||||
Guillaume Taze
|
||||
Guillaume Chouvenc
|
||||
Gill Peacegood
|
||||
Gerrick Bivins
|
||||
George Tarantilis
|
||||
Ferdi Smit
|
||||
@@ -263,17 +287,19 @@ Eric Buehler
|
||||
Eduardo Poyart
|
||||
Edgar Ellis
|
||||
Dimi Christopoulos
|
||||
Dietmar Funck
|
||||
Diane Delallée
|
||||
David Longest
|
||||
David Ergo
|
||||
Daniel Trstenjak
|
||||
Craig Bosma
|
||||
Claus Scheiblauer
|
||||
Christophe Loustaunau
|
||||
Christian Ruzicka
|
||||
Brad Anderegg
|
||||
Aric Aumann
|
||||
Andrew Sampson
|
||||
Andrew Lorino
|
||||
Alexandre Amalric
|
||||
Alessandro Terenzi
|
||||
Zbigniew Sroczynski
|
||||
Yuri Vilmanis
|
||||
Xin Li
|
||||
@@ -287,15 +313,19 @@ Vincent Vivanloc
|
||||
Vincent Gadoury
|
||||
Vasily Radostev
|
||||
Valery Bickov
|
||||
Valeriy Dubov
|
||||
Vaclav Bilek
|
||||
Tyge L<>vset
|
||||
Troy Yee
|
||||
Tomas Hogarth
|
||||
Tomas Hnilica
|
||||
Todd Furlong
|
||||
Tobias Ottenweller
|
||||
Tino Schwarze
|
||||
Thorsten Brehm
|
||||
Thomas Weidner
|
||||
Tan Dunning
|
||||
Tamer Fahmy
|
||||
Stewart Andreason
|
||||
Steven Thomas
|
||||
Simon Hammett
|
||||
@@ -311,6 +341,7 @@ Ross Anderson
|
||||
Ronny Krueger
|
||||
Ronald van Maarseveen
|
||||
Romain Charbit
|
||||
Rocco Martino
|
||||
Robert Swain
|
||||
Rob Smith
|
||||
Rob Radtke
|
||||
@@ -326,10 +357,11 @@ Pierre Bourdin
|
||||
Philipp Svehla
|
||||
Philipp Siemoleit
|
||||
Philipp M<>chler
|
||||
Philip Lamb
|
||||
Petr Salinger
|
||||
Peter Bear
|
||||
Peter Amstutz
|
||||
Paul Palumbo
|
||||
Paul Idstein
|
||||
Paul Fredrikson
|
||||
Paul Fotheringham
|
||||
Pau Garcia
|
||||
@@ -338,20 +370,25 @@ Parag Chaudhur
|
||||
Panagiotis Papadakos
|
||||
Panagiotis Koutsourakis
|
||||
Orhun Birsoy
|
||||
Oren Fromberg
|
||||
Oliver Neumann
|
||||
Ole-Morten Duesund
|
||||
Nicolas Brodu
|
||||
Morten Haukness
|
||||
Nick Black
|
||||
Mojtaba Fathi
|
||||
Mirko Viviani
|
||||
Mikkel Gjøl
|
||||
Mike Garrity
|
||||
Miha Ravsel
|
||||
Michael Polak
|
||||
Michael Morrison
|
||||
Michael Logan
|
||||
Michael Kapelko
|
||||
Michael Bach Jensen
|
||||
Max Rhiener
|
||||
Max Behensky
|
||||
Mauricio Hofmam
|
||||
Matthias Helsing
|
||||
Matthew May
|
||||
Matthew Johnson-Roberson
|
||||
Matt Green
|
||||
@@ -359,29 +396,33 @@ Matt Burke
|
||||
Mathias Walker
|
||||
Mathias Goldau
|
||||
Mason Menninger
|
||||
Martin von Gargern
|
||||
Martin Scheffler
|
||||
Martin Lambers
|
||||
Martin Innus
|
||||
Martin Beck
|
||||
Marius Kintel
|
||||
Mario Guimaraes
|
||||
Marco Sciabica
|
||||
Marco Lehmann
|
||||
Marcin Prus
|
||||
Marcel Pursche
|
||||
Maik Keller
|
||||
Lukas Diduch
|
||||
Louis Hamilton
|
||||
Lewis Harmon
|
||||
Leigh Stivers
|
||||
Laurence Muller
|
||||
Laura Cerritelli
|
||||
Lars Nillson
|
||||
Kyle Centers
|
||||
Kristopher Bixler
|
||||
Konstantin Matveyev
|
||||
Kim Seokhwan
|
||||
Kim Bale
|
||||
Karsten Weiss
|
||||
Karl Heijdenberg
|
||||
Jutta Sauer
|
||||
Julian Scheid
|
||||
Juergen Rensen
|
||||
Juan Manuel Alvarez
|
||||
Juan Hernando
|
||||
Josh Portway
|
||||
John Tan
|
||||
@@ -397,13 +438,15 @@ Jay Zuckerman
|
||||
Jason Howlett
|
||||
Jason Ballenger
|
||||
Jan Klimke
|
||||
James Turner
|
||||
James Killian
|
||||
James Athey
|
||||
J.E. Hoffmann
|
||||
Holger Helmich
|
||||
Henrique Bucher
|
||||
Hautio Jari
|
||||
Hartmut Seichter
|
||||
Gunter Huber
|
||||
Guillaume Millet
|
||||
Gregory Jaegy
|
||||
Graeme Harkness
|
||||
Gian Lorenzetto
|
||||
@@ -411,10 +454,13 @@ George Papagiannakis
|
||||
Galen Faidley
|
||||
Frida Schlaug
|
||||
Frederic Smith
|
||||
Frederic Morin
|
||||
Frank Warmerdam
|
||||
Frank Midgley
|
||||
Frank Lindeman
|
||||
Frank Lichtenheld
|
||||
Francois Tigeot
|
||||
Filip Arlet
|
||||
Ferdinand Cornelissen
|
||||
Fajran Iman
|
||||
Fabien Dachicourt
|
||||
@@ -436,9 +482,10 @@ Cyril Brulebois
|
||||
Clay Fowler
|
||||
Chuck Sembroski
|
||||
Christopher Blaesius
|
||||
Christophe Herreman
|
||||
Christian Noon
|
||||
Christian Kaser
|
||||
Christian Ehrlicher
|
||||
Christian Buchner
|
||||
Chris McGlone
|
||||
Carlos Garcea
|
||||
Bryce Eldridge
|
||||
@@ -447,6 +494,7 @@ Brian Keener
|
||||
Brandon Hamm
|
||||
Bora Utka
|
||||
Bj<EFBFBD>rn Hein
|
||||
Bjorn Blissing
|
||||
Bill Prendergast
|
||||
Bernardt Duvenhage
|
||||
Benoit Laniel
|
||||
@@ -462,7 +510,6 @@ Andreas Jochens
|
||||
Andre Normann
|
||||
Almalric Alexandre
|
||||
Allen Bierbaum
|
||||
Alexander Sinditskiy
|
||||
Alberto Jaspe
|
||||
Alan Purvis
|
||||
Alan Ott
|
||||
|
||||
236
CMakeLists.txt
236
CMakeLists.txt
@@ -20,21 +20,38 @@ if(COMMAND cmake_policy)
|
||||
# statements.
|
||||
cmake_policy(SET CMP0005 NEW)
|
||||
|
||||
# tell CMake to prefer CMake's own CMake modules when available
|
||||
# only available from cmake-2.8.4
|
||||
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 8 AND ${CMAKE_PATCH_VERSION} GREATER 3)
|
||||
cmake_policy(SET CMP0017 NEW)
|
||||
endif()
|
||||
|
||||
# cmake-2.6.1 introduces policy cmp0008 decide how to treat full path libraries that do not appear to be valid library file names
|
||||
# quote from cvslog "Such libraries worked by accident in the VS IDE and Xcode generators in CMake 2.4 and below."
|
||||
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND ${CMAKE_PATCH_VERSION} GREATER 0)
|
||||
cmake_policy(SET CMP0008 OLD)
|
||||
endif()
|
||||
|
||||
# disable autolinking to qtmain as we have our own main() functions (new in Qt 5.1)
|
||||
if((${CMAKE_MAJOR_VERSION} EQUAL 2 OR ${CMAKE_MAJOR_VERSION} GREATER 2) AND
|
||||
(${CMAKE_MINOR_VERSION} EQUAL 8 OR ${CMAKE_MINOR_VERSION} GREATER 8) AND
|
||||
${CMAKE_PATCH_VERSION} GREATER 10)
|
||||
cmake_policy(SET CMP0020 OLD)
|
||||
endif()
|
||||
# nicer version check - but needs at least CMake 2.6.2? Worth upgrading the requirements?
|
||||
#if("${CMAKE_VERSION}" VERSION_GREATER 2.8.10)
|
||||
|
||||
|
||||
endif()
|
||||
|
||||
PROJECT(OpenSceneGraph)
|
||||
|
||||
SET(OPENSCENEGRAPH_MAJOR_VERSION 3)
|
||||
SET(OPENSCENEGRAPH_MINOR_VERSION 0)
|
||||
SET(OPENSCENEGRAPH_MINOR_VERSION 2)
|
||||
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
|
||||
SET(OPENSCENEGRAPH_SOVERSION 80)
|
||||
SET(OPENSCENEGRAPH_SOVERSION 100)
|
||||
|
||||
# set to 0 when not a release candidate, non zero means that any generated
|
||||
# set to 0 when not a release candidate, non zero means that any generated
|
||||
# svn tags will be treated as release candidates of given number
|
||||
SET(OPENSCENEGRAPH_RELEASE_CANDIDATE 0)
|
||||
|
||||
@@ -71,17 +88,48 @@ IF(OSG_BUILD_PLATFORM_ANDROID)
|
||||
|
||||
INCLUDE(OsgAndroidMacroUtils)
|
||||
SET(ANDROID TRUE)
|
||||
SET(ANDROID_PLATFORM 5)
|
||||
FIND_PACKAGE(AndroidNDK REQUIRED)
|
||||
IF(NOT ANDROID_PLATFORM)
|
||||
MESSAGE("Warning Android Platform version NOT defined, Default selected version: 5")
|
||||
SET(ANDROID_PLATFORM 5)
|
||||
ENDIF()
|
||||
IF(NOT ANDROID_ABI)
|
||||
MESSAGE("Warning Android ABI version NOT defined, Default selection: armeabi armeabi-v7a")
|
||||
SET(ANDROID_ABI "armeabi armeabi-v7a")
|
||||
ENDIF()
|
||||
IF(NOT ANDROID_STL)
|
||||
MESSAGE("Warning Android STL NOT defined, Default selection: gnustl_static")
|
||||
SET(ANDROID_STL "gnustl_static")
|
||||
ENDIF()
|
||||
IF(ANDROID_DEBUG)
|
||||
MESSAGE("Warning Android Build is in debug mode")
|
||||
SET(ANDROID_RELEASE_OPTIM "debug")
|
||||
ELSE()
|
||||
MESSAGE("Warning Android Build is in release mode")
|
||||
SET(ANDROID_RELEASE_OPTIM "release")
|
||||
ENDIF()
|
||||
IF(ANDROID_NEON)
|
||||
MESSAGE("Warning Android NEON optimizations enabled, this will not be available on all armeabi-v7a devices ie. Tegra2")
|
||||
SET(ANDROID_OPTIM_NEON true)
|
||||
ELSE()
|
||||
SET(ANDROID_OPTIM_NEON false)
|
||||
ENDIF()
|
||||
IF(ANDROID_ARM32)
|
||||
MESSAGE("Warning ARM 32bit instruction set will be used")
|
||||
SET(ANDROID_OPTIM_ARM32 true)
|
||||
ELSE()
|
||||
SET(ANDROID_OPTIM_ARM32 false)
|
||||
ENDIF()
|
||||
|
||||
FIND_PACKAGE(AndroidNDK REQUIRED)
|
||||
|
||||
SET(OSG_ANDROID_TEMPLATES "${CMAKE_SOURCE_DIR}/PlatformSpecifics/Android")
|
||||
|
||||
|
||||
SET(J "4" CACHE STRING "how many processes for make -j <J>")
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT Android-OpenSceneGraph
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/Android.mk
|
||||
COMMAND "${ANDROID_NDK}/ndk-build"
|
||||
COMMAND "${ANDROID_NDK}/ndk-build"
|
||||
ARGS --directory=${CMAKE_BINARY_DIR} NDK_APPLICATION_MK=Application.mk -j${J} NDK_LOG=1
|
||||
)
|
||||
|
||||
@@ -134,9 +182,9 @@ IF (OSG_MAINTAINER)
|
||||
# Provide target for tagging a release
|
||||
#
|
||||
SET(SVNCOMMAND svn)
|
||||
SET(SVNTRUNKDIR http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk)
|
||||
SET(SVNTAGDIR http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags)
|
||||
SET(SVNBRANCHDIR http://www.openscenegraph.org/svn/osg/OpenSceneGraph/branches)
|
||||
SET(SVNTRUNKDIR http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk)
|
||||
SET(SVNTAGDIR http://svn.openscenegraph.org/osg/OpenSceneGraph/tags)
|
||||
SET(SVNBRANCHDIR http://svn.openscenegraph.org/osg/OpenSceneGraph/branches)
|
||||
|
||||
IF (OPENSCENEGRAPH_SVN STREQUAL "trunk")
|
||||
SET(SVNSOURCEDIR ${SVNTRUNKDIR})
|
||||
@@ -177,11 +225,18 @@ IF (OSG_MAINTAINER)
|
||||
COMMAND ${SVNCOMMAND} update
|
||||
COMMAND ${GENERATELOGS} ${SVNSOURCEDIR}
|
||||
)
|
||||
|
||||
|
||||
ENDIF(OSG_MAINTAINER)
|
||||
|
||||
IF(NOT ANDROID)
|
||||
IF(APPLE)
|
||||
# Determine the canonical name of the selected Platform SDK
|
||||
EXECUTE_PROCESS(COMMAND "/usr/bin/sw_vers" "-productVersion"
|
||||
OUTPUT_VARIABLE OSG_OSX_SDK_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
STRING(SUBSTRING "${OSG_OSX_SDK_NAME}" 0 4 OSG_OSX_SDK_NAME)
|
||||
SET(OSG_OSX_SDK_NAME "macosx${OSG_OSX_SDK_NAME}")
|
||||
|
||||
# Trying to get CMake to generate an XCode IPhone project, current efforts are to get iphoneos sdk 3.1 working
|
||||
# Added option which needs manually setting to select the IPhone SDK for building. We can only have one of the below
|
||||
# set to true. Should realy have an OSG_BUILD_PLATFORM variable that we set to our desired platform
|
||||
@@ -191,21 +246,21 @@ IF(APPLE)
|
||||
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
|
||||
|
||||
#you need to manually set the default sdk version here
|
||||
SET (IPHONE_SDKVER "3.2")
|
||||
SET (IPHONE_SDKVER "6.0" CACHE STRING "IOS SDK-Version")
|
||||
|
||||
#the below is taken from ogre, it states the gcc stuff needs to happen before PROJECT() is called. I've no clue if we even need it
|
||||
# Force gcc <= 4.2 on iPhone
|
||||
include(CMakeForceCompiler)
|
||||
CMAKE_FORCE_C_COMPILER(gcc-4.2 GNU)
|
||||
CMAKE_FORCE_CXX_COMPILER(gcc-4.2 GNU)
|
||||
CMAKE_FORCE_C_COMPILER(llvm-gcc-4.2 GNU)
|
||||
CMAKE_FORCE_CXX_COMPILER(llvm-gcc-4.2 GNU)
|
||||
SET(GCC_THUMB_SUPPORT NO)
|
||||
|
||||
#set either the device sdk or the simulator sdk. Can't find away to separate these in the same project
|
||||
IF(OSG_BUILD_PLATFORM_IPHONE)
|
||||
SET (IPHONE_DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer")
|
||||
SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer")
|
||||
SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneOS${IPHONE_SDKVER}.sdk")
|
||||
ELSE()
|
||||
SET (IPHONE_DEVROOT "/Developer/Platforms/iPhoneSimulator.platform/Developer")
|
||||
SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer")
|
||||
SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneSimulator${IPHONE_SDKVER}.sdk")
|
||||
ENDIF()
|
||||
|
||||
@@ -302,7 +357,13 @@ IF(WIN32 AND NOT ANDROID)
|
||||
STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
|
||||
ENDIF(MSVC_USE_DEFAULT_STACK_SIZE)
|
||||
|
||||
get_filename_component( CMAKE_MAKE_PROGRAM_NAME ${CMAKE_MAKE_PROGRAM} NAME)
|
||||
IF (CMAKE_MAKE_PROGRAM_NAME STREQUAL "VCExpress.exe")
|
||||
OPTION(MSVC_BUILD_USE_SOLUTION_FOLDERS "Enable project grouping in VS - VCExpress detected, not supported in VCExpress )" OFF)
|
||||
ELSE()
|
||||
OPTION(MSVC_BUILD_USE_SOLUTION_FOLDERS "Enable project grouping in VS" ON)
|
||||
ENDIF()
|
||||
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ${MSVC_BUILD_USE_SOLUTION_FOLDERS})
|
||||
ENDIF()
|
||||
|
||||
#needed for net plugin
|
||||
@@ -385,6 +446,7 @@ MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
|
||||
|
||||
OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
|
||||
|
||||
|
||||
OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON)
|
||||
OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." ON)
|
||||
OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." OFF)
|
||||
@@ -403,7 +465,7 @@ SET(OPENGL_egl_LIBRARY CACHE STRING "Set the OpenGL egl library.")
|
||||
OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertexPointer/glColorPointer etc." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE})
|
||||
|
||||
OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
|
||||
@@ -461,11 +523,10 @@ ELSE()
|
||||
FIND_PACKAGE(OpenVRML)
|
||||
FIND_PACKAGE(Performer)
|
||||
FIND_PACKAGE(GDAL)
|
||||
FIND_PACKAGE(GTA)
|
||||
FIND_PACKAGE(CURL)
|
||||
FIND_PACKAGE(ITK)
|
||||
FIND_PACKAGE(LibVNCServer)
|
||||
FIND_PACKAGE(OurDCMTK)
|
||||
FIND_PACKAGE(OpenAL)
|
||||
FIND_PACKAGE(FFmpeg)
|
||||
FIND_PACKAGE(DirectShow)
|
||||
FIND_PACKAGE(SDL)
|
||||
@@ -474,17 +535,30 @@ ELSE()
|
||||
FIND_PACKAGE(GtkGl)
|
||||
FIND_PACKAGE(DirectInput)
|
||||
FIND_PACKAGE(NVTT)
|
||||
IF (NOT WIN32)
|
||||
FIND_PACKAGE(Asio)
|
||||
ENDIF()
|
||||
FIND_PACKAGE(ZeroConf)
|
||||
ENDIF()
|
||||
|
||||
IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 8)
|
||||
FIND_PACKAGE(ITK)
|
||||
ENDIF()
|
||||
|
||||
# Include macro utilities here
|
||||
INCLUDE(OsgMacroUtils)
|
||||
|
||||
IF(NOT ANDROID)
|
||||
# To select a specific version of QT define DESIRED_QT_VERSION
|
||||
# via cmake -DDESIRED_QT_VERSION=4
|
||||
IF (DESIRED_QT_VERSION)
|
||||
OPTION(OSG_USE_QT "Enable to use Qt (build Qt-dependent libraries, plugins and examples)" ON)
|
||||
|
||||
IF (DESIRED_QT_VERSION MATCHES 4)
|
||||
IF(OSG_USE_QT AND NOT ANDROID)
|
||||
# To select a specific version of QT define DESIRED_QT_VERSION
|
||||
# via cmake -DDESIRED_QT_VERSION=5
|
||||
# QUIET option disables messages if the package cannot be found.
|
||||
|
||||
IF (DESIRED_QT_VERSION)
|
||||
IF (DESIRED_QT_VERSION MATCHES 5)
|
||||
FIND_PACKAGE(Qt5Widgets)
|
||||
ELSEIF (DESIRED_QT_VERSION MATCHES 4)
|
||||
FIND_PACKAGE(Qt4)
|
||||
ELSE()
|
||||
FIND_PACKAGE(Qt3)
|
||||
@@ -492,14 +566,37 @@ IF(NOT ANDROID)
|
||||
|
||||
ELSE()
|
||||
|
||||
FIND_PACKAGE(Qt4)
|
||||
FIND_PACKAGE(Qt5Widgets QUIET)
|
||||
|
||||
IF (NOT QT4_FOUND)
|
||||
FIND_PACKAGE(Qt3)
|
||||
IF ( Qt5Widgets_FOUND )
|
||||
# CMake 2.8.8 or greater required
|
||||
BUILDER_VERSION_GREATER(2 8 7)
|
||||
IF(NOT VALID_BUILDER_VERSION)
|
||||
MESSAGE(
|
||||
SEND_ERROR
|
||||
"Qt5 requires CMake version 2.8.8 or greater!\n"
|
||||
"Update CMake or set DESIRED_QT_VERSION to less than 5
|
||||
or disable OSG_USE_QT."
|
||||
)
|
||||
ENDIF( )
|
||||
ENDIF( )
|
||||
|
||||
IF ( NOT Qt5Widgets_FOUND )
|
||||
FIND_PACKAGE(Qt4)
|
||||
|
||||
IF (NOT QT4_FOUND)
|
||||
FIND_PACKAGE(Qt3)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
ENDIF(NOT ANDROID)
|
||||
|
||||
#If we have found Qt5, let's try to top off by getting the webkit as well
|
||||
IF ( Qt5Widgets_FOUND )
|
||||
FIND_PACKAGE(Qt5WebKitWidgets)
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
|
||||
#optional example related dependencies
|
||||
IF (BUILD_OSG_EXAMPLES AND NOT ANDROID)
|
||||
|
||||
@@ -534,16 +631,19 @@ IF(NOT ANDROID)
|
||||
FIND_PACKAGE(JPEG)
|
||||
FIND_PACKAGE(PNG)
|
||||
FIND_PACKAGE(TIFF)
|
||||
|
||||
# QuickTime is required for OS X, but optional for Windows.
|
||||
IF(WIN32)
|
||||
FIND_PACKAGE(QuickTime)
|
||||
ENDIF()
|
||||
|
||||
ELSE()
|
||||
FIND_PACKAGE(TIFF)
|
||||
FIND_PACKAGE(QuickTime)
|
||||
FIND_PACKAGE(QTKit)
|
||||
FIND_PACKAGE(CoreVideo)
|
||||
FIND_PACKAGE(CoreMedia)
|
||||
FIND_PACKAGE(QuartzCore)
|
||||
FIND_PACKAGE(AVFoundation)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
@@ -701,19 +801,18 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# Previous included -Wformat=2 in OSG_AGGRESSIVE_WARNING_FLAGS but had to remove it due to standard library errors
|
||||
|
||||
|
||||
ELSE()
|
||||
IF(MSVC)
|
||||
# FIXME: What are good aggressive warning flags for Visual Studio?
|
||||
# And do we need to further subcase this for different versions of VS?
|
||||
# CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
|
||||
ELSEIF(MSVC)
|
||||
#disable specific warning level 4 warnings:
|
||||
#C4100 'identifier' : unreferenced formal parameter
|
||||
#C4127 Error Message conditional expression is constant
|
||||
#C4706 assignment within conditional expression
|
||||
SET(OSG_AGGRESSIVE_WARNING_FLAGS /W4 /wd4706 /wd4127 /wd4100)
|
||||
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -Wno-overloaded-virtual)
|
||||
|
||||
|
||||
ELSE()
|
||||
# CMake lacks an elseif, so other non-gcc, non-VS compilers need
|
||||
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
|
||||
# remain unset.
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# This part is for the CMake menu option to toggle the warnings on/off.
|
||||
@@ -766,7 +865,7 @@ IF (BUILD_OSG_EXAMPLES)
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(APPLE)
|
||||
IF(APPLE AND NOT ANDROID)
|
||||
|
||||
#Here we check if the user specified IPhone SDK
|
||||
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
|
||||
@@ -774,7 +873,7 @@ IF(APPLE)
|
||||
#set iphone arch and flags taken from http://sites.google.com/site/michaelsafyan/coding/resources/how-to-guides/cross-compile-for-the-iphone/how-to-cross-compile-for-the-iphone-using-cmake
|
||||
IF(OSG_BUILD_PLATFORM_IPHONE)
|
||||
SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=3.1 -mno-thumb -arch armv6 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=4.1 -mno-thumb -arch armv6 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSE()
|
||||
#simulator uses i386 architectures
|
||||
SET(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Build architectures for iOS Simulator" FORCE)
|
||||
@@ -806,18 +905,23 @@ IF(APPLE)
|
||||
# FORCE is used because the options are not reflected in the UI otherwise.
|
||||
# Seems like a good place to add version specific compiler flags too.
|
||||
IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||
# This is really fragile, but CMake doesn't provide the OS system
|
||||
# version information we need. (Darwin versions can be changed
|
||||
# independently of OS X versions.)
|
||||
# It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
|
||||
IF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
|
||||
# 64-bit compiles are not supported with Carbon. We should enable
|
||||
# 64-bit compilation by default once osgviewer has been
|
||||
# rewritten with Cocoa.
|
||||
#SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8")
|
||||
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
|
||||
# 64 Bit Works, i386,ppc is not supported any more
|
||||
SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.8 -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7")
|
||||
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
|
||||
# 64 Bit Works, PPC is not supported any more
|
||||
SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
|
||||
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
|
||||
# 64-bit compiles are not supported with Carbon.
|
||||
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSEIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
|
||||
ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
|
||||
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "quicktime" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
|
||||
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSE()
|
||||
@@ -825,21 +929,21 @@ IF(APPLE)
|
||||
# Should break down further to set the -mmacosx-version-min,
|
||||
# but the SDK detection is too unreliable here.
|
||||
ENDIF()
|
||||
ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||
ENDIF()
|
||||
|
||||
OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
|
||||
|
||||
ENDIF()
|
||||
|
||||
ENDIF(APPLE)
|
||||
ENDIF()
|
||||
|
||||
|
||||
# For Doxygen
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
|
||||
OPTION(BUILD_DOCUMENTATION "Build OpenSceneGraph reference documentation using doxygen (use: make DoxygenDoc)" OFF)
|
||||
OPTION(BUILD_DOCUMENTATION "Build OpenSceneGraph reference documentation using doxygen (use: make doc_openscenegraph doc_openthreads)" OFF)
|
||||
MARK_AS_ADVANCED(CLEAR BUILD_DOCUMENTATION)
|
||||
# To build the documention, you will have to enable it
|
||||
# and then do the equivalent of "make DoxygenDoc".
|
||||
# and then do the equivalent of "make doc_openscenegraph doc_openthreads".
|
||||
IF(BUILD_DOCUMENTATION)
|
||||
|
||||
OPTION(BUILD_REF_DOCS_SEARCHENGINE "Enable doxygen's search engine (requires that documentation to be installed on a php enabled web server)" OFF)
|
||||
@@ -861,19 +965,19 @@ IF(BUILD_DOCUMENTATION)
|
||||
ELSE()
|
||||
SET(HAVE_DOT NO)
|
||||
ENDIF()
|
||||
|
||||
|
||||
# If html help generation was requested. DOCUMENTATION_HTML_HELP is defined by Documentation.cmake
|
||||
SET(GENERATE_HTMLHELP "NO")
|
||||
IF(DOCUMENTATION_HTML_HELP)
|
||||
# on windows Documentation.cmake finds the html help workshop fi it exists. On u*ix we might have it with wine but no way to point it out
|
||||
# on windows Documentation.cmake finds the html help workshop if it exists. On u*ix we might have it with wine but no way to point it out
|
||||
IF(NOT WIN32)
|
||||
SET(HTML_HELP_COMPILER "" CACHE FILEPATH "Enter location of the HTML help compiler to let doxygen compile html")
|
||||
MARK_AS_ADVANCED(HTML_HELP_COMPILER)
|
||||
ENDIF()
|
||||
# this var sets a proper value in .doxygen files when coniguring them below
|
||||
# this var sets a proper value in .doxygen files when configuring them below
|
||||
SET(GENERATE_HTMLHELP "YES")
|
||||
endif()
|
||||
|
||||
|
||||
# This processes our doxyfile.cmake and substitutes paths to generate
|
||||
# a final Doxyfile
|
||||
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/doxyfile.cmake
|
||||
@@ -909,7 +1013,7 @@ IF(BUILD_DOCUMENTATION)
|
||||
${PROJECT_BINARY_DIR}/doc/auto_Doxyfile)
|
||||
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/core_Doxyfile
|
||||
${PROJECT_BINARY_DIR}/doc/core_Doxyfile)
|
||||
|
||||
|
||||
# This creates a new target to build documentation.
|
||||
# It runs ${DOXYGEN} which is the full path and executable to
|
||||
# Doxygen on your system, set by the FindDoxygen.cmake module
|
||||
@@ -920,17 +1024,17 @@ IF(BUILD_DOCUMENTATION)
|
||||
${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
|
||||
)
|
||||
SET_TARGET_PROPERTIES(doc_openscenegraph PROPERTIES FOLDER "Documentation")
|
||||
|
||||
|
||||
ADD_CUSTOM_TARGET(doc_openthreads ${DOXYGEN}
|
||||
${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
|
||||
)
|
||||
SET_TARGET_PROPERTIES(doc_openthreads PROPERTIES FOLDER "Documentation")
|
||||
ENDIF(BUILD_DOCUMENTATION)
|
||||
|
||||
OPTION(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of OpenSceneGraph builds here http://www.cdash.org/CDashPublic/index.php?project=OpenSceneGraph" OFF)
|
||||
OPTION(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of OpenSceneGraph builds here http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph" OFF)
|
||||
IF(BUILD_DASHBOARD_REPORTS)
|
||||
# The following are required to uses Dart and the Cdash dashboard
|
||||
# viewable here : http://www.cdash.org/CDashPublic/index.php?project=OpenSceneGraph
|
||||
# viewable here : http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph
|
||||
INCLUDE(Dart)
|
||||
ENDIF()
|
||||
|
||||
@@ -963,9 +1067,9 @@ SET(PKGCONFIG_FILES
|
||||
openscenegraph-osgVolume
|
||||
)
|
||||
|
||||
IF(QT4_FOUND)
|
||||
IF(QT4_FOUND OR Qt5Widgets_FOUND )
|
||||
SET(PKGCONFIG_FILES ${PKGCONFIG_FILES} openscenegraph-osgQt)
|
||||
ENDIF(QT4_FOUND)
|
||||
ENDIF()
|
||||
|
||||
FOREACH(PKGCONFIG_FILE ${PKGCONFIG_FILES})
|
||||
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc.in
|
||||
@@ -997,7 +1101,7 @@ IF(REQUIRES_LIBPATH_MESSAGE)
|
||||
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/ld.so.conf.d/openscenegraph.conf.in
|
||||
${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
|
||||
)
|
||||
ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different
|
||||
ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different
|
||||
${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
|
||||
/etc/ld.so.conf.d/openscenegraph.conf
|
||||
COMMAND ldconfig
|
||||
|
||||
@@ -54,12 +54,12 @@ ENDMACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES_BASE SEARCHPATHLIST D
|
||||
|
||||
|
||||
################################################################################################
|
||||
# this Macro is tailored to Mike dependencies
|
||||
# this Macro is tailored to Mike and Torbens dependencies
|
||||
################################################################################################
|
||||
|
||||
MACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
|
||||
FIND_DEPENDENCY(TIFF tiff.h libtiff ${OSG_3RDPARTY_BIN} "D" "_i")
|
||||
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype2311MT;freetype234;freetype234MT;freetype235;freetype237;freetype238;freetype244;" ${OSG_3RDPARTY_BIN} "d" "")
|
||||
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype2311MT;freetype234;freetype234MT;freetype235;freetype237;freetype238;freetype244;freetype250;" ${OSG_3RDPARTY_BIN} "d" "")
|
||||
IF(FREETYPE_FOUND)
|
||||
#forcing subsequent FindFreeType stuff to not search for other variables.... kind of a hack
|
||||
SET(FREETYPE_INCLUDE_DIR_ft2build ${FREETYPE_INCLUDE_DIR} CACHE PATH "" FORCE)
|
||||
@@ -79,21 +79,21 @@ MACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
|
||||
FIND_DEPENDENCY(GIFLIB gif_lib.h "ungif;libungif;giflib" ${OSG_3RDPARTY_BIN} "D" "")
|
||||
FIND_DEPENDENCY(ZLIB zlib.h "z;zlib;zlib1" ${OSG_3RDPARTY_BIN} "D" "")
|
||||
IF(ZLIB_FOUND)
|
||||
FIND_DEPENDENCY(PNG png.h "libpng;libpng13;libpng15" ${OSG_3RDPARTY_BIN} "D" "")
|
||||
FIND_DEPENDENCY(PNG png.h "libpng;libpng13;libpng15;libpng16" ${OSG_3RDPARTY_BIN} "D" "")
|
||||
IF(PNG_FOUND)
|
||||
#forcing subsequent FindPNG stuff to not search for other variables.... kind of a hack
|
||||
SET(PNG_PNG_INCLUDE_DIR ${PNG_INCLUDE_DIR} CACHE FILEPATH "")
|
||||
MARK_AS_ADVANCED(PNG_PNG_INCLUDE_DIR)
|
||||
ENDIF(PNG_FOUND)
|
||||
ENDIF(ZLIB_FOUND)
|
||||
FIND_DEPENDENCY(LIBXML2 libxml "libxml2" ${OSG_3RDPARTY_BIN} "D" "")
|
||||
FIND_DEPENDENCY(LIBXML2 libxml2 "libxml2" ${OSG_3RDPARTY_BIN} "D" "")
|
||||
IF(LIBXML2_FOUND)
|
||||
# The CMAKE find libxml module uses LIBXML2_LIBRARIES -> fill it.... kind of a hack
|
||||
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY} CACHE FILEPATH "" FORCE)
|
||||
SET(LIBXML2_XMLLINT_EXECUTABLE ${OSG_3RDPARTY_BIN}/bin/xmllint.exe CACHE FILEPATH "Path to xmllint executable" FORCE)
|
||||
ENDIF(LIBXML2_FOUND)
|
||||
#FIND_DEPENDENCY(DEPNAME INCLUDEFILE LIBRARY_NAMES_BASE SEARCHPATHLIST DEBUGSUFFIX EXSUFFIX)
|
||||
FIND_Package(NVTT)
|
||||
FIND_Package(NVTT)
|
||||
#luigi#INCLUDE(FindOSGDepends.cmake)
|
||||
ENDMACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
|
||||
|
||||
|
||||
42
CMakeModules/FindAVFoundation.cmake
Normal file
42
CMakeModules/FindAVFoundation.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
# Locate Apple AVFoundation (next-generation QTKit)
|
||||
# This module defines
|
||||
# AV_FOUNDATION_LIBRARY
|
||||
# AV_FOUNDATION_FOUND, if false, do not try to link to gdal
|
||||
# AV_FOUNDATION_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# $AV_FOUNDATION_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$AV_FOUNDATION_DIR
|
||||
#
|
||||
# Created by Stephan Maximilian Huber
|
||||
|
||||
|
||||
IF(APPLE)
|
||||
FIND_PATH(AV_FOUNDATION_INCLUDE_DIR AVFoundation/AVFoundation.h)
|
||||
FIND_LIBRARY(AV_FOUNDATION_LIBRARY AVFoundation)
|
||||
ENDIF()
|
||||
|
||||
SET(AV_FOUNDATION_FOUND "NO")
|
||||
IF(AV_FOUNDATION_LIBRARY AND AV_FOUNDATION_INCLUDE_DIR)
|
||||
SET(AV_FOUNDATION_FOUND "YES")
|
||||
ENDIF()
|
||||
|
||||
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
|
||||
# AVFoundation exists ON iOS, too -- good support for SDK 6.0 and greater
|
||||
IF(${IPHONE_SDKVER} LESS "6.0")
|
||||
SET(AV_FOUNDATION_FOUND "NO")
|
||||
ELSE()
|
||||
SET(AV_FOUNDATION_FOUND "YES")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
IF(APPLE)
|
||||
# AVFoundation exists since 10.7, but only 10.8 has all features necessary for OSG
|
||||
# so check the SDK-setting
|
||||
|
||||
IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8")
|
||||
# nothing special here ;-)
|
||||
ELSE()
|
||||
MESSAGE("AVFoundation disabled for SDK < 10.8")
|
||||
SET(AV_FOUNDATION_FOUND "NO")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
20
CMakeModules/FindAsio.cmake
Executable file
20
CMakeModules/FindAsio.cmake
Executable file
@@ -0,0 +1,20 @@
|
||||
# Locate ASIO-headers (http://think-async.com/Asio)
|
||||
# This module defines
|
||||
# ASIO_FOUND, if false, do not try to link to gdal
|
||||
# ASIO_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# Created by Stephan Maximilian Huber
|
||||
|
||||
FIND_PATH(ASIO_INCLUDE_DIR
|
||||
NAMES
|
||||
asio.hpp
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
)
|
||||
|
||||
SET(ASIO_FOUND "NO")
|
||||
FIND_PACKAGE( Boost 1.37 )
|
||||
IF(Boost_FOUND AND ASIO_INCLUDE_DIR)
|
||||
SET(ASIO_FOUND "YES")
|
||||
ENDIF()
|
||||
@@ -28,6 +28,12 @@ IF(APPLE)
|
||||
SET(COLLADA_BUILDNAME "mac")
|
||||
ELSEIF(MINGW)
|
||||
SET(COLLADA_BUILDNAME "mingw")
|
||||
ELSEIF(MSVC12)
|
||||
SET(COLLADA_BUILDNAME "vc12")
|
||||
ELSEIF(MSVC11)
|
||||
SET(COLLADA_BUILDNAME "vc11")
|
||||
ELSEIF(MSVC10)
|
||||
SET(COLLADA_BUILDNAME "vc10")
|
||||
ELSEIF(MSVC90)
|
||||
SET(COLLADA_BUILDNAME "vc9")
|
||||
ELSEIF(MSVC80)
|
||||
@@ -47,6 +53,7 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
|
||||
/usr/local/include
|
||||
/usr/local/include/colladadom
|
||||
/usr/local/include/collada-dom
|
||||
/opt/local/include/collada-dom
|
||||
/usr/include/
|
||||
/usr/include/colladadom
|
||||
/usr/include/collada-dom
|
||||
@@ -235,7 +242,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
|
||||
)
|
||||
|
||||
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY
|
||||
NAMES libboost_filesystem boost_filesystem libboost_filesystem-vc90-mt libboost_filesystem-vc100-mt
|
||||
NAMES libboost_filesystem boost_filesystem boost_filesystem-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_54
|
||||
PATHS
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
|
||||
@@ -243,7 +250,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
|
||||
)
|
||||
|
||||
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY_DEBUG
|
||||
NAMES libboost_filesystem-d boost_filesystem-d libboost_filesystem-vc90-mt-gd libboost_filesystem-vc100-mt-gd
|
||||
NAMES libboost_filesystem-d boost_filesystem-d boost_filesystem-mt-d libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_54
|
||||
PATHS
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
|
||||
@@ -251,7 +258,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
|
||||
)
|
||||
|
||||
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY
|
||||
NAMES libboost_system boost_system libboost_system-vc90-mt libboost_system-vc100-mt
|
||||
NAMES libboost_system boost_system boost_system-mt libboost_system-${COLLADA_BUILDNAME}0-mt libboost_system-${COLLADA_BUILDNAME}0-mt-1_54
|
||||
PATHS
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
|
||||
@@ -259,7 +266,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
|
||||
)
|
||||
|
||||
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY_DEBUG
|
||||
NAMES libboost_system-d boost_system-d libboost_system-vc90-mt-gd libboost_system-vc100-mt-gd
|
||||
NAMES libboost_system-d boost_system-d boost_system-mt-d libboost_system-${COLLADA_BUILDNAME}0-mt-gd libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_54
|
||||
PATHS
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
|
||||
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
|
||||
|
||||
23
CMakeModules/FindCoreMedia.cmake
Normal file
23
CMakeModules/FindCoreMedia.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
# Locate Apple CoreMedia
|
||||
# This module defines
|
||||
# COREMEDIA_LIBRARY
|
||||
# COREMEDIA_FOUND, if false, do not try to link to gdal
|
||||
# COREMEDIA_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# $COREMEDIA_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$COREMEDIA_DIR
|
||||
#
|
||||
# Created by Stephan Maximilian Huber.
|
||||
|
||||
|
||||
IF(APPLE)
|
||||
FIND_PATH(COREMEDIA_INCLUDE_DIR CoreMedia/CoreMedia.h)
|
||||
FIND_LIBRARY(COREMEDIA_LIBRARY CoreMedia)
|
||||
ENDIF()
|
||||
|
||||
|
||||
SET(COREMEDIA_FOUND "NO")
|
||||
IF(COREMEDIA_LIBRARY AND COREMEDIA_INCLUDE_DIR)
|
||||
SET(COREMEDIA_FOUND "YES")
|
||||
ENDIF()
|
||||
|
||||
@@ -16,8 +16,10 @@ ELSEIF(MSVC80)
|
||||
SET(FBX_LIBDIR "vs2005")
|
||||
ELSEIF(MSVC90)
|
||||
SET(FBX_LIBDIR "vs2008")
|
||||
ELSEIF(MSVC100 OR MSVC_VER>1600)
|
||||
ELSEIF(MSVC10)
|
||||
SET(FBX_LIBDIR "vs2010")
|
||||
ELSEIF(MSVC11 OR MSVC_VERSION>1700)
|
||||
SET(FBX_LIBDIR "vs2012")
|
||||
ENDIF()
|
||||
|
||||
IF(APPLE)
|
||||
@@ -31,20 +33,20 @@ ELSE()
|
||||
ENDIF()
|
||||
|
||||
IF(APPLE)
|
||||
SET(FBX_LIBNAME "fbxsdk-2012.1-static")
|
||||
SET(FBX_LIBNAME "libfbxsdk")
|
||||
ELSEIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(FBX_LIBNAME "fbxsdk-2012.1-static")
|
||||
SET(FBX_LIBNAME "fbxsdk")
|
||||
ELSE()
|
||||
SET(FBX_LIBNAME "fbxsdk-2012.1-md")
|
||||
SET(FBX_LIBNAME "libfbxsdk-md")
|
||||
ENDIF()
|
||||
|
||||
SET(FBX_LIBNAME_DEBUG ${FBX_LIBNAME}d)
|
||||
|
||||
SET( FBX_SEARCH_PATHS
|
||||
$ENV{FBX_DIR}
|
||||
$ENV{ProgramW6432}/Autodesk/FBX/FbxSdk/2012.1
|
||||
$ENV{PROGRAMFILES}/Autodesk/FBX/FbxSdk/2012.1
|
||||
/Applications/Autodesk/FBXSDK20121
|
||||
"$ENV{ProgramW6432}/Autodesk/FBX/FBX SDK/2014.1"
|
||||
"$ENV{PROGRAMFILES}/Autodesk/FBX/FBX SDK/2014.1"
|
||||
/Applications/Autodesk/FBXSDK20141
|
||||
)
|
||||
|
||||
# search for headers & debug/release libraries
|
||||
@@ -53,7 +55,14 @@ FIND_PATH(FBX_INCLUDE_DIR "fbxsdk.h"
|
||||
PATH_SUFFIXES "include")
|
||||
FIND_LIBRARY( FBX_LIBRARY ${FBX_LIBNAME}
|
||||
PATHS ${FBX_SEARCH_PATHS}
|
||||
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
|
||||
PATH_SUFFIXES "lib/${FBX_LIBDIR}/release" "lib/${FBX_LIBDIR}")
|
||||
|
||||
#Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
|
||||
|
||||
#no debug d suffix, search in debug folder only
|
||||
FIND_LIBRARY( FBX_LIBRARY_DEBUG ${FBX_LIBNAME}
|
||||
PATHS ${FBX_SEARCH_PATHS}
|
||||
PATH_SUFFIXES "lib/${FBX_LIBDIR}/debug")
|
||||
FIND_LIBRARY( FBX_LIBRARY_DEBUG ${FBX_LIBNAME_DEBUG}
|
||||
PATHS ${FBX_SEARCH_PATHS}
|
||||
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
|
||||
@@ -63,3 +72,41 @@ IF(FBX_LIBRARY AND FBX_LIBRARY_DEBUG AND FBX_INCLUDE_DIR)
|
||||
ELSE()
|
||||
SET(FBX_FOUND "NO")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT FBX_FOUND)
|
||||
#try to use 2013.3 version
|
||||
IF(APPLE)
|
||||
SET(FBX_LIBNAME "fbxsdk-2013.3-static")
|
||||
ELSEIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(FBX_LIBNAME "fbxsdk-2013.3-static")
|
||||
ELSE()
|
||||
SET(FBX_LIBNAME "fbxsdk-2013.3-md")
|
||||
ENDIF()
|
||||
|
||||
SET(FBX_LIBNAME_DEBUG ${FBX_LIBNAME}d)
|
||||
|
||||
SET( FBX_SEARCH_PATHS
|
||||
$ENV{FBX_DIR}
|
||||
$ENV{ProgramW6432}/Autodesk/FBX/FBX SDK/2013.3
|
||||
$ENV{PROGRAMFILES}/Autodesk/FBX/FBX SDK/2013.3
|
||||
/Applications/Autodesk/FBXSDK20141
|
||||
)
|
||||
|
||||
# search for headers & debug/release libraries
|
||||
FIND_PATH(FBX_INCLUDE_DIR "fbxsdk.h"
|
||||
PATHS ${FBX_SEARCH_PATHS}
|
||||
PATH_SUFFIXES "include")
|
||||
FIND_LIBRARY( FBX_LIBRARY ${FBX_LIBNAME}
|
||||
PATHS ${FBX_SEARCH_PATHS}
|
||||
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
|
||||
|
||||
FIND_LIBRARY( FBX_LIBRARY_DEBUG ${FBX_LIBNAME_DEBUG}
|
||||
PATHS ${FBX_SEARCH_PATHS}
|
||||
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
|
||||
IF(FBX_LIBRARY AND FBX_LIBRARY_DEBUG AND FBX_INCLUDE_DIR)
|
||||
SET(FBX_FOUND "YES")
|
||||
ELSE()
|
||||
SET(FBX_FOUND "NO")
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
|
||||
|
||||
#In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
|
||||
#In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg
|
||||
#In OSG ffmpeg plugin, we used "#include <header.h>" for compatibility with old version of ffmpeg
|
||||
#With the new version of FFmpeg, a file named "time.h" was added that breaks compatability with the old version of ffmpeg.
|
||||
|
||||
#We have to search the path which contain the header.h (usefull for old version)
|
||||
#and search the path which contain the libname/header.h (usefull for new version)
|
||||
@@ -131,20 +132,17 @@ IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODE
|
||||
SET(FFMPEG_FOUND "YES")
|
||||
|
||||
SET(FFMPEG_INCLUDE_DIRS
|
||||
${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat
|
||||
${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice
|
||||
${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec
|
||||
${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavutil
|
||||
${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
|
||||
${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}
|
||||
${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
|
||||
${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Using the new include style for FFmpeg prevents issues with #include <time.h>
|
||||
IF (FFMPEG_STDINT_INCLUDE_DIR)
|
||||
SET(FFMPEG_INCLUDE_DIRS
|
||||
${FFMPEG_INCLUDE_DIRS}
|
||||
${FFMPEG_STDINT_INCLUDE_DIR}
|
||||
${FFMPEG_STDINT_INCLUDE_DIR}/libavformat
|
||||
${FFMPEG_STDINT_INCLUDE_DIR}/libavdevice
|
||||
${FFMPEG_STDINT_INCLUDE_DIR}/libavcodec
|
||||
${FFMPEG_STDINT_INCLUDE_DIR}/libavutil
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
|
||||
56
CMakeModules/FindGTA.cmake
Normal file
56
CMakeModules/FindGTA.cmake
Normal file
@@ -0,0 +1,56 @@
|
||||
# Locate libgta
|
||||
# This module defines
|
||||
# GTA_FOUND, if false, do not try to link to libgta
|
||||
# GTA_INCLUDE_DIRS, where to find the headers
|
||||
# GTA_LIBRARIES
|
||||
#
|
||||
# $GTA_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$GTA_DIR
|
||||
# used in building libgta.
|
||||
|
||||
INCLUDE(FindPkgConfig OPTIONAL)
|
||||
|
||||
IF(PKG_CONFIG_FOUND)
|
||||
|
||||
INCLUDE(FindPkgConfig)
|
||||
|
||||
PKG_CHECK_MODULES(GTA gta)
|
||||
|
||||
ELSE(PKG_CONFIG_FOUND)
|
||||
|
||||
FIND_PATH(GTA_INCLUDE_DIRS gta/gta.hpp
|
||||
$ENV{GTA_DIR}/include
|
||||
$ENV{GTA_DIR}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/sw/include # Fink
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include # Blastwave
|
||||
/opt/include
|
||||
/usr/freeware/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(GTA_LIBRARIES
|
||||
NAMES gta libgta
|
||||
PATHS
|
||||
$ENV{GTA_DIR}/lib
|
||||
$ENV{GTA_DIR}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
SET(GTA_FOUND "NO")
|
||||
IF(GTA_LIBRARIES AND GTA_INCLUDE_DIRS)
|
||||
SET(GTA_FOUND "YES")
|
||||
ENDIF(GTA_LIBRARIES AND GTA_INCLUDE_DIRS)
|
||||
|
||||
ENDIF(PKG_CONFIG_FOUND)
|
||||
@@ -15,6 +15,7 @@ FIND_PATH(NVTT_INCLUDE_DIR nvtt/nvtt.h
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
# NVTT
|
||||
FIND_LIBRARY(NVTT_LIBRARY
|
||||
NAMES nvtt
|
||||
PATHS
|
||||
@@ -25,6 +26,17 @@ FIND_LIBRARY(NVTT_LIBRARY
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
|
||||
FIND_LIBRARY(NVTT_LIBRARY_DEBUG
|
||||
NAMES nvtt_d
|
||||
PATHS
|
||||
/usr/local
|
||||
/usr
|
||||
$ENV{NVTT_DIR}
|
||||
${3rdPartyRoot}
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
|
||||
# NVIMAGE
|
||||
FIND_LIBRARY(NVIMAGE_LIBRARY
|
||||
NAMES nvimage
|
||||
PATHS
|
||||
@@ -35,6 +47,17 @@ FIND_LIBRARY(NVIMAGE_LIBRARY
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
|
||||
FIND_LIBRARY(NVIMAGE_LIBRARY_DEBUG
|
||||
NAMES nvimage_d
|
||||
PATHS
|
||||
/usr/local
|
||||
/usr
|
||||
$ENV{NVTT_DIR}
|
||||
${3rdPartyRoot}
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
|
||||
# NVMATH
|
||||
FIND_LIBRARY(NVMATH_LIBRARY
|
||||
NAMES nvmath
|
||||
PATHS
|
||||
@@ -45,6 +68,17 @@ FIND_LIBRARY(NVMATH_LIBRARY
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
|
||||
FIND_LIBRARY(NVMATH_LIBRARY_DEBUG
|
||||
NAMES nvmath_d
|
||||
PATHS
|
||||
/usr/local
|
||||
/usr
|
||||
$ENV{NVTT_DIR}
|
||||
${3rdPartyRoot}
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
|
||||
# NVCORE
|
||||
FIND_LIBRARY(NVCORE_LIBRARY
|
||||
NAMES nvcore
|
||||
PATHS
|
||||
@@ -54,6 +88,18 @@ FIND_LIBRARY(NVCORE_LIBRARY
|
||||
${3rdPartyRoot}
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
FIND_LIBRARY(NVCORE_LIBRARY_DEBUG
|
||||
NAMES nvcore_d
|
||||
PATHS
|
||||
/usr/local
|
||||
/usr
|
||||
$ENV{NVTT_DIR}
|
||||
${3rdPartyRoot}
|
||||
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
SET(NVTT_FOUND "NO")
|
||||
IF(NVTT_LIBRARY AND NVTT_INCLUDE_DIR)
|
||||
|
||||
@@ -96,12 +96,17 @@ MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
|
||||
IF( NOT ${MYLIBRARY}_DEBUG)
|
||||
IF(MYLIBRARY)
|
||||
SET(${MYLIBRARY}_DEBUG ${MYLIBRARY})
|
||||
ENDIF(MYLIBRARY)
|
||||
ENDIF( NOT ${MYLIBRARY}_DEBUG)
|
||||
ENDIF(MYLIBRARY)
|
||||
ELSE()
|
||||
IF( NOT MYLIBRARY )
|
||||
SET(${MYLIBRARY} ${${MYLIBRARY}_DEBUG} )
|
||||
ENDIF(NOT MYLIBRARY)
|
||||
|
||||
ENDIF( NOT ${MYLIBRARY}_DEBUG )
|
||||
|
||||
ENDMACRO(FIND_OSG_LIBRARY LIBRARY LIBRARYNAME)
|
||||
|
||||
@@ -111,12 +116,20 @@ FIND_OSG_LIBRARY(OSGUTIL_LIBRARY osgUtil)
|
||||
FIND_OSG_LIBRARY(OSGDB_LIBRARY osgDB)
|
||||
FIND_OSG_LIBRARY(OSGTEXT_LIBRARY osgText)
|
||||
FIND_OSG_LIBRARY(OSGWIDGET_LIBRARY osgWidget)
|
||||
FIND_OSG_LIBRARY(OSGQT_LIBRARY osgQt)
|
||||
FIND_OSG_LIBRARY(OSGTERRAIN_LIBRARY osgTerrain)
|
||||
FIND_OSG_LIBRARY(OSGFX_LIBRARY osgFX)
|
||||
FIND_OSG_LIBRARY(OSGVIEWER_LIBRARY osgViewer)
|
||||
FIND_OSG_LIBRARY(OSGVOLUME_LIBRARY osgVolume)
|
||||
FIND_OSG_LIBRARY(OSGMANIPULATOR_LIBRARY osgManipulator)
|
||||
FIND_OSG_LIBRARY(OSGANIMATION_LIBRARY osgAnimation)
|
||||
FIND_OSG_LIBRARY(OSGPARTICLE_LIBRARY osgParticle)
|
||||
FIND_OSG_LIBRARY(OSGSHADOW_LIBRARY osgShadow)
|
||||
FIND_OSG_LIBRARY(OSGPRESENTATION_LIBRARY osgPresentation)
|
||||
FIND_OSG_LIBRARY(OSGSIM osgSim)
|
||||
FIND_OSG_LIBRARY(OPENTHREADS_LIBRARY OpenThreads)
|
||||
|
||||
|
||||
SET(OSG_FOUND "NO")
|
||||
IF(OSG_LIBRARY AND OSG_INCLUDE_DIR)
|
||||
SET(OSG_FOUND "YES")
|
||||
|
||||
23
CMakeModules/FindQuartzCore.cmake
Normal file
23
CMakeModules/FindQuartzCore.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
# Locate Apple QuartzCore
|
||||
# This module defines
|
||||
# QUARTZCORE_LIBRARY
|
||||
# QUARTZCORE_FOUND, if false, do not try to link to QUARTZCORE
|
||||
# QUARTZCORE_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# $QUARTZCORE_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$QUARTZCORE_DIR
|
||||
#
|
||||
# Created by Stephan Maximilian Huber.
|
||||
|
||||
|
||||
IF(APPLE)
|
||||
FIND_PATH(QUARTZCORE_INCLUDE_DIR QuartzCore/QuartzCore.h)
|
||||
FIND_LIBRARY(QUARTZCORE_LIBRARY QuartzCore)
|
||||
ENDIF()
|
||||
|
||||
|
||||
SET(QUARTZCORE_FOUND "NO")
|
||||
IF(QUARTZCORE_LIBRARY AND QUARTZCORE_INCLUDE_DIR)
|
||||
SET(QUARTZCORE_FOUND "YES")
|
||||
ENDIF()
|
||||
|
||||
@@ -49,18 +49,24 @@ ENDIF()
|
||||
|
||||
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
|
||||
SET(QUICKTIME_FOUND "NO")
|
||||
ENDIF()
|
||||
|
||||
IF(APPLE)
|
||||
#Quicktime is not supported under 64bit OSX build so we need to detect it and disable it.
|
||||
#First check to see if we are running with a native 64-bit compiler (10.6 default) and implicit arch
|
||||
IF(NOT CMAKE_OSX_ARCHITECTURES AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
SET(QUICKTIME_FOUND "NO")
|
||||
ELSE()
|
||||
#Otherwise check to see if 64-bit is explicitly called for.
|
||||
LIST(FIND CMAKE_OSX_ARCHITECTURES "x86_64" has64Compile)
|
||||
IF(NOT has64Compile EQUAL -1)
|
||||
SET(QUICKTIME_FOUND "NO")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ELSE()
|
||||
IF(APPLE)
|
||||
#Quicktime is not supported under 64bit OSX build so we need to detect it and disable it.
|
||||
#First check to see if we are running with a native 64-bit compiler (10.6 default) and implicit arch
|
||||
IF(NOT CMAKE_OSX_ARCHITECTURES AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
SET(QUICKTIME_FOUND "NO")
|
||||
ELSE()
|
||||
#Otherwise check to see if 64-bit is explicitly called for.
|
||||
LIST(FIND CMAKE_OSX_ARCHITECTURES "x86_64" has64Compile)
|
||||
IF(NOT has64Compile EQUAL -1)
|
||||
SET(QUICKTIME_FOUND "NO")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
# Disable quicktime for >= 10.7, as it's officially deprecated
|
||||
|
||||
IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.9")
|
||||
MESSAGE("disabling quicktime because it's not supported by the selected SDK ${OSG_OSX_SDK_NAME}")
|
||||
SET(QUICKTIME_FOUND "NO")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
47
CMakeModules/FindZeroConf.cmake
Executable file
47
CMakeModules/FindZeroConf.cmake
Executable file
@@ -0,0 +1,47 @@
|
||||
# Locate ZeroConf / Bonjour
|
||||
# This module defines
|
||||
# ZEROCONF_LIBRARY
|
||||
# ZEROCONF_FOUND, if false, do not try to link to gdal
|
||||
# ZEROCONF_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# $ZEROCONF_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$ZEROCONF_DIR
|
||||
|
||||
# Created by Stephan Maximilian Huber
|
||||
|
||||
SET(ZEROCONF_FOUND "NO")
|
||||
|
||||
IF(APPLE)
|
||||
# bonjour is part of the system on os x / ios
|
||||
SET(ZEROCONF_FOUND "YES")
|
||||
ELSE()
|
||||
IF(WIN32)
|
||||
# find the Bonjour SDK
|
||||
FIND_PATH(ZEROCONF_INCLUDE_DIR dnssd.h
|
||||
$ENV{ZEROCONF_DIR}/include
|
||||
$ENV{ZEROCONF_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
FIND_PATH(ZEROCONF_INCLUDE_DIR dnssd.h
|
||||
PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
|
||||
NO_DEFAULT_PATH
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
FIND_PATH(ZEROCONF_INCLUDE_DIR dnssd.h)
|
||||
|
||||
FIND_LIBRARY(ZEROCONF_LIBRARY dnssd
|
||||
PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
|
||||
NO_DEFAULT_PATH
|
||||
PATH_SUFFIXES lib64 lib
|
||||
)
|
||||
FIND_LIBRARY(ZEROCONF_LIBRARY dnssd)
|
||||
|
||||
SET(ZEROCONF_FOUND "NO")
|
||||
IF(ZEROCONF_LIBRARY AND ZEROCONF_INCLUDE_DIR)
|
||||
SET(ZEROCONF_FOUND "YES")
|
||||
ENDIF()
|
||||
|
||||
ELSE()
|
||||
# TODO find AVAHI on linux
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@@ -1,12 +1,15 @@
|
||||
MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
|
||||
|
||||
foreach(arg ${TARGET_LIBRARIES})
|
||||
set(MODULE_LIBS "${MODULE_LIBS} -l${arg}")
|
||||
endforeach(arg ${TARGET_LIBRARIES})
|
||||
#foreach(arg ${TARGET_LIBRARIES})
|
||||
# set(MODULE_LIBS "${MODULE_LIBS} -l${arg}")
|
||||
#endforeach(arg ${TARGET_LIBRARIES})
|
||||
|
||||
foreach(arg ${TARGET_SRC})
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" n_f ${arg})
|
||||
set(MODULE_SOURCES "${MODULE_SOURCES} ${n_f}")
|
||||
IF ("${arg}" MATCHES ".*\\.c$" OR "${arg}" MATCHES ".*\\.cpp$")
|
||||
#We only include source files, not header files, this removes anoying warnings
|
||||
set(MODULE_SOURCES "${MODULE_SOURCES} ${n_f}")
|
||||
ENDIF()
|
||||
endforeach(arg ${TARGET_SRC})
|
||||
|
||||
#SET(MODULE_INCLUDES "${CMAKE_SOURCE_DIR}/include include")
|
||||
@@ -35,7 +38,8 @@ MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
|
||||
ELSEIF(OSG_GLES2_AVAILABLE)
|
||||
SET(OPENGLES_LIBRARY -lGLESv2)
|
||||
ENDIF()
|
||||
set(MODULE_LIBS "${MODULE_LIBS} ${OPENGLES_LIBRARY} -ldl")
|
||||
#${MODULE_LIBS}
|
||||
set(MODULE_LIBS_FLAGS "${OPENGLES_LIBRARY} -ldl")
|
||||
if(NOT CPP_EXTENSION)
|
||||
set(CPP_EXTENSION "cpp")
|
||||
endif()
|
||||
@@ -44,8 +48,12 @@ MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
|
||||
ENDIF()
|
||||
IF("MODULE_USER_STATIC_OR_DYNAMIC" MATCHES "STATIC")
|
||||
SET(MODULE_BUILD_TYPE "\$\(BUILD_STATIC_LIBRARY\)")
|
||||
SET(MODULE_LIBS_SHARED " ")
|
||||
SET(MODULE_LIBS_STATIC ${TARGET_LIBRARIES})
|
||||
ELSE()
|
||||
SET(MODULE_BUILD_TYPE "\$\(BUILD_DYNAMIC_LIBRARY\)")
|
||||
SET(MODULE_BUILD_TYPE "\$\(BUILD_SHARED_LIBRARY\)")
|
||||
SET(MODULE_LIBS_SHARED ${TARGET_LIBRARIES})
|
||||
SET(MODULE_LIBS_STATIC " ")
|
||||
ENDIF()
|
||||
set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} ${LIB_NAME}")
|
||||
set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${CMAKE_CURRENT_BINARY_DIR}/Android.mk \n")
|
||||
|
||||
@@ -1,27 +1,36 @@
|
||||
#ANDROID makefile ${MODULE_NAME}
|
||||
#ANDROID makefile ${MODULE_NAME}
|
||||
|
||||
LOCAL_PATH := ${MODULE_DIR}
|
||||
LOCAL_PATH := ${MODULE_DIR}
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
LOCAL_ARM_NEON := true
|
||||
ifeq (${ANDROID_OPTIM_NEON},true)
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
LOCAL_ARM_NEON := true
|
||||
endif
|
||||
endif
|
||||
|
||||
LOCAL_CPP_EXTENSION := ${CPP_EXTENSION}
|
||||
ifeq (${ANDROID_OPTIM_ARM32},true)
|
||||
LOCAL_ARM_MODE := arm
|
||||
endif
|
||||
|
||||
LOCAL_LDLIBS := ${MODULE_LIBS}
|
||||
|
||||
LOCAL_MODULE := ${MODULE_NAME}
|
||||
LOCAL_CPP_EXTENSION := ${CPP_EXTENSION}
|
||||
|
||||
LOCAL_SRC_FILES := ${MODULE_SOURCES}
|
||||
LOCAL_LDLIBS := ${MODULE_LIBS_FLAGS}
|
||||
|
||||
LOCAL_C_INCLUDES := ${MODULE_INCLUDES}
|
||||
LOCAL_MODULE := ${MODULE_NAME}
|
||||
|
||||
LOCAL_CFLAGS := ${MODULE_FLAGS_C}
|
||||
LOCAL_SRC_FILES := ${MODULE_SOURCES}
|
||||
|
||||
LOCAL_CPPFLAGS := ${MODULE_FLAGS_CPP}
|
||||
LOCAL_C_INCLUDES := ${MODULE_INCLUDES}
|
||||
|
||||
LOCAL_CFLAGS := ${MODULE_FLAGS_C}
|
||||
|
||||
LOCAL_CPPFLAGS := ${MODULE_FLAGS_CPP}
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := ${MODULE_LIBS_SHARED}
|
||||
LOCAL_STATIC_LIBRARIES := ${MODULE_LIBS_STATIC}
|
||||
|
||||
#include $(BUILD_STATIC_LIBRARY)
|
||||
include ${MODULE_BUILD_TYPE}
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
package="com.openscenegraph"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
</manifest>
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
APP_BUILD_SCRIPT := $(call my-dir)/Android.mk
|
||||
APP_PROJECT_PATH := $(call my-dir)
|
||||
|
||||
APP_OPTIM := release
|
||||
APP_OPTIM := ${ANDROID_RELEASE_OPTIM}
|
||||
|
||||
APP_PLATFORM := android-5
|
||||
APP_STL := gnustl_static
|
||||
APP_PLATFORM := ${ANDROID_PLATFORM}
|
||||
APP_STL := ${ANDROID_STL}
|
||||
APP_CPPFLAGS := -fexceptions -frtti
|
||||
#APP_CPPFLAGS := -Os -mthumb-interwork -fno-short-enums
|
||||
#APP_CPPFLAGS := -Wl,--no-undefined
|
||||
|
||||
APP_ABI := armeabi armeabi-v7a
|
||||
APP_ABI := ${ANDROID_ABI}
|
||||
|
||||
APP_MODULES := $ENV{AND_OSG_LIB_NAMES}
|
||||
|
||||
78
README.txt
78
README.txt
@@ -1,18 +1,14 @@
|
||||
Welcome to the OpenSceneGraph (OSG).
|
||||
|
||||
For up-to-date information on the project, in-depth details on how to
|
||||
compile and run libraries and examples, see the documentation on the
|
||||
For up-to-date information on the project, in-depth details on how to
|
||||
compile and run libraries and examples, see the documentation on the
|
||||
OpenSceneGraph website:
|
||||
|
||||
http://www.openscenegraph.org
|
||||
|
||||
For support subscribe to our public mailing list:
|
||||
http://www.openscenegraph.org/index.php/documentation
|
||||
|
||||
http://www.openscenegraph.org/projects/osg/wiki/MailingLists
|
||||
For support subscribe to our public mailing list or forum, details at:
|
||||
|
||||
or forum:
|
||||
|
||||
http://forum.openscenegraph.org/
|
||||
http://www.openscenegraph.org/index.php/support
|
||||
|
||||
For the impatient, we've included quick build instructions below, these
|
||||
are are broken down is three parts:
|
||||
@@ -27,41 +23,41 @@ more indepth instructions.
|
||||
|
||||
Robert Osfield.
|
||||
Project Lead.
|
||||
28th June 2011.
|
||||
24th July 2013.
|
||||
|
||||
--
|
||||
|
||||
Section 1. How to build the OpenSceneGraph
|
||||
==========================================
|
||||
|
||||
The OpenSceneGraph uses the CMake build system to generate a
|
||||
platform-specific build environment. CMake reads the CMakeLists.txt
|
||||
files that you'll find throughout the OpenSceneGraph directories,
|
||||
checks for installed dependenciesand then generates the appropriate
|
||||
The OpenSceneGraph uses the CMake build system to generate a
|
||||
platform-specific build environment. CMake reads the CMakeLists.txt
|
||||
files that you'll find throughout the OpenSceneGraph directories,
|
||||
checks for installed dependenciesand then generates the appropriate
|
||||
build system.
|
||||
|
||||
If you don't already have CMake installed on your system you can grab
|
||||
it from http://www.cmake.org, use version 2.4.6 or later. Details on the
|
||||
If you don't already have CMake installed on your system you can grab
|
||||
it from http://www.cmake.org, use version 2.4.6 or later. Details on the
|
||||
OpenSceneGraph's CMake build can be found at:
|
||||
|
||||
http://www.openscenegraph.org/projects/osg/wiki/Build/CMake
|
||||
|
||||
Under unices (i.e. Linux, IRIX, Solaris, Free-BSD, HP-Ux, AIX, OSX)
|
||||
use the cmake or ccmake command-line utils, or use the included tiny
|
||||
configure script that'll run cmake for you. The configure script
|
||||
simply runs 'cmake . -DCMAKE_BUILD_TYPE=Release' to ensure that you
|
||||
Under unices (i.e. Linux, IRIX, Solaris, Free-BSD, HP-Ux, AIX, OSX)
|
||||
use the cmake or ccmake command-line utils, or use the included tiny
|
||||
configure script that'll run cmake for you. The configure script
|
||||
simply runs 'cmake . -DCMAKE_BUILD_TYPE=Release' to ensure that you
|
||||
get the best performance from your final libraries/applications.
|
||||
|
||||
|
||||
cd OpenSceneGraph
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Alternatively, you can create an out-of-source build directory and run
|
||||
cmake or ccmake from there. The advantage to this approach is that the
|
||||
temporary files created by CMake won't clutter the OpenSceneGraph
|
||||
source directory, and also makes it possible to have multiple
|
||||
independent build targets by creating multiple build directories. In a
|
||||
|
||||
Alternatively, you can create an out-of-source build directory and run
|
||||
cmake or ccmake from there. The advantage to this approach is that the
|
||||
temporary files created by CMake won't clutter the OpenSceneGraph
|
||||
source directory, and also makes it possible to have multiple
|
||||
independent build targets by creating multiple build directories. In a
|
||||
directory alongside the OpenSceneGraph use:
|
||||
|
||||
mkdir build
|
||||
@@ -70,22 +66,22 @@ directory alongside the OpenSceneGraph use:
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Under Windows use the GUI tool CMakeSetup to build your VisualStudio
|
||||
files. The following page on our wiki dedicated to the CMake build
|
||||
Under Windows use the GUI tool CMakeSetup to build your VisualStudio
|
||||
files. The following page on our wiki dedicated to the CMake build
|
||||
system should help guide you through the process:
|
||||
|
||||
http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio
|
||||
http://www.openscenegraph.org/index.php/documentation/platform-specifics/windows
|
||||
|
||||
Under OSX you can either use the CMake build system above, or use the
|
||||
Xcode projects that you will find in the OpenSceneGraph/Xcode
|
||||
Under OSX you can either use the CMake build system above, or use the
|
||||
Xcode projects that you will find in the OpenSceneGraph/Xcode
|
||||
directory. See release notes on OSX CMake build below.
|
||||
|
||||
For further details on compilation, installation and platform-specific
|
||||
For further details on compilation, installation and platform-specific
|
||||
information read "Getting Started" guide:
|
||||
|
||||
http://www.openscenegraph.org/projects/osg/wiki/Support/GettingStarted
|
||||
|
||||
|
||||
http://www.openscenegraph.org/index.php/documentation/10-getting-started
|
||||
|
||||
|
||||
Section 2. Release notes on OSX build, by Eric Sokolowsky, August 5, 2008
|
||||
=========================================================================
|
||||
|
||||
@@ -169,11 +165,11 @@ Section 3. Release notes on iOS build, by Thomas Hoghart
|
||||
* Check that CMAKE_OSX_ARCHITECTURE is i386 for the simulator or armv6;armv7 for the device
|
||||
* Disable DYNAMIC_OPENSCENEGRAPH, DYNAMIC_OPENTHREADS
|
||||
This will give us the static build we need for iPhone.
|
||||
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE,
|
||||
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE,
|
||||
OSG_GL_DISPLAYLISTS_AVAILABLE, OSG_GL_VERTEX_FUNCS_AVAILABLE
|
||||
* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE
|
||||
* Ensure OSG_WINDOWING_SYSTEM is set to IOS
|
||||
* Change FREETYPE include and library paths to an iPhone version
|
||||
* Change FREETYPE include and library paths to an iPhone version
|
||||
(OpenFrameworks has one bundled with its distribution)
|
||||
* Ensure that CMake_OSX_SYSROOT points to your iOS SDK.
|
||||
* Generate the Xcode project
|
||||
@@ -206,9 +202,9 @@ $ cmake -G Xcode \
|
||||
|
||||
|
||||
Known issues:
|
||||
* When Linking final app against ive plugin, you need to add -lz to
|
||||
* When Linking final app against ive plugin, you need to add -lz to
|
||||
the 'Other linker flags' list.
|
||||
* Apps and exes don't get created
|
||||
* You can only select Simulator, or Device projects. In the XCode
|
||||
project you will see both types but the sdk they link will
|
||||
* You can only select Simulator, or Device projects. In the XCode
|
||||
project you will see both types but the sdk they link will
|
||||
be the same.
|
||||
|
||||
@@ -29,7 +29,7 @@ int main( int argc, char **argv )
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of seperate files into a single archive file that can be later read in OSG applications..");
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of separate files into a single archive file that can be later read in OSG applications..");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
|
||||
// if user request help write it out to cout.
|
||||
@@ -139,7 +139,15 @@ int main( int argc, char **argv )
|
||||
if (obj.valid())
|
||||
{
|
||||
std::cout<<" write to archive "<<*itr<<std::endl;
|
||||
archive->writeObject(*obj, *itr);
|
||||
osg::Image* image = dynamic_cast<osg::Image*>(obj.get());
|
||||
osg::HeightField* hf = dynamic_cast<osg::HeightField*>(obj.get());
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(obj.get());
|
||||
osg::Shader* shader = dynamic_cast<osg::Shader*>(obj.get());
|
||||
if (image) archive->writeImage(*image, *itr);
|
||||
else if (hf) archive->writeHeightField(*hf, *itr);
|
||||
else if (node) archive->writeNode(*node, *itr);
|
||||
else if (shader) archive->writeShader(*shader, *itr);
|
||||
else archive->writeObject(*obj, *itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ class MyGraphicsContext {
|
||||
if (!_gc)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl;
|
||||
|
||||
|
||||
traits->pbuffer = false;
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
}
|
||||
|
||||
if (_gc.valid())
|
||||
if (_gc.valid())
|
||||
{
|
||||
_gc->realize();
|
||||
_gc->makeCurrent();
|
||||
@@ -70,9 +70,9 @@ class MyGraphicsContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool valid() const { return _gc.valid() && _gc->isRealized(); }
|
||||
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::GraphicsContext> _gc;
|
||||
};
|
||||
@@ -95,8 +95,7 @@ public:
|
||||
{
|
||||
osg::ref_ptr< osg::Vec3Array > newnormals = new osg::Vec3Array;
|
||||
newnormals->push_back( osg::Z_AXIS );
|
||||
geometry->setNormalArray( newnormals.get() );
|
||||
geometry->setNormalBinding( osg::Geometry::BIND_OVERALL );
|
||||
geometry->setNormalArray( newnormals.get(), osg::Array::BIND_OVERALL );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,20 +120,20 @@ public:
|
||||
if (node.getStateSet()) apply(*node.getStateSet());
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
|
||||
virtual void apply(osg::Geode& node)
|
||||
{
|
||||
if (node.getStateSet()) apply(*node.getStateSet());
|
||||
|
||||
|
||||
for(unsigned int i=0;i<node.getNumDrawables();++i)
|
||||
{
|
||||
osg::Drawable* drawable = node.getDrawable(i);
|
||||
if (drawable && drawable->getStateSet()) apply(*drawable->getStateSet());
|
||||
}
|
||||
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
|
||||
virtual void apply(osg::StateSet& stateset)
|
||||
{
|
||||
// search for the existence of any texture object attributes
|
||||
@@ -147,7 +146,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void compress()
|
||||
{
|
||||
MyGraphicsContext context;
|
||||
@@ -164,21 +163,21 @@ public:
|
||||
++itr)
|
||||
{
|
||||
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());
|
||||
|
||||
|
||||
osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
|
||||
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
|
||||
if (image.valid() &&
|
||||
if (image.valid() &&
|
||||
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
|
||||
(image->s()>=32 && image->t()>=32))
|
||||
{
|
||||
texture->setInternalFormatMode(_internalFormatMode);
|
||||
|
||||
|
||||
// need to disable the unref after apply, other the image could go out of scope.
|
||||
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
|
||||
texture->setUnRefImageDataAfterApply(false);
|
||||
|
||||
|
||||
// get OpenGL driver to create texture from image.
|
||||
texture->apply(*state);
|
||||
|
||||
@@ -199,10 +198,10 @@ public:
|
||||
++itr)
|
||||
{
|
||||
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());
|
||||
|
||||
|
||||
osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
|
||||
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
|
||||
if (image.valid())
|
||||
{
|
||||
@@ -215,11 +214,11 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef std::set< osg::ref_ptr<osg::Texture> > TextureSet;
|
||||
TextureSet _textureSet;
|
||||
osg::Texture::InternalFormatMode _internalFormatMode;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -243,7 +242,7 @@ public:
|
||||
{
|
||||
std::cout<<"Running FixTransparencyVisitor..."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
~FixTransparencyVisitor()
|
||||
{
|
||||
std::cout<<" Number of Transparent StateSet "<<_numTransparent<<std::endl;
|
||||
@@ -256,20 +255,20 @@ public:
|
||||
if (node.getStateSet()) isTransparent(*node.getStateSet());
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
|
||||
virtual void apply(osg::Geode& node)
|
||||
{
|
||||
if (node.getStateSet()) isTransparent(*node.getStateSet());
|
||||
|
||||
|
||||
for(unsigned int i=0;i<node.getNumDrawables();++i)
|
||||
{
|
||||
osg::Drawable* drawable = node.getDrawable(i);
|
||||
if (drawable && drawable->getStateSet()) isTransparent(*drawable->getStateSet());
|
||||
}
|
||||
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
|
||||
virtual bool isTransparent(osg::StateSet& stateset)
|
||||
{
|
||||
bool hasTranslucentTexture = false;
|
||||
@@ -289,15 +288,15 @@ public:
|
||||
for (unsigned int im=0;im<texture->getNumImages();++im)
|
||||
{
|
||||
osg::Image* image = texture->getImage(im);
|
||||
if (image && image->isImageTranslucent()) hasTranslucentTexture = true;
|
||||
if (image && image->isImageTranslucent()) hasTranslucentTexture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hasTranslucentTexture || hasBlendFunc || hasTransparentRenderingHint || hasDepthSortBin)
|
||||
{
|
||||
++_numTransparent;
|
||||
|
||||
|
||||
bool makeNonTransparent = false;
|
||||
|
||||
switch(_mode)
|
||||
@@ -315,7 +314,7 @@ public:
|
||||
makeNonTransparent = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (makeNonTransparent)
|
||||
{
|
||||
stateset.removeAttribute(osg::StateAttribute::BLENDFUNC);
|
||||
@@ -335,7 +334,7 @@ public:
|
||||
}
|
||||
|
||||
unsigned int _numTransparent;
|
||||
unsigned int _numOpaque;
|
||||
unsigned int _numOpaque;
|
||||
unsigned int _numTransparentMadeOpaque;
|
||||
FixTransparencyMode _mode;
|
||||
};
|
||||
@@ -350,7 +349,7 @@ public:
|
||||
{
|
||||
std::cout<<"Running PruneStateSet..."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
~PruneStateSetVisitor()
|
||||
{
|
||||
std::cout<<" Number of StateState removed "<<_numStateSetRemoved<<std::endl;
|
||||
@@ -365,7 +364,7 @@ public:
|
||||
}
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
|
||||
virtual void apply(osg::Geode& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
@@ -373,7 +372,7 @@ public:
|
||||
node.setStateSet(0);
|
||||
++_numStateSetRemoved;
|
||||
}
|
||||
|
||||
|
||||
for(unsigned int i=0;i<node.getNumDrawables();++i)
|
||||
{
|
||||
osg::Drawable* drawable = node.getDrawable(i);
|
||||
@@ -383,10 +382,10 @@ public:
|
||||
++_numStateSetRemoved;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
|
||||
unsigned int _numStateSetRemoved;
|
||||
};
|
||||
|
||||
@@ -408,8 +407,7 @@ public:
|
||||
{
|
||||
osg::Vec4Array* colours = new osg::Vec4Array(1);
|
||||
(*colours)[0].set(1.0f,1.0f,1.0f,1.0f);
|
||||
geometry->setColorArray(colours);
|
||||
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geometry->setColorArray(colours, osg::Array::BIND_OVERALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -545,7 +543,7 @@ int main( int argc, char **argv )
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a utility for converting between various input and output databases formats.");
|
||||
@@ -558,18 +556,18 @@ int main( int argc, char **argv )
|
||||
|
||||
// if user request help write it out to cout.
|
||||
if (arguments.read("-h") || arguments.read("--help"))
|
||||
{
|
||||
{
|
||||
usage( arguments.getApplicationName().c_str(), 0 );
|
||||
//arguments.getApplicationUsage()->write(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.read("--help-env"))
|
||||
{
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout, osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.read("--plugins"))
|
||||
{
|
||||
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
|
||||
@@ -580,23 +578,23 @@ int main( int argc, char **argv )
|
||||
std::cout<<"Plugin "<<*itr<<std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string plugin;
|
||||
if (arguments.read("--plugin", plugin))
|
||||
{
|
||||
osgDB::outputPluginDetails(std::cout, plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string ext;
|
||||
if (arguments.read("--format", ext))
|
||||
{
|
||||
plugin = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
|
||||
osgDB::outputPluginDetails(std::cout, plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (arguments.read("--formats"))
|
||||
{
|
||||
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
|
||||
@@ -607,8 +605,8 @@ int main( int argc, char **argv )
|
||||
osgDB::outputPluginDetails(std::cout,*itr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (arguments.argc()<=1)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||
@@ -637,7 +635,7 @@ int main( int argc, char **argv )
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
|
||||
osgDB::Registry::instance()->loadLibrary(libName);
|
||||
}
|
||||
|
||||
|
||||
std::string libName;
|
||||
while (arguments.read("-l",libName))
|
||||
{
|
||||
@@ -672,7 +670,7 @@ int main( int argc, char **argv )
|
||||
oc.setRotation( from, to );
|
||||
do_convert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (arguments.read("-s",str))
|
||||
{
|
||||
@@ -717,7 +715,7 @@ int main( int argc, char **argv )
|
||||
do_convert = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FixTransparencyVisitor::FixTransparencyMode fixTransparencyMode = FixTransparencyVisitor::NO_TRANSPARANCY_FIXING;
|
||||
std::string fixString;
|
||||
while(arguments.read("--fix-transparency")) fixTransparencyMode = FixTransparencyVisitor::MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE;
|
||||
@@ -726,7 +724,7 @@ int main( int argc, char **argv )
|
||||
if (fixString=="MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE") fixTransparencyMode = FixTransparencyVisitor::MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE;
|
||||
if (fixString=="MAKE_ALL_STATESET_OPAQUE") fixTransparencyMode = FixTransparencyVisitor::MAKE_ALL_STATESET_OPAQUE;
|
||||
};
|
||||
|
||||
|
||||
bool pruneStateSet = false;
|
||||
while(arguments.read("--prune-StateSet")) pruneStateSet = true;
|
||||
|
||||
@@ -739,7 +737,7 @@ int main( int argc, char **argv )
|
||||
|
||||
bool smooth = false;
|
||||
while(arguments.read("--smooth")) { smooth = true; }
|
||||
|
||||
|
||||
bool addMissingColours = false;
|
||||
while(arguments.read("--addMissingColours") || arguments.read("--addMissingColors")) { addMissingColours = true; }
|
||||
|
||||
@@ -805,13 +803,13 @@ int main( int argc, char **argv )
|
||||
|
||||
if ( root.valid() )
|
||||
{
|
||||
|
||||
|
||||
if (smooth)
|
||||
{
|
||||
osgUtil::SmoothingVisitor sv;
|
||||
root->accept(sv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (addMissingColours)
|
||||
{
|
||||
AddMissingColoursToGeometryVisitor av;
|
||||
@@ -821,10 +819,10 @@ int main( int argc, char **argv )
|
||||
// optimize the scene graph, remove rendundent nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(root.get());
|
||||
|
||||
|
||||
if( do_convert )
|
||||
root = oc.convert( root.get() );
|
||||
|
||||
|
||||
if (internalFormatMode != osg::Texture::USE_IMAGE_DATA_FORMAT)
|
||||
{
|
||||
std::string ext = osgDB::getFileExtension(fileNameOut);
|
||||
|
||||
@@ -130,40 +130,6 @@ struct Extents
|
||||
osg::Vec2d _max;
|
||||
};
|
||||
|
||||
class CheckValidVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
CheckValidVisitor():
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_numInvalidGeometries(0) {}
|
||||
|
||||
void apply(osg::Geode& geode)
|
||||
{
|
||||
unsigned int local_numInvalidGeometries = 0;
|
||||
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
|
||||
{
|
||||
osg::Geometry* geometry = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
|
||||
if (geometry)
|
||||
{
|
||||
if (!geometry->verifyArrays(_errorReports)) ++local_numInvalidGeometries;
|
||||
}
|
||||
}
|
||||
if (local_numInvalidGeometries)
|
||||
{
|
||||
_errorReports<<"Geode "<<geode.getName()<<" contains problem geometries"<<std::endl;
|
||||
_numInvalidGeometries += local_numInvalidGeometries;
|
||||
}
|
||||
}
|
||||
|
||||
bool valid() const { return _numInvalidGeometries==0; }
|
||||
|
||||
unsigned int _numInvalidGeometries;
|
||||
std::stringstream _errorReports;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LoadDataVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
@@ -309,7 +275,7 @@ public:
|
||||
osg::Node* readNodeFileAndWriteToCache(const std::string& filename)
|
||||
{
|
||||
osg::Node* node = 0;
|
||||
if (_fileCache.valid() && osgDB::containsServerAddress(filename))
|
||||
if (_fileCache.valid() )
|
||||
{
|
||||
if (_fileCache->existsInCache(filename))
|
||||
{
|
||||
@@ -334,17 +300,6 @@ public:
|
||||
osg::notify(osg::NOTICE)<<"reading : "<<filename<<std::endl;
|
||||
node = osgDB::readNodeFile(filename);
|
||||
}
|
||||
|
||||
if (node)
|
||||
{
|
||||
CheckValidVisitor cvv;
|
||||
node->accept(cvv);
|
||||
if (!cvv.valid())
|
||||
{
|
||||
OSG_NOTICE<<"Warning, errors in geometry found in file "<<filename<<std::endl;
|
||||
OSG_NOTICE<<cvv._errorReports.str()<<std::endl;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -451,7 +406,7 @@ int main( int argc, char **argv )
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of seperate files into a single archive file that can be later read in OSG applications..");
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of separate files into a single archive file that can be later read in OSG applications..");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-l level","Read down to level across the whole database.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-e level minX minY maxX maxY","Read down to <level> across the extents minX, minY to maxY, maxY. Note, for geocentric datase X and Y are longitude and latitude respectively.");
|
||||
|
||||
@@ -122,6 +122,7 @@ const char* invalidNames[] =
|
||||
"LineStipple",
|
||||
"Logos",
|
||||
"LongIDRecord",
|
||||
"InputIterator",
|
||||
"Make",
|
||||
"Makefile",
|
||||
"Material",
|
||||
@@ -247,7 +248,13 @@ const char* invalidNames[] =
|
||||
"UpdateSkeleton",
|
||||
"Vec3",
|
||||
"Plugin",
|
||||
"Get"
|
||||
"Get",
|
||||
"LightSource",
|
||||
"SlideEventHandler",
|
||||
"GraphicsContext*",
|
||||
"Apple",
|
||||
"GeometryNew",
|
||||
"FrameBufferObject"
|
||||
};
|
||||
|
||||
|
||||
@@ -259,6 +266,7 @@ struct TypoCorrection
|
||||
|
||||
TypoCorrection typoCorrections[] =
|
||||
{
|
||||
{"Cheaev", "Chebaev"},
|
||||
{"Alaxandre", "Alexandre"},
|
||||
{"Aderian", "Adrian"},
|
||||
{"Adndre", "Andre"},
|
||||
@@ -268,6 +276,7 @@ TypoCorrection typoCorrections[] =
|
||||
{"André", "Andr<EFBFBD>"},
|
||||
{"Antione", "Antoine"},
|
||||
{"Antonoine", "Antoine"},
|
||||
{"Aurelein", "Aurelien"},
|
||||
{"Atr", "Art"},
|
||||
{"Baverage", "Beverage"},
|
||||
{"Bistroviae", "Bistrovic"},
|
||||
@@ -286,6 +295,7 @@ TypoCorrection typoCorrections[] =
|
||||
{"Fabian", "Fabien"},
|
||||
{"Fautre", "Fautr<EFBFBD>"},
|
||||
{"Frashid", "Farshid"},
|
||||
{"Farshild", "Farshid"},
|
||||
{"Fred", "Frederic"},
|
||||
{"Fredrick", "Frederic"},
|
||||
{"Fredric", "Frederic"},
|
||||
@@ -311,6 +321,8 @@ TypoCorrection typoCorrections[] =
|
||||
{"Happalahti", "Haapalahti"},
|
||||
{"Hertlien", "Hertlein"},
|
||||
{"Hatwig", "Hartwig"},
|
||||
{"Hauknes", "Haukness"},
|
||||
{"Hunber", "Huber"},
|
||||
{"Hi", "He"},
|
||||
{"Hooper", "Hopper"},
|
||||
{"Inverson", "Iverson"},
|
||||
@@ -380,6 +392,7 @@ TypoCorrection typoCorrections[] =
|
||||
{"Oritz", "Ortiz"},
|
||||
{"Osfeld", "Osfield"},
|
||||
{"Osfied", "Osfield"},
|
||||
{"Paulk", "Paul"},
|
||||
{"Pail", "Paul"},
|
||||
{"Perciva", "Peciva"},
|
||||
{"Pecvia", "Peciva"},
|
||||
@@ -440,7 +453,8 @@ TypoCorrection typoCorrections[] =
|
||||
{"Jahannes","Johannes"},
|
||||
{"Eskland","Ekstrand"},
|
||||
{"Baeuerele","Baeuerle"},
|
||||
{"Bauerle","Baeuerle"}
|
||||
{"Bauerle","Baeuerle"},
|
||||
{"Baeurele","Baeuerle"}
|
||||
};
|
||||
|
||||
|
||||
@@ -454,16 +468,28 @@ struct NameCorrection
|
||||
|
||||
NameCorrection nameCorrections[] =
|
||||
{
|
||||
{"FrancoisTigeot","",
|
||||
"Francois", "Tigeot"},
|
||||
{"Juan","Manuel",
|
||||
"Juan", "Manuel Alvarez"},
|
||||
{"Jaap","Gas",
|
||||
"Jaap", "Glas"},
|
||||
{"Philip","Lamp",
|
||||
"Philip", "Lamb"},
|
||||
{"Dimi","Christop",
|
||||
"Dimi", "Christopoulos"},
|
||||
{"Jorge","Ciges",
|
||||
"Jorge", "Izquierdo"},
|
||||
"Jorge", "Izquierdo Ciges"},
|
||||
{"Jorge","Izquierdo",
|
||||
"Jorge", "Izquierdo Ciges"},
|
||||
{"Rafa","Gata",
|
||||
"Rafa", "Gaitan"},
|
||||
{"Sukender","I",
|
||||
"Sukender", ""},
|
||||
{"Sukender","Here",
|
||||
"Sukender", ""},
|
||||
{"Sukender","Fix",
|
||||
"Sukender", ""},
|
||||
{"Ewe","Woessner",
|
||||
"Uwe", "Woessner"},
|
||||
{"Martin","von",
|
||||
@@ -478,6 +504,8 @@ NameCorrection nameCorrections[] =
|
||||
"Thomas", "Hogarth"},
|
||||
{"Marin", "Lavery",
|
||||
"Martin", "Lavery"},
|
||||
{"Michael", "Bach",
|
||||
"Michael", "Bach Jensen"},
|
||||
{"Nguyen", "Van",
|
||||
"Nguyen", "Van Truong"},
|
||||
{"Thom", "Carlo",
|
||||
@@ -568,6 +596,8 @@ NameCorrection nameCorrections[] =
|
||||
"Romano", "Jos<EFBFBD> Magacho da Silva"},
|
||||
{"Leandro", "Motta",
|
||||
"Leandro", "Motta Barros"},
|
||||
{"Leandro", "Motto",
|
||||
"Leandro", "Motta Barros"},
|
||||
{"A", "Botorabi",
|
||||
"Ali", "Botorabi"},
|
||||
{"Waltice", "",
|
||||
@@ -584,6 +614,8 @@ NameCorrection nameCorrections[] =
|
||||
"Luc", "Frauciel"},
|
||||
{"Alberto", "Lucas",
|
||||
"Alberto", "Luaces"},
|
||||
{"Alberto", "Luacus",
|
||||
"Alberto", "Luaces"},
|
||||
{"Tyge", "",
|
||||
"Tyge", "L<EFBFBD>vset"},
|
||||
{"Ricard", "Schmidt",
|
||||
|
||||
@@ -28,8 +28,116 @@
|
||||
#include <osgGA/TerrainManipulator>
|
||||
#include <osgGA/SphericalManipulator>
|
||||
|
||||
#include <osgGA/Device>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <osg/GLExtensions>
|
||||
|
||||
#ifndef GL_ARB_sync
|
||||
#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
|
||||
#define GL_OBJECT_TYPE 0x9112
|
||||
#define GL_SYNC_CONDITION 0x9113
|
||||
#define GL_SYNC_STATUS 0x9114
|
||||
#define GL_SYNC_FLAGS 0x9115
|
||||
#define GL_SYNC_FENCE 0x9116
|
||||
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
|
||||
#define GL_UNSIGNALED 0x9118
|
||||
#define GL_SIGNALED 0x9119
|
||||
#define GL_ALREADY_SIGNALED 0x911A
|
||||
#define GL_TIMEOUT_EXPIRED 0x911B
|
||||
#define GL_CONDITION_SATISFIED 0x911C
|
||||
#define GL_WAIT_FAILED 0x911D
|
||||
#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
|
||||
#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
|
||||
#endif
|
||||
|
||||
class MySwapBuffersCallback : public osg::GraphicsContext::SwapCallback
|
||||
{
|
||||
public:
|
||||
MySwapBuffersCallback():
|
||||
_extensionInitialized(false),
|
||||
_glFenceSync(0),
|
||||
_glIsSync(0),
|
||||
_glDeleteSync(0),
|
||||
_glClientWaitSync(0),
|
||||
_glWaitSync(0),
|
||||
_glGetInteger64v(0),
|
||||
_glGetSynciv(0),
|
||||
_previousSync(0)
|
||||
{
|
||||
OSG_NOTICE<<"Created Swap callback."<<std::endl;
|
||||
}
|
||||
|
||||
void setUpExtensions()
|
||||
{
|
||||
_extensionInitialized = true;
|
||||
osg::setGLExtensionFuncPtr(_glFenceSync, "glFenceSync");
|
||||
osg::setGLExtensionFuncPtr(_glIsSync, "glIsSync");
|
||||
osg::setGLExtensionFuncPtr(_glDeleteSync, "glDeleteSync");
|
||||
osg::setGLExtensionFuncPtr(_glClientWaitSync, "glClientWaitSync");
|
||||
osg::setGLExtensionFuncPtr(_glWaitSync, "glWaitSync");
|
||||
osg::setGLExtensionFuncPtr(_glGetInteger64v, "glGetInteger64v");
|
||||
osg::setGLExtensionFuncPtr(_glGetSynciv, "glGetSynciv");
|
||||
}
|
||||
|
||||
virtual void swapBuffersImplementation(osg::GraphicsContext* gc)
|
||||
{
|
||||
// OSG_NOTICE<<"Before swap - place to do swap ready sync"<<std::endl;
|
||||
gc->swapBuffersImplementation();
|
||||
//glFinish();
|
||||
|
||||
if (!_extensionInitialized) setUpExtensions();
|
||||
|
||||
if (_glClientWaitSync)
|
||||
{
|
||||
if (_previousSync)
|
||||
{
|
||||
unsigned int num_seconds = 1;
|
||||
GLuint64 timeout = num_seconds * ((GLuint64)1000 * 1000 * 1000);
|
||||
_glClientWaitSync(_previousSync, 0, timeout);
|
||||
|
||||
_glDeleteSync(_previousSync);
|
||||
}
|
||||
|
||||
_previousSync = _glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
//gc->getState()->checkGLErrors("after glWaitSync");
|
||||
|
||||
//OSG_NOTICE<<"After swap"<<std::endl;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef __int64 GLint64;
|
||||
typedef unsigned __int64 GLuint64;
|
||||
#else
|
||||
typedef int64_t GLint64;
|
||||
typedef uint64_t GLuint64;
|
||||
#endif
|
||||
|
||||
typedef struct __GLsync *GLsync;
|
||||
|
||||
typedef GLsync (GL_APIENTRY * PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);
|
||||
typedef GLboolean (GL_APIENTRY * PFNGLISSYNCPROC) (GLsync sync);
|
||||
typedef void (GL_APIENTRY * PFNGLDELETESYNCPROC) (GLsync sync);
|
||||
typedef GLenum (GL_APIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
typedef void (GL_APIENTRY * PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
typedef void (GL_APIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params);
|
||||
typedef void (GL_APIENTRY * PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
|
||||
|
||||
bool _extensionInitialized;
|
||||
|
||||
PFNGLFENCESYNCPROC _glFenceSync;
|
||||
PFNGLISSYNCPROC _glIsSync;
|
||||
PFNGLDELETESYNCPROC _glDeleteSync;
|
||||
PFNGLCLIENTWAITSYNCPROC _glClientWaitSync;
|
||||
PFNGLWAITSYNCPROC _glWaitSync;
|
||||
PFNGLGETINTEGER64VPROC _glGetInteger64v;
|
||||
PFNGLGETSYNCIVPROC _glGetSynciv;
|
||||
|
||||
GLsync _previousSync;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
@@ -41,6 +149,9 @@ int main(int argc, char** argv)
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Play specified camera path animation file, previously saved with 'z' key.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--speed <factor>","Speed factor for animation playing (1 == normal speed).");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--device <device-name>","add named device to the viewer");
|
||||
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
@@ -76,6 +187,16 @@ int main(int argc, char** argv)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
std::string device;
|
||||
while(arguments.read("--device", device))
|
||||
{
|
||||
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device);
|
||||
if (dev.valid())
|
||||
{
|
||||
viewer.addDevice(dev.get());
|
||||
}
|
||||
}
|
||||
|
||||
// set up the camera manipulators.
|
||||
{
|
||||
@@ -110,6 +231,8 @@ int main(int argc, char** argv)
|
||||
viewer.setCameraManipulator( keyswitchManipulator.get() );
|
||||
}
|
||||
|
||||
bool doArbSync = arguments.read("--sync");
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
|
||||
@@ -161,6 +284,18 @@ int main(int argc, char** argv)
|
||||
|
||||
viewer.realize();
|
||||
|
||||
if (doArbSync)
|
||||
{
|
||||
osgViewer::ViewerBase::Contexts contexts;
|
||||
viewer.getContexts(contexts);
|
||||
for(osgViewer::ViewerBase::Contexts::iterator itr = contexts.begin();
|
||||
itr != contexts.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setSwapCallback(new MySwapBuffersCallback);
|
||||
}
|
||||
}
|
||||
|
||||
return viewer.run();
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#if defined(__linux)
|
||||
#include <unistd.h>
|
||||
#include <linux/sockios.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <unistd.h>
|
||||
#include <sys/sockio.h>
|
||||
#elif defined(__sgi)
|
||||
@@ -240,7 +240,7 @@ void CameraPacket::readEventQueue(osgViewer::Viewer& viewer)
|
||||
|
||||
void CameraPacket::writeEventQueue(osgViewer::Viewer& viewer)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"recieved events = "<<_events.size()<<std::endl;
|
||||
osg::notify(osg::INFO)<<"received events = "<<_events.size()<<std::endl;
|
||||
|
||||
// copy the events to osgProducer style events.
|
||||
viewer.getEventQueue()->appendEvents(_events);
|
||||
@@ -336,7 +336,8 @@ void Receiver::sync( void )
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(__linux) || defined(__FreeBSD__) || defined( __APPLE__ )
|
||||
#if defined(__linux) || defined(__FreeBSD__) || defined( __APPLE__ ) || \
|
||||
defined(__DragonFly__)
|
||||
socklen_t
|
||||
#else
|
||||
int
|
||||
|
||||
@@ -251,8 +251,12 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
|
||||
|
||||
if(node)
|
||||
{
|
||||
|
||||
if (node->getName().empty()) node->setName( arguments[pos] );
|
||||
nodeList.push_back(node);
|
||||
|
||||
// make sure that this presentation isn't cached
|
||||
osgDB::Registry::instance()->removeFromObjectCache( arguments[pos] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <OpenThreads/Thread>
|
||||
|
||||
#include <osgGA/GUIEventHandler>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
@@ -127,89 +128,64 @@ void setViewer(osgViewer::Viewer& viewer, float width, float height, float dista
|
||||
// double hfov = osg::RadiansToDegrees(atan2(width/2.0f,distance)*2.0);
|
||||
|
||||
viewer.getCamera()->setProjectionMatrixAsPerspective( vfov, width/height, 0.1, 1000.0);
|
||||
|
||||
OSG_NOTICE<<"setProjectionMatrixAsPerspective( "<<vfov<<", "<<width/height<<", "<<0.1<<", "<<1000.0<<");"<<std::endl;
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
||||
class RayFollowsMouseCallback : public osg::Drawable::EventCallback
|
||||
{
|
||||
RayFollowsMouseCallback() {}
|
||||
|
||||
/** do customized Event code. */
|
||||
virtual void event(osg::NodeVisitor* nv, osg::Drawable* drawable)
|
||||
class ForwardToDeviceEventHandler : public osgGA::GUIEventHandler {
|
||||
public:
|
||||
ForwardToDeviceEventHandler(osgGA::Device* device) : osgGA::GUIEventHandler(), _device(device) {}
|
||||
|
||||
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
|
||||
{
|
||||
osg::Geometry* geometry = drawable->asGeometry();
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
|
||||
if (!ev || !geometry) return;
|
||||
|
||||
osgGA::GUIActionAdapter* aa = ev->getActionAdapter();
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(aa);
|
||||
if (!view) return;
|
||||
|
||||
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray());
|
||||
if (!vertices) return;
|
||||
|
||||
osg::Camera* camera = view->getCamera();
|
||||
osg::Matrix VP = camera->getViewMatrix() * camera->getProjectionMatrix();
|
||||
|
||||
osg::Matrix inverse_VP;
|
||||
inverse_VP.invert(VP);
|
||||
|
||||
osgGA::EventQueue::Events& events = ev->getEvents();
|
||||
for(osgGA::EventQueue::Events::iterator itr = events.begin();
|
||||
itr != events.end();
|
||||
++itr)
|
||||
{
|
||||
handle(inverse_VP, *(*itr), vertices);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void handle(const osg::Matrix& inverse_VP, osgGA::GUIEventAdapter& ea, osg::Vec3Array* vertices)
|
||||
{
|
||||
osg::Vec3d start_eye(ea.getXnormalized(), ea.getYnormalized(), 0.0);
|
||||
osg::Vec3d end_eye(ea.getXnormalized(), ea.getYnormalized(), 1.0);
|
||||
|
||||
osg::Vec3d start_world = start_eye * inverse_VP;
|
||||
osg::Vec3d end_world = start_eye * inverse_VP;
|
||||
|
||||
osg::notify(osg::NOTICE)<<"start_world="<<start_world<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"end_world="<<end_world<<std::endl;
|
||||
|
||||
(*vertices)[0] = start_world;
|
||||
(*vertices)[1] = end_world;
|
||||
OSG_INFO<<"ForwardToDeviceEventHandler::setEvent("<<ea.getKey()<<")"<<std::endl;
|
||||
_device->sendEvent(ea);
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osgGA::Device> _device;
|
||||
};
|
||||
|
||||
|
||||
class FollowMouseCallback: public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
FollowMouseCallback():
|
||||
_mousePostition(0.5,0.5) {}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
|
||||
{
|
||||
osg::AutoTransform* transform = dynamic_cast<osg::AutoTransform*>(object);
|
||||
if (!transform) return false;
|
||||
|
||||
osg::NotifySeverity level = osg::INFO;
|
||||
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::PUSH):
|
||||
case(osgGA::GUIEventAdapter::RELEASE):
|
||||
case(osgGA::GUIEventAdapter::MOVE):
|
||||
case(osgGA::GUIEventAdapter::DRAG):
|
||||
|
||||
osg::notify(level)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;
|
||||
osg::notify(level)<<"ea.getWindowWidth()="<<ea.getWindowWidth()<<std::endl;
|
||||
osg::notify(level)<<"ea.getWindowHeight()="<<ea.getWindowHeight()<<std::endl;
|
||||
osg::notify(level)<<"ea.getX()="<<ea.getX()<<std::endl;
|
||||
osg::notify(level)<<"ea.getXin()="<<ea.getXmin()<<std::endl;
|
||||
osg::notify(level)<<"ea.getXmax()="<<ea.getXmax()<<std::endl;
|
||||
osg::notify(level)<<"ea.getY()="<<ea.getY()<<std::endl;
|
||||
osg::notify(level)<<"ea.getYin()="<<ea.getYmin()<<std::endl;
|
||||
osg::notify(level)<<"ea.getYmax()="<<ea.getYmax()<<std::endl;
|
||||
|
||||
_mousePostition.set(ea.getXnormalized(), ea.getYnormalized());
|
||||
break;
|
||||
|
||||
case(osgGA::GUIEventAdapter::FRAME):
|
||||
//case(osgGA::GUIEventAdapter::MOVE):
|
||||
//case(osgGA::GUIEventAdapter::DRAG):
|
||||
{
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
|
||||
|
||||
transform->setNodeMask(0x0);
|
||||
|
||||
osg::notify(osg::NOTICE)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getWindowWidth()="<<ea.getWindowWidth()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getWindowHeight()="<<ea.getWindowHeight()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getX()="<<ea.getX()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getXin()="<<ea.getXmin()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getXmax()="<<ea.getXmax()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getY()="<<ea.getY()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getYin()="<<ea.getYmin()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"ea.getYmax()="<<ea.getYmax()<<std::endl;
|
||||
|
||||
osg::Camera* camera = view->getCamera();
|
||||
osg::Matrix VP = camera->getViewMatrix() * camera->getProjectionMatrix();
|
||||
@@ -217,18 +193,20 @@ class FollowMouseCallback: public osgGA::GUIEventHandler
|
||||
osg::Matrix inverse_VP;
|
||||
inverse_VP.invert(VP);
|
||||
|
||||
osg::Vec3d start_eye(ea.getXnormalized(), ea.getYnormalized(), 0.0);
|
||||
osg::Vec3d end_eye(ea.getXnormalized(), ea.getYnormalized(), 1.0);
|
||||
osg::Vec3d start_eye(_mousePostition.x(), _mousePostition.y(), 0.0);
|
||||
osg::Vec3d end_eye(_mousePostition.x(), _mousePostition.y(), 1.0);
|
||||
|
||||
osg::Vec3d start_world = start_eye * inverse_VP;
|
||||
osg::Vec3d end_world = start_eye * inverse_VP;
|
||||
|
||||
osg::notify(osg::NOTICE)<<"start_world="<<start_world<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"end_world="<<end_world<<std::endl;
|
||||
osg::notify(level)<<"start_world="<<start_world<<std::endl;
|
||||
osg::notify(level)<<"end_world="<<end_world<<std::endl;
|
||||
|
||||
transform->setPosition(end_world);
|
||||
|
||||
transform->setNodeMask(0xffffffff);
|
||||
if (end_world.valid()) transform->setPosition(end_world);
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"Ignoring invalid end_world position"<<std::endl;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -258,6 +236,7 @@ class FollowMouseCallback: public osgGA::GUIEventHandler
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
osg::Vec2d _mousePostition;
|
||||
};
|
||||
|
||||
osg::Node* createCursorSubgraph(const std::string& filename, float size)
|
||||
@@ -267,13 +246,14 @@ osg::Node* createCursorSubgraph(const std::string& filename, float size)
|
||||
size = 20.0f;
|
||||
|
||||
osg::Geometry* geom = osg::createTexturedQuadGeometry(osg::Vec3(-size*0.5f,-size*0.5f,0.0f),osg::Vec3(size,0.0f,0.0f),osg::Vec3(0.0f,size,0.0f));
|
||||
geom->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
|
||||
osg::Image* image = osgDB::readImageFile(osgDB::findDataFile(filename));
|
||||
if (image)
|
||||
{
|
||||
osg::StateSet* stateset = geom->getOrCreateStateSet();
|
||||
stateset->setTextureAttributeAndModes(0, new osg::Texture2D(image),osg::StateAttribute::ON);
|
||||
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||
stateset->setTextureAttributeAndModes(0, new osg::Texture2D(image),osg::StateAttribute::ON|osg::StateAttribute::PROTECTED);
|
||||
stateset->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::PROTECTED);
|
||||
// stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||
stateset->setRenderBinDetails(1000, "DepthSortedBin");
|
||||
}
|
||||
@@ -291,101 +271,6 @@ osg::Node* createCursorSubgraph(const std::string& filename, float size)
|
||||
return transform;
|
||||
|
||||
}
|
||||
#else
|
||||
class FollowMouseCallback: public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object* object, osg::NodeVisitor*)
|
||||
{
|
||||
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::MOVE):
|
||||
case(osgGA::GUIEventAdapter::DRAG):
|
||||
{
|
||||
osg::Camera* camera = dynamic_cast<osg::Camera*>(object);
|
||||
if (camera)
|
||||
{
|
||||
double x = ea.getXnormalized();
|
||||
double y = ea.getYnormalized();
|
||||
|
||||
camera->setViewMatrix(osg::Matrixd::translate(x,y,0.0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey()=='c')
|
||||
{
|
||||
osg::Camera* camera = dynamic_cast<osg::Camera*>(object);
|
||||
if (camera)
|
||||
{
|
||||
for(unsigned int i=0; i< camera->getNumChildren(); ++i)
|
||||
{
|
||||
osg::Node* node = camera->getChild(i);
|
||||
node->setNodeMask(
|
||||
node->getNodeMask()!=0 ?
|
||||
0 :
|
||||
0xffffff);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void accept(osgGA::GUIEventHandlerVisitor& v)
|
||||
{
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
osg::Node* createCursorSubgraph(const std::string& filename, float size)
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
|
||||
osg::Geometry* geom = osg::createTexturedQuadGeometry(osg::Vec3(-size*0.5f,-size*0.5f,0.0f),osg::Vec3(size,0.0f,0.0f),osg::Vec3(0.0f,size,0.0f));
|
||||
|
||||
osg::Image* image = osgDB::readImageFile(osgDB::findDataFile(filename));
|
||||
if (image)
|
||||
{
|
||||
osg::StateSet* stateset = geom->getOrCreateStateSet();
|
||||
stateset->setTextureAttributeAndModes(0, new osg::Texture2D(image),osg::StateAttribute::ON);
|
||||
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||
stateset->setRenderBinDetails(1000, "DepthSortedBin");
|
||||
}
|
||||
|
||||
geode->addDrawable(geom);
|
||||
|
||||
osg::Camera* camera = new osg::Camera;
|
||||
|
||||
// set the projection matrix
|
||||
camera->setProjectionMatrix(osg::Matrix::ortho2D(-1,1,-1,1));
|
||||
|
||||
// set the view matrix
|
||||
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
camera->setViewMatrix(osg::Matrix::identity());
|
||||
|
||||
// only clear the depth buffer
|
||||
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// draw subgraph after main camera view.
|
||||
camera->setRenderOrder(osg::CameraNode::NESTED_RENDER);
|
||||
|
||||
camera->addChild(geode);
|
||||
|
||||
camera->setEventCallback(new FollowMouseCallback());
|
||||
|
||||
return camera;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
enum P3DApplicationType
|
||||
@@ -396,6 +281,47 @@ enum P3DApplicationType
|
||||
};
|
||||
|
||||
|
||||
void processLoadedModel(osg::ref_ptr<osg::Node>& loadedModel, int optimizer_options, const std::string& cursorFileName)
|
||||
{
|
||||
if (!loadedModel) return;
|
||||
|
||||
#if !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||
|
||||
// add back in enabling of the GL_ALPHA_TEST to get around the core OSG no longer setting it by default for opaque bins.
|
||||
// the alpha test is required for the volume rendering alpha clipping to work.
|
||||
loadedModel->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
|
||||
#endif
|
||||
|
||||
// optimize the scene graph, remove rendundent nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get(), optimizer_options);
|
||||
|
||||
if (!cursorFileName.empty())
|
||||
{
|
||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||
group->addChild(loadedModel.get());
|
||||
group->addChild(createCursorSubgraph(cursorFileName, 0.05f));
|
||||
loadedModel = group;
|
||||
}
|
||||
}
|
||||
|
||||
void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name)
|
||||
{
|
||||
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device_name);
|
||||
if (dev.valid())
|
||||
{
|
||||
OSG_INFO << "Adding Device : " << device_name << std::endl;
|
||||
viewer.addDevice(dev.get());
|
||||
|
||||
if (dev->getCapabilities() & osgGA::Device::SEND_EVENTS)
|
||||
viewer.getEventHandlers().push_front(new ForwardToDeviceEventHandler(dev.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN << "could not open device: " << device_name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
@@ -442,6 +368,21 @@ int main( int argc, char **argv )
|
||||
osg::DisplaySettings::instance()->readEnvironmentalVariables();
|
||||
}
|
||||
|
||||
// set up any logins required for http access
|
||||
std::string url, username, password;
|
||||
while(arguments.read("--login",url, username, password))
|
||||
{
|
||||
if (!osgDB::Registry::instance()->getAuthenticationMap())
|
||||
{
|
||||
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
|
||||
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
|
||||
url,
|
||||
new osgDB::AuthenticationDetails(username, password)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef USE_SDL
|
||||
SDLIntegration sdlIntegration;
|
||||
@@ -509,6 +450,45 @@ int main( int argc, char **argv )
|
||||
viewer.readConfiguration(configurationFile);
|
||||
doSetViewer = false;
|
||||
}
|
||||
|
||||
const char* p3dDevice = getenv("P3D_DEVICE");
|
||||
if (p3dDevice)
|
||||
{
|
||||
osgDB::StringList devices;
|
||||
osgDB::split(p3dDevice, devices);
|
||||
for(osgDB::StringList::iterator i = devices.begin(); i != devices.end(); ++i)
|
||||
{
|
||||
addDeviceTo(viewer, *i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string device;
|
||||
while (arguments.read("--device", device))
|
||||
{
|
||||
addDeviceTo(viewer, device);
|
||||
|
||||
}
|
||||
|
||||
if (arguments.read("--http-control"))
|
||||
{
|
||||
|
||||
std::string server_address = "localhost";
|
||||
std::string server_port = "8080";
|
||||
std::string document_root = "htdocs";
|
||||
|
||||
while (arguments.read("--http-server-address", server_address)) {}
|
||||
while (arguments.read("--http-server-port", server_port)) {}
|
||||
while (arguments.read("--http-document-root", document_root)) {}
|
||||
|
||||
osg::ref_ptr<osgDB::Options> device_options = new osgDB::Options("documentRegisteredHandlers");
|
||||
|
||||
osg::ref_ptr<osgGA::Device> rest_http_device = osgDB::readFile<osgGA::Device>(server_address+":"+server_port+"/"+document_root+".resthttp", device_options.get());
|
||||
if (rest_http_device.valid())
|
||||
{
|
||||
viewer.addDevice(rest_http_device.get());
|
||||
}
|
||||
}
|
||||
|
||||
// set up stereo masks
|
||||
viewer.getCamera()->setCullMask(0xffffffff);
|
||||
@@ -542,7 +522,9 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
osg::ref_ptr<osgGA::StateSetManipulator> ssManipulator = new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet());
|
||||
ssManipulator->setKeyEventToggleTexturing('e');
|
||||
viewer.addEventHandler( ssManipulator.get() );
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgViewer::StatsHandler() );
|
||||
@@ -557,10 +539,19 @@ int main( int argc, char **argv )
|
||||
std::string cursorFileName( p3dCursor ? p3dCursor : "");
|
||||
while (arguments.read("--cursor",cursorFileName)) {}
|
||||
|
||||
const char* p3dShowCursor = getenv("P3D_SHOW_CURSOR");
|
||||
std::string showCursor( p3dShowCursor ? p3dShowCursor : "YES");
|
||||
while (arguments.read("--show-cursor")) { showCursor="YES"; }
|
||||
while (arguments.read("--hide-cursor")) { showCursor="NO"; }
|
||||
|
||||
bool hideCursor = (showCursor=="No" || showCursor=="NO" || showCursor=="no");
|
||||
|
||||
while (arguments.read("--set-viewer")) { doSetViewer = true; }
|
||||
|
||||
while (arguments.read("--no-set-viewer")) { doSetViewer = false; }
|
||||
|
||||
// if we want to hide the cursor override the custom cursor.
|
||||
if (hideCursor) cursorFileName.clear();
|
||||
|
||||
|
||||
// cluster related entries.
|
||||
@@ -589,10 +580,29 @@ int main( int argc, char **argv )
|
||||
bool loopPresentation = false;
|
||||
while (arguments.read("--loop")) loopPresentation = true;
|
||||
|
||||
{
|
||||
// set update hte default traversal mode settings for update visitor
|
||||
// default to osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN.
|
||||
osg::NodeVisitor::TraversalMode updateTraversalMode = osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN; // viewer.getUpdateVisitor()->getTraversalMode();
|
||||
|
||||
const char* p3dUpdateStr = getenv("P3D_UPDATE");
|
||||
if (p3dUpdateStr)
|
||||
{
|
||||
std::string updateStr(p3dUpdateStr);
|
||||
if (updateStr=="active" || updateStr=="Active" || updateStr=="ACTIVE") updateTraversalMode = osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN;
|
||||
else if (updateStr=="all" || updateStr=="All" || updateStr=="ALL") updateTraversalMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN;
|
||||
}
|
||||
|
||||
while(arguments.read("--update-active")) updateTraversalMode = osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN;
|
||||
while(arguments.read("--update-all")) updateTraversalMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN;
|
||||
|
||||
viewer.getUpdateVisitor()->setTraversalMode(updateTraversalMode);
|
||||
}
|
||||
|
||||
|
||||
// register the slide event handler - which moves the presentation from slide to slide, layer to layer.
|
||||
osgPresentation::SlideEventHandler* seh = new osgPresentation::SlideEventHandler(&viewer);
|
||||
viewer.addEventHandler(seh);
|
||||
osg::ref_ptr<osgPresentation::SlideEventHandler> seh = new osgPresentation::SlideEventHandler(&viewer);
|
||||
viewer.addEventHandler(seh.get());
|
||||
|
||||
seh->setAutoSteppingActive(autoSteppingActive);
|
||||
seh->setTimeDelayBetweenSlides(timeDelayBetweenSlides);
|
||||
@@ -628,9 +638,20 @@ int main( int argc, char **argv )
|
||||
// osgDB::Registry::instance()->getOrCreateDatabasePager()->setExpiryDelay(1.0f);
|
||||
|
||||
// register the handler for modifying the point size
|
||||
PointsEventHandler* peh = new PointsEventHandler;
|
||||
viewer.addEventHandler(peh);
|
||||
|
||||
osg::ref_ptr<PointsEventHandler> peh = new PointsEventHandler;
|
||||
viewer.addEventHandler(peh.get());
|
||||
|
||||
// add the screen capture handler
|
||||
std::string screenCaptureFilename = "screen_shot.jpg";
|
||||
while(arguments.read("--screenshot", screenCaptureFilename)) {}
|
||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler::WriteToFile> writeFile = new osgViewer::ScreenCaptureHandler::WriteToFile(
|
||||
osgDB::getNameLessExtension(screenCaptureFilename),
|
||||
osgDB::getFileExtension(screenCaptureFilename) );
|
||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler = new osgViewer::ScreenCaptureHandler(writeFile.get());
|
||||
screenCaptureHandler->setKeyEventTakeScreenShot('m');//osgGA::GUIEventAdapter::KEY_Print);
|
||||
screenCaptureHandler->setKeyEventToggleContinuousCapture('M');
|
||||
viewer.addEventHandler(screenCaptureHandler.get());
|
||||
|
||||
// osg::DisplaySettings::instance()->setSplitStereoAutoAjustAspectRatio(false);
|
||||
|
||||
float width = osg::DisplaySettings::instance()->getScreenWidth();
|
||||
@@ -789,26 +810,7 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
|
||||
#if !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||
|
||||
// add back in enabling of the GL_ALPHA_TEST to get around the core OSG no longer setting it by default for opaque bins.
|
||||
// the alpha test is required for the volume rendering alpha clipping to work.
|
||||
loadedModel->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
|
||||
#endif
|
||||
|
||||
|
||||
// optimize the scene graph, remove rendundent nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get(), optimizer_options);
|
||||
|
||||
if (!cursorFileName.empty())
|
||||
{
|
||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||
group->addChild(loadedModel.get());
|
||||
group->addChild(createCursorSubgraph(cursorFileName, 0.05f));
|
||||
|
||||
loadedModel = group.get();
|
||||
}
|
||||
processLoadedModel(loadedModel, optimizer_options, cursorFileName);
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(loadedModel.get());
|
||||
@@ -827,7 +829,23 @@ int main( int argc, char **argv )
|
||||
viewerInitialized = true;
|
||||
}
|
||||
|
||||
if (!cursorFileName.empty())
|
||||
|
||||
|
||||
|
||||
// pass the model to the slide event handler so it knows which to manipulate.
|
||||
seh->set(loadedModel.get());
|
||||
seh->selectSlide(0);
|
||||
|
||||
seh->home();
|
||||
|
||||
if (!outputFileName.empty())
|
||||
{
|
||||
osgDB::writeNodeFile(*loadedModel,outputFileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!cursorFileName.empty() || hideCursor)
|
||||
{
|
||||
// have to add a frame in here to avoid problems with X11 threading issue on switching off the cursor
|
||||
// not yet sure why it makes a difference, but it at least fixes the crash that would otherwise occur
|
||||
@@ -845,18 +863,6 @@ int main( int argc, char **argv )
|
||||
}
|
||||
}
|
||||
|
||||
// pass the model to the slide event handler so it knows which to manipulate.
|
||||
seh->set(loadedModel.get());
|
||||
seh->selectSlide(0);
|
||||
|
||||
seh->home();
|
||||
|
||||
if (!outputFileName.empty())
|
||||
{
|
||||
osgDB::writeNodeFile(*loadedModel,outputFileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
osg::Timer_t startOfFrameTick = osg::Timer::instance()->tick();
|
||||
double targetFrameTime = 1.0/targetFrameRate;
|
||||
|
||||
@@ -944,6 +950,31 @@ int main( int argc, char **argv )
|
||||
// call all node update callbacks and animations.
|
||||
viewer.eventTraversal();
|
||||
|
||||
if (seh->getRequestReload())
|
||||
{
|
||||
OSG_INFO<<"Reload requested"<<std::endl;
|
||||
seh->setRequestReload(false);
|
||||
int previous_ActiveSlide = seh->getActiveSlide();
|
||||
int previous_ActiveLayer = seh->getActiveLayer();
|
||||
|
||||
// reset time so any event key generate
|
||||
|
||||
loadedModel = p3d::readShowFiles(arguments,cacheAllOption.get());
|
||||
processLoadedModel(loadedModel, optimizer_options, cursorFileName);
|
||||
|
||||
if (!loadedModel)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
viewer.setSceneData(loadedModel.get());
|
||||
seh->set(loadedModel.get());
|
||||
seh->selectSlide(previous_ActiveSlide, previous_ActiveLayer);
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// update the scene by traversing it with the the update visitor which will
|
||||
// call all node update callbacks and animations.
|
||||
viewer.updateTraversal();
|
||||
@@ -963,9 +994,9 @@ int main( int argc, char **argv )
|
||||
}
|
||||
else
|
||||
{
|
||||
ExportHTML::write(seh, viewer, exportName);
|
||||
ExportHTML::write(seh.get(), viewer, exportName);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ SHORT_NAMES = YES
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
@@ -76,7 +75,6 @@ GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
@@ -138,7 +136,6 @@ HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER = ${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
|
||||
@@ -31,7 +31,6 @@ SHORT_NAMES = YES
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
@@ -76,7 +75,6 @@ GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
@@ -151,7 +149,6 @@ HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER = ${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
|
||||
@@ -128,13 +128,6 @@ JAVADOC_AUTOBRIEF = NO
|
||||
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
|
||||
# If the DETAILS_AT_TOP tag is set to YES then Doxygen
|
||||
# will output the detailed description near the top, like JavaDoc.
|
||||
# If set to NO, the detailed description appears after the member
|
||||
# documentation.
|
||||
|
||||
DETAILS_AT_TOP = NO
|
||||
|
||||
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
|
||||
# member inherits the documentation from any documented member that it
|
||||
# re-implements.
|
||||
@@ -571,12 +564,6 @@ HTML_FOOTER =
|
||||
|
||||
HTML_STYLESHEET =
|
||||
|
||||
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
|
||||
# files or namespaces will be aligned in HTML using tables. If set to
|
||||
# NO a bullet list will be used.
|
||||
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
|
||||
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
|
||||
# will be generated that can be used as input for tools like the
|
||||
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
|
||||
|
||||
@@ -21,7 +21,6 @@ SHORT_NAMES = YES
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
@@ -66,7 +65,6 @@ GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
@@ -141,7 +139,6 @@ HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER = ${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
|
||||
@@ -66,7 +66,6 @@ GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
@@ -141,7 +140,6 @@ HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER = "${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html"
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
|
||||
@@ -66,7 +66,6 @@ GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
@@ -126,7 +125,6 @@ HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER = "${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html"
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
SET(TARGET_DEFAULT_PREFIX "example_")
|
||||
SET(TARGET_DEFAULT_LABEL_PREFIX "Examples")
|
||||
|
||||
SET(TARGET_COMMON_LIBRARIES
|
||||
SET(TARGET_COMMON_LIBRARIES
|
||||
OpenThreads
|
||||
osg
|
||||
osgDB
|
||||
osg
|
||||
osgDB
|
||||
osgUtil
|
||||
osgGA
|
||||
osgViewer
|
||||
osgText
|
||||
osgViewer
|
||||
osgText
|
||||
)
|
||||
|
||||
IF(ANDROID)
|
||||
@@ -23,6 +23,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osg2cpp)
|
||||
ADD_SUBDIRECTORY(osganalysis)
|
||||
ADD_SUBDIRECTORY(osganimate)
|
||||
ADD_SUBDIRECTORY(osgatomiccounter)
|
||||
ADD_SUBDIRECTORY(osgautocapture)
|
||||
ADD_SUBDIRECTORY(osgautotransform)
|
||||
ADD_SUBDIRECTORY(osgbillboard)
|
||||
@@ -45,9 +46,9 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgfont)
|
||||
ADD_SUBDIRECTORY(osgforest)
|
||||
ADD_SUBDIRECTORY(osgfxbrowser)
|
||||
ADD_SUBDIRECTORY(osgframerenderer)
|
||||
ADD_SUBDIRECTORY(osgoutline)
|
||||
ADD_SUBDIRECTORY(osggameoflife)
|
||||
ADD_SUBDIRECTORY(osggeodemo)
|
||||
ADD_SUBDIRECTORY(osggeometry)
|
||||
ADD_SUBDIRECTORY(osggeometryshaders)
|
||||
ADD_SUBDIRECTORY(osghangglide)
|
||||
@@ -58,6 +59,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgkdtree)
|
||||
ADD_SUBDIRECTORY(osgkeyboard)
|
||||
ADD_SUBDIRECTORY(osgkeyboardmouse)
|
||||
ADD_SUBDIRECTORY(osgkeystone)
|
||||
ADD_SUBDIRECTORY(osglauncher)
|
||||
ADD_SUBDIRECTORY(osglight)
|
||||
ADD_SUBDIRECTORY(osglightpoint)
|
||||
@@ -67,13 +69,16 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osggraphicscost)
|
||||
ADD_SUBDIRECTORY(osgmanipulator)
|
||||
ADD_SUBDIRECTORY(osgmovie)
|
||||
ADD_SUBDIRECTORY(osgmultiplemovies)
|
||||
ADD_SUBDIRECTORY(osgmultiplerendertargets)
|
||||
ADD_SUBDIRECTORY(osgmultitexture)
|
||||
ADD_SUBDIRECTORY(osgmultitexturecontrol)
|
||||
ADD_SUBDIRECTORY(osgmultitouch)
|
||||
ADD_SUBDIRECTORY(osgmultiviewpaging)
|
||||
ADD_SUBDIRECTORY(osgoccluder)
|
||||
ADD_SUBDIRECTORY(osgocclusionquery)
|
||||
ADD_SUBDIRECTORY(osgoit)
|
||||
ADD_SUBDIRECTORY(osgoscdevice)
|
||||
ADD_SUBDIRECTORY(osgpackeddepthstencil)
|
||||
ADD_SUBDIRECTORY(osgpagedlod)
|
||||
ADD_SUBDIRECTORY(osgparametric)
|
||||
@@ -101,6 +106,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgshadow)
|
||||
ADD_SUBDIRECTORY(osgshape)
|
||||
ADD_SUBDIRECTORY(osgsharedarray)
|
||||
ADD_SUBDIRECTORY(osgsimpleshaders)
|
||||
ADD_SUBDIRECTORY(osgsimplifier)
|
||||
ADD_SUBDIRECTORY(osgsimulation)
|
||||
ADD_SUBDIRECTORY(osgsidebyside)
|
||||
@@ -153,6 +159,9 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgwidgetwindow)
|
||||
ADD_SUBDIRECTORY(osguserdata)
|
||||
|
||||
# GL3/GL4 example
|
||||
ADD_SUBDIRECTORY(osgsimplegl3)
|
||||
|
||||
IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(osgunittests)
|
||||
ADD_SUBDIRECTORY(osgmemorytest)
|
||||
@@ -170,6 +179,8 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
|
||||
ADD_SUBDIRECTORY(osgphotoalbum)
|
||||
ADD_SUBDIRECTORY(osgtessellate)
|
||||
ADD_SUBDIRECTORY(osgtessellationshaders)
|
||||
ADD_SUBDIRECTORY(osgcomputeshaders)
|
||||
|
||||
ADD_SUBDIRECTORY(osgpdf)
|
||||
|
||||
@@ -189,34 +200,35 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgviewerFOX)
|
||||
ENDIF(FOX_FOUND)
|
||||
|
||||
IF (wxWidgets_FOUND)
|
||||
ADD_SUBDIRECTORY(osgviewerWX)
|
||||
ENDIF(wxWidgets_FOUND)
|
||||
IF (wxWidgets_FOUND AND CMAKE_BUILD_TYPE)
|
||||
IF (${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
ADD_SUBDIRECTORY(osgviewerWX)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF (QT_FOUND AND NOT OSG_GLES1_AVAILABLE AND NOT OSG_GLES2_AVAILABLE AND NOT OSG_GL3_AVAILABLE)
|
||||
OPTION(BUILD_QT_EXAMPLES "Enable the build of the examples that depend on Qt" ON)
|
||||
IF ( (QT4_FOUND OR Qt5Widgets_FOUND) AND NOT OSG_GLES1_AVAILABLE AND NOT OSG_GLES2_AVAILABLE AND NOT OSG_GL3_AVAILABLE)
|
||||
|
||||
IF (BUILD_QT_EXAMPLES AND QT_QTOPENGL_LIBRARY)
|
||||
IF ( QT4_FOUND OR Qt5Widgets_FOUND)
|
||||
ADD_SUBDIRECTORY(osgviewerQt)
|
||||
ADD_SUBDIRECTORY(osgqfont)
|
||||
ENDIF()
|
||||
|
||||
IF (BUILD_QT_EXAMPLES AND QT4_FOUND AND QT_QTWEBKIT_FOUND)
|
||||
IF ( (QT4_FOUND AND QT_QTWEBKIT_FOUND) OR Qt5WebKitWidgets_FOUND )
|
||||
ADD_SUBDIRECTORY(osgQtWidgets)
|
||||
ADD_SUBDIRECTORY(osgQtBrowser)
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
|
||||
IF (FLTK_FOUND)
|
||||
IF (FLTK_FOUND AND FLTK_GL_LIBRARY)
|
||||
ADD_SUBDIRECTORY(osgviewerFLTK)
|
||||
ENDIF(FLTK_FOUND)
|
||||
ENDIF()
|
||||
|
||||
IF (WIN32)
|
||||
|
||||
OPTION(BUILD_MFC_EXAMPLE "Enable the build of the MFC Example" OFF)
|
||||
|
||||
IF (BUILD_MFC_EXAMPLE)
|
||||
IF (BUILD_MFC_EXAMPLE)
|
||||
ADD_SUBDIRECTORY(osgviewerMFC)
|
||||
ENDIF(BUILD_MFC_EXAMPLE)
|
||||
|
||||
@@ -247,7 +259,7 @@ ELSE(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgviewerIPhone)
|
||||
ENDIF()
|
||||
# IPHONE_PORT@tom
|
||||
|
||||
|
||||
ENDIF(DYNAMIC_OPENSCENEGRAPH)
|
||||
|
||||
ENDIF(ANDROID)
|
||||
|
||||
@@ -66,7 +66,7 @@ int main( int argc, char **argv )
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a utility for converting between various input and output databases formats.");
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a utility for converting glsl shader files into char arrays that can be compiled into applications.");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--shader <filename>","Shader file to create a .cpp file for.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
|
||||
|
||||
@@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_setClearColor(JNIEnv
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address){
|
||||
//Import Strings from JNI
|
||||
const char *nativeAddress = env->GetStringUTFChars(address, false);
|
||||
const char *nativeAddress = env->GetStringUTFChars(address, JNI_FALSE);
|
||||
|
||||
mainApp.loadObject(std::string(nativeAddress));
|
||||
|
||||
@@ -84,8 +84,8 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv *
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address, jstring name){
|
||||
//Import Strings from JNI
|
||||
const char *nativeAddress = env->GetStringUTFChars(address, false);
|
||||
const char *nativeName = env->GetStringUTFChars(name, false);
|
||||
const char *nativeAddress = env->GetStringUTFChars(address,JNI_FALSE);
|
||||
const char *nativeName = env->GetStringUTFChars(name, JNI_FALSE);
|
||||
|
||||
mainApp.loadObject(std::string(nativeName),std::string(nativeAddress));
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_setClearColor(JNIEnv
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address){
|
||||
//Import Strings from JNI
|
||||
const char *nativeAddress = env->GetStringUTFChars(address, false);
|
||||
const char *nativeAddress = env->GetStringUTFChars(address, JNI_FALSE);
|
||||
|
||||
mainApp.loadObject(std::string(nativeAddress));
|
||||
|
||||
@@ -84,8 +84,8 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv *
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address, jstring name){
|
||||
//Import Strings from JNI
|
||||
const char *nativeAddress = env->GetStringUTFChars(address, false);
|
||||
const char *nativeName = env->GetStringUTFChars(name, false);
|
||||
const char *nativeAddress = env->GetStringUTFChars(address,JNI_FALSE);
|
||||
const char *nativeName = env->GetStringUTFChars(name, JNI_FALSE);
|
||||
|
||||
mainApp.loadObject(std::string(nativeName),std::string(nativeAddress));
|
||||
|
||||
|
||||
@@ -7,10 +7,19 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
ENDIF()
|
||||
|
||||
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
|
||||
if ( QT4_FOUND )
|
||||
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTWEBKIT_INCLUDE_DIR} )
|
||||
endif( QT4_FOUND )
|
||||
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget osgQt)
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgQtBrowser)
|
||||
SET ( EXAMPLE_NAME osgQtBrowser )
|
||||
SETUP_EXAMPLE(${EXAMPLE_NAME})
|
||||
|
||||
IF ( Qt5Widgets_FOUND )
|
||||
qt5_use_modules( example_${EXAMPLE_NAME} Widgets OpenGL WebKitWidgets )
|
||||
ENDIF( Qt5Widgets_FOUND )
|
||||
|
||||
|
||||
|
||||
@@ -29,14 +29,20 @@
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osgWidget/Browser>
|
||||
|
||||
#include <QtGlobal>
|
||||
#if QT_VERSION >= 0x050000
|
||||
# include <QtWebKitWidgets>
|
||||
#else
|
||||
# include <QtWebKit>
|
||||
#endif
|
||||
|
||||
#include <QtWebKit/QWebSettings>
|
||||
#include <QtWebKit/QtWebKit>
|
||||
#include <QtGui/QGraphicsScene>
|
||||
#include <QtGui/QGraphicsView>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QtEvents>
|
||||
#include <QWebSettings>
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QtEvents>
|
||||
|
||||
#include <osgQt/QGraphicsViewAdapter>
|
||||
#include <osgQt/QWebViewImage>
|
||||
|
||||
@@ -7,10 +7,17 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
ENDIF()
|
||||
|
||||
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
|
||||
if ( QT4_FOUND )
|
||||
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTWEBKIT_INCLUDE_DIR} )
|
||||
endif( QT4_FOUND )
|
||||
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget osgQt)
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgQtWidgets)
|
||||
SET ( EXAMPLE_NAME osgQtWidgets )
|
||||
SETUP_EXAMPLE(${EXAMPLE_NAME})
|
||||
|
||||
IF ( Qt5Widgets_FOUND )
|
||||
qt5_use_modules( example_${EXAMPLE_NAME} OpenGL WebKitWidgets )
|
||||
ENDIF( Qt5Widgets_FOUND )
|
||||
|
||||
@@ -36,17 +36,16 @@
|
||||
#include <osgWidget/Browser>
|
||||
|
||||
|
||||
//#include <QtWebKit/QWebSettings>
|
||||
//#include <QtWebKit/QtWebKit>
|
||||
#include <QtGui/QGraphicsScene>
|
||||
#include <QtGui/QGraphicsView>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QtEvents>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtOpenGL/QtOpenGL>
|
||||
//#include <QWebSettings>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QtEvents>
|
||||
#include <QDialog>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMainWindow>
|
||||
#include <QtOpenGL>
|
||||
|
||||
#include <osgQt/QGraphicsViewAdapter>
|
||||
#include <osgQt/QWebViewImage>
|
||||
@@ -98,7 +97,11 @@ protected:
|
||||
virtual void mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
bool ok = false;
|
||||
#if QT_VERSION >= 0x040500
|
||||
int val = QInputDialog::getInt(this, "Get integer", "Please enter an integer between 0 and pi", 0, 0, 3, 1, &ok);
|
||||
#else
|
||||
int val = QInputDialog::getInteger(this, "Get integer", "Please enter an integer between 0 and pi", 0, 0, 3, 1, &ok);
|
||||
#endif
|
||||
std::cout << "Ok was " << (ok ? "" : "not") << " pressed, val is " << val << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -134,11 +134,11 @@ public:
|
||||
|
||||
if (_imageProcessor.valid())
|
||||
{
|
||||
OSG_NOTICE<<"Will be using ImageProcessor to proces image "<<image->getFileName()<<std::endl;
|
||||
OSG_NOTICE<<"Will be using ImageProcessor to process image "<<image->getFileName()<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"No ImageProcessor to proces image "<<image->getFileName()<<std::endl;
|
||||
OSG_NOTICE<<"No ImageProcessor to process image "<<image->getFileName()<<std::endl;
|
||||
}
|
||||
OSG_NOTICE<<" compressImage "<<_compressImages<<std::endl;
|
||||
OSG_NOTICE<<" generateMipmaps "<<_generateMipmaps<<std::endl;
|
||||
|
||||
@@ -38,46 +38,46 @@
|
||||
|
||||
osg::AnimationPath* createAnimationPath(const osg::Vec3& center,float radius,double looptime)
|
||||
{
|
||||
// set up the animation path
|
||||
// set up the animation path
|
||||
osg::AnimationPath* animationPath = new osg::AnimationPath;
|
||||
animationPath->setLoopMode(osg::AnimationPath::LOOP);
|
||||
|
||||
|
||||
int numSamples = 40;
|
||||
float yaw = 0.0f;
|
||||
float yaw_delta = 2.0f*osg::PI/((float)numSamples-1.0f);
|
||||
float roll = osg::inDegrees(30.0f);
|
||||
|
||||
|
||||
double time=0.0f;
|
||||
double time_delta = looptime/(double)numSamples;
|
||||
for(int i=0;i<numSamples;++i)
|
||||
{
|
||||
osg::Vec3 position(center+osg::Vec3(sinf(yaw)*radius,cosf(yaw)*radius,0.0f));
|
||||
osg::Quat rotation(osg::Quat(roll,osg::Vec3(0.0,1.0,0.0))*osg::Quat(-(yaw+osg::inDegrees(90.0f)),osg::Vec3(0.0,0.0,1.0)));
|
||||
|
||||
|
||||
animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation));
|
||||
|
||||
yaw += yaw_delta;
|
||||
time += time_delta;
|
||||
|
||||
}
|
||||
return animationPath;
|
||||
return animationPath;
|
||||
}
|
||||
|
||||
osg::Node* createBase(const osg::Vec3& center,float radius)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
int numTilesX = 10;
|
||||
int numTilesY = 10;
|
||||
|
||||
|
||||
float width = 2*radius;
|
||||
float height = 2*radius;
|
||||
|
||||
|
||||
osg::Vec3 v000(center - osg::Vec3(width*0.5f,height*0.5f,0.0f));
|
||||
osg::Vec3 dx(osg::Vec3(width/((float)numTilesX),0.0,0.0f));
|
||||
osg::Vec3 dy(osg::Vec3(0.0f,height/((float)numTilesY),0.0f));
|
||||
|
||||
|
||||
// fill in vertices for grid, note numTilesX+1 * numTilesY+1...
|
||||
osg::Vec3Array* coords = new osg::Vec3Array;
|
||||
int iy;
|
||||
@@ -88,54 +88,45 @@ osg::Node* createBase(const osg::Vec3& center,float radius)
|
||||
coords->push_back(v000+dx*(float)ix+dy*(float)iy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Just two colours - black and white.
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); // white
|
||||
colors->push_back(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); // black
|
||||
int numColors=colors->size();
|
||||
|
||||
|
||||
|
||||
osg::ref_ptr<osg::DrawElementsUShort> whitePrimitives = new osg::DrawElementsUShort(GL_QUADS);
|
||||
osg::ref_ptr<osg::DrawElementsUShort> blackPrimitives = new osg::DrawElementsUShort(GL_QUADS);
|
||||
|
||||
int numIndicesPerRow=numTilesX+1;
|
||||
osg::UByteArray* coordIndices = new osg::UByteArray; // assumes we are using less than 256 points...
|
||||
osg::UByteArray* colorIndices = new osg::UByteArray;
|
||||
for(iy=0;iy<numTilesY;++iy)
|
||||
{
|
||||
for(int ix=0;ix<numTilesX;++ix)
|
||||
{
|
||||
// four vertices per quad.
|
||||
coordIndices->push_back(ix +(iy+1)*numIndicesPerRow);
|
||||
coordIndices->push_back(ix +iy*numIndicesPerRow);
|
||||
coordIndices->push_back((ix+1)+iy*numIndicesPerRow);
|
||||
coordIndices->push_back((ix+1)+(iy+1)*numIndicesPerRow);
|
||||
|
||||
// one color per quad
|
||||
colorIndices->push_back((ix+iy)%numColors);
|
||||
osg::DrawElementsUShort* primitives = ((iy+ix)%2==0) ? whitePrimitives.get() : blackPrimitives.get();
|
||||
primitives->push_back(ix +(iy+1)*numIndicesPerRow);
|
||||
primitives->push_back(ix +iy*numIndicesPerRow);
|
||||
primitives->push_back((ix+1)+iy*numIndicesPerRow);
|
||||
primitives->push_back((ix+1)+(iy+1)*numIndicesPerRow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set up a single normal
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
|
||||
|
||||
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
geom->setVertexArray(coords);
|
||||
geom->setVertexIndices(coordIndices);
|
||||
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorIndices(colorIndices);
|
||||
geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
|
||||
geom->setNormalArray(normals);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,coordIndices->size()));
|
||||
|
||||
|
||||
geom->setColorArray(colors, osg::Array::BIND_PER_PRIMITIVE_SET);
|
||||
|
||||
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitiveSet(whitePrimitives.get());
|
||||
geom->addPrimitiveSet(blackPrimitives.get());
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(geom);
|
||||
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
@@ -158,16 +149,16 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
||||
positioned->setMatrix(osg::Matrix::translate(-bs.center())*
|
||||
osg::Matrix::scale(size,size,size)*
|
||||
osg::Matrix::rotate(osg::inDegrees(-90.0f),0.0f,0.0f,1.0f));
|
||||
|
||||
|
||||
positioned->addChild(glider);
|
||||
|
||||
osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform;
|
||||
|
||||
osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform;
|
||||
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0,1.0));
|
||||
xform->addChild(positioned);
|
||||
|
||||
model->addChild(xform);
|
||||
}
|
||||
|
||||
|
||||
osg::Node* cessna = osgDB::readNodeFile("cessna.osgt");
|
||||
if (cessna)
|
||||
{
|
||||
@@ -179,16 +170,16 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
||||
positioned->setMatrix(osg::Matrix::translate(-bs.center())*
|
||||
osg::Matrix::scale(size,size,size)*
|
||||
osg::Matrix::rotate(osg::inDegrees(180.0f),0.0f,0.0f,1.0f));
|
||||
|
||||
|
||||
positioned->addChild(cessna);
|
||||
|
||||
|
||||
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
||||
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0));
|
||||
xform->addChild(positioned);
|
||||
|
||||
model->addChild(xform);
|
||||
}
|
||||
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -214,10 +205,10 @@ osg::Node* createModel(bool overlay, osgSim::OverlayNode::OverlayTechnique techn
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
root->addChild(baseModel);
|
||||
}
|
||||
|
||||
|
||||
root->addChild(movingModel);
|
||||
|
||||
return root;
|
||||
@@ -226,16 +217,16 @@ osg::Node* createModel(bool overlay, osgSim::OverlayNode::OverlayTechnique techn
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
|
||||
bool overlay = false;
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
while (arguments.read("--overlay")) overlay = true;
|
||||
|
||||
|
||||
osgSim::OverlayNode::OverlayTechnique technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY;
|
||||
while (arguments.read("--object")) { technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; overlay=true; }
|
||||
while (arguments.read("--ortho") || arguments.read("--orthographic")) { technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; overlay=true; }
|
||||
while (arguments.read("--persp") || arguments.read("--perspective")) { technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY; overlay=true; }
|
||||
|
||||
|
||||
|
||||
// initialize the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
@@ -246,7 +237,7 @@ int main( int argc, char **argv )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// tilt the scene so the default eye position is looking down on the model.
|
||||
osg::MatrixTransform* rootnode = new osg::MatrixTransform;
|
||||
rootnode->setMatrix(osg::Matrix::rotate(osg::inDegrees(30.0f),1.0f,0.0f,0.0f));
|
||||
@@ -255,7 +246,7 @@ int main( int argc, char **argv )
|
||||
// run optimization over the scene graph
|
||||
osgUtil::Optimizer optimzer;
|
||||
optimzer.optimize(rootnode);
|
||||
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(rootnode);
|
||||
|
||||
@@ -266,17 +257,17 @@ int main( int argc, char **argv )
|
||||
#if 0
|
||||
|
||||
// use of custom simulation time.
|
||||
|
||||
|
||||
viewer.realize();
|
||||
|
||||
|
||||
double simulationTime = 0.0;
|
||||
|
||||
|
||||
while (!viewer.done())
|
||||
{
|
||||
viewer.frame(simulationTime);
|
||||
simulationTime += 0.001;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
#else
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* -*-c++-*-
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2010 Jeremy Moles <cubicool@gmail.com>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
@@ -50,8 +50,7 @@ osg::Geometry* createEaseMotionGeometry(osgAnimation::Motion* motion) {
|
||||
|
||||
geom->setUseDisplayList(false);
|
||||
geom->setVertexArray(v);
|
||||
geom->setColorArray(cols);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setColorArray(cols, osg::Array::BIND_OVERALL);
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, 0, v->size()));
|
||||
|
||||
return geom;
|
||||
@@ -105,11 +104,11 @@ struct ColorLabel: public osgWidget::Label {
|
||||
setFont("fonts/VeraMono.ttf");
|
||||
setFontSize(14);
|
||||
setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
|
||||
setColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
setPadding(2.0f);
|
||||
setCanFill(true);
|
||||
|
||||
|
||||
addSize(150.0f, 25.0f);
|
||||
|
||||
setLabel(label);
|
||||
@@ -118,9 +117,9 @@ struct ColorLabel: public osgWidget::Label {
|
||||
|
||||
bool mousePush(double, double, const osgWidget::WindowManager*) {
|
||||
osgWidget::Table* p = dynamic_cast<osgWidget::Table*>(_parent);
|
||||
|
||||
|
||||
if(!p) return false;
|
||||
|
||||
|
||||
p->hide();
|
||||
|
||||
const std::string& name = getName();
|
||||
@@ -232,7 +231,7 @@ struct ColorLabel: public osgWidget::Label {
|
||||
else if(!name.compare("InOutExpoMotion"))
|
||||
EASE_MOTION_SAMPLER->setMotion<osgAnimation::InOutExpoMotion>()
|
||||
;
|
||||
|
||||
|
||||
else EASE_MOTION_SAMPLER->setMotion<osgAnimation::LinearMotion>();
|
||||
|
||||
return true;
|
||||
@@ -240,13 +239,13 @@ struct ColorLabel: public osgWidget::Label {
|
||||
|
||||
bool mouseEnter(double, double, const osgWidget::WindowManager*) {
|
||||
setColor(0.9f, 0.6f, 0.1f, 1.0f);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseLeave(double, double, const osgWidget::WindowManager*) {
|
||||
setColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -286,7 +285,7 @@ public:
|
||||
_window->addWidget(new ColorLabel("OutCircMotion"), 3, 3);
|
||||
_window->addWidget(new ColorLabel("InCircMotion"), 4, 3);
|
||||
_window->addWidget(new ColorLabel("InOutCircMotion"), 5, 3);
|
||||
|
||||
|
||||
_window->addWidget(new ColorLabel("OutExpoMotion"), 0, 4);
|
||||
_window->addWidget(new ColorLabel("InExpoMotion"), 1, 4);
|
||||
_window->addWidget(new ColorLabel("InOutExpoMotion"), 2, 4);
|
||||
|
||||
@@ -115,7 +115,7 @@ struct MyRigTransformHardware : public osgAnimation::RigTransformHardware
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "boneWeight" << i;
|
||||
geom.setVertexAttribData(attribIndex + i, osg::Geometry::ArrayData(getVertexAttrib(i),osg::Geometry::BIND_PER_VERTEX));
|
||||
geom.setVertexAttribArray(attribIndex + i, getVertexAttrib(i));
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::StateSet> ss = new osg::StateSet;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* -*-c++-*-
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ class AnimtkUpdateCallback : public osg::NodeCallback
|
||||
public:
|
||||
META_Object(osgAnimation, AnimtkUpdateCallback);
|
||||
|
||||
AnimtkUpdateCallback()
|
||||
AnimtkUpdateCallback()
|
||||
{
|
||||
_sampler = new osgAnimation::Vec3CubicBezierSampler;
|
||||
_playing = false;
|
||||
@@ -46,9 +46,9 @@ public:
|
||||
|
||||
/** Callback method called by the NodeVisitor when visiting a node.*/
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
|
||||
nv->getFrameStamp() &&
|
||||
{
|
||||
if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
|
||||
nv->getFrameStamp() &&
|
||||
nv->getFrameStamp()->getFrameNumber() != _lastUpdate) {
|
||||
|
||||
_lastUpdate = nv->getFrameStamp()->getFrameNumber();
|
||||
@@ -89,7 +89,7 @@ class AnimtkStateSetUpdateCallback : public osg::StateSet::Callback
|
||||
public:
|
||||
META_Object(osgAnimation, AnimtkStateSetUpdateCallback);
|
||||
|
||||
AnimtkStateSetUpdateCallback()
|
||||
AnimtkStateSetUpdateCallback()
|
||||
{
|
||||
_sampler = new osgAnimation::Vec4LinearSampler;
|
||||
_playing = false;
|
||||
@@ -109,20 +109,20 @@ public:
|
||||
|
||||
/** Callback method called by the NodeVisitor when visiting a node.*/
|
||||
virtual void operator()(osg::StateSet* state, osg::NodeVisitor* nv)
|
||||
{
|
||||
if (state &&
|
||||
nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
|
||||
nv->getFrameStamp() &&
|
||||
nv->getFrameStamp()->getFrameNumber() != _lastUpdate)
|
||||
{
|
||||
if (state &&
|
||||
nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
|
||||
nv->getFrameStamp() &&
|
||||
nv->getFrameStamp()->getFrameNumber() != _lastUpdate)
|
||||
{
|
||||
|
||||
_lastUpdate = nv->getFrameStamp()->getFrameNumber();
|
||||
_currentTime = osg::Timer::instance()->tick();
|
||||
|
||||
if (_playing && _sampler.get() && _sampler->getKeyframeContainer())
|
||||
if (_playing && _sampler.get() && _sampler->getKeyframeContainer())
|
||||
{
|
||||
osg::Material* material = dynamic_cast<osg::Material*>(state->getAttribute(osg::StateAttribute::MATERIAL));
|
||||
if (material)
|
||||
if (material)
|
||||
{
|
||||
osg::Vec4 result;
|
||||
float t = osg::Timer::instance()->delta_s(_startTime, _currentTime);
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
|
||||
osg::Geode* createAxis()
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry());
|
||||
|
||||
osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
|
||||
@@ -168,9 +168,7 @@ osg::Geode* createAxis()
|
||||
colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
|
||||
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
|
||||
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
|
||||
geometry->setColorArray (colors.get());
|
||||
|
||||
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
|
||||
geometry->setColorArray (colors.get(), osg::Array::BIND_PER_VERTEX);
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
|
||||
|
||||
geode->addDrawable( geometry.get() );
|
||||
@@ -217,7 +215,7 @@ osg::MatrixTransform* setupAnimtkNode()
|
||||
osgAnimation::Vec3CubicBezierKeyframeContainer* keys = callback->_sampler->getOrCreateKeyframeContainer();
|
||||
keys->push_back(osgAnimation::Vec3CubicBezierKeyframe(0, osgAnimation::Vec3CubicBezier(
|
||||
v[0], // pos
|
||||
v[0] + (v[0] - v[3]), // p1
|
||||
v[0] + (v[0] - v[3]), // p1
|
||||
v[1] - (v[1] - v[0]) // p2
|
||||
)));
|
||||
keys->push_back(osgAnimation::Vec3CubicBezierKeyframe(2, osgAnimation::Vec3CubicBezier(
|
||||
@@ -254,7 +252,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
osgGA::TrackballManipulator* manipulator = new osgGA::TrackballManipulator();
|
||||
viewer.setCameraManipulator(manipulator);
|
||||
|
||||
|
||||
osg::Group* root = new osg::Group;
|
||||
root->setInitialBound(osg::BoundingSphere(osg::Vec3(10,0,10), 30));
|
||||
root->addChild(createAxis());
|
||||
@@ -266,7 +264,7 @@ int main (int argc, char* argv[])
|
||||
viewer.setSceneData( root );
|
||||
viewer.realize();
|
||||
|
||||
while (!viewer.done())
|
||||
while (!viewer.done())
|
||||
{
|
||||
viewer.frame();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* -*-c++-*-
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
osg::Geode* createAxis()
|
||||
{
|
||||
osg::Geode* geode (new osg::Geode());
|
||||
osg::Geode* geode (new osg::Geode());
|
||||
osg::Geometry* geometry (new osg::Geometry());
|
||||
|
||||
osg::Vec3Array* vertices (new osg::Vec3Array());
|
||||
@@ -53,9 +53,7 @@ osg::Geode* createAxis()
|
||||
colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
|
||||
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
|
||||
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
|
||||
geometry->setColorArray (colors);
|
||||
|
||||
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
|
||||
geometry->setColorArray (colors, osg::Array::BIND_PER_VERTEX);
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
|
||||
|
||||
geode->addDrawable( geometry );
|
||||
@@ -70,12 +68,11 @@ osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
|
||||
osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
|
||||
osg::ref_ptr<osg::Vec3Array> colors (new osg::Vec3Array());
|
||||
geometry->setVertexArray (vertices.get());
|
||||
geometry->setColorArray (colors.get());
|
||||
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
|
||||
|
||||
geometry->setColorArray (colors.get(), osg::Array::BIND_PER_VERTEX);
|
||||
|
||||
float step = size / static_cast<float>(nsplit);
|
||||
float s = 0.5f/4.0f;
|
||||
for (int i = 0; i < nsplit; i++)
|
||||
for (int i = 0; i < nsplit; i++)
|
||||
{
|
||||
float x = -1.0f + static_cast<float>(i) * step;
|
||||
std::cout << x << std::endl;
|
||||
@@ -92,7 +89,7 @@ osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::UIntArray> array = new osg::UIntArray;
|
||||
for (int i = 0; i < nsplit - 1; i++)
|
||||
for (int i = 0; i < nsplit - 1; i++)
|
||||
{
|
||||
int base = i * 4;
|
||||
array->push_back(base);
|
||||
@@ -123,7 +120,7 @@ osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
|
||||
array->push_back(base+2);
|
||||
array->push_back(base+7);
|
||||
}
|
||||
|
||||
|
||||
geometry->addPrimitiveSet(new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, array->size(), &array->front()));
|
||||
geometry->setUseDisplayList( false );
|
||||
riggeometry->setSourceGeometry(geometry);
|
||||
@@ -144,7 +141,7 @@ void initVertexMap(osgAnimation::Bone* b0,
|
||||
(*vim)[b1->getName()].setName(b1->getName());
|
||||
(*vim)[b2->getName()].setName(b2->getName());
|
||||
|
||||
for (int i = 0; i < (int)array->size(); i++)
|
||||
for (int i = 0; i < (int)array->size(); i++)
|
||||
{
|
||||
float val = (*array)[i][0];
|
||||
std::cout << val << std::endl;
|
||||
@@ -229,7 +226,7 @@ int main (int argc, char* argv[])
|
||||
}
|
||||
manager->registerAnimation(anim);
|
||||
manager->buildTargetReference();
|
||||
|
||||
|
||||
// let's start !
|
||||
manager->playAnimation(anim);
|
||||
|
||||
@@ -247,7 +244,7 @@ int main (int argc, char* argv[])
|
||||
trueroot->setDataVariance(osg::Object::DYNAMIC);
|
||||
rootTransform->addChild(trueroot);
|
||||
scene->addChild(rootTransform);
|
||||
|
||||
|
||||
osgAnimation::RigGeometry* geom = createTesselatedBox(4, 4.0f);
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(geom);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* -*-c++-*-
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ using namespace osgAnimation;
|
||||
|
||||
osg::ref_ptr<osg::Geode> createAxis()
|
||||
{
|
||||
osg::ref_ptr<osg::Geode> geode (new osg::Geode());
|
||||
osg::ref_ptr<osg::Geode> geode (new osg::Geode());
|
||||
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry());
|
||||
|
||||
osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
|
||||
@@ -49,9 +49,7 @@ osg::ref_ptr<osg::Geode> createAxis()
|
||||
colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
|
||||
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
|
||||
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
|
||||
geometry->setColorArray (colors.get());
|
||||
|
||||
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
|
||||
geometry->setColorArray (colors.get(), osg::Array::BIND_PER_VERTEX);
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
|
||||
|
||||
geode->addDrawable( geometry.get() );
|
||||
@@ -114,7 +112,7 @@ int main (int argc, char* argv[])
|
||||
channelAnimation1->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(0, osg::Vec3(0,0,0)));
|
||||
channelAnimation1->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(2, osg::Vec3(1,1,0)));
|
||||
osgAnimation::Animation* anim1 = new osgAnimation::Animation;
|
||||
anim1->addChannel(channelAnimation1);
|
||||
anim1->addChannel(channelAnimation1);
|
||||
anim1->setPlayMode(osgAnimation::Animation::PPONG);
|
||||
|
||||
|
||||
@@ -130,12 +128,12 @@ int main (int argc, char* argv[])
|
||||
osgAnimation::Animation* anim2 = new osgAnimation::Animation;
|
||||
anim2->addChannel(channelAnimation2);
|
||||
anim2->setPlayMode(osgAnimation::Animation::LOOP);
|
||||
|
||||
|
||||
|
||||
// We register all animation inside the scheduler
|
||||
mng->registerAnimation(anim1);
|
||||
mng->registerAnimation(anim2);
|
||||
|
||||
|
||||
//start the animation
|
||||
mng->playAnimation(anim1);
|
||||
mng->playAnimation(anim2);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* -*-c++-*-
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*
|
||||
* Authors:
|
||||
@@ -37,13 +37,13 @@ const int WIDTH = 1440;
|
||||
const int HEIGHT = 900;
|
||||
|
||||
|
||||
osg::Geode* createAxis()
|
||||
osg::Geode* createAxis()
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
osg::Geometry* geometry = new osg::Geometry();
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array();
|
||||
osg::Vec4Array* colors = new osg::Vec4Array();
|
||||
|
||||
|
||||
vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
|
||||
vertices->push_back(osg::Vec3(1.0f, 0.0f, 0.0f));
|
||||
vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
|
||||
@@ -57,10 +57,9 @@ osg::Geode* createAxis()
|
||||
colors->push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
|
||||
|
||||
geometry->setVertexArray(vertices);
|
||||
geometry->setColorArray(colors);
|
||||
geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
geometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, 6));
|
||||
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, false);
|
||||
|
||||
@@ -100,7 +99,7 @@ struct AddHelperBone : public osg::NodeVisitor
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
@@ -153,7 +152,7 @@ int main(int argc, char** argv)
|
||||
|
||||
AnimtkViewerGUI* gui = new AnimtkViewerGUI(&viewer, WIDTH, HEIGHT, 0x1234);
|
||||
osg::Camera* camera = gui->createParentOrthoCamera();
|
||||
|
||||
|
||||
node->setNodeMask(0x0001);
|
||||
|
||||
group->addChild(node);
|
||||
|
||||
4
examples/osgatomiccounter/CMakeLists.txt
Normal file
4
examples/osgatomiccounter/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
SET(TARGET_SRC osgatomiccounter.cpp)
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgatomiccounter)
|
||||
238
examples/osgatomiccounter/osgatomiccounter.cpp
Normal file
238
examples/osgatomiccounter/osgatomiccounter.cpp
Normal file
@@ -0,0 +1,238 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2012-2012 David Callu
|
||||
*
|
||||
* This application is open source and may be redistributed and/or modified
|
||||
* freely and without restriction, both in commercial and non commercial applications,
|
||||
* as long as this copyright notice is maintained.
|
||||
*
|
||||
* This application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <osg/BufferIndexBinding>
|
||||
#include <osg/BufferObject>
|
||||
#include <osg/Camera>
|
||||
#include <osg/Program>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
#include <osgGA/KeySwitchMatrixManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
#include <osgGA/TerrainManipulator>
|
||||
#include <osgGA/SphericalManipulator>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
class AdaptNumPixelUniform : public osg::Camera::DrawCallback
|
||||
{
|
||||
public:
|
||||
AdaptNumPixelUniform()
|
||||
{
|
||||
_atomicCounterArray = new osg::UIntArray;
|
||||
_atomicCounterArray->push_back(0);
|
||||
}
|
||||
|
||||
virtual void operator () (osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
_acbb->readData(*renderInfo.getState(), *_atomicCounterArray);
|
||||
unsigned int numPixel = osg::maximum(1u, _atomicCounterArray->front());
|
||||
|
||||
if ((renderInfo.getView()->getFrameStamp()->getFrameNumber() % 10) == 0)
|
||||
{
|
||||
OSG_INFO << "osgatomiccounter : draw " << numPixel << " pixels." << std::endl;
|
||||
}
|
||||
|
||||
_invNumPixelUniform->set( 1.0f / static_cast<float>(numPixel) );
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Uniform> _invNumPixelUniform;
|
||||
osg::ref_ptr<osg::UIntArray> _atomicCounterArray;
|
||||
osg::ref_ptr<osg::AtomicCounterBufferBinding> _acbb;
|
||||
};
|
||||
|
||||
|
||||
osg::Program * createProgram()
|
||||
{
|
||||
|
||||
std::stringstream vp;
|
||||
vp << "#version 420 compatibility\n"
|
||||
<< "\n"
|
||||
<< "void main(void)\n"
|
||||
<< "{\n"
|
||||
<< " gl_Position = ftransform();\n"
|
||||
<< "}\n";
|
||||
osg::Shader * vpShader = new osg::Shader( osg::Shader::VERTEX, vp.str() );
|
||||
|
||||
|
||||
|
||||
std::stringstream fp;
|
||||
fp << "#version 420 compatibility\n"
|
||||
<< "\n"
|
||||
<< "layout(binding = 0) uniform atomic_uint acRed;\n"
|
||||
<< "layout(binding = 0, offset = 4) uniform atomic_uint acGreen;\n"
|
||||
<< "layout(binding = 2) uniform atomic_uint acBlue;\n"
|
||||
<< "\n"
|
||||
<< "uniform float invNumPixel;\n"
|
||||
<< "\n"
|
||||
<< "void main(void)\n"
|
||||
<< "{\n"
|
||||
<< " float r = float(atomicCounterIncrement(acRed)) * invNumPixel;\n"
|
||||
<< " float g = float(atomicCounterIncrement(acGreen)) * invNumPixel;\n"
|
||||
<< " float b = float(atomicCounterIncrement(acBlue)) * invNumPixel;\n"
|
||||
<< " gl_FragColor = vec4(r, g, b, 1.0);\n"
|
||||
<< "}\n"
|
||||
<< "\n";
|
||||
osg::Shader * fpShader = new osg::Shader( osg::Shader::FRAGMENT, fp.str() );
|
||||
|
||||
osg::Program * program = new osg::Program;
|
||||
program->addShader(vpShader);
|
||||
program->addShader(fpShader);
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
class ResetAtomicCounter : public osg::StateAttributeCallback
|
||||
{
|
||||
public:
|
||||
virtual void operator () (osg::StateAttribute* sa, osg::NodeVisitor*)
|
||||
{
|
||||
osg::AtomicCounterBufferBinding * acbb = dynamic_cast<osg::AtomicCounterBufferBinding *>(sa);
|
||||
if (acbb)
|
||||
{
|
||||
osg::AtomicCounterBufferObject * acbo = dynamic_cast<osg::AtomicCounterBufferObject*>(acbb->getBufferObject());
|
||||
if (acbo && acbo->getBufferData(0))
|
||||
{
|
||||
acbo->getBufferData(0)->dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a simple example which show draw order of pixel.");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
unsigned int helpType = 0;
|
||||
if ((helpType = arguments.readHelpType()))
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout, helpType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// report any errors if they have occurred when parsing the program arguments.
|
||||
if (arguments.errors())
|
||||
{
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// set up the camera manipulators.
|
||||
viewer.setCameraManipulator( new osgGA::TrackballManipulator() );
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
|
||||
// add the thread model handler
|
||||
viewer.addEventHandler(new osgViewer::ThreadingHandler);
|
||||
|
||||
// add the window size toggle handler
|
||||
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
|
||||
|
||||
// add the stats handler
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
// add the help handler
|
||||
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
|
||||
|
||||
// add the screen capture handler
|
||||
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
||||
|
||||
// load the data
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||
if (!loadedModel)
|
||||
{
|
||||
osg::Geometry * quad = osg::createTexturedQuadGeometry(osg::Vec3f(-2.0f, 0.0f, -2.0f),
|
||||
osg::Vec3f(2.0f, 0.0f, 0.0f),
|
||||
osg::Vec3f(0.0f, 0.0f, 2.0f) );
|
||||
|
||||
osg::Geode * geode = new osg::Geode;
|
||||
geode->addDrawable(quad);
|
||||
loadedModel = geode;
|
||||
}
|
||||
|
||||
// any option left unread are converted into errors to write out later.
|
||||
arguments.reportRemainingOptionsAsUnrecognized();
|
||||
|
||||
// report any errors if they have occurred when parsing the program arguments.
|
||||
if (arguments.errors())
|
||||
{
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
osg::StateSet * ss = loadedModel->asGeode()->getDrawable(0)->getOrCreateStateSet();
|
||||
ss->setAttributeAndModes( createProgram(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED );
|
||||
|
||||
ss = loadedModel->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::UIntArray> atomicCounterArrayRedAndGreen = new osg::UIntArray;
|
||||
atomicCounterArrayRedAndGreen->push_back(0);
|
||||
atomicCounterArrayRedAndGreen->push_back(0);
|
||||
|
||||
osg::ref_ptr<osg::UIntArray> atomicCounterArrayBlue = new osg::UIntArray;
|
||||
atomicCounterArrayBlue->push_back(0);
|
||||
|
||||
osg::ref_ptr<osg::AtomicCounterBufferObject> acboRedAndGreen = new osg::AtomicCounterBufferObject;
|
||||
acboRedAndGreen->setUsage(GL_STREAM_COPY);
|
||||
atomicCounterArrayRedAndGreen->setBufferObject(acboRedAndGreen.get());
|
||||
|
||||
osg::ref_ptr<osg::AtomicCounterBufferObject> acboBlue = new osg::AtomicCounterBufferObject;
|
||||
acboBlue->setUsage(GL_STREAM_COPY);
|
||||
atomicCounterArrayBlue->setBufferObject(acboBlue.get());
|
||||
|
||||
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbRedAndGreen = new osg::AtomicCounterBufferBinding(0, acboRedAndGreen.get(), 0, sizeof(GLuint)*3);
|
||||
ss->setAttributeAndModes(acbbRedAndGreen.get());
|
||||
|
||||
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbBlue = new osg::AtomicCounterBufferBinding(2, acboBlue.get(), 0, sizeof(GLuint));
|
||||
ss->setAttributeAndModes(acbbBlue.get());
|
||||
|
||||
acbbRedAndGreen->setUpdateCallback(new ResetAtomicCounter);
|
||||
acbbBlue->setUpdateCallback(new ResetAtomicCounter);
|
||||
|
||||
osg::ref_ptr<osg::Uniform> invNumPixelUniform = new osg::Uniform("invNumPixel", 1.0f/(800.0f*600.0f));
|
||||
ss->addUniform( invNumPixelUniform.get() );
|
||||
|
||||
AdaptNumPixelUniform * drawCallback = new AdaptNumPixelUniform;
|
||||
drawCallback->_invNumPixelUniform = invNumPixelUniform;
|
||||
drawCallback->_acbb = acbbBlue;
|
||||
|
||||
viewer.getCamera()->setFinalDrawCallback(drawCallback);
|
||||
|
||||
// optimize the scene graph, remove redundant nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get());
|
||||
|
||||
viewer.setSceneData( loadedModel.get() );
|
||||
|
||||
viewer.realize();
|
||||
|
||||
return viewer.run();
|
||||
|
||||
}
|
||||
@@ -348,6 +348,8 @@ int main( int argc, char **argv )
|
||||
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
|
||||
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
|
||||
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
|
||||
|
||||
viewer.setCameraManipulator( keyswitchManipulator.get() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
osg::Node* createLabel(const osg::Vec3& pos, float size, const std::string& label, osgText::Text::AxisAlignment axisAlignment)
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
|
||||
std::string timesFont("fonts/arial.ttf");
|
||||
|
||||
{
|
||||
@@ -50,17 +50,17 @@ osg::Node* createLabel(const osg::Vec3& pos, float size, const std::string& labe
|
||||
text->setAxisAlignment(axisAlignment);
|
||||
text->setAlignment(osgText::Text::CENTER_CENTER);
|
||||
text->setText(label);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return geode;
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
|
||||
osg::Node* createLabel3(const osg::Vec3& pos, float size, const std::string& label)
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
|
||||
std::string timesFont("fonts/arial.ttf");
|
||||
|
||||
{
|
||||
@@ -75,10 +75,10 @@ osg::Node* createLabel3(const osg::Vec3& pos, float size, const std::string& lab
|
||||
text->setAutoRotateToScreen(true);
|
||||
text->setCharacterSizeMode(osgText::Text::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT);
|
||||
text->setText(label);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return geode;
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::AutoTransform::AutoRotateMode autoRotateMode, osgText::Text::AxisAlignment axisAlignment, const std::string& str)
|
||||
@@ -113,8 +113,7 @@ osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::
|
||||
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
geom->setVertexArray(vertices);
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size()));
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
@@ -140,8 +139,7 @@ osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::
|
||||
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
geom->setVertexArray(vertices);
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size()));
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
@@ -149,7 +147,7 @@ osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::
|
||||
|
||||
group->addChild(geode);
|
||||
}
|
||||
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -169,25 +167,25 @@ osg::Node* createAutoScale(const osg::Vec3& position, float characterSize, const
|
||||
|
||||
osg::AutoTransform* at = new osg::AutoTransform;
|
||||
at->addChild(geode);
|
||||
|
||||
|
||||
at->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
|
||||
at->setAutoScaleToScreen(true);
|
||||
at->setMinimumScale(minScale);
|
||||
at->setMaximumScale(maxScale);
|
||||
at->setPosition(position);
|
||||
|
||||
|
||||
return at;
|
||||
}
|
||||
|
||||
osg::Node* createScene()
|
||||
{
|
||||
osg::Group* root = new osg::Group;
|
||||
|
||||
|
||||
// int numReps = 3333;
|
||||
int numReps = 10;
|
||||
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(1000.0,0.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_CAMERA,osgText::Text::XY_PLANE, "ROTATE_TO_CAMERA"));
|
||||
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,1000.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_SCREEN,osgText::Text::XY_PLANE, "ROTATE_TO_SCREEN"));
|
||||
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,0.0,1000.0),numReps,osg::AutoTransform::NO_ROTATION,osgText::Text::XZ_PLANE, "NO_ROTATION"));
|
||||
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,0.0,1000.0),numReps,osg::AutoTransform::NO_ROTATION,osgText::Text::XZ_PLANE, "NO_ROTATION"));
|
||||
|
||||
root->addChild(createAutoScale(osg::Vec3(500.0,500.0,500.0), 25.0, "AutoScale with no min, max limits"));
|
||||
root->addChild(createAutoScale(osg::Vec3(500.0,500.0,300.0), 25.0, "AutoScale with minScale = 1, maxScale = 2.0 ", 1, 2.0));
|
||||
@@ -202,7 +200,7 @@ int main(int, char**)
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(createScene());
|
||||
|
||||
|
||||
// run the viewers frame loop
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
//
|
||||
// A simple demo demonstrating different texturing modes,
|
||||
// A simple demo demonstrating different texturing modes,
|
||||
// including using of texture extensions.
|
||||
//
|
||||
|
||||
@@ -59,9 +59,8 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
|
||||
osg::Vec3Array* norms = new osg::Vec3Array(1);
|
||||
(*norms)[0] = width^height;
|
||||
(*norms)[0].normalize();
|
||||
|
||||
geom->setNormalArray(norms);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->setNormalArray(norms, osg::Array::BIND_OVERALL);
|
||||
|
||||
osg::Vec2Array* tcoords = new osg::Vec2Array(4);
|
||||
(*tcoords)[0].set(0.0f,0.0f);
|
||||
@@ -69,9 +68,9 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
|
||||
(*tcoords)[2].set(1.0f,1.0f);
|
||||
(*tcoords)[3].set(0.0f,1.0f);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
|
||||
if (image)
|
||||
{
|
||||
osg::StateSet* stateset = new osg::StateSet;
|
||||
@@ -80,7 +79,7 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
|
||||
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
geom->setStateSet(stateset);
|
||||
}
|
||||
|
||||
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -110,19 +109,18 @@ osg::Drawable* createAxis(const osg::Vec3& corner,const osg::Vec3& xdir,const os
|
||||
(*color)[3] = y_color;
|
||||
(*color)[4] = z_color;
|
||||
(*color)[5] = z_color;
|
||||
|
||||
geom->setColorArray(color);
|
||||
geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
|
||||
|
||||
geom->setColorArray(color, osg::Array::BIND_PER_VERTEX);
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
|
||||
|
||||
|
||||
osg::StateSet* stateset = new osg::StateSet;
|
||||
osg::LineWidth* linewidth = new osg::LineWidth();
|
||||
linewidth->setWidth(4.0f);
|
||||
stateset->setAttributeAndModes(linewidth,osg::StateAttribute::ON);
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
geom->setStateSet(stateset);
|
||||
|
||||
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -138,7 +136,7 @@ osg::Node* createModel()
|
||||
center->addDrawable(
|
||||
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readImageFile("Images/reflect.rgb")),
|
||||
osg::Vec3(0.0f,0.0f,0.0f));
|
||||
|
||||
|
||||
osg::Billboard* x_arrow = new osg::Billboard();
|
||||
x_arrow->setMode(osg::Billboard::AXIAL_ROT);
|
||||
x_arrow->setAxis(osg::Vec3(1.0f,0.0f,0.0f));
|
||||
@@ -182,7 +180,7 @@ int main(int, char**)
|
||||
{
|
||||
// construct the viewer
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(createModel());
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
~PickHandler() {}
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
|
||||
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
|
||||
{
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
|
||||
if (!view) return false;
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
{
|
||||
if (_mx==ea.getX() && _my==ea.getY())
|
||||
{
|
||||
pick(view, ea.getX(), ea.getY());
|
||||
pick(view, ea);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -81,13 +81,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void pick(osgViewer::View* view, float x, float y)
|
||||
void pick(osgViewer::View* view, const osgGA::GUIEventAdapter& event)
|
||||
{
|
||||
osg::Node* node = 0;
|
||||
osg::Group* parent = 0;
|
||||
|
||||
osgUtil::LineSegmentIntersector::Intersections intersections;
|
||||
if (view->computeIntersections(x, y, intersections))
|
||||
if (view->computeIntersections(event, intersections))
|
||||
{
|
||||
osgUtil::LineSegmentIntersector::Intersection intersection = *intersections.begin();
|
||||
osg::NodePath& nodePath = intersection.nodePath;
|
||||
@@ -98,7 +98,6 @@ public:
|
||||
// now we try to decorate the hit node by the osgFX::Scribe to show that its been "picked"
|
||||
if (parent && node)
|
||||
{
|
||||
|
||||
osgFX::Scribe* parentAsScribe = dynamic_cast<osgFX::Scribe*>(parent);
|
||||
if (!parentAsScribe)
|
||||
{
|
||||
|
||||
2
examples/osgcomputeshaders/CMakeLists.txt
Normal file
2
examples/osgcomputeshaders/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
SET(TARGET_SRC osgcomputeshaders.cpp)
|
||||
SETUP_EXAMPLE(osgcomputeshaders)
|
||||
92
examples/osgcomputeshaders/osgcomputeshaders.cpp
Normal file
92
examples/osgcomputeshaders/osgcomputeshaders.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/* -*-c++-*- OpenSceneGraph example, osgcomputeshaders.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Written by Wang Rui
|
||||
// This example can work only if GL version is 4.3 or greater
|
||||
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Geode>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
static const char* computeSrc = {
|
||||
"#version 430\n"
|
||||
"uniform float osg_FrameTime;\n"
|
||||
"uniform image2D targetTex;\n"
|
||||
"layout (local_size_x = 16, local_size_y = 16) in;\n"
|
||||
"void main() {\n"
|
||||
" ivec2 storePos = ivec2(gl_GlobalInvocationID.xy);\n"
|
||||
" float coeffcient = 0.5*sin(float(gl_WorkGroupID.x + gl_WorkGroupID.y)*0.1 + osg_FrameTime);\n"
|
||||
" coeffcient *= length(vec2(ivec2(gl_LocalInvocationID.xy) - ivec2(8)) / vec2(8.0));\n"
|
||||
" imageStore(targetTex, storePos, vec4(1.0-coeffcient, 0.0, 0.0, 0.0));\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
osg::ArgumentParser arguments( &argc, argv );
|
||||
|
||||
// Create the texture as both the output of compute shader and the input of a normal quad
|
||||
osg::ref_ptr<osg::Texture2D> tex2D = new osg::Texture2D;
|
||||
tex2D->setTextureSize( 512, 512 );
|
||||
tex2D->setFilter( osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR );
|
||||
tex2D->setFilter( osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR );
|
||||
tex2D->setInternalFormat( GL_R32F );
|
||||
tex2D->setSourceFormat( GL_RED );
|
||||
tex2D->setSourceType( GL_FLOAT );
|
||||
tex2D->bindToImageUnit( 0, osg::Texture::WRITE_ONLY ); // So we can use 'image2D' in the compute shader
|
||||
|
||||
// The compute shader can't work with other kinds of shaders
|
||||
// It also requires the work group numbers. Setting them to 0 will disable the compute shader
|
||||
osg::ref_ptr<osg::Program> computeProg = new osg::Program;
|
||||
computeProg->setComputeGroups( 512/16, 512/16, 1 );
|
||||
computeProg->addShader( new osg::Shader(osg::Shader::COMPUTE, computeSrc) );
|
||||
|
||||
// Create a node for outputting to the texture.
|
||||
// It is OK to have just an empty node here, but seems inbuilt uniforms like osg_FrameTime won't work then.
|
||||
// TODO: maybe we can have a custom drawable which also will implement glMemoryBarrier?
|
||||
osg::Node* sourceNode = osgDB::readNodeFile("axes.osgt");
|
||||
if ( !sourceNode ) sourceNode = new osg::Node;
|
||||
sourceNode->setDataVariance( osg::Object::DYNAMIC );
|
||||
sourceNode->getOrCreateStateSet()->setAttributeAndModes( computeProg.get() );
|
||||
sourceNode->getOrCreateStateSet()->addUniform( new osg::Uniform("targetTex", (int)0) );
|
||||
sourceNode->getOrCreateStateSet()->setTextureAttributeAndModes( 0, tex2D.get() );
|
||||
|
||||
// Display the texture on a quad. We will also be able to operate on the data if reading back to CPU side
|
||||
osg::Geometry* geom = osg::createTexturedQuadGeometry(
|
||||
osg::Vec3(), osg::Vec3(1.0f,0.0f,0.0f), osg::Vec3(0.0f,0.0f,1.0f) );
|
||||
osg::ref_ptr<osg::Geode> quad = new osg::Geode;
|
||||
quad->addDrawable( geom );
|
||||
quad->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
|
||||
quad->getOrCreateStateSet()->setTextureAttributeAndModes( 0, tex2D.get() );
|
||||
|
||||
// Create the scene graph and start the viewer
|
||||
osg::ref_ptr<osg::Group> scene = new osg::Group;
|
||||
scene->addChild( sourceNode );
|
||||
scene->addChild( quad.get() );
|
||||
|
||||
osgViewer::Viewer viewer;
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
viewer.addEventHandler( new osgViewer::StatsHandler );
|
||||
viewer.addEventHandler( new osgViewer::WindowSizeHandler );
|
||||
viewer.setSceneData( scene.get() );
|
||||
return viewer.run();
|
||||
}
|
||||
@@ -45,21 +45,21 @@
|
||||
class WallConstraint: public osgUtil::DelaunayConstraint { // forces lines to eb edge
|
||||
// wall constraint - can generate a wall at the coordinates of the constraint
|
||||
public:
|
||||
/** if you derive a class from DelaunayConstraint then you can create
|
||||
/** if you derive a class from DelaunayConstraint then you can create
|
||||
* a specific geometry creation routine.
|
||||
*/
|
||||
WallConstraint() : height(0), txxrepWall(10), txyrepWall(10) { }
|
||||
|
||||
|
||||
/** or create a wall around the constraint area: */
|
||||
virtual osg::Geometry * makeWallGeometry(void) const;
|
||||
|
||||
|
||||
/** for basic purposes, you can call these routines to make simple fill in geometries */
|
||||
virtual osg::DrawArrays* makeWall(void ) const { // build a wall height high around the constraint
|
||||
const osg::Vec3Array *_line= dynamic_cast<const osg::Vec3Array*>(getVertexArray());
|
||||
return (new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,2*_line->size()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual osg::Vec3Array *getWall(const float height) const;
|
||||
virtual osg::Vec2Array *getWallTexcoords(const float height) const;
|
||||
virtual osg::Vec3Array *getWallNormals(void) const {
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
const osg::Vec3Array *vertices= dynamic_cast<const osg::Vec3Array*>(getVertexArray());
|
||||
for (unsigned int ipr=0; ipr<getNumPrimitiveSets(); ipr++) {
|
||||
const osg::PrimitiveSet* prset=getPrimitiveSet(ipr);
|
||||
if (prset->getMode()==osg::PrimitiveSet::LINE_LOOP ||
|
||||
if (prset->getMode()==osg::PrimitiveSet::LINE_LOOP ||
|
||||
prset->getMode()==osg::PrimitiveSet::LINE_STRIP) { // loops and walls
|
||||
// start with the last point on the loop
|
||||
osg::Vec3 prevp=(*vertices)[prset->index (prset->getNumIndices()-1)];
|
||||
@@ -88,12 +88,12 @@ public:
|
||||
}
|
||||
return nrms.release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// geometry creation parameters
|
||||
void setWallTexrep(const float w,const float h) { txxrepWall=w;txyrepWall=h;}
|
||||
|
||||
|
||||
/** Wall Geometry will return with this texture applied: */
|
||||
void setTexture(const char *tx) { texture=tx;}
|
||||
/** fence/wall height */
|
||||
@@ -106,18 +106,18 @@ protected:
|
||||
class ArealConstraint: public osgUtil::DelaunayConstraint { // forces edges of an area to fit triangles
|
||||
// areal constraint - general nonuniform field, forest, lake etc.
|
||||
public:
|
||||
/** if you derive a class from DelaunayConstraint then you can create
|
||||
/** if you derive a class from DelaunayConstraint then you can create
|
||||
* a specific geometry creation routine.
|
||||
*/
|
||||
ArealConstraint() : txxrepArea(10), txyrepArea(10),txxrepWall(10), txyrepWall(10) { }
|
||||
|
||||
|
||||
/** return a geometry that fills the constraint.
|
||||
*/
|
||||
virtual osg::Geometry * makeAreal( osg::Vec3Array *points);
|
||||
|
||||
virtual deprecated_osg::Geometry * makeAreal( osg::Vec3Array *points);
|
||||
|
||||
/** or create a wall around the constraint area: */
|
||||
virtual osg::Geometry * makeWallGeometry( osg::Vec3Array *points) ;
|
||||
|
||||
virtual deprecated_osg::Geometry * makeWallGeometry( osg::Vec3Array *points) ;
|
||||
|
||||
/** for basic purposes, you can call these routines to make simple fill in geometries */
|
||||
virtual osg::DrawArrays* makeWall(void ) const;
|
||||
virtual osg::Vec3Array *getWall(const float height) const;
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
virtual osg::Vec3Array *getCanopy(const osg::Vec3Array *points,const float height) const;
|
||||
virtual osg::Vec2Array *getCanopyTexcoords(const osg::Vec3Array *points) const;
|
||||
virtual osg::Vec3Array *getCanopyNormals(const osg::Vec3Array *points) const;
|
||||
|
||||
|
||||
// geometry creation parameters
|
||||
void setTexrep(const float w,const float h) { txxrepArea=w;txyrepArea=h;}
|
||||
void setWallTexrep(const float w,const float h) { txxrepWall=w;txyrepWall=h;}
|
||||
@@ -147,39 +147,39 @@ protected:
|
||||
float txxrepWall, txyrepWall;
|
||||
};
|
||||
|
||||
class LinearConstraint: public osgUtil::DelaunayConstraint {
|
||||
class LinearConstraint: public osgUtil::DelaunayConstraint {
|
||||
/** forces edges of a "road" to fit triangles
|
||||
* if 2 roads cross, then the overlap will be replaced by a 'cross road'
|
||||
* and the roads built up to the cross roads with a texture along its length. */
|
||||
public:
|
||||
LinearConstraint() : osgUtil::DelaunayConstraint(), txxrepAlong(10), txyrepAcross(10), width(2) { }
|
||||
|
||||
|
||||
/** geometry creation parameters */
|
||||
/* Width of linear feature (eg road, railway) */
|
||||
void setWidth(const float w) { width=w;}
|
||||
|
||||
|
||||
/** Texture repeat distance across linear (often equal to width) and along its length */
|
||||
virtual void setTexrep(const float w,const float h) { txyrepAcross=h;txxrepAlong=w; }
|
||||
|
||||
|
||||
/** generate constant width around line - creates the area to be cut into the terrain. */
|
||||
virtual void setVertices( osg::Vec3Array *lp, const float width);
|
||||
|
||||
|
||||
/** return a geometry that fills the constraint.
|
||||
*/
|
||||
virtual osg::Geometry *makeGeometry(const osg::Vec3Array *points) ;
|
||||
|
||||
virtual deprecated_osg::Geometry *makeGeometry(const osg::Vec3Array *points) ;
|
||||
|
||||
/** return normals array - flat shaded */
|
||||
osg::Vec3Array* getNormals(const osg::Vec3Array *points);
|
||||
|
||||
|
||||
/** Roads apply a texture proportional to length along the road line. */
|
||||
virtual osg::DrawArrays* makeRoad( ) const;
|
||||
virtual osg::Vec3Array *getRoadVertices() const;
|
||||
virtual osg::Vec2Array *getRoadTexcoords(const osg::Vec3Array *points) ;
|
||||
|
||||
|
||||
virtual osg::Vec3Array *getRoadNormals(const osg::Vec3Array *points) const;
|
||||
/** Geometry will return with this texture applied: */
|
||||
void setTexture(const char *tx) { texture=tx;}
|
||||
|
||||
|
||||
protected:
|
||||
osg::ref_ptr<osg::Vec2Array> _tcoords;
|
||||
osg::ref_ptr<osg::Vec3Array> _edgecoords;
|
||||
@@ -196,19 +196,19 @@ class pyramid : public osgUtil::DelaunayConstraint {
|
||||
* geometry of an Egyptian pyramid to fit the hole. */
|
||||
public:
|
||||
pyramid() : _side(100.) {}
|
||||
|
||||
|
||||
void setpos(const osg::Vec3 p, const float size) { _pos=p;_side=size;}
|
||||
|
||||
|
||||
virtual osg::Geometry * makeGeometry(void) const
|
||||
{
|
||||
// create pyramid geometry. Centre plus points around base
|
||||
const osg::Vec3Array *_line= dynamic_cast<const osg::Vec3Array*>(getVertexArray());
|
||||
osg::Geometry *gm=new osg::Geometry;
|
||||
deprecated_osg::Geometry *gm=new deprecated_osg::Geometry;
|
||||
osg::Vec3Array *pts=new osg::Vec3Array;
|
||||
osg::Vec3Array *norms=new osg::Vec3Array;
|
||||
osg::Vec2Array *tcoords=new osg::Vec2Array;
|
||||
int ip;
|
||||
|
||||
|
||||
pts->push_back(_pos+osg::Vec3(0,0,_side)*0.5);
|
||||
for (ip=0; ip<4; ip++) {
|
||||
pts->push_back((*_line)[ip]);
|
||||
@@ -218,12 +218,12 @@ public:
|
||||
nrm.normalize( );
|
||||
norms->push_back(nrm);
|
||||
}
|
||||
|
||||
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
|
||||
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
gm->setVertexArray(pts);
|
||||
osg::StateSet *dstate= gm->getOrCreateStateSet( );
|
||||
dstate->setMode( GL_LIGHTING, osg::StateAttribute::ON );
|
||||
|
||||
|
||||
osg::Image* image = osgDB::readImageFile("Images/Brick-Std-Orange.TGA");
|
||||
if (image)
|
||||
{
|
||||
@@ -283,66 +283,66 @@ osg::Vec3d getpt(const int np)
|
||||
osg::Node* createHUD(const int ndcs,std::string what)
|
||||
{ // add a string reporting the type of winding rule tessellation applied
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
|
||||
std::string timesFont("fonts/arial.ttf");
|
||||
|
||||
|
||||
// turn lighting off for the text and disable depth test to ensure its always ontop.
|
||||
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
|
||||
// Disable depth test, and make sure that the hud is drawn after everything
|
||||
|
||||
// Disable depth test, and make sure that the hud is drawn after everything
|
||||
// else so that it always appears ontop.
|
||||
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||
stateset->setRenderBinDetails(11,"RenderBin");
|
||||
|
||||
|
||||
osg::Vec3 position(50.0f,900.0f,0.0f);
|
||||
osg::Vec3 delta(0.0f,-35.0f,0.0f);
|
||||
|
||||
|
||||
{
|
||||
osgText::Text* text = new osgText::Text;
|
||||
geode->addDrawable( text );
|
||||
std::ostringstream cue;
|
||||
cue<<"Delaunay triangulation with constraints level "<<ndcs <<"\n"<< what;
|
||||
|
||||
|
||||
text->setFont(timesFont);
|
||||
text->setPosition(position);
|
||||
text->setText(cue.str());
|
||||
text->setColor(osg::Vec4(1.0,1.0,0.8,1.0));
|
||||
position += delta*(ndcs+2);
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
text = new osgText::Text;
|
||||
geode->addDrawable( text );
|
||||
|
||||
|
||||
text->setFont(timesFont);
|
||||
text->setPosition(position);
|
||||
text->setText("(use 'W' wireframe & 'T' texture to visualise mesh)");
|
||||
text->setColor(osg::Vec4(1.0,1.0,0.8,1.0));
|
||||
position += delta;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
{
|
||||
osgText::Text* text = new osgText::Text;
|
||||
geode->addDrawable( text );
|
||||
|
||||
|
||||
text->setFont(timesFont);
|
||||
text->setPosition(position);
|
||||
text->setText("Press 'n' to add another constraint.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// create the hud.
|
||||
osg::MatrixTransform* modelview_abs = new osg::MatrixTransform;
|
||||
modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
modelview_abs->setMatrix(osg::Matrix::identity());
|
||||
modelview_abs->addChild(geode);
|
||||
|
||||
|
||||
osg::Projection* projection = new osg::Projection;
|
||||
projection->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
|
||||
projection->addChild(modelview_abs);
|
||||
|
||||
|
||||
return projection;
|
||||
|
||||
|
||||
}
|
||||
osg::Group *makedelaunay(const int ndcs)
|
||||
{ // create a terrain tile. This is just an example!
|
||||
@@ -351,9 +351,9 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
osg::ref_ptr<osg::Geode> geode=new osg::Geode;
|
||||
osg::ref_ptr<osgUtil::DelaunayTriangulator> trig=new osgUtil::DelaunayTriangulator();
|
||||
osg::StateSet *stateset=geode->getOrCreateStateSet();
|
||||
|
||||
|
||||
osg::Vec3Array *points=new osg::Vec3Array;
|
||||
|
||||
|
||||
osg::Image* image = osgDB::readImageFile("Images/blueFlowers.png");
|
||||
if (image)
|
||||
{
|
||||
@@ -363,10 +363,10 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
texture->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT );
|
||||
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
|
||||
geode->setStateSet( stateset );
|
||||
unsigned int i;
|
||||
|
||||
|
||||
int eod=0;
|
||||
while (eod>=0) {
|
||||
osg::Vec3d pos=getpt(eod);
|
||||
@@ -400,7 +400,7 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
}
|
||||
dc->setVertexArray(bounds);
|
||||
dc->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,nmax) );
|
||||
|
||||
|
||||
trig->addInputConstraint(dc.get());
|
||||
what << nmax << " point simple constraint\n";
|
||||
}
|
||||
@@ -426,10 +426,10 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
}
|
||||
dc->setVertexArray(bounds);
|
||||
dc->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,12) );
|
||||
|
||||
|
||||
trig->addInputConstraint(dc.get());
|
||||
what << 12 << " point closed loop";
|
||||
|
||||
|
||||
if (ndcs>2) {
|
||||
wc=new WallConstraint; // This example does not remove the interior
|
||||
// eg to force terrain edges that are on ridges in the terrain etc.
|
||||
@@ -447,7 +447,7 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
trig->addInputConstraint(wc.get());
|
||||
what << " with interior removed\n";
|
||||
what << 5 << " point wall derived constraint\n";
|
||||
|
||||
|
||||
if (ndcs>3) {
|
||||
// add a removed area and replace it with a different texture
|
||||
dc2=new ArealConstraint;
|
||||
@@ -461,7 +461,7 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
dc2->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,18) );
|
||||
trig->addInputConstraint(dc2.get());
|
||||
what << 18 << " point area replaced\n";
|
||||
|
||||
|
||||
if (ndcs>4) {
|
||||
dc3=new LinearConstraint;
|
||||
// a linear feature or 'road'
|
||||
@@ -495,7 +495,7 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
forest->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,12) );
|
||||
if (ndcs==6) trig->addInputConstraint(forest.get());
|
||||
what << 12 << " point forest constraint\n";
|
||||
|
||||
|
||||
if (ndcs>6) { // add roads that intersect forest
|
||||
osg::ref_ptr<osgUtil::DelaunayConstraint> forestplus=new osgUtil::DelaunayConstraint;
|
||||
forestroad=new LinearConstraint;
|
||||
@@ -605,17 +605,17 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
}
|
||||
} // ndcs>0
|
||||
trig->setInputPointArray(points);
|
||||
|
||||
|
||||
/** NB you need to supply a vec3 array for the triangulator to calculate normals into */
|
||||
osg::Vec3Array *norms=new osg::Vec3Array;
|
||||
trig->setOutputNormalArray(norms);
|
||||
|
||||
|
||||
trig->triangulate();
|
||||
osg::notify(osg::WARN) << " End of trig\n " <<std::endl;
|
||||
|
||||
// Calculate the texture coordinates after triangulation as
|
||||
|
||||
// Calculate the texture coordinates after triangulation as
|
||||
//the points may get disordered by the triangulate function
|
||||
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry;
|
||||
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry;
|
||||
gm->setVertexArray(points); // points may have been modified in order by triangulation.
|
||||
/** calculate texture coords for terrain points */
|
||||
if (image) {
|
||||
@@ -629,17 +629,17 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
}
|
||||
gm->addPrimitiveSet(trig->getTriangles());
|
||||
gm->setNormalArray(trig->getOutputNormalArray());
|
||||
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
geode->addDrawable(gm.get());
|
||||
if (ndcs>0) {
|
||||
for ( std::vector < pyramid* >::iterator itr=pyrlist.begin(); itr!=pyrlist.end(); itr++) {
|
||||
trig->removeInternalTriangles(*itr);
|
||||
geode->addDrawable((*itr)->makeGeometry()); // this fills the holes of each pyramid with geometry
|
||||
}
|
||||
|
||||
|
||||
if (ndcs>2) {
|
||||
trig->removeInternalTriangles(dc.get());
|
||||
|
||||
|
||||
wc->setTexture("Images/Brick-Norman-Brown.TGA"); // wall looks like brick
|
||||
geode->addDrawable(wc->makeWallGeometry()); // this creates wall at wc drawarrays
|
||||
if (ndcs>3) {
|
||||
@@ -647,13 +647,13 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
osg::ref_ptr<osg::Vec3Array> arpts=dc2->getPoints(points);
|
||||
dc2->setTexture("Images/purpleFlowers.png");
|
||||
geode->addDrawable(dc2->makeAreal(arpts.get())); // this creates fill in geometry
|
||||
|
||||
|
||||
if (ndcs>4) { // a simple "road"
|
||||
trig->removeInternalTriangles(dc3.get());
|
||||
dc3->setTexture ("Images/road.png");
|
||||
dc3->setTexrep(40,9.5); // texture is repeated at this frequency
|
||||
geode->addDrawable(dc3->makeGeometry(points)); // this creates road geometry
|
||||
|
||||
|
||||
if (ndcs>5) {
|
||||
if (ndcs>6) { // road & forest overlap - order of removal is important
|
||||
trig->removeInternalTriangles(forestroad.get());
|
||||
@@ -661,11 +661,11 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
trig->removeInternalTriangles(forestroad3.get());
|
||||
}
|
||||
trig->removeInternalTriangles(forest.get());
|
||||
forest->setTexture("Images/forestRoof.png");
|
||||
forest->setTexture("Images/forestRoof.png");
|
||||
osg::ref_ptr<osg::Vec3Array> locpts=forest->getPoints(points);
|
||||
geode->addDrawable(forest->makeAreal(locpts.get()));
|
||||
|
||||
forest->setWallTexture("Images/forestWall.png");
|
||||
forest->setWallTexture("Images/forestWall.png");
|
||||
geode->addDrawable(forest->makeWallGeometry(locpts.get()) );
|
||||
for (osg::Vec3Array::iterator vit=(*locpts).begin(); vit!=(*locpts).end(); vit++) {
|
||||
(*vit)+=osg::Vec3(0,0,30);
|
||||
@@ -713,10 +713,10 @@ osg::Group *makedelaunay(const int ndcs)
|
||||
class KeyboardEventHandler : public osgGA::GUIEventHandler
|
||||
{ // extra event handler traps 'n' key to re-triangulate the basic terrain.
|
||||
public:
|
||||
|
||||
|
||||
KeyboardEventHandler(osgViewer::Viewer &vr):
|
||||
viewer(vr), iview(0) {}
|
||||
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
|
||||
{
|
||||
switch(ea.getEventType())
|
||||
@@ -738,7 +738,7 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
osgViewer::Viewer &viewer;
|
||||
int iview;
|
||||
};
|
||||
@@ -786,11 +786,11 @@ osg::Vec2Array * WallConstraint::getWallTexcoords(const float height) const
|
||||
}
|
||||
const osg::Vec3 curp=(*vertices)[prset->index (0)];
|
||||
circumference+=(curp-prevp).length();
|
||||
|
||||
|
||||
int nround=(int)(circumference/txxrepWall);
|
||||
if (nround<1) nround=1; // at least one repeat.
|
||||
texrepRound=circumference/nround;
|
||||
|
||||
|
||||
float ds=0;
|
||||
prevp=(*vertices)[prset->index (prset->getNumIndices()-1)];
|
||||
if (tcoords) {
|
||||
@@ -809,7 +809,7 @@ osg::Vec2Array * WallConstraint::getWallTexcoords(const float height) const
|
||||
tcoords->push_back(tci);
|
||||
}
|
||||
} // per primitiveset
|
||||
|
||||
|
||||
}
|
||||
return tcoords;
|
||||
}
|
||||
@@ -836,9 +836,8 @@ osg::Geometry *WallConstraint::makeWallGeometry() const
|
||||
gm->setVertexArray(getWall(height));
|
||||
gm->addPrimitiveSet(makeWall());
|
||||
gm->setTexCoordArray(0,getWallTexcoords(height));
|
||||
gm->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
gm->setNormalArray(getWallNormals()); // this creates normals to walls
|
||||
|
||||
gm->setNormalArray(getWallNormals(), osg::Array::BIND_PER_VERTEX); // this creates normals to walls
|
||||
|
||||
return gm.release();
|
||||
}
|
||||
|
||||
@@ -913,11 +912,11 @@ osg::Vec2Array * ArealConstraint::getWallTexcoords(const float height) const
|
||||
}
|
||||
const osg::Vec3 curp=(*vertices)[prset->index (0)];
|
||||
circumference+=(curp-prevp).length();
|
||||
|
||||
|
||||
int nround=(int)(circumference/txxrepWall);
|
||||
if (nround<1) nround=1; // at least one repeat.
|
||||
texrepRound=circumference/nround;
|
||||
|
||||
|
||||
float ds=0;
|
||||
prevp=(*vertices)[prset->index (prset->getNumIndices()-1)];
|
||||
if (tcoords) {
|
||||
@@ -988,23 +987,23 @@ osg::DrawArrays * ArealConstraint::makeWall(void) const
|
||||
return (new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,2+2*_line->size()));
|
||||
}
|
||||
|
||||
osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
|
||||
deprecated_osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
|
||||
{
|
||||
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the wall
|
||||
osg::ref_ptr<osg::Geometry> edges=new osg::Geometry; // edges of bounds
|
||||
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry; // the wall
|
||||
osg::ref_ptr<deprecated_osg::Geometry> edges=new deprecated_osg::Geometry; // edges of bounds
|
||||
edges->setVertexArray(pt);
|
||||
osg::DrawElementsUInt *trgeom=getTriangles();
|
||||
edges->addPrimitiveSet(trgeom);
|
||||
|
||||
|
||||
osg::ref_ptr<osgUtil::Tessellator> tscx=new osgUtil::Tessellator; // this assembles all the constraints
|
||||
tscx->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
|
||||
tscx->setBoundaryOnly(true);
|
||||
tscx->setWindingType( osgUtil::Tessellator::TESS_WINDING_NONZERO);
|
||||
tscx->setWindingType( osgUtil::Tessellator::TESS_WINDING_NONZERO);
|
||||
// find all edges.
|
||||
const osg::Vec3Array *points=dynamic_cast<osg::Vec3Array*>(getVertexArray());
|
||||
|
||||
|
||||
tscx->retessellatePolygons(*(edges)); // find all edges
|
||||
|
||||
|
||||
if (walltexture!="") {
|
||||
osg::Image* image = osgDB::readImageFile(walltexture.c_str());
|
||||
if (image)
|
||||
@@ -1047,21 +1046,21 @@ osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
|
||||
nstart+=2+2*pr->getNumIndices();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return gm.release();
|
||||
}
|
||||
|
||||
|
||||
osg::Geometry * ArealConstraint::makeAreal( osg::Vec3Array *points)
|
||||
deprecated_osg::Geometry * ArealConstraint::makeAreal( osg::Vec3Array *points)
|
||||
{
|
||||
osg::ref_ptr<osg::Geometry> gm; // the fill in area
|
||||
osg::ref_ptr<deprecated_osg::Geometry> gm; // the fill in area
|
||||
if (_interiorTris.size()>0) {
|
||||
gm =new osg::Geometry; // the forest roof
|
||||
gm =new deprecated_osg::Geometry; // the forest roof
|
||||
gm->setVertexArray(points);
|
||||
osg::DrawElementsUInt *trgeom=getTriangles();
|
||||
gm->addPrimitiveSet(trgeom);
|
||||
gm->setNormalArray(getCanopyNormals(points));
|
||||
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
gm->setTexCoordArray(0,getCanopyTexcoords(points));
|
||||
osg::Image* image = osgDB::readImageFile(texture);
|
||||
if (image)
|
||||
@@ -1094,7 +1093,7 @@ void LinearConstraint::setVertices( osg::Vec3Array *lp, const float w)
|
||||
for(unsigned int i=0;i<lp->size();i++) {
|
||||
osg::Vec3 valong;
|
||||
osg::Vec3 pos[2];
|
||||
|
||||
|
||||
if (i==0) {
|
||||
valong=(*lp)[i+1]-(*lp)[i];
|
||||
} else if (i==lp->size()-1) {
|
||||
@@ -1121,7 +1120,7 @@ void LinearConstraint::setVertices( osg::Vec3Array *lp, const float w)
|
||||
osg::DrawArrays* LinearConstraint::makeRoad(void ) const
|
||||
{
|
||||
return new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,2*_midline->size());
|
||||
|
||||
|
||||
}
|
||||
|
||||
osg::Vec3Array *LinearConstraint::getRoadNormals(const osg::Vec3Array* /*points*/) const
|
||||
@@ -1199,7 +1198,7 @@ osg::Vec2Array *LinearConstraint::getRoadTexcoords(const osg::Vec3Array *points)
|
||||
ptfound=true;
|
||||
}
|
||||
ibm1=ib;
|
||||
ib++;
|
||||
ib++;
|
||||
pminus=(*vit);
|
||||
}
|
||||
}
|
||||
@@ -1219,7 +1218,7 @@ osg::Vec2Array *LinearConstraint::getRoadTexcoords(const osg::Vec3Array *points)
|
||||
}
|
||||
return tcoords.release();
|
||||
}
|
||||
osg::Vec3Array * LinearConstraint::getNormals(const osg::Vec3Array *points)
|
||||
osg::Vec3Array * LinearConstraint::getNormals(const osg::Vec3Array *points)
|
||||
{
|
||||
osg::ref_ptr<osg::Vec3Array> norms=new osg::Vec3Array;
|
||||
for (osg::DrawElementsUInt::iterator uiitr=prim_tris_->begin(); uiitr!=prim_tris_->end();uiitr+=3) {
|
||||
@@ -1233,9 +1232,9 @@ osg::Vec3Array * LinearConstraint::getNormals(const osg::Vec3Array *points)
|
||||
return norms.release();
|
||||
}
|
||||
|
||||
osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
|
||||
deprecated_osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
|
||||
{
|
||||
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the fill in road/railway
|
||||
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry; // the fill in road/railway
|
||||
if (_midline->size()>0) {
|
||||
osg::ref_ptr<osg::Vec3Array> locpts=getPoints(points);
|
||||
if (texture!="") {
|
||||
@@ -1258,19 +1257,19 @@ osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
|
||||
}
|
||||
gm->setVertexArray(locpts.get());
|
||||
gm->setNormalArray(getNormals(locpts.get()));
|
||||
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
gm->addPrimitiveSet(getTriangles());
|
||||
}
|
||||
|
||||
|
||||
return gm.release();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
@@ -1279,24 +1278,24 @@ int main( int argc, char **argv )
|
||||
|
||||
// create the scene from internal specified terrain/constraints.
|
||||
osg::ref_ptr<osg::Node> loadedModel = makedelaunay(0);
|
||||
|
||||
|
||||
// if no model has been successfully loaded report failure.
|
||||
if (!loadedModel)
|
||||
if (!loadedModel)
|
||||
{
|
||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// optimize the scene graph, remove redundant nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get());
|
||||
|
||||
|
||||
// pass the loaded scene graph to the viewer.
|
||||
viewer.setSceneData(loadedModel.get());
|
||||
|
||||
|
||||
// copied from osgtessealte.cpp
|
||||
// add event handler for keyboard 'n' to retriangulate
|
||||
viewer.addEventHandler(new KeyboardEventHandler(viewer));
|
||||
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ osg::Node* createScene()
|
||||
osg::Geode* earth_geode = new osg::Geode;
|
||||
earth_geode->setName("EarthGeode");
|
||||
earth_geode->addDrawable(earth_sd);
|
||||
|
||||
|
||||
// Create the Sun, in yellow
|
||||
osg::ShapeDrawable *sun_sd = new osg::ShapeDrawable;
|
||||
osg::Sphere* sun_sphere = new osg::Sphere;
|
||||
@@ -63,13 +63,12 @@ osg::Node* createScene()
|
||||
osg::PositionAttitudeTransform *pat = new osg::PositionAttitudeTransform;
|
||||
pat->setPosition(osg::Vec3d(0.0, AU, 0.0));
|
||||
pat->addChild(sun_geode);
|
||||
|
||||
|
||||
osg::Geometry * unitCircle = new osg::Geometry();
|
||||
{
|
||||
osg::Vec4Array * colours = new osg::Vec4Array(1);
|
||||
(*colours)[0] = osg::Vec4d(1.0,1.0,1.0,1.0);
|
||||
unitCircle->setColorArray(colours);
|
||||
unitCircle->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
unitCircle->setColorArray(colours, osg::Array::BIND_OVERALL);
|
||||
const unsigned int n_points = 1024;
|
||||
osg::Vec3Array * coords = new osg::Vec3Array(n_points);
|
||||
const double dx = 2.0*osg::PI/n_points;
|
||||
@@ -88,8 +87,7 @@ osg::Node* createScene()
|
||||
{
|
||||
osg::Vec4Array *colours = new osg::Vec4Array(1);
|
||||
(*colours)[0] = osg::Vec4d(1.0,0.0,0.0,1.0);
|
||||
axes->setColorArray(colours);
|
||||
axes->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
axes->setColorArray(colours, osg::Array::BIND_OVERALL);
|
||||
osg::Vec3Array *coords = new osg::Vec3Array(6);
|
||||
(*coords)[0].set(osg::Vec3d(0.0, 0.0, 0.0));
|
||||
(*coords)[1].set(osg::Vec3d(0.5, 0.0, 0.0));
|
||||
@@ -101,25 +99,25 @@ osg::Node* createScene()
|
||||
axes->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
axes->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
|
||||
}
|
||||
|
||||
|
||||
// Earth orbit
|
||||
osg::Geode * earthOrbitGeode = new osg::Geode;
|
||||
earthOrbitGeode->addDrawable(unitCircle);
|
||||
earthOrbitGeode->addDrawable(axes);
|
||||
earthOrbitGeode->setName("EarthOrbitGeode");
|
||||
|
||||
|
||||
osg::PositionAttitudeTransform * earthOrbitPAT = new osg::PositionAttitudeTransform;
|
||||
earthOrbitPAT->setScale(osg::Vec3d(AU,AU,AU));
|
||||
earthOrbitPAT->setPosition(osg::Vec3d(0.0, AU, 0.0));
|
||||
earthOrbitPAT->addChild(earthOrbitGeode);
|
||||
earthOrbitPAT->setName("EarthOrbitPAT");
|
||||
|
||||
|
||||
osg::Group* scene = new osg::Group;
|
||||
scene->setName("SceneGroup");
|
||||
scene->addChild(earth_geode);
|
||||
scene->addChild(pat);
|
||||
scene->addChild(earthOrbitPAT);
|
||||
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
@@ -144,9 +142,9 @@ int main( int argc, char **argv )
|
||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
||||
|
||||
// if one hasn't been loaded create an earth and sun test model.
|
||||
if (!scene)
|
||||
if (!scene)
|
||||
{
|
||||
scene = createScene();
|
||||
scene = createScene();
|
||||
needToSetHomePosition = true;
|
||||
}
|
||||
// pass the loaded scene graph to the viewer.
|
||||
@@ -158,7 +156,7 @@ int main( int argc, char **argv )
|
||||
{
|
||||
viewer.getCameraManipulator()->setHomePosition(osg::Vec3d(0.0,-5.0*r_earth,0.0),osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,0.0,1.0));
|
||||
}
|
||||
|
||||
|
||||
double zNear=1.0, zMid=10.0, zFar=1000.0;
|
||||
if (arguments.read("--depth-partition",zNear, zMid, zFar))
|
||||
{
|
||||
@@ -175,7 +173,7 @@ int main( int argc, char **argv )
|
||||
// set up depth partitioning with default settings
|
||||
viewer.setUpDepthPartition();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
@@ -27,48 +27,48 @@
|
||||
DePee::DePee(osg::Group* parent, osg::Group* subgraph, unsigned width, unsigned height)
|
||||
{
|
||||
_renderToFirst = false;
|
||||
|
||||
|
||||
_isSketchy =false;
|
||||
_isColored = false;
|
||||
_isEdgy = true;
|
||||
_isCrayon = false;
|
||||
|
||||
|
||||
_normalDepthMapProgram = Utility::createProgram("shaders/depthpeel_normaldepthmap.vert","shaders/depthpeel_normaldepthmap.frag");
|
||||
_colorMapProgram = Utility::createProgram("shaders/depthpeel_colormap.vert","shaders/depthpeel_colormap.frag" );
|
||||
_edgeMapProgram = Utility::createProgram("shaders/depthpeel_edgemap.vert", "shaders/depthpeel_edgemap.frag");
|
||||
|
||||
|
||||
_parent = new osg::Group;
|
||||
parent->addChild(_parent.get());
|
||||
_subgraph = subgraph;
|
||||
|
||||
|
||||
_width = width;
|
||||
_height = height;
|
||||
_texWidth = width;
|
||||
_texHeight = height;
|
||||
|
||||
|
||||
assert(parent);
|
||||
assert(subgraph);
|
||||
|
||||
_fps = 0;
|
||||
_colorCamera = 0;
|
||||
|
||||
|
||||
_sketchy = new osg::Uniform("sketchy", false);
|
||||
_colored = new osg::Uniform("colored", false);
|
||||
_edgy = new osg::Uniform("edgy", true);
|
||||
_sketchiness = new osg::Uniform("sketchiness", (float) 1.0);
|
||||
|
||||
|
||||
_normalDepthMap0 = Utility::newColorTexture2D(_texWidth, _texHeight, 32);
|
||||
_normalDepthMap1 = Utility::newColorTexture2D(_texWidth, _texHeight, 32);
|
||||
_edgeMap = Utility::newColorTexture2D(_texWidth, _texHeight, 8);
|
||||
_colorMap = Utility::newColorTexture2D(_texWidth, _texHeight, 8);
|
||||
|
||||
|
||||
//create a noise map...this doesn't end up in a new rendering pass
|
||||
(void) createMap(NOISE_MAP);
|
||||
|
||||
//the viewport aligned quad
|
||||
_quadGeode = Utility::getCanvasQuad(_width, _height);
|
||||
|
||||
|
||||
|
||||
|
||||
//!!!Getting problems if assigning unit to texture in depth peeling subgraph and removing depth peeling steps!!!
|
||||
//That's why it is done here
|
||||
osg::StateSet* stateset = _parent->getOrCreateStateSet();
|
||||
@@ -77,12 +77,12 @@ DePee::DePee(osg::Group* parent, osg::Group* subgraph, unsigned width, unsigned
|
||||
stateset->setTextureAttributeAndModes(3, _edgeMap.get(), osg::StateAttribute::ON);
|
||||
stateset->setTextureAttributeAndModes(4, _colorMap.get(), osg::StateAttribute::ON);
|
||||
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::ON);
|
||||
|
||||
|
||||
// render the final thing
|
||||
(void) createFinal();
|
||||
|
||||
|
||||
//take one step initially
|
||||
addDePeePass();
|
||||
addDePeePass();
|
||||
|
||||
//render head up display
|
||||
(void) createHUD();
|
||||
@@ -111,7 +111,7 @@ void DePee::setSketchiness(double sketchiness)
|
||||
{
|
||||
_sketchiness->set((float)sketchiness);
|
||||
}
|
||||
|
||||
|
||||
void DePee::setColored(bool colored)
|
||||
{
|
||||
if(colored == !_isColored)
|
||||
@@ -128,20 +128,20 @@ void DePee::setColored(bool colored)
|
||||
_isColored = colored;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DePee::setEdgy(bool edgy)
|
||||
{
|
||||
|
||||
|
||||
if(edgy != _isEdgy)
|
||||
{
|
||||
|
||||
|
||||
_isEdgy = edgy;
|
||||
unsigned int n = 0;
|
||||
while(remDePeePass())
|
||||
{
|
||||
++n;
|
||||
}
|
||||
|
||||
|
||||
if(edgy)
|
||||
{
|
||||
(void) createMap(EDGE_MAP,_dePeePasses.size() == 1);
|
||||
@@ -150,7 +150,7 @@ void DePee::setEdgy(bool edgy)
|
||||
{
|
||||
_dePeePasses.back()->remRenderPass(EDGE_MAP);
|
||||
}
|
||||
|
||||
|
||||
for(unsigned int i=0; i < n; i++)
|
||||
{
|
||||
addDePeePass();
|
||||
@@ -158,8 +158,8 @@ void DePee::setEdgy(bool edgy)
|
||||
}
|
||||
_edgy->set(edgy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DePee::setFPS(double* fps)
|
||||
{
|
||||
@@ -177,29 +177,29 @@ unsigned int DePee::getNumberOfRenderPasses()
|
||||
|
||||
bool DePee::addDePeePass()
|
||||
{
|
||||
|
||||
|
||||
if(_isColored)
|
||||
{
|
||||
//remove previous color pass
|
||||
_dePeePasses.back()->remRenderPass(COLOR_MAP);
|
||||
}
|
||||
|
||||
|
||||
_dePeePasses.push_back(new DePeePass());
|
||||
_parent->addChild(_dePeePasses.back()->root.get());
|
||||
|
||||
|
||||
//need to create a depth map in every case
|
||||
(void) createMap(NORMAL_DEPTH_MAP, _dePeePasses.size() == 1);
|
||||
|
||||
|
||||
if(_isEdgy)
|
||||
{
|
||||
(void) createMap(EDGE_MAP,_dePeePasses.size() == 1);
|
||||
}
|
||||
|
||||
|
||||
if(_isColored)
|
||||
{
|
||||
(void) createMap(COLOR_MAP, false);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -213,12 +213,12 @@ bool DePee::remDePeePass()
|
||||
_dePeePasses.pop_back();
|
||||
|
||||
_renderToFirst = !_renderToFirst;
|
||||
|
||||
|
||||
if(_isColored)
|
||||
{
|
||||
(void) createMap(COLOR_MAP, false);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -234,11 +234,11 @@ bool DePee::createNoiseMap()
|
||||
_noiseMap->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
|
||||
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
|
||||
osg::Image* image = new osg::Image;
|
||||
unsigned char* data = new unsigned char[_width*_height];
|
||||
unsigned char* tmpData = new unsigned char[_width*_height];
|
||||
|
||||
|
||||
int random=rand() % 5000;
|
||||
for(unsigned y=0; y < _height; y++)
|
||||
for(unsigned x=0; x < _width; x++)
|
||||
@@ -258,10 +258,10 @@ bool DePee::createNoiseMap()
|
||||
data[y*_width + x] = (unsigned char)Utility::smoothNoise(_width, _height, x,y, tmpData);
|
||||
}
|
||||
}
|
||||
|
||||
image->setImage(_width, _height, 1,
|
||||
1, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
||||
data,
|
||||
|
||||
image->setImage(_width, _height, 1,
|
||||
1, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
||||
data,
|
||||
osg::Image::USE_NEW_DELETE);
|
||||
_noiseMap->setImage(image);
|
||||
return true;
|
||||
@@ -270,24 +270,24 @@ bool DePee::createNoiseMap()
|
||||
bool DePee::createHUD()
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
|
||||
std::string timesFont("fonts/arial.ttf");
|
||||
|
||||
// turn lighting off for the text and disable depth test to ensure its always ontop.
|
||||
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
|
||||
|
||||
stateset->setTextureAttributeAndModes(1, _normalDepthMap0.get(), osg::StateAttribute::OFF);
|
||||
stateset->setTextureAttributeAndModes(2, _normalDepthMap1.get(), osg::StateAttribute::OFF);
|
||||
stateset->setTextureAttributeAndModes(3, _edgeMap.get(), osg::StateAttribute::OFF);
|
||||
stateset->setTextureAttributeAndModes(4, _colorMap.get(), osg::StateAttribute::OFF);
|
||||
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::OFF);
|
||||
|
||||
|
||||
osg::Vec3 position(5.0f,7.0f,0.0f);
|
||||
osg::Vec3 delta(0.0f,-120.0f,0.0f);
|
||||
|
||||
_hudText = new osgText::Text;
|
||||
|
||||
|
||||
{
|
||||
geode->addDrawable( _hudText );
|
||||
_hudText->setDataVariance(osg::Object::DYNAMIC);
|
||||
@@ -298,16 +298,16 @@ bool DePee::createHUD()
|
||||
_hudText->setCharacterSize(20.0);
|
||||
position += delta;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
osg::BoundingBox bb;
|
||||
for(unsigned int i=0;i<geode->getNumDrawables();++i)
|
||||
{
|
||||
bb.expandBy(geode->getDrawable(i)->getBound());
|
||||
}
|
||||
|
||||
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array;
|
||||
float depth = bb.zMin()-0.1;
|
||||
vertices->push_back(osg::Vec3(bb.xMin(),bb.yMax(),depth));
|
||||
@@ -315,24 +315,22 @@ bool DePee::createHUD()
|
||||
vertices->push_back(osg::Vec3(bb.xMax(),bb.yMin(),depth));
|
||||
vertices->push_back(osg::Vec3(bb.xMax(),bb.yMax(),depth));
|
||||
geom->setVertexArray(vertices);
|
||||
|
||||
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
|
||||
geom->setNormalArray(normals);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(0.0f,0.0,0.0f,0.3f));
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
|
||||
|
||||
|
||||
osg::StateSet* stateset = geom->getOrCreateStateSet();
|
||||
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||
|
||||
|
||||
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
|
||||
|
||||
//geode->addDrawable(geom);
|
||||
}
|
||||
|
||||
@@ -341,7 +339,7 @@ bool DePee::createHUD()
|
||||
// set the projection matrix
|
||||
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
|
||||
|
||||
// set the view matrix
|
||||
// set the view matrix
|
||||
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
camera->setViewMatrix(osg::Matrix::identity());
|
||||
|
||||
@@ -352,19 +350,19 @@ bool DePee::createHUD()
|
||||
camera->setRenderOrder(osg::Camera::POST_RENDER);
|
||||
|
||||
camera->addChild(geode);
|
||||
|
||||
|
||||
_parent->addChild(camera);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// then create the first camera node to do the render to texture
|
||||
// render normal and depth map color map
|
||||
|
||||
bool DePee::createMap(MapMode mapMode, bool first)
|
||||
{
|
||||
{
|
||||
switch(mapMode)
|
||||
{
|
||||
case EDGE_MAP:
|
||||
@@ -377,13 +375,13 @@ bool DePee::createMap(MapMode mapMode, bool first)
|
||||
default:
|
||||
std::cerr << "mapMode not recognized!!!\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DePee::createFinal()
|
||||
{
|
||||
osg::Projection* screenAlignedProjectionMatrix = new osg::Projection;
|
||||
|
||||
|
||||
screenAlignedProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,_width,0,_height));
|
||||
screenAlignedProjectionMatrix->setCullingActive(false);
|
||||
|
||||
@@ -393,20 +391,20 @@ bool DePee::createFinal()
|
||||
// Make sure the model view matrix is not affected by any transforms
|
||||
// above it in the scene graph:
|
||||
screenAlignedModelViewMatrix->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
|
||||
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
// StateSet to contain the Texture StateAttribute.
|
||||
osg::StateSet* stateset = new osg::StateSet;
|
||||
|
||||
|
||||
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||
|
||||
|
||||
_quadGeode->setStateSet(stateset);
|
||||
|
||||
|
||||
_parent->addChild(screenAlignedProjectionMatrix);
|
||||
screenAlignedProjectionMatrix->addChild(screenAlignedModelViewMatrix);
|
||||
screenAlignedModelViewMatrix->addChild(_quadGeode.get());
|
||||
|
||||
|
||||
//setup shader
|
||||
std::string vertSource;
|
||||
if(!Utility::readFile("shaders/depthpeel_final.vert", vertSource))
|
||||
@@ -414,82 +412,82 @@ bool DePee::createFinal()
|
||||
printf("shader source not found\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::string fragSource;
|
||||
if(!Utility::readFile("shaders/depthpeel_final.frag", fragSource))
|
||||
{
|
||||
printf("shader source not found\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Program> program = new osg::Program;
|
||||
program->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource.c_str() ) );
|
||||
program->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource.c_str() ) );
|
||||
|
||||
|
||||
//choose map to display
|
||||
stateset->addUniform( new osg::Uniform("normalDepthMap0", 1));
|
||||
stateset->addUniform( new osg::Uniform("normalDepthMap1", 2));
|
||||
stateset->addUniform(new osg::Uniform("edgeMap", 3));
|
||||
stateset->addUniform( new osg::Uniform("colorMap", 4));
|
||||
stateset->addUniform( new osg::Uniform("noiseMap", 5));
|
||||
|
||||
|
||||
stateset->addUniform(_sketchy);
|
||||
stateset->addUniform(_colored);
|
||||
stateset->addUniform(_edgy);
|
||||
stateset->addUniform(_sketchiness);
|
||||
|
||||
|
||||
stateset->setAttributeAndModes( program.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
|
||||
|
||||
|
||||
//switch lighting off
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DePee::createEdgeMap(bool first)
|
||||
//create the edge map of the first normal and depth map
|
||||
{
|
||||
{
|
||||
_dePeePasses.back()->newRenderPass(EDGE_MAP);
|
||||
|
||||
|
||||
|
||||
|
||||
// set up the background color and clear mask.
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setClearColor(osg::Vec4(0.3,0.3f,0.3f,1.0f));
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
const osg::BoundingSphere& bs = _quadGeode->getBound();
|
||||
if (!bs.valid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
float znear = 1.0f*bs.radius();
|
||||
float zfar = 3.0f*bs.radius();
|
||||
|
||||
|
||||
znear *= 0.9f;
|
||||
zfar *= 1.1f;
|
||||
|
||||
|
||||
|
||||
|
||||
// set up projection.
|
||||
//_dePeePasses.back()->Cameras.top()->setProjectionMatrixAsFrustum(-proj_right,proj_right,-proj_top,proj_top,znear,zfar);
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setProjectionMatrixAsOrtho(0,_width,0,_height,znear,zfar);
|
||||
|
||||
|
||||
//set view
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
|
||||
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setViewMatrixAsLookAt(osg::Vec3(0.0f,0.0f,2.0f)*bs.radius(), osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0f,1.0f,0.0f));
|
||||
|
||||
|
||||
// set viewport
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setViewport(0,0,_texWidth,_texHeight);
|
||||
|
||||
|
||||
// set the camera to render before the main camera.
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||
|
||||
// tell the camera to use OpenGL frame buffer object
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER);
|
||||
|
||||
|
||||
//switch lighting off
|
||||
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_renderToFirst)
|
||||
{
|
||||
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
|
||||
@@ -501,14 +499,14 @@ bool DePee::createEdgeMap(bool first)
|
||||
|
||||
_dePeePasses.back()->Cameras[EDGE_MAP]->attach(osg::Camera::COLOR_BUFFER, _edgeMap.get());
|
||||
stateset->addUniform( new osg::Uniform("edgeMap", 3));
|
||||
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
|
||||
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
|
||||
osg::StateAttribute::OFF);
|
||||
//setup shader
|
||||
stateset->setAttributeAndModes(_edgeMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
|
||||
stateset->addUniform(new osg::Uniform("width", (float) _width));
|
||||
stateset->addUniform(new osg::Uniform("height", (float) _height));
|
||||
|
||||
|
||||
if(first)
|
||||
{
|
||||
stateset->addUniform(new osg::Uniform("first", (float)1.0));
|
||||
@@ -518,12 +516,12 @@ bool DePee::createEdgeMap(bool first)
|
||||
stateset->addUniform(new osg::Uniform("first", (float)0.0));
|
||||
}
|
||||
_dePeePasses.back()->settingNodes[EDGE_MAP]->setStateSet(stateset.get());
|
||||
|
||||
|
||||
// add subgraph to render
|
||||
assert(_dePeePasses.size() > 0);
|
||||
|
||||
|
||||
_dePeePasses.back()->settingNodes[EDGE_MAP]->addChild(_quadGeode.get());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -531,13 +529,13 @@ bool DePee::createEdgeMap(bool first)
|
||||
bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
|
||||
{
|
||||
DePeePass* pass;
|
||||
|
||||
|
||||
pass = _dePeePasses.back();
|
||||
|
||||
|
||||
pass->newRenderPass(mapMode);
|
||||
|
||||
|
||||
//
|
||||
// setup camera
|
||||
// setup camera
|
||||
//
|
||||
|
||||
// set up the background color and clear mask
|
||||
@@ -549,23 +547,23 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
float znear = 1.0f*bs.radius();
|
||||
float zfar = 3.0f*bs.radius();
|
||||
|
||||
|
||||
// 2:1 aspect ratio as per flag geometry below.
|
||||
float projTop = 0.25f*znear;
|
||||
float projRight = projTop * ((double)_width/(double)_height);
|
||||
|
||||
|
||||
znear *= 0.9f;
|
||||
zfar *= 1.1f;
|
||||
|
||||
|
||||
// set up projection.
|
||||
pass->Cameras[mapMode]->setProjectionMatrixAsFrustum(-projRight,projRight,-projTop,projTop, znear,zfar);
|
||||
|
||||
|
||||
// setup view
|
||||
pass->Cameras[mapMode]->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
|
||||
|
||||
pass->Cameras[mapMode]->setViewMatrixAsLookAt(bs.center()-osg::Vec3(0.0f,2.0f,0.0f)*bs.radius(),
|
||||
bs.center(),
|
||||
osg::Vec3(0.0f,0.0f,1.0f));
|
||||
@@ -574,24 +572,24 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
|
||||
|
||||
// set the camera to render before the main camera.
|
||||
pass->Cameras[mapMode]->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||
|
||||
|
||||
pass->Cameras[mapMode]->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
|
||||
|
||||
|
||||
//
|
||||
// setup stateset
|
||||
//
|
||||
//switch lighting off
|
||||
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
|
||||
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
|
||||
osg::StateAttribute::OFF);
|
||||
|
||||
|
||||
switch(mapMode)
|
||||
{
|
||||
case NORMAL_DEPTH_MAP:
|
||||
|
||||
|
||||
_renderToFirst = !_renderToFirst;
|
||||
|
||||
|
||||
if(_renderToFirst)
|
||||
{
|
||||
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _normalDepthMap0.get());
|
||||
@@ -602,17 +600,17 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
|
||||
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _normalDepthMap1.get());
|
||||
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
|
||||
}
|
||||
|
||||
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
|
||||
stateset->setAttributeAndModes(_normalDepthMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
|
||||
break;
|
||||
|
||||
|
||||
case COLOR_MAP:
|
||||
|
||||
|
||||
assert(pass == _dePeePasses.back());
|
||||
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _colorMap.get());
|
||||
|
||||
|
||||
|
||||
|
||||
if(_renderToFirst)
|
||||
{
|
||||
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
|
||||
@@ -626,26 +624,26 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
|
||||
stateset->setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
|
||||
stateset->setAttributeAndModes(_colorMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
|
||||
stateset->addUniform(new osg::Uniform("tex", 0));
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
// add subgraph to render
|
||||
|
||||
|
||||
pass->settingNodes[mapMode]->addChild(_subgraph.get());
|
||||
|
||||
|
||||
stateset->addUniform(new osg::Uniform("first", first));
|
||||
|
||||
|
||||
stateset->addUniform(new osg::Uniform("width", (float) _width));
|
||||
stateset->addUniform(new osg::Uniform("height", (float) _height));
|
||||
stateset->addUniform(new osg::Uniform("znear", znear));
|
||||
stateset->addUniform(new osg::Uniform("zfar", zfar));
|
||||
|
||||
|
||||
|
||||
pass->settingNodes[mapMode]->setStateSet(stateset.get());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -665,7 +663,7 @@ bool DePee::updateHUDText()
|
||||
+ (_isSketchy ? "+" : "-") + "(S)ketchy " +
|
||||
+ (_isColored ? "+" : "-") + "(C)olored " +
|
||||
+ "-> "+Utility::toString(getNumberOfRenderPasses())+ " Rendering Passes "
|
||||
+ "@ "
|
||||
+ "@ "
|
||||
+ tmp + " fps");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ bool Utility::readFile(const char* fName, std::string& s)
|
||||
{
|
||||
std::string foundFile = osgDB::findDataFile(fName);
|
||||
if (foundFile.empty()) return false;
|
||||
|
||||
|
||||
osgDB::ifstream is;//(fName);
|
||||
is.open(foundFile.c_str());
|
||||
if (is.fail())
|
||||
@@ -51,17 +51,17 @@ osg::Program* Utility::createProgram(std::string vs, std::string fs)
|
||||
if(!readFile((char*)vs.c_str(), vertSource))
|
||||
{
|
||||
printf("shader source not found\n");
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
std::string fragSource;
|
||||
if(!readFile((char*)fs.c_str(), fragSource))
|
||||
{
|
||||
printf("shader source not found\n");
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
osg::Program* program = new osg::Program;
|
||||
program->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource.c_str() ) );
|
||||
program->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource.c_str() ) );
|
||||
@@ -80,28 +80,28 @@ double Utility::getNoise(unsigned x, unsigned y, unsigned random)
|
||||
double Utility::smoothNoise(unsigned width, unsigned height, unsigned x, unsigned y, unsigned char* noise)
|
||||
{
|
||||
assert(noise);
|
||||
|
||||
if(x==0 || x > width -2
|
||||
|
||||
if(x==0 || x > width -2
|
||||
|| y==0 || y > height -2)
|
||||
return noise[x + y*width];
|
||||
|
||||
|
||||
double corners = (noise[x-1 + (y-1) *width]
|
||||
+noise[x+1 + (y-1)*width]
|
||||
+noise[x-1 + (y+1) * width]
|
||||
+noise[x+1 + (y+1) * width]) / 16.0;
|
||||
double sides = (noise[x-1 + y*width]
|
||||
+noise[x+1 + y*width]
|
||||
+noise[x + (y-1)*width]
|
||||
double sides = (noise[x-1 + y*width]
|
||||
+noise[x+1 + y*width]
|
||||
+noise[x + (y-1)*width]
|
||||
+noise[x + (y+1)*width]) / 8.0;
|
||||
double center = noise[x + y*width] / 4.0;
|
||||
|
||||
|
||||
return corners + sides + center;
|
||||
}
|
||||
|
||||
osg::Texture2D* Utility::newColorTexture2D(unsigned width, unsigned height, unsigned accuracy)
|
||||
{
|
||||
osg::Texture2D* texture2D = new osg::Texture2D;
|
||||
|
||||
|
||||
texture2D->setTextureSize(width, height);
|
||||
if(accuracy == 32)
|
||||
{
|
||||
@@ -124,30 +124,29 @@ osg::Geode* Utility::getCanvasQuad(unsigned width, unsigned height, double depth
|
||||
osg::Vec2Array* texCoords = new osg::Vec2Array;
|
||||
vertices->push_back(osg::Vec3(0,0,depth));
|
||||
texCoords->push_back(osg::Vec2(0,0));
|
||||
|
||||
|
||||
vertices->push_back(osg::Vec3(width,0,depth));
|
||||
texCoords->push_back(osg::Vec2(1,0));
|
||||
|
||||
|
||||
vertices->push_back(osg::Vec3(0,height,depth));
|
||||
texCoords->push_back(osg::Vec2(0,1));
|
||||
|
||||
|
||||
vertices->push_back(osg::Vec3(width,height,depth));
|
||||
texCoords->push_back(osg::Vec2(1,1));
|
||||
|
||||
|
||||
osg::Geometry* quad = new osg::Geometry;
|
||||
quad->setVertexArray(vertices);
|
||||
quad->setTexCoordArray(1,texCoords);
|
||||
|
||||
|
||||
quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,vertices->size()));
|
||||
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
quad->setColorArray(colors);
|
||||
quad->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
quad->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
geode->addDrawable(quad);
|
||||
|
||||
|
||||
return geode;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,16 +55,16 @@ using namespace osg;
|
||||
osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearColour)
|
||||
{
|
||||
osg::Group* distortionNode = new osg::Group;
|
||||
|
||||
|
||||
unsigned int tex_width = 1024;
|
||||
unsigned int tex_height = 1024;
|
||||
|
||||
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
texture->setTextureSize(tex_width, tex_height);
|
||||
texture->setInternalFormat(GL_RGBA);
|
||||
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
|
||||
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
|
||||
|
||||
|
||||
// set up the render to texture camera.
|
||||
{
|
||||
osg::Camera* camera = new osg::Camera;
|
||||
@@ -92,10 +92,10 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
|
||||
|
||||
// add subgraph to render
|
||||
camera->addChild(subgraph);
|
||||
|
||||
|
||||
distortionNode->addChild(camera);
|
||||
}
|
||||
|
||||
|
||||
// set up the hud camera
|
||||
{
|
||||
// create the quad to visualize.
|
||||
@@ -141,8 +141,7 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
|
||||
// pass the created vertex array to the points geometry object.
|
||||
polyGeom->setVertexArray(vertices);
|
||||
|
||||
polyGeom->setColorArray(colors);
|
||||
polyGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
polyGeom->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
|
||||
|
||||
polyGeom->setTexCoordArray(0,texcoords);
|
||||
|
||||
@@ -159,7 +158,7 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
|
||||
}
|
||||
|
||||
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
// StateSet to contain the Texture StateAttribute.
|
||||
osg::StateSet* stateset = polyGeom->getOrCreateStateSet();
|
||||
stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
|
||||
@@ -181,7 +180,7 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
|
||||
|
||||
// add subgraph to render
|
||||
camera->addChild(geode);
|
||||
|
||||
|
||||
distortionNode->addChild(camera);
|
||||
}
|
||||
return distortionNode;
|
||||
@@ -189,9 +188,9 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
|
||||
|
||||
void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
|
||||
{
|
||||
|
||||
|
||||
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
if (!wsi)
|
||||
if (!wsi)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
|
||||
return;
|
||||
@@ -237,7 +236,7 @@ void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
|
||||
|
||||
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
|
||||
}
|
||||
|
||||
|
||||
// top face
|
||||
{
|
||||
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
|
||||
@@ -297,7 +296,7 @@ void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
|
||||
|
||||
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(-180.0f), 1.0,0.0,0.0));
|
||||
}
|
||||
|
||||
|
||||
viewer.getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0);
|
||||
|
||||
viewer.assignSceneDataToCameras();
|
||||
@@ -314,15 +313,15 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
|
||||
|
||||
osg::Vec3d center(0.0,0.0,0.0);
|
||||
osg::Vec3d eye(0.0,0.0,0.0);
|
||||
|
||||
|
||||
double distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
|
||||
if (arguments.read("--distance", distance)) {}
|
||||
|
||||
|
||||
bool centerProjection = false;
|
||||
|
||||
osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, distance);
|
||||
|
||||
|
||||
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Projector position = "<<projector<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"distance = "<<distance<<std::endl;
|
||||
|
||||
@@ -339,7 +338,7 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
|
||||
osg::Vec3 yAxis(heightVector);
|
||||
float height = heightVector.length();
|
||||
yAxis /= height;
|
||||
|
||||
|
||||
int noSteps = 50;
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array;
|
||||
@@ -349,7 +348,7 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
|
||||
osg::Vec3 bottom = origin;
|
||||
osg::Vec3 dx = xAxis*(width/((float)(noSteps-1)));
|
||||
osg::Vec3 dy = yAxis*(height/((float)(noSteps-1)));
|
||||
|
||||
|
||||
osg::Vec3d screenCenter = origin + widthVector*0.5f + heightVector*0.5f;
|
||||
float screenRadius = heightVector.length() * 0.5f;
|
||||
|
||||
@@ -396,13 +395,13 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
|
||||
if (phi > osg::PI_2) phi = osg::PI_2;
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"theta = "<<theta<< "phi="<<phi<<std::endl;
|
||||
|
||||
|
||||
double f = distance * sin(phi);
|
||||
double e = distance * cos(phi) + sqrt( sphere_radius*sphere_radius - f*f);
|
||||
double l = e * cos(phi);
|
||||
double h = e * sin(phi);
|
||||
double z = l - distance;
|
||||
|
||||
|
||||
osg::Vec3 texcoord(h * cos(theta) / sphere_radius,
|
||||
h * sin(theta) / sphere_radius,
|
||||
z / sphere_radius);
|
||||
@@ -416,12 +415,11 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
|
||||
// osg::notify(osg::NOTICE)<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
geometry->setVertexArray(vertices);
|
||||
|
||||
geometry->setColorArray(colors);
|
||||
geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
geometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
|
||||
|
||||
geometry->setTexCoordArray(0,texcoords);
|
||||
|
||||
@@ -435,15 +433,15 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
|
||||
}
|
||||
geometry->addPrimitiveSet(elements);
|
||||
}
|
||||
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
|
||||
{
|
||||
|
||||
|
||||
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
if (!wsi)
|
||||
if (!wsi)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
|
||||
return;
|
||||
@@ -463,8 +461,8 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
if (!gc)
|
||||
@@ -485,8 +483,8 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
|
||||
texture->setInternalFormat(GL_RGB);
|
||||
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
||||
|
||||
#if 0
|
||||
|
||||
#if 0
|
||||
osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::SEPERATE_WINDOW;
|
||||
GLenum buffer = GL_FRONT;
|
||||
#else
|
||||
@@ -512,7 +510,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
|
||||
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// top face
|
||||
{
|
||||
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
|
||||
@@ -608,7 +606,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
|
||||
|
||||
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(180.0f), 1.0,0.0,0.0));
|
||||
}
|
||||
|
||||
|
||||
viewer.getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0);
|
||||
|
||||
|
||||
@@ -618,7 +616,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
geode->addDrawable(createDomeDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), arguments));
|
||||
|
||||
// new we need to add the texture to the mesh, we do so by creating a
|
||||
// new we need to add the texture to the mesh, we do so by creating a
|
||||
// StateSet to contain the Texture StateAttribute.
|
||||
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
||||
stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
|
||||
@@ -636,18 +634,18 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
|
||||
camera->setAllowEventFocus(false);
|
||||
//camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE);
|
||||
//camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
|
||||
|
||||
camera->setProjectionMatrixAsOrtho2D(0,width,0,height);
|
||||
camera->setViewMatrix(osg::Matrix::identity());
|
||||
|
||||
// add subgraph to render
|
||||
camera->addChild(geode);
|
||||
|
||||
|
||||
camera->setName("DistortionCorrectionCamera");
|
||||
|
||||
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false);
|
||||
}
|
||||
|
||||
|
||||
viewer.getCamera()->setNearFarRatio(0.0001f);
|
||||
}
|
||||
|
||||
@@ -665,23 +663,23 @@ int main(int argc, char** argv)
|
||||
|
||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
|
||||
|
||||
|
||||
if (!loadedModel)
|
||||
{
|
||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (arguments.read("--dome") || arguments.read("--puffer") )
|
||||
{
|
||||
{
|
||||
|
||||
setDomeCorrection(viewer, arguments);
|
||||
|
||||
|
||||
viewer.setSceneData( loadedModel );
|
||||
}
|
||||
else if (arguments.read("--faces"))
|
||||
{
|
||||
{
|
||||
|
||||
setDomeFaces(viewer, arguments);
|
||||
|
||||
@@ -697,7 +695,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
viewer.setLightingMode(osg::View::SKY_LIGHT);
|
||||
}
|
||||
|
||||
|
||||
if (viewer.getLightingMode()==osg::View::HEADLIGHT)
|
||||
{
|
||||
viewer.getLight()->setPosition(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
|
||||
@@ -726,7 +724,7 @@ int main(int argc, char** argv)
|
||||
while (arguments.read("-p",pathfile))
|
||||
{
|
||||
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
|
||||
if (apm || !apm->valid())
|
||||
if (apm || !apm->valid())
|
||||
{
|
||||
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
|
||||
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
|
||||
@@ -742,7 +740,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
|
||||
|
||||
// add the stats handler
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Switch>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TextureBuffer>
|
||||
#include <osg/Image>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/VertexProgram>
|
||||
#include <osg/FragmentProgram>
|
||||
@@ -85,9 +87,9 @@ public:
|
||||
float _height;
|
||||
unsigned int _type;
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector< osg::ref_ptr<Tree> > TreeList;
|
||||
|
||||
|
||||
class Cell : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
@@ -95,21 +97,21 @@ public:
|
||||
|
||||
Cell():_parent(0) {}
|
||||
Cell(osg::BoundingBox& bb):_parent(0), _bb(bb) {}
|
||||
|
||||
|
||||
void addCell(Cell* cell) { cell->_parent=this; _cells.push_back(cell); }
|
||||
|
||||
void addTree(Tree* tree) { _trees.push_back(tree); }
|
||||
|
||||
|
||||
void addTrees(const TreeList& trees) { _trees.insert(_trees.end(),trees.begin(),trees.end()); }
|
||||
|
||||
|
||||
void computeBound();
|
||||
|
||||
|
||||
bool contains(const osg::Vec3& position) const { return _bb.contains(position); }
|
||||
|
||||
|
||||
bool divide(unsigned int maxNumTreesPerCell=10);
|
||||
|
||||
|
||||
bool divide(bool xAxis, bool yAxis, bool zAxis);
|
||||
|
||||
|
||||
void bin();
|
||||
|
||||
|
||||
@@ -117,7 +119,7 @@ public:
|
||||
osg::BoundingBox _bb;
|
||||
CellList _cells;
|
||||
TreeList _trees;
|
||||
|
||||
|
||||
};
|
||||
|
||||
float random(float min,float max) { return min + (max-min)*(float)rand()/(float)RAND_MAX; }
|
||||
@@ -139,11 +141,17 @@ public:
|
||||
osg::Node* createTransformGraph(Cell* cell,osg::StateSet* stateset);
|
||||
|
||||
osg::Node* createShaderGraph(Cell* cell,osg::StateSet* stateset);
|
||||
|
||||
|
||||
osg::Node* createGeometryShaderGraph(Cell* cell, osg::StateSet* stateset);
|
||||
|
||||
osg::Node* createTextureBufferGraph(Cell* cell, osg::Geometry* templateGeometry);
|
||||
|
||||
void CollectTreePositions(Cell* cell, std::vector< osg::Vec3 >& positions);
|
||||
|
||||
osg::Node* createHUDWithText(const std::string& text);
|
||||
|
||||
osg::Node* createScene(unsigned int numTreesToCreates);
|
||||
|
||||
osg::Node* createScene(unsigned int numTreesToCreates, unsigned int maxNumTreesPerCell);
|
||||
|
||||
void advanceToNextTechnique(int delta=1)
|
||||
{
|
||||
if (_techniqueSwitch.valid())
|
||||
@@ -156,10 +164,10 @@ public:
|
||||
_techniqueSwitch->setSingleChildOn(_currentTechnique);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Switch> _techniqueSwitch;
|
||||
int _currentTechnique;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -169,22 +177,22 @@ class TechniqueEventHandler : public osgGA::GUIEventHandler
|
||||
public:
|
||||
|
||||
TechniqueEventHandler(ForestTechniqueManager* ttm=0) { _ForestTechniqueManager = ttm; }
|
||||
|
||||
|
||||
META_Object(osgforestApp,TechniqueEventHandler);
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object*, osg::NodeVisitor*);
|
||||
|
||||
|
||||
virtual void getUsage(osg::ApplicationUsage& usage) const;
|
||||
|
||||
protected:
|
||||
|
||||
~TechniqueEventHandler() {}
|
||||
|
||||
|
||||
TechniqueEventHandler(const TechniqueEventHandler&,const osg::CopyOp&) {}
|
||||
|
||||
|
||||
osg::ref_ptr<ForestTechniqueManager> _ForestTechniqueManager;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object*, osg::NodeVisitor*)
|
||||
@@ -194,14 +202,14 @@ bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAc
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey()=='n' ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Right ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Right ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Right)
|
||||
{
|
||||
_ForestTechniqueManager->advanceToNextTechnique(1);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='p' ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
|
||||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left)
|
||||
{
|
||||
_ForestTechniqueManager->advanceToNextTechnique(-1);
|
||||
@@ -329,7 +337,7 @@ bool ForestTechniqueManager::Cell::divide(bool xAxis, bool yAxis, bool zAxis)
|
||||
}
|
||||
|
||||
void ForestTechniqueManager::Cell::bin()
|
||||
{
|
||||
{
|
||||
// put trees in appropriate cells.
|
||||
TreeList treesNotAssigned;
|
||||
for(TreeList::iterator titr=_trees.begin();
|
||||
@@ -387,9 +395,9 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
|
||||
texture->setImage(image);
|
||||
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
|
||||
geode->setStateSet( stateset );
|
||||
|
||||
|
||||
unsigned int numColumns = 38;
|
||||
unsigned int numRows = 39;
|
||||
unsigned int r;
|
||||
@@ -406,7 +414,7 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
|
||||
max_z = osg::maximum(max_z,vertex[r+c*numRows][2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float scale_z = size.z()/(max_z-min_z);
|
||||
|
||||
|
||||
@@ -427,22 +435,22 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
|
||||
grid->setHeight(c,r,(vertex[r+c*numRows][2]-min_z)*scale_z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
geode->addDrawable(new osg::ShapeDrawable(grid));
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::Geometry* geometry = new osg::Geometry;
|
||||
|
||||
|
||||
osg::Vec3Array& v = *(new osg::Vec3Array(numColumns*numRows));
|
||||
osg::Vec2Array& t = *(new osg::Vec2Array(numColumns*numRows));
|
||||
osg::Vec4ubArray& color = *(new osg::Vec4ubArray(1));
|
||||
|
||||
|
||||
color[0].set(255,255,255,255);
|
||||
|
||||
float rowCoordDelta = size.y()/(float)(numRows-1);
|
||||
float columnCoordDelta = size.x()/(float)(numColumns-1);
|
||||
|
||||
|
||||
float rowTexDelta = 1.0f/(float)(numRows-1);
|
||||
float columnTexDelta = 1.0f/(float)(numColumns-1);
|
||||
|
||||
@@ -464,12 +472,11 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
|
||||
pos.y() += rowCoordDelta;
|
||||
tex.y() += rowTexDelta;
|
||||
}
|
||||
|
||||
|
||||
geometry->setVertexArray(&v);
|
||||
geometry->setColorArray(&color);
|
||||
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geometry->setColorArray(&color, osg::Array::BIND_OVERALL);
|
||||
geometry->setTexCoordArray(0,&t);
|
||||
|
||||
|
||||
for(r=0;r<numRows-1;++r)
|
||||
{
|
||||
osg::DrawElementsUShort& drawElements = *(new osg::DrawElementsUShort(GL_QUAD_STRIP,2*numColumns));
|
||||
@@ -481,13 +488,13 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
|
||||
drawElements[ei++] = (r)*numColumns+c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
geode->addDrawable(geometry);
|
||||
|
||||
|
||||
osgUtil::SmoothingVisitor sv;
|
||||
sv.smooth(*geometry);
|
||||
}
|
||||
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
@@ -496,7 +503,7 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3&
|
||||
|
||||
float max_TreeHeight = sqrtf(size.length2()/(float)numTreesToCreate);
|
||||
float max_TreeWidth = max_TreeHeight*0.5f;
|
||||
|
||||
|
||||
float min_TreeHeight = max_TreeHeight*0.3f;
|
||||
float min_TreeWidth = min_TreeHeight*0.5f;
|
||||
|
||||
@@ -511,14 +518,14 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3&
|
||||
tree->_width = random(min_TreeWidth,max_TreeWidth);
|
||||
tree->_height = random(min_TreeHeight,max_TreeHeight);
|
||||
tree->_type = 0;
|
||||
|
||||
|
||||
if (terrain)
|
||||
{
|
||||
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
|
||||
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
|
||||
new osgUtil::LineSegmentIntersector(tree->_position,tree->_position+osg::Vec3(0.0f,0.0f,size.z()));
|
||||
|
||||
osgUtil::IntersectionVisitor iv(intersector.get());
|
||||
|
||||
|
||||
terrain->accept(iv);
|
||||
|
||||
if (intersector->containsIntersections())
|
||||
@@ -533,7 +540,7 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3&
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
trees.push_back(tree);
|
||||
}
|
||||
}
|
||||
@@ -563,8 +570,7 @@ osg::Geometry* ForestTechniqueManager::createSprite( float w, float h, osg::Vec4
|
||||
|
||||
geom->setTexCoordArray( 0, &t );
|
||||
|
||||
geom->setColorArray( &c );
|
||||
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
|
||||
geom->setColorArray( &c, osg::Array::BIND_OVERALL );
|
||||
|
||||
geom->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4) );
|
||||
|
||||
@@ -577,7 +583,7 @@ osg::Geometry* ForestTechniqueManager::createOrthogonalQuads( const osg::Vec3& p
|
||||
osg::Vec3Array& v = *(new osg::Vec3Array(8));
|
||||
osg::Vec2Array& t = *(new osg::Vec2Array(8));
|
||||
osg::Vec4ubArray& c = *(new osg::Vec4ubArray(1));
|
||||
|
||||
|
||||
float rotation = random(0.0f,osg::PI/2.0f);
|
||||
float sw = sinf(rotation)*w*0.5f;
|
||||
float cw = cosf(rotation)*w*0.5f;
|
||||
@@ -610,8 +616,7 @@ osg::Geometry* ForestTechniqueManager::createOrthogonalQuads( const osg::Vec3& p
|
||||
|
||||
geom->setTexCoordArray( 0, &t );
|
||||
|
||||
geom->setColorArray( &c );
|
||||
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
|
||||
geom->setColorArray( &c, osg::Array::BIND_OVERALL );
|
||||
|
||||
geom->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,8) );
|
||||
|
||||
@@ -622,10 +627,10 @@ osg::Node* ForestTechniqueManager::createBillboardGraph(Cell* cell,osg::StateSet
|
||||
{
|
||||
bool needGroup = !(cell->_cells.empty());
|
||||
bool needBillboard = !(cell->_trees.empty());
|
||||
|
||||
|
||||
osg::Billboard* billboard = 0;
|
||||
osg::Group* group = 0;
|
||||
|
||||
|
||||
if (needBillboard)
|
||||
{
|
||||
billboard = new osg::Billboard;
|
||||
@@ -635,10 +640,10 @@ osg::Node* ForestTechniqueManager::createBillboardGraph(Cell* cell,osg::StateSet
|
||||
++itr)
|
||||
{
|
||||
Tree& tree = **itr;
|
||||
billboard->addDrawable(createSprite(tree._width,tree._height,tree._color),tree._position);
|
||||
billboard->addDrawable(createSprite(tree._width,tree._height,tree._color),tree._position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (needGroup)
|
||||
{
|
||||
group = new osg::Group;
|
||||
@@ -648,9 +653,9 @@ osg::Node* ForestTechniqueManager::createBillboardGraph(Cell* cell,osg::StateSet
|
||||
{
|
||||
group->addChild(createBillboardGraph(itr->get(),stateset));
|
||||
}
|
||||
|
||||
|
||||
if (billboard) group->addChild(billboard);
|
||||
|
||||
|
||||
}
|
||||
if (group) return group;
|
||||
else return billboard;
|
||||
@@ -660,15 +665,15 @@ osg::Node* ForestTechniqueManager::createXGraph(Cell* cell,osg::StateSet* states
|
||||
{
|
||||
bool needGroup = !(cell->_cells.empty());
|
||||
bool needTrees = !(cell->_trees.empty());
|
||||
|
||||
|
||||
osg::Geode* geode = 0;
|
||||
osg::Group* group = 0;
|
||||
|
||||
|
||||
if (needTrees)
|
||||
{
|
||||
geode = new osg::Geode;
|
||||
geode->setStateSet(stateset);
|
||||
|
||||
|
||||
for(TreeList::iterator itr=cell->_trees.begin();
|
||||
itr!=cell->_trees.end();
|
||||
++itr)
|
||||
@@ -677,7 +682,7 @@ osg::Node* ForestTechniqueManager::createXGraph(Cell* cell,osg::StateSet* states
|
||||
geode->addDrawable(createOrthogonalQuads(tree._position,tree._width,tree._height,tree._color));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (needGroup)
|
||||
{
|
||||
group = new osg::Group;
|
||||
@@ -687,9 +692,9 @@ osg::Node* ForestTechniqueManager::createXGraph(Cell* cell,osg::StateSet* states
|
||||
{
|
||||
group->addChild(createXGraph(itr->get(),stateset));
|
||||
}
|
||||
|
||||
|
||||
if (geode) group->addChild(geode);
|
||||
|
||||
|
||||
}
|
||||
if (group) return group;
|
||||
else return geode;
|
||||
@@ -699,16 +704,16 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
|
||||
{
|
||||
bool needGroup = !(cell->_cells.empty());
|
||||
bool needTrees = !(cell->_trees.empty());
|
||||
|
||||
|
||||
osg::Group* transform_group = 0;
|
||||
osg::Group* group = 0;
|
||||
|
||||
|
||||
if (needTrees)
|
||||
{
|
||||
transform_group = new osg::Group;
|
||||
|
||||
|
||||
osg::Geometry* geometry = createOrthogonalQuads(osg::Vec3(0.0f,0.0f,0.0f),1.0f,1.0f,osg::Vec4ub(255,255,255,255));
|
||||
|
||||
|
||||
for(TreeList::iterator itr=cell->_trees.begin();
|
||||
itr!=cell->_trees.end();
|
||||
++itr)
|
||||
@@ -716,7 +721,7 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
|
||||
Tree& tree = **itr;
|
||||
osg::MatrixTransform* transform = new osg::MatrixTransform;
|
||||
transform->setMatrix(osg::Matrix::scale(tree._width,tree._width,tree._height)*osg::Matrix::translate(tree._position));
|
||||
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->setStateSet(stateset);
|
||||
geode->addDrawable(geometry);
|
||||
@@ -724,7 +729,7 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
|
||||
transform_group->addChild(transform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (needGroup)
|
||||
{
|
||||
group = new osg::Group;
|
||||
@@ -734,9 +739,9 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
|
||||
{
|
||||
group->addChild(createTransformGraph(itr->get(),stateset));
|
||||
}
|
||||
|
||||
|
||||
if (transform_group) group->addChild(transform_group);
|
||||
|
||||
|
||||
}
|
||||
if (group) return group;
|
||||
else return transform_group;
|
||||
@@ -747,7 +752,7 @@ osg::Geometry* ForestTechniqueManager::createOrthogonalQuadsNoColor( const osg::
|
||||
// set up the coords
|
||||
osg::Vec3Array& v = *(new osg::Vec3Array(8));
|
||||
osg::Vec2Array& t = *(new osg::Vec2Array(8));
|
||||
|
||||
|
||||
float rotation = random(0.0f,osg::PI/2.0f);
|
||||
float sw = sinf(rotation)*w*0.5f;
|
||||
float cw = cosf(rotation)*w*0.5f;
|
||||
@@ -795,7 +800,7 @@ class ShaderGeometry : public osg::Drawable
|
||||
META_Object(osg,ShaderGeometry)
|
||||
|
||||
typedef std::vector<osg::Vec4> PositionSizeList;
|
||||
|
||||
|
||||
virtual void drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
for(PositionSizeList::const_iterator itr = _trees.begin();
|
||||
@@ -822,29 +827,241 @@ class ShaderGeometry : public osg::Drawable
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
||||
void setGeometry(osg::Geometry* geometry)
|
||||
{
|
||||
_geometry = geometry;
|
||||
}
|
||||
|
||||
|
||||
void addTree(ForestTechniqueManager::Tree& tree)
|
||||
{
|
||||
_trees.push_back(osg::Vec4(tree._position.x(), tree._position.y(), tree._position.z(), tree._height));
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Geometry> _geometry;
|
||||
|
||||
PositionSizeList _trees;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual ~ShaderGeometry() {}
|
||||
|
||||
|
||||
};
|
||||
|
||||
osg::Geometry* shared_geometry = 0;
|
||||
|
||||
osg::Program* createGeometryShader()
|
||||
{
|
||||
static const char* vertSource = {
|
||||
"#version 120\n"
|
||||
"#extension GL_EXT_geometry_shader4 : enable\n"
|
||||
"varying vec2 texcoord;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = gl_Vertex;\n"
|
||||
" texcoord = gl_MultiTexCoord0.st;\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
static const char* geomSource = {
|
||||
"#version 120\n"
|
||||
"#extension GL_EXT_geometry_shader4 : enable\n"
|
||||
"varying vec2 texcoord;\n"
|
||||
"varying float intensity; \n"
|
||||
"varying float red_intensity; \n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 v = gl_PositionIn[0];\n"
|
||||
" vec4 info = gl_PositionIn[1];\n"
|
||||
" intensity = info.y;\n"
|
||||
" red_intensity = info.z;\n"
|
||||
"\n"
|
||||
" float h = info.x;\n"
|
||||
" float w = h*0.35;\n"
|
||||
" vec4 e;\n"
|
||||
" e = v + vec4(-w,0.0,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,0.0); EmitVertex();\n"
|
||||
" e = v + vec4(w,0.0,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,0.0); EmitVertex();\n"
|
||||
" e = v + vec4(-w,0.0,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,1.0); EmitVertex();\n"
|
||||
" e = v + vec4(w,0.0,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,1.0); EmitVertex();\n"
|
||||
" EndPrimitive();\n"
|
||||
" e = v + vec4(0.0,-w,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,0.0); EmitVertex();\n"
|
||||
" e = v + vec4(0.0,w,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,0.0); EmitVertex();\n"
|
||||
" e = v + vec4(0.0,-w,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,1.0); EmitVertex();\n"
|
||||
" e = v + vec4(0.0,w,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,1.0); EmitVertex();\n"
|
||||
" EndPrimitive();\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
|
||||
static const char* fragSource = {
|
||||
"uniform sampler2D baseTexture; \n"
|
||||
"varying vec2 texcoord; \n"
|
||||
"varying float intensity; \n"
|
||||
"varying float red_intensity; \n"
|
||||
"\n"
|
||||
"void main(void) \n"
|
||||
"{ \n"
|
||||
" vec4 finalColor = texture2D( baseTexture, texcoord); \n"
|
||||
" vec4 color = finalColor * intensity;\n"
|
||||
" color.w = finalColor.w;\n"
|
||||
" color.x *= red_intensity;\n"
|
||||
" gl_FragColor = color;\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
|
||||
osg::Program* pgm = new osg::Program;
|
||||
pgm->setName( "osgshader2 demo" );
|
||||
|
||||
pgm->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource ) );
|
||||
pgm->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource ) );
|
||||
|
||||
pgm->addShader( new osg::Shader( osg::Shader::GEOMETRY, geomSource ) );
|
||||
pgm->setParameter( GL_GEOMETRY_VERTICES_OUT_EXT, 8 );
|
||||
pgm->setParameter( GL_GEOMETRY_INPUT_TYPE_EXT, GL_LINES );
|
||||
pgm->setParameter( GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
|
||||
|
||||
return pgm;
|
||||
}
|
||||
|
||||
void ForestTechniqueManager::CollectTreePositions(Cell* cell, std::vector< osg::Vec3 >& positions)
|
||||
{
|
||||
bool needGroup = !(cell->_cells.empty());
|
||||
bool needTrees = !(cell->_trees.empty());
|
||||
|
||||
if (needTrees)
|
||||
{
|
||||
for(TreeList::iterator itr=cell->_trees.begin();
|
||||
itr!=cell->_trees.end();
|
||||
++itr)
|
||||
{
|
||||
Tree& tree = **itr;
|
||||
positions.push_back(tree._position);
|
||||
}
|
||||
}
|
||||
|
||||
if (needGroup)
|
||||
{
|
||||
for(Cell::CellList::iterator itr=cell->_cells.begin();
|
||||
itr!=cell->_cells.end();
|
||||
++itr)
|
||||
{
|
||||
CollectTreePositions(itr->get(),positions);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
osg::Node* ForestTechniqueManager::createGeometryShaderGraph(Cell* cell, osg::StateSet* dstate)
|
||||
{
|
||||
bool needGroup = !(cell->_cells.empty());
|
||||
bool needTrees = !(cell->_trees.empty());
|
||||
|
||||
osg::Geode* geode = 0;
|
||||
osg::Group* group = 0;
|
||||
|
||||
if (needTrees)
|
||||
{
|
||||
geode = new osg::Geode;
|
||||
geode->setStateSet(dstate);
|
||||
|
||||
osg::Geometry* geometry = new osg::Geometry;
|
||||
geode->addDrawable(geometry);
|
||||
|
||||
osg::Vec3Array* v = new osg::Vec3Array;
|
||||
|
||||
for(TreeList::iterator itr=cell->_trees.begin();
|
||||
itr!=cell->_trees.end();
|
||||
++itr)
|
||||
{
|
||||
Tree& tree = **itr;
|
||||
v->push_back(tree._position);
|
||||
v->push_back(osg::Vec3(/*tree._height*/30.0,(double)random(0.75f,1.15f),(double)random(1.0f,1.250f)));
|
||||
}
|
||||
geometry->setVertexArray( v );
|
||||
geometry->addPrimitiveSet( new osg::DrawArrays( GL_LINES, 0, v->size() ) );
|
||||
|
||||
osg::StateSet* sset = geode->getOrCreateStateSet();
|
||||
sset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
|
||||
sset->setAttribute( createGeometryShader() );
|
||||
|
||||
osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0);
|
||||
sset->addUniform(baseTextureSampler);
|
||||
|
||||
}
|
||||
|
||||
if (needGroup)
|
||||
{
|
||||
group = new osg::Group;
|
||||
for(Cell::CellList::iterator itr=cell->_cells.begin();
|
||||
itr!=cell->_cells.end();
|
||||
++itr)
|
||||
{
|
||||
group->addChild(createGeometryShaderGraph(itr->get(),dstate));
|
||||
}
|
||||
|
||||
if (geode) group->addChild(geode);
|
||||
|
||||
}
|
||||
if (group) return group;
|
||||
else return geode;
|
||||
}
|
||||
|
||||
osg::Node* ForestTechniqueManager::createTextureBufferGraph(Cell* cell, osg::Geometry* templateGeometry)
|
||||
{
|
||||
bool needGroup = !(cell->_cells.empty());
|
||||
bool needTrees = !(cell->_trees.empty());
|
||||
|
||||
osg::Geode* geode = 0;
|
||||
osg::Group* group = 0;
|
||||
|
||||
if (needTrees)
|
||||
{
|
||||
osg::Geometry* geometry = (osg::Geometry*)templateGeometry->clone( osg::CopyOp::DEEP_COPY_PRIMITIVES );
|
||||
osg::DrawArrays* primSet = dynamic_cast<osg::DrawArrays*>( geometry->getPrimitiveSet(0) );
|
||||
primSet->setNumInstances( cell->_trees.size() );
|
||||
geode = new osg::Geode;
|
||||
geode->addDrawable(geometry);
|
||||
|
||||
osg::ref_ptr<osg::Image> treeParamsImage = new osg::Image;
|
||||
treeParamsImage->allocateImage( 3*cell->_trees.size(), 1, 1, GL_RGBA, GL_FLOAT );
|
||||
|
||||
unsigned int i=0;
|
||||
for(TreeList::iterator itr=cell->_trees.begin();
|
||||
itr!=cell->_trees.end();
|
||||
++itr,++i)
|
||||
{
|
||||
osg::Vec4f* ptr = (osg::Vec4f*)treeParamsImage->data(3*i);
|
||||
Tree& tree = **itr;
|
||||
ptr[0] = osg::Vec4f(tree._position.x(),tree._position.y(),tree._position.z(),1.0);
|
||||
ptr[1] = osg::Vec4f((float)tree._color.r()/255.0f,(float)tree._color.g()/255.0f, (float)tree._color.b()/255.0f, 1.0);
|
||||
ptr[2] = osg::Vec4f(tree._width, tree._height, 1.0, 1.0);
|
||||
}
|
||||
osg::ref_ptr<osg::TextureBuffer> tbo = new osg::TextureBuffer;
|
||||
tbo->setImage( treeParamsImage.get() );
|
||||
tbo->setInternalFormat(GL_RGBA32F_ARB);
|
||||
geometry->getOrCreateStateSet()->setTextureAttribute(1, tbo.get());
|
||||
geometry->setInitialBound( cell->_bb );
|
||||
}
|
||||
|
||||
if (needGroup)
|
||||
{
|
||||
group = new osg::Group;
|
||||
for(Cell::CellList::iterator itr=cell->_cells.begin();
|
||||
itr!=cell->_cells.end();
|
||||
++itr)
|
||||
{
|
||||
group->addChild(createTextureBufferGraph(itr->get(),templateGeometry));
|
||||
}
|
||||
|
||||
if (geode) group->addChild(geode);
|
||||
|
||||
}
|
||||
if (group) return group;
|
||||
else return geode;
|
||||
}
|
||||
|
||||
|
||||
osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* stateset)
|
||||
{
|
||||
if (shared_geometry==0)
|
||||
@@ -856,18 +1073,18 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
|
||||
|
||||
bool needGroup = !(cell->_cells.empty());
|
||||
bool needTrees = !(cell->_trees.empty());
|
||||
|
||||
|
||||
osg::Geode* geode = 0;
|
||||
osg::Group* group = 0;
|
||||
|
||||
|
||||
if (needTrees)
|
||||
{
|
||||
geode = new osg::Geode;
|
||||
|
||||
|
||||
ShaderGeometry* shader_geometry = new ShaderGeometry;
|
||||
shader_geometry->setGeometry(shared_geometry);
|
||||
|
||||
|
||||
|
||||
|
||||
for(TreeList::iterator itr=cell->_trees.begin();
|
||||
itr!=cell->_trees.end();
|
||||
++itr)
|
||||
@@ -880,7 +1097,7 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
|
||||
geode->setStateSet(stateset);
|
||||
geode->addDrawable(shader_geometry);
|
||||
}
|
||||
|
||||
|
||||
if (needGroup)
|
||||
{
|
||||
group = new osg::Group;
|
||||
@@ -890,9 +1107,9 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
|
||||
{
|
||||
group->addChild(createShaderGraph(itr->get(),stateset));
|
||||
}
|
||||
|
||||
|
||||
if (geode) group->addChild(geode);
|
||||
|
||||
|
||||
}
|
||||
if (group) return group;
|
||||
else return geode;
|
||||
@@ -901,14 +1118,14 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
|
||||
osg::Node* ForestTechniqueManager::createHUDWithText(const std::string& str)
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
|
||||
std::string timesFont("fonts/arial.ttf");
|
||||
|
||||
// turn lighting off for the text and disable depth test to ensure its always ontop.
|
||||
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
|
||||
// or disable depth test, and make sure that the hud is drawn after everything
|
||||
// or disable depth test, and make sure that the hud is drawn after everything
|
||||
// else so that it always appears ontop.
|
||||
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||
stateset->setRenderBinDetails(11,"RenderBin");
|
||||
@@ -923,11 +1140,11 @@ osg::Node* ForestTechniqueManager::createHUDWithText(const std::string& str)
|
||||
text->setFont(timesFont);
|
||||
text->setPosition(position);
|
||||
text->setText(str);
|
||||
|
||||
position += delta;
|
||||
}
|
||||
|
||||
|
||||
position += delta;
|
||||
}
|
||||
|
||||
|
||||
// create the hud.
|
||||
osg::MatrixTransform* modelview_abs = new osg::MatrixTransform;
|
||||
modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
@@ -941,7 +1158,7 @@ osg::Node* ForestTechniqueManager::createHUDWithText(const std::string& str)
|
||||
return projection;
|
||||
}
|
||||
|
||||
osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, unsigned int maxNumTreesPerCell)
|
||||
{
|
||||
osg::Vec3 origin(0.0f,0.0f,0.0f);
|
||||
osg::Vec3 size(1000.0f,1000.0f,200.0f);
|
||||
@@ -949,26 +1166,26 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
std::cout<<"Creating terrain...";
|
||||
osg::ref_ptr<osg::Node> terrain = createTerrain(origin,size);
|
||||
std::cout<<"done."<<std::endl;
|
||||
|
||||
|
||||
std::cout<<"Creating tree locations...";std::cout.flush();
|
||||
TreeList trees;
|
||||
createTreeList(terrain.get(),origin,size,numTreesToCreates,trees);
|
||||
std::cout<<"done."<<std::endl;
|
||||
|
||||
|
||||
std::cout<<"Creating cell subdivision...";
|
||||
osg::ref_ptr<Cell> cell = new Cell;
|
||||
cell->addTrees(trees);
|
||||
cell->divide();
|
||||
std::cout<<"done."<<std::endl;
|
||||
|
||||
|
||||
cell->divide(maxNumTreesPerCell);
|
||||
std::cout<<"done."<<std::endl;
|
||||
|
||||
|
||||
osg::Texture2D *tex = new osg::Texture2D;
|
||||
tex->setWrap( osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP );
|
||||
tex->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP );
|
||||
tex->setImage(osgDB::readImageFile("Images/tree0.rgba"));
|
||||
|
||||
osg::StateSet *dstate = new osg::StateSet;
|
||||
{
|
||||
{
|
||||
dstate->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON );
|
||||
|
||||
dstate->setTextureAttribute(0, new osg::TexEnv );
|
||||
@@ -983,7 +1200,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
|
||||
dstate->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
|
||||
}
|
||||
|
||||
|
||||
|
||||
_techniqueSwitch = new osg::Switch;
|
||||
|
||||
@@ -991,11 +1208,11 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
std::cout<<"Creating osg::Billboard based forest...";
|
||||
osg::Group* group = new osg::Group;
|
||||
group->addChild(createBillboardGraph(cell.get(),dstate));
|
||||
group->addChild(createHUDWithText("Using osg::Billboard's to create a forest\n\nPress left cursor key to select OpenGL shader based forest\nPress right cursor key to select double quad based forest"));
|
||||
group->addChild(createHUDWithText("Using osg::Billboard's to create a forest\n\nPress left cursor key to select geometry instancing with Texture Buffer Object\nPress right cursor key to select double quad based forest"));
|
||||
_techniqueSwitch->addChild(group);
|
||||
std::cout<<"done."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
std::cout<<"Creating double quad based forest...";
|
||||
osg::Group* group = new osg::Group;
|
||||
@@ -1025,7 +1242,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
std::ostringstream vp_oss;
|
||||
vp_oss <<
|
||||
"!!ARBvp1.0\n"
|
||||
|
||||
|
||||
"ATTRIB vpos = vertex.position;\n"
|
||||
"ATTRIB vcol = vertex.color;\n"
|
||||
"ATTRIB tc = vertex.texcoord[" << 0 << "];"
|
||||
@@ -1034,8 +1251,8 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
"PARAM one = { 1.0, 1.0, 1.0, 1.0 };"
|
||||
|
||||
"TEMP position;\n"
|
||||
|
||||
// vec3 position = gl_Vertex.xyz * gl_Color.w + gl_Color.xyz;
|
||||
|
||||
// vec3 position = gl_Vertex.xyz * gl_Color.w + gl_Color.xyz;
|
||||
"MAD position, vpos, vcol.w, vcol;\n"
|
||||
|
||||
// gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0);
|
||||
@@ -1048,7 +1265,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
// gl_FrontColor = vec4(1.0,1.0,1.0,1.0);
|
||||
"MOV result.color.front.primary, one;\n"
|
||||
|
||||
// texcoord = gl_MultiTexCoord0.st;
|
||||
// texcoord = gl_MultiTexCoord0.st;
|
||||
"MOV result.texcoord, tc;\n"
|
||||
"END\n";
|
||||
|
||||
@@ -1087,10 +1304,10 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
|
||||
#if 1
|
||||
// use inline shaders
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// vertex shader using just Vec4 coefficients
|
||||
char vertexShaderSource[] =
|
||||
char vertexShaderSource[] =
|
||||
"varying vec2 texcoord;\n"
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
@@ -1104,7 +1321,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// fragment shader
|
||||
//
|
||||
char fragmentShaderSource[] =
|
||||
char fragmentShaderSource[] =
|
||||
"uniform sampler2D baseTexture; \n"
|
||||
"varying vec2 texcoord; \n"
|
||||
"\n"
|
||||
@@ -1118,7 +1335,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
|
||||
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource);
|
||||
program->addShader(fragment_shader);
|
||||
|
||||
|
||||
#else
|
||||
|
||||
// get shaders from source
|
||||
@@ -1132,17 +1349,99 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
|
||||
}
|
||||
|
||||
group->addChild(createShaderGraph(cell.get(),stateset));
|
||||
group->addChild(createHUDWithText("Using OpenGL Shader to create a forest\n\nPress left cursor key to select osg::Vertex/FragmentProgram based forest\nPress right cursor key to select osg::Billboard based forest"));
|
||||
group->addChild(createHUDWithText("Using OpenGL Shader to create a forest\n\nPress left cursor key to select osg::Vertex/FragmentProgram based forest\nPress right cursor key to select osg::Vertex/Geometry/FragmentProgram based forest"));
|
||||
_techniqueSwitch->addChild(group);
|
||||
std::cout<<"done."<<std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
std::cout<<"Creating Geometry Shader based forest...";
|
||||
|
||||
osg::StateSet* stateset = new osg::StateSet(*dstate, osg::CopyOp::DEEP_COPY_ALL);
|
||||
|
||||
osg::Group* group = new osg::Group;
|
||||
group->addChild(createGeometryShaderGraph(cell.get(), stateset));
|
||||
group->addChild(createHUDWithText("Using osg::Vertex/Geometry/FragmentProgram to create a forest\n\nPress left cursor key to select OpenGL Shader based forest\nPress right cursor key to select geometry instancing with Texture Buffer Object"));
|
||||
|
||||
_techniqueSwitch->addChild(group);
|
||||
std::cout<<"done."<<std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
std::cout<<"Creating forest using geometry instancing and texture buffer objects ...";
|
||||
|
||||
osg::StateSet* stateset = new osg::StateSet(*dstate, osg::CopyOp::DEEP_COPY_ALL);
|
||||
{
|
||||
osg::Program* program = new osg::Program;
|
||||
stateset->setAttribute(program);
|
||||
|
||||
char vertexShaderSource[] =
|
||||
"#version 420 compatibility\n"
|
||||
"uniform samplerBuffer dataBuffer;\n"
|
||||
"layout(location = 0) in vec3 VertexPosition;\n"
|
||||
"layout(location = 8) in vec3 VertexTexCoord;\n"
|
||||
"out vec2 TexCoord;\n"
|
||||
"out vec4 Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" int instanceAddress = gl_InstanceID * 3;\n"
|
||||
" vec3 position = texelFetch(dataBuffer, instanceAddress).xyz;\n"
|
||||
" Color = texelFetch(dataBuffer, instanceAddress + 1);\n"
|
||||
" vec2 size = texelFetch(dataBuffer, instanceAddress + 2).xy;\n"
|
||||
" mat4 mvpMatrix = gl_ModelViewProjectionMatrix *\n"
|
||||
" mat4( size.x, 0.0, 0.0, 0.0,\n"
|
||||
" 0.0, size.x, 0.0, 0.0,\n"
|
||||
" 0.0, 0.0, size.y, 0.0,\n"
|
||||
" position.x, position.y, position.z, 1.0);\n"
|
||||
" gl_Position = mvpMatrix * vec4(VertexPosition,1.0) ;\n"
|
||||
" TexCoord = VertexTexCoord.xy;\n"
|
||||
"}\n";
|
||||
|
||||
char fragmentShaderSource[] =
|
||||
"#version 420 core\n"
|
||||
"uniform sampler2D baseTexture; \n"
|
||||
"in vec2 TexCoord;\n"
|
||||
"in vec4 Color;\n"
|
||||
"layout(location = 0, index = 0) out vec4 FragData0;\n"
|
||||
"void main(void) \n"
|
||||
"{\n"
|
||||
" FragData0 = Color*texture(baseTexture, TexCoord);\n"
|
||||
"}\n";
|
||||
|
||||
osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource);
|
||||
program->addShader(vertex_shader);
|
||||
|
||||
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource);
|
||||
program->addShader(fragment_shader);
|
||||
|
||||
osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0);
|
||||
stateset->addUniform(baseTextureSampler);
|
||||
|
||||
osg::Uniform* dataBufferSampler = new osg::Uniform("dataBuffer",1);
|
||||
stateset->addUniform(dataBufferSampler);
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Geometry> templateGeometry = createOrthogonalQuadsNoColor(osg::Vec3(0.0f,0.0f,0.0f),1.0f,1.0f);
|
||||
templateGeometry->setUseVertexBufferObjects(true);
|
||||
templateGeometry->setUseDisplayList(false);
|
||||
osg::Node* textureBufferGraph = createTextureBufferGraph(cell.get(), templateGeometry.get());
|
||||
textureBufferGraph->setStateSet( stateset );
|
||||
osg::Group* group = new osg::Group;
|
||||
group->addChild(textureBufferGraph);
|
||||
group->addChild(createHUDWithText("Using geometry instancing to create a forest\n\nPress left cursor key to select osg::Vertex/Geometry/FragmentProgram based forest\nPress right cursor key to select osg::Billboard based forest"));
|
||||
|
||||
_techniqueSwitch->addChild(group);
|
||||
|
||||
std::cout<<"done."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
_currentTechnique = 0;
|
||||
_techniqueSwitch->setSingleChildOn(_currentTechnique);
|
||||
|
||||
|
||||
|
||||
osg::Group* scene = new osg::Group;
|
||||
|
||||
|
||||
scene->addChild(terrain.get());
|
||||
scene->addChild(_techniqueSwitch.get());
|
||||
|
||||
@@ -1154,15 +1453,19 @@ int main( int argc, char **argv )
|
||||
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
float numTreesToCreates = 10000;
|
||||
arguments.read("--trees",numTreesToCreates);
|
||||
|
||||
unsigned int numTreesToCreate = 10000;
|
||||
arguments.read("--trees",numTreesToCreate);
|
||||
|
||||
unsigned int maxNumTreesPerCell = sqrtf(static_cast<float>(numTreesToCreate));
|
||||
|
||||
arguments.read("--trees-per-cell",maxNumTreesPerCell);
|
||||
|
||||
osg::ref_ptr<ForestTechniqueManager> ttm = new ForestTechniqueManager;
|
||||
|
||||
|
||||
// add the stats handler
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
@@ -1170,7 +1473,7 @@ int main( int argc, char **argv )
|
||||
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
|
||||
|
||||
// add model to viewer.
|
||||
viewer.setSceneData( ttm->createScene((unsigned int)numTreesToCreates) );
|
||||
viewer.setSceneData( ttm->createScene(numTreesToCreate, maxNumTreesPerCell) );
|
||||
|
||||
|
||||
return viewer.run();
|
||||
|
||||
11
examples/osgframerenderer/CMakeLists.txt
Normal file
11
examples/osgframerenderer/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
SET(TARGET_SRC
|
||||
CameraPathProperty.cpp
|
||||
CameraProperty.cpp
|
||||
CaptureSettings.cpp
|
||||
EventProperty.cpp
|
||||
osgframerenderer.cpp
|
||||
UpdateProperty.cpp
|
||||
)
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgframerenderer)
|
||||
88
examples/osgframerenderer/CameraPathProperty.cpp
Normal file
88
examples/osgframerenderer/CameraPathProperty.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "CameraPathProperty.h"
|
||||
|
||||
using namespace gsc;
|
||||
|
||||
void CameraPathProperty::update(osgViewer::View* view)
|
||||
{
|
||||
osg::Camera* camera = view->getCamera();
|
||||
osg::FrameStamp* fs = view->getFrameStamp();
|
||||
|
||||
if (_animationPath.valid())
|
||||
{
|
||||
osg::AnimationPath::ControlPoint cp;
|
||||
_animationPath->getInterpolatedControlPoint( fs->getSimulationTime(), cp );
|
||||
|
||||
OSG_NOTICE<<"CameraPathProperty "<<fs->getFrameNumber()<<" "<<fs->getSimulationTime()<<std::endl;
|
||||
|
||||
osg::Matrixd matrix;
|
||||
cp.getMatrix( matrix );
|
||||
camera->setViewMatrix( osg::Matrix::inverse(matrix) );
|
||||
}
|
||||
}
|
||||
|
||||
void CameraPathProperty::loadAnimationPath()
|
||||
{
|
||||
_animationPath = new osg::AnimationPath;;
|
||||
//_animationPath->setLoopMode(osg::AnimationPath::LOOP);
|
||||
|
||||
osgDB::ifstream in(_filename.c_str());
|
||||
if (!in)
|
||||
{
|
||||
OSG_WARN << "CameraPathProperty: Cannot open animation path file \"" << _filename << "\".\n";
|
||||
return;
|
||||
}
|
||||
|
||||
_animationPath->read(in);
|
||||
}
|
||||
|
||||
bool CameraPathProperty::getTimeRange(double& startTime, double& endTime) const
|
||||
{
|
||||
if (!_animationPath) return false;
|
||||
|
||||
const osg::AnimationPath::TimeControlPointMap& tcpm = _animationPath->getTimeControlPointMap();
|
||||
if (tcpm.empty()) return false;
|
||||
|
||||
startTime = tcpm.begin()->first;
|
||||
endTime = tcpm.rbegin()->first;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CameraPathProperty::resetTimeRange(double startTime, double endTime)
|
||||
{
|
||||
if (!_animationPath) return;
|
||||
|
||||
osg::AnimationPath::TimeControlPointMap& tcpm = _animationPath->getTimeControlPointMap();
|
||||
if (tcpm.empty()) return;
|
||||
|
||||
osg::AnimationPath::TimeControlPointMap copy_tcpm = tcpm;
|
||||
|
||||
double offset = tcpm.begin()->first;
|
||||
double originalLength = tcpm.rbegin()->first - tcpm.begin()->first ;
|
||||
double scale = originalLength>0.0 ? (endTime-startTime)/originalLength : 1.0;
|
||||
|
||||
tcpm.clear();
|
||||
|
||||
for(osg::AnimationPath::TimeControlPointMap::iterator itr = copy_tcpm.begin();
|
||||
itr != copy_tcpm.end();
|
||||
++itr)
|
||||
{
|
||||
tcpm[startTime + (itr->first-offset)*scale] = itr->second;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Serialization support
|
||||
//
|
||||
REGISTER_OBJECT_WRAPPER( gsc_CameraPathProperty,
|
||||
new gsc::CameraPathProperty,
|
||||
gsc::CameraPathProperty,
|
||||
"osg::Object gsc::CameraPathProperty" )
|
||||
{
|
||||
ADD_STRING_SERIALIZER( AnimationPathFileName, "" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
46
examples/osgframerenderer/CameraPathProperty.h
Normal file
46
examples/osgframerenderer/CameraPathProperty.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef CAMERAPATHPROPERTY_H
|
||||
#define CAMERAPATHPROPERTY_H
|
||||
|
||||
#include <osg/AnimationPath>
|
||||
|
||||
#include "UpdateProperty.h"
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
|
||||
class CameraPathProperty : public gsc::UpdateProperty
|
||||
{
|
||||
public:
|
||||
|
||||
CameraPathProperty() {}
|
||||
CameraPathProperty(const std::string& filename) { setAnimationPathFileName(filename); }
|
||||
CameraPathProperty(const CameraPathProperty& cpp, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
|
||||
|
||||
META_Object(gsc, CameraPathProperty);
|
||||
|
||||
void setAnimationPathFileName(const std::string& filename) { _filename = filename; loadAnimationPath(); }
|
||||
const std::string& getAnimationPathFileName() const { return _filename; }
|
||||
|
||||
void setAnimationPath(osg::AnimationPath* ap) { _animationPath = ap; }
|
||||
osg::AnimationPath* getAnimationPath() { return _animationPath.get(); }
|
||||
const osg::AnimationPath* getAnimationPath() const { return _animationPath.get(); }
|
||||
|
||||
bool getTimeRange(double& startTime, double& endTime) const;
|
||||
|
||||
void resetTimeRange(double startTime, double endTime);
|
||||
|
||||
virtual void update(osgViewer::View* view);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~CameraPathProperty() {}
|
||||
|
||||
void loadAnimationPath();
|
||||
|
||||
std::string _filename;
|
||||
osg::ref_ptr<osg::AnimationPath> _animationPath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
81
examples/osgframerenderer/CameraProperty.cpp
Normal file
81
examples/osgframerenderer/CameraProperty.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#include "CameraProperty.h"
|
||||
|
||||
using namespace gsc;
|
||||
|
||||
void CameraProperty::setToModel(const osg::Node* node)
|
||||
{
|
||||
osg::BoundingSphere bs = node->getBound();
|
||||
|
||||
double dist = osg::DisplaySettings::instance()->getScreenDistance();
|
||||
|
||||
OSG_NOTICE<<"Node name "<<node->getName()<<std::endl;
|
||||
|
||||
#if 1
|
||||
if (node->getName().find("Presentation")==std::string::npos)
|
||||
{
|
||||
double screenWidth = osg::DisplaySettings::instance()->getScreenWidth();
|
||||
double screenHeight = osg::DisplaySettings::instance()->getScreenHeight();
|
||||
double screenDistance = osg::DisplaySettings::instance()->getScreenDistance();
|
||||
|
||||
double vfov = atan2(screenHeight/2.0,screenDistance)*2.0;
|
||||
double hfov = atan2(screenWidth/2.0,screenDistance)*2.0;
|
||||
double viewAngle = vfov<hfov ? vfov : hfov;
|
||||
|
||||
dist = bs.radius() / sin(viewAngle*0.5);
|
||||
}
|
||||
#endif
|
||||
|
||||
_center = bs.center();
|
||||
_eye = _center - osg::Vec3d(0.0, dist, 0.0);
|
||||
_up = osg::Vec3d(0.0, 0.0, 1.0);
|
||||
|
||||
_rotationCenter = _center;
|
||||
_rotationAxis = osg::Vec3d(0.0, 0.0, 1.0);
|
||||
_rotationSpeed = 0.0;
|
||||
}
|
||||
|
||||
|
||||
void CameraProperty::update(osgViewer::View* view)
|
||||
{
|
||||
osg::Camera* camera = view->getCamera();
|
||||
osg::FrameStamp* fs = view->getFrameStamp();
|
||||
|
||||
osg::Matrixd matrix;
|
||||
matrix.makeLookAt(_eye, _center, _up);
|
||||
|
||||
if (_rotationSpeed!=0.0)
|
||||
{
|
||||
matrix.preMult(osg::Matrixd::translate(-_rotationCenter) *
|
||||
osg::Matrix::rotate(osg::DegreesToRadians(_rotationSpeed*fs->getSimulationTime()), _rotationAxis) *
|
||||
osg::Matrixd::translate(_rotationCenter));
|
||||
}
|
||||
|
||||
camera->setViewMatrix( matrix );
|
||||
|
||||
// set the fusion distance up so that the left and right eye images are co-incedent on the image plane at the center of ration.
|
||||
view->setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,(_center-_eye).length());
|
||||
// view->setFusionDistance(osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE, 1.0);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Serialization support
|
||||
//
|
||||
REGISTER_OBJECT_WRAPPER( gsc_CameraProperty,
|
||||
new gsc::CameraProperty,
|
||||
gsc::CameraProperty,
|
||||
"osg::Object gsc::CameraProperty" )
|
||||
{
|
||||
ADD_VEC3D_SERIALIZER( Center, osg::Vec3d(0.0,0.0,0.0) );
|
||||
ADD_VEC3D_SERIALIZER( EyePoint, osg::Vec3d(0.0,-1.0,0.0) );
|
||||
ADD_VEC3D_SERIALIZER( UpVector, osg::Vec3d(0.0,0.0,1.0) );
|
||||
ADD_VEC3D_SERIALIZER( RotationCenter, osg::Vec3d(0.0,0.0,0.0) );
|
||||
ADD_VEC3D_SERIALIZER( RotationAxis, osg::Vec3d(0.0,0.0,1.0) );
|
||||
ADD_DOUBLE_SERIALIZER( RotationSpeed, 0.0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
72
examples/osgframerenderer/CameraProperty.h
Normal file
72
examples/osgframerenderer/CameraProperty.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef CAMERAPROPERTY_H
|
||||
#define CAMERAPROPERTY_H
|
||||
|
||||
#include <osg/AnimationPath>
|
||||
|
||||
#include "UpdateProperty.h"
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
|
||||
class CameraProperty : public gsc::UpdateProperty
|
||||
{
|
||||
public:
|
||||
|
||||
CameraProperty():
|
||||
_center(0.0,0.0,0.0),
|
||||
_eye(0.0,-1.0,0.0),
|
||||
_up(0.0,0.0,1.0),
|
||||
_rotationCenter(0.0,0.0,0.0),
|
||||
_rotationAxis(0.0,0.0,1.0),
|
||||
_rotationSpeed(0.0) {}
|
||||
|
||||
CameraProperty(const CameraProperty& cp, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||
_center(cp._center),
|
||||
_eye(cp._eye),
|
||||
_up(cp._up),
|
||||
_rotationCenter(cp._rotationCenter),
|
||||
_rotationAxis(cp._rotationAxis),
|
||||
_rotationSpeed(cp._rotationSpeed)
|
||||
{}
|
||||
|
||||
META_Object(gsc, CameraProperty);
|
||||
|
||||
void setToModel(const osg::Node* node);
|
||||
|
||||
void setCenter(const osg::Vec3d& center) { _center = center; }
|
||||
const osg::Vec3d& getCenter() const { return _center; }
|
||||
|
||||
void setEyePoint(const osg::Vec3d& eye) { _eye = eye; }
|
||||
const osg::Vec3d& getEyePoint() const { return _eye; }
|
||||
|
||||
void setUpVector(const osg::Vec3d& up) { _up = up; }
|
||||
const osg::Vec3d& getUpVector() const { return _up; }
|
||||
|
||||
void setRotationCenter(const osg::Vec3d& center) { _rotationCenter = center; }
|
||||
const osg::Vec3d& getRotationCenter() const { return _rotationCenter; }
|
||||
|
||||
void setRotationAxis(const osg::Vec3d& axis) { _rotationAxis = axis; }
|
||||
const osg::Vec3d& getRotationAxis() const { return _rotationAxis; }
|
||||
|
||||
void setRotationSpeed(double speed) { _rotationSpeed = speed; }
|
||||
double getRotationSpeed() const { return _rotationSpeed; }
|
||||
|
||||
virtual void update(osgViewer::View* view);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~CameraProperty() {}
|
||||
|
||||
|
||||
osg::Vec3d _center;
|
||||
osg::Vec3d _eye;
|
||||
osg::Vec3d _up;
|
||||
osg::Vec3d _rotationCenter;
|
||||
osg::Vec3d _rotationAxis;
|
||||
double _rotationSpeed;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
187
examples/osgframerenderer/CaptureSettings.cpp
Normal file
187
examples/osgframerenderer/CaptureSettings.cpp
Normal file
@@ -0,0 +1,187 @@
|
||||
#include "CaptureSettings.h"
|
||||
|
||||
using namespace gsc;
|
||||
|
||||
CaptureSettings::CaptureSettings():
|
||||
_stereoMode(OFF),
|
||||
_offscreen(false),
|
||||
_outputImageFlip(false),
|
||||
_width(1024),
|
||||
_height(512),
|
||||
_screenWidth(0.0),
|
||||
_screenHeight(0.0),
|
||||
_screenDistance(0.0),
|
||||
_samples(0),
|
||||
_sampleBuffers(0),
|
||||
_frameRate(60.0),
|
||||
_numberOfFrames(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
CaptureSettings::CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& copyop):
|
||||
osg::Object(cs, copyop),
|
||||
_inputFileName(cs._inputFileName),
|
||||
_outputFileName(cs._outputFileName),
|
||||
_outputDirectoryName(cs._outputDirectoryName),
|
||||
_outputBaseFileName(cs._outputBaseFileName),
|
||||
_outputExtension(cs._outputExtension),
|
||||
_stereoMode(cs._stereoMode),
|
||||
_offscreen(cs._offscreen),
|
||||
_outputImageFlip(cs._outputImageFlip),
|
||||
_width(cs._width),
|
||||
_height(cs._height),
|
||||
_screenWidth(cs._screenWidth),
|
||||
_screenHeight(cs._screenHeight),
|
||||
_screenDistance(cs._screenDistance),
|
||||
_samples(cs._samples),
|
||||
_sampleBuffers(cs._sampleBuffers),
|
||||
_frameRate(cs._frameRate),
|
||||
_numberOfFrames(cs._numberOfFrames),
|
||||
_eventHandlers(cs._eventHandlers),
|
||||
_properties(cs._properties)
|
||||
{
|
||||
}
|
||||
|
||||
void CaptureSettings::setOutputFileName(const std::string& filename)
|
||||
{
|
||||
_outputFileName = filename;
|
||||
|
||||
_outputDirectoryName = osgDB::getFilePath(filename);
|
||||
if (!_outputDirectoryName.empty()) _outputDirectoryName += osgDB::getNativePathSeparator();
|
||||
|
||||
_outputBaseFileName = osgDB::getStrippedName(filename);
|
||||
|
||||
_outputExtension = osgDB::getFileExtensionIncludingDot(filename);
|
||||
}
|
||||
|
||||
const std::string& CaptureSettings::getOutputFileName() const
|
||||
{
|
||||
return _outputFileName;
|
||||
}
|
||||
|
||||
std::string CaptureSettings::getOutputFileName(unsigned int frameNumber) const
|
||||
{
|
||||
std::stringstream str;
|
||||
str<<_outputDirectoryName<<_outputBaseFileName<<"_"<<frameNumber<<_outputExtension;
|
||||
return str.str();
|
||||
}
|
||||
std::string CaptureSettings::getOutputFileName(unsigned int cameraNum, unsigned int frameNumber) const
|
||||
{
|
||||
std::stringstream str;
|
||||
str<<_outputDirectoryName<<_outputBaseFileName<<"_"<<cameraNum<<"_"<<frameNumber<<_outputExtension;
|
||||
return str.str();
|
||||
}
|
||||
|
||||
bool CaptureSettings::valid() const
|
||||
{
|
||||
return _numberOfFrames>0 && !_outputBaseFileName.empty() && !_outputExtension.empty() && !_inputFileName.empty();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Serialization support
|
||||
//
|
||||
static bool checkEventHandlers( const gsc::CaptureSettings& cs )
|
||||
{
|
||||
return !cs.getEventHandlers().empty();
|
||||
}
|
||||
|
||||
static bool readEventHandlers( osgDB::InputStream& is, gsc::CaptureSettings& cs )
|
||||
{
|
||||
unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
osg::ref_ptr<osg::Object> obj = is.readObject();
|
||||
gsc::UpdateProperty* up = dynamic_cast<gsc::UpdateProperty*>( obj.get() );
|
||||
if ( up ) cs.addUpdateProperty( up );
|
||||
}
|
||||
is >> is.END_BRACKET;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool writeEventHandlers( osgDB::OutputStream& os, const gsc::CaptureSettings& cs )
|
||||
{
|
||||
const gsc::CaptureSettings::EventHandlers& pl = cs.getEventHandlers();
|
||||
unsigned int size = pl.size();
|
||||
os << size << os.BEGIN_BRACKET << std::endl;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
os << pl[i].get();
|
||||
}
|
||||
os << os.END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool checkProperties( const gsc::CaptureSettings& cs )
|
||||
{
|
||||
return !cs.getProperties().empty();
|
||||
}
|
||||
|
||||
static bool readProperties( osgDB::InputStream& is, gsc::CaptureSettings& cs )
|
||||
{
|
||||
unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
osg::ref_ptr<osg::Object> obj = is.readObject();
|
||||
gsc::UpdateProperty* up = dynamic_cast<gsc::UpdateProperty*>( obj.get() );
|
||||
if ( up ) cs.addUpdateProperty( up );
|
||||
}
|
||||
is >> is.END_BRACKET;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool writeProperties( osgDB::OutputStream& os, const gsc::CaptureSettings& cs )
|
||||
{
|
||||
const gsc::CaptureSettings::Properties& pl = cs.getProperties();
|
||||
unsigned int size = pl.size();
|
||||
os << size << os.BEGIN_BRACKET << std::endl;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
os << pl[i].get();
|
||||
}
|
||||
os << os.END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( gsc_CaptureSettings,
|
||||
new gsc::CaptureSettings,
|
||||
gsc::CaptureSettings,
|
||||
"osg::Object gsc::CaptureSettings" )
|
||||
{
|
||||
ADD_STRING_SERIALIZER( InputFileName, "" );
|
||||
ADD_STRING_SERIALIZER( OutputFileName, "" );
|
||||
ADD_DOUBLE_SERIALIZER( FrameRate, 60.0 );
|
||||
|
||||
BEGIN_ENUM_SERIALIZER( StereoMode, OFF );
|
||||
ADD_ENUM_VALUE( OFF );
|
||||
ADD_ENUM_VALUE( HORIZONTAL_SPLIT );
|
||||
ADD_ENUM_VALUE( VERTICAL_SPLIT );
|
||||
END_ENUM_SERIALIZER();
|
||||
|
||||
ADD_BOOL_SERIALIZER( Offscreen, false );
|
||||
ADD_BOOL_SERIALIZER( OutputImageFlip, false );
|
||||
|
||||
ADD_UINT_SERIALIZER( Width, 1024 );
|
||||
ADD_UINT_SERIALIZER( Height, 512 );
|
||||
|
||||
ADD_FLOAT_SERIALIZER( ScreenWidth, 0.0 );
|
||||
ADD_FLOAT_SERIALIZER( ScreenHeight, 0.0 );
|
||||
ADD_FLOAT_SERIALIZER( ScreenDistance, 0.0 );
|
||||
|
||||
BEGIN_ENUM_SERIALIZER( PixelFormat, RGB );
|
||||
ADD_ENUM_VALUE( RGB );
|
||||
ADD_ENUM_VALUE( RGBA );
|
||||
END_ENUM_SERIALIZER();
|
||||
|
||||
ADD_UINT_SERIALIZER( Samples, 0 );
|
||||
ADD_UINT_SERIALIZER( SampleBuffers, 0 );
|
||||
|
||||
ADD_UINT_SERIALIZER( NumberOfFrames, 0 );
|
||||
ADD_USER_SERIALIZER( EventHandlers );
|
||||
ADD_USER_SERIALIZER( Properties );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
148
examples/osgframerenderer/CaptureSettings.h
Normal file
148
examples/osgframerenderer/CaptureSettings.h
Normal file
@@ -0,0 +1,148 @@
|
||||
#ifndef CAPTURESETTINGS_H
|
||||
#define CAPTURESETTINGS_H
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osg/AnimationPath>
|
||||
|
||||
#include "UpdateProperty.h"
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
|
||||
class CaptureSettings : public osg::Object
|
||||
{
|
||||
public:
|
||||
CaptureSettings();
|
||||
CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(gsc, CaptureSettings);
|
||||
|
||||
void setInputFileName(const std::string& filename) { _inputFileName = filename; }
|
||||
const std::string& getInputFileName() const { return _inputFileName; }
|
||||
|
||||
void setOutputFileName(const std::string& filename);
|
||||
const std::string& getOutputFileName() const;
|
||||
|
||||
std::string getOutputFileName(unsigned int frameNumber) const;
|
||||
std::string getOutputFileName(unsigned int cameraNumber, unsigned int frameNumber) const;
|
||||
|
||||
enum StereoMode
|
||||
{
|
||||
OFF,
|
||||
HORIZONTAL_SPLIT,
|
||||
VERTICAL_SPLIT
|
||||
};
|
||||
|
||||
void setStereoMode(StereoMode mode) { _stereoMode = mode; }
|
||||
StereoMode getStereoMode() const { return _stereoMode; }
|
||||
|
||||
void setOffscreen(bool o) { _offscreen = o; }
|
||||
bool getOffscreen() const { return _offscreen; }
|
||||
|
||||
void setOutputImageFlip(bool flip) { _outputImageFlip = flip; }
|
||||
bool getOutputImageFlip() const { return _outputImageFlip; }
|
||||
|
||||
void setWidth(unsigned int width) { _width = width; }
|
||||
unsigned int getWidth() const { return _width; }
|
||||
|
||||
void setHeight(unsigned int height) { _height = height; }
|
||||
unsigned int getHeight() const { return _height; }
|
||||
|
||||
void setScreenWidth(float width) { _screenWidth = width; }
|
||||
float getScreenWidth() const { return _screenWidth; }
|
||||
|
||||
void setScreenHeight(float height) { _screenHeight = height; }
|
||||
float getScreenHeight() const { return _screenHeight; }
|
||||
|
||||
void setScreenDistance(float distance) { _screenDistance = distance; }
|
||||
float getScreenDistance() const { return _screenDistance; }
|
||||
|
||||
|
||||
enum PixelFormat
|
||||
{
|
||||
RGB,
|
||||
RGBA
|
||||
};
|
||||
|
||||
void setPixelFormat(PixelFormat format) { _pixelFormat = format; }
|
||||
PixelFormat getPixelFormat() const { return _pixelFormat; }
|
||||
|
||||
void setSamples(unsigned int s) { _samples = s; }
|
||||
unsigned int getSamples() const { return _samples; }
|
||||
|
||||
void setSampleBuffers(unsigned int s) { _sampleBuffers = s; }
|
||||
unsigned int getSampleBuffers() const { return _sampleBuffers; }
|
||||
|
||||
void setFrameRate(double fr) { _frameRate = fr; }
|
||||
double getFrameRate() const { return _frameRate; }
|
||||
|
||||
void setNumberOfFrames(unsigned int nf) { _numberOfFrames = nf; }
|
||||
unsigned int getNumberOfFrames() const { return _numberOfFrames; }
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
|
||||
void setEventHandlers(const EventHandlers& eh);
|
||||
EventHandlers& getEventHandlers() { return _eventHandlers; }
|
||||
const EventHandlers& getEventHandlers() const { return _eventHandlers; }
|
||||
|
||||
typedef std::vector< osg::ref_ptr<UpdateProperty> > Properties;
|
||||
|
||||
void addUpdateProperty(UpdateProperty* up) { _properties.push_back(up); }
|
||||
|
||||
void setProperties(const Properties& pl) { _properties = pl; }
|
||||
Properties& getProperties() { return _properties; }
|
||||
const Properties& getProperties() const { return _properties; }
|
||||
|
||||
template<typename T>
|
||||
T* getPropertyOfType()
|
||||
{
|
||||
for(Properties::iterator itr = _properties.begin();
|
||||
itr != _properties.end();
|
||||
++itr)
|
||||
{
|
||||
T* p = dynamic_cast<T*>(itr->get());
|
||||
if (p) return p;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool valid() const;
|
||||
|
||||
protected:
|
||||
virtual ~CaptureSettings() {}
|
||||
|
||||
std::string _inputFileName;
|
||||
|
||||
std::string _outputFileName;
|
||||
std::string _outputDirectoryName;
|
||||
std::string _outputBaseFileName;
|
||||
std::string _outputExtension;
|
||||
|
||||
StereoMode _stereoMode;
|
||||
bool _offscreen;
|
||||
bool _outputImageFlip;
|
||||
|
||||
unsigned int _width;
|
||||
unsigned int _height;
|
||||
|
||||
float _screenWidth;
|
||||
float _screenHeight;
|
||||
float _screenDistance;
|
||||
|
||||
PixelFormat _pixelFormat;
|
||||
unsigned int _samples;
|
||||
unsigned int _sampleBuffers;
|
||||
|
||||
double _frameRate;
|
||||
unsigned int _numberOfFrames;
|
||||
|
||||
EventHandlers _eventHandlers;
|
||||
Properties _properties;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
41
examples/osgframerenderer/EventProperty.cpp
Normal file
41
examples/osgframerenderer/EventProperty.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "EventProperty.h"
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
|
||||
void EventProperty::update(osgViewer::View* view)
|
||||
{
|
||||
if (view && view->getEventQueue() && _event.valid())
|
||||
{
|
||||
view->getEventQueue()->addEvent(_event.get());
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Serialization support
|
||||
//
|
||||
REGISTER_OBJECT_WRAPPER( gsc_EventProperty,
|
||||
new gsc::EventProperty,
|
||||
gsc::EventProperty,
|
||||
"osg::Object gsc::EventProperty" )
|
||||
{
|
||||
ADD_OBJECT_SERIALIZER( Event, osgGA::GUIEventAdapter, NULL );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
namespace osgGA
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
namespace B
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
38
examples/osgframerenderer/EventProperty.h
Normal file
38
examples/osgframerenderer/EventProperty.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef EVENTPROPERTY_H
|
||||
#define EVENTPROPERTY_H
|
||||
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include "UpdateProperty.h"
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
|
||||
class EventProperty : public gsc::UpdateProperty
|
||||
{
|
||||
public:
|
||||
|
||||
EventProperty() {}
|
||||
EventProperty(osgGA::GUIEventAdapter* event):_event(event) {}
|
||||
EventProperty(const EventProperty& cpp, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
|
||||
|
||||
META_Object(gsc, EventProperty);
|
||||
|
||||
void setEvent(osgGA::GUIEventAdapter* ea) { _event = ea; }
|
||||
osgGA::GUIEventAdapter* getEvent() { return _event.get(); }
|
||||
const osgGA::GUIEventAdapter* getEvent() const { return _event.get(); }
|
||||
|
||||
virtual void update(osgViewer::View* view);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~EventProperty() {}
|
||||
|
||||
double _previousFrameTime;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> _event;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
4
examples/osgframerenderer/UpdateProperty.cpp
Normal file
4
examples/osgframerenderer/UpdateProperty.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "UpdateProperty.h"
|
||||
|
||||
using namespace gsc;
|
||||
|
||||
32
examples/osgframerenderer/UpdateProperty.h
Normal file
32
examples/osgframerenderer/UpdateProperty.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef UPDATEPROPERTY_H
|
||||
#define UPDATEPROPERTY_H
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osg/AnimationPath>
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
|
||||
class UpdateProperty : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
UpdateProperty() {}
|
||||
UpdateProperty(const UpdateProperty& up, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
|
||||
|
||||
META_Object(gsc, UpdateProperty);
|
||||
|
||||
virtual void update(osgViewer::View* view) {}
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~UpdateProperty() {}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
559
examples/osgframerenderer/osgframerenderer.cpp
Normal file
559
examples/osgframerenderer/osgframerenderer.cpp
Normal file
@@ -0,0 +1,559 @@
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osg/AnimationPath>
|
||||
|
||||
#include "UpdateProperty.h"
|
||||
#include "CameraProperty.h"
|
||||
#include "CameraPathProperty.h"
|
||||
#include "EventProperty.h"
|
||||
|
||||
#include "CaptureSettings.h"
|
||||
|
||||
#include <osgGA/StateSetManipulator>
|
||||
|
||||
|
||||
struct ScreenShot : public osg::Camera::DrawCallback
|
||||
{
|
||||
ScreenShot(GLenum pixelFormat, bool flip):
|
||||
_pixelFormat(pixelFormat),
|
||||
_flip(flip) {}
|
||||
|
||||
virtual void operator () (osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
if (!_frameCapture)
|
||||
{
|
||||
OSG_NOTICE<<"No FrameCamera assigned"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber();
|
||||
|
||||
CameraNumMap::const_iterator itr = _cameraNumMap.find(renderInfo.getCurrentCamera());
|
||||
std::string outputFileName = (itr!=_cameraNumMap.end()) ?
|
||||
_frameCapture->getOutputFileName(itr->second, frameNumber) :
|
||||
_frameCapture->getOutputFileName(frameNumber);
|
||||
|
||||
OSG_NOTICE<<"outputFileName="<<outputFileName<<std::endl;
|
||||
|
||||
osg::Camera* camera = renderInfo.getCurrentCamera();
|
||||
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
|
||||
if (viewport)
|
||||
{
|
||||
OSG_NOTICE<<"Doing read of ="<<viewport->x()<<", "<<viewport->y()<<", "<<viewport->width()<<", "<<viewport->height()<<" with pixelFormat=0x"<<std::hex<<_pixelFormat<<std::dec<<std::endl;
|
||||
|
||||
glReadBuffer(camera->getDrawBuffer());
|
||||
osg::ref_ptr<osg::Image> image = new osg::Image;
|
||||
|
||||
image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(),
|
||||
_pixelFormat, GL_UNSIGNED_BYTE, 1);
|
||||
|
||||
if (_flip) image->flipVertical();
|
||||
|
||||
osgDB::writeImageFile(*image, outputFileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
typedef std::map<const osg::Camera*, unsigned int> CameraNumMap;
|
||||
|
||||
GLenum _pixelFormat;
|
||||
bool _flip;
|
||||
osg::ref_ptr<gsc::CaptureSettings> _frameCapture;
|
||||
CameraNumMap _cameraNumMap;
|
||||
};
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of 3D textures.");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options]");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-i <filename>","Input scene (or presentation) filename.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-o <filename>","Base ouput filename of the images, recommended to use something like Images/image.png");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--cs <filename>","Load pre-generated configuration file for run.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--ouput-cs <filename>","Output configuration file with settings provided on commandline.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Use specificied camera path file to control camera position.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--offscreen","Use an pbuffer to render the images offscreen.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--screen","Use an window to render the images.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--width <width>","Window/output image width.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--height <height>","Window/output image height.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--screen-distance <distance>","Set the distance of the viewer from the physical screen.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--screen-width <width>","Set the width of the physical screen.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--screen-height <height>","Set the height of the physical screen.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--ms <s>","Number of multi-samples to use when rendering, an enable a single sample buffer.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--samples <s>","Number of multi-samples to use when rendering.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--sampleBuffers <sb>","Number of sample buffers to use when rendering.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-f <fps>","Number of frames per second in simulation time.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-n <frames>","Number of frames to render/images to create.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-d <time>","Duration of rendering run (duration = frames/fps).");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--center <x> <y> <z>","View center.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--eye <x> <y> <z>","Camera eye point.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--up <x> <y> <z>","Camera up vector.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-center <x> <y> <z>","Position to rotatate around.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-axis <x> <y> <z>","Axis to rotate around.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-speed <v>","Degrees per second.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--stereo <mode>","OFF | HORIZONTAL_SPLIT | VERTICAL_SPLIT");
|
||||
|
||||
unsigned int helpType = 0;
|
||||
if ((helpType = arguments.readHelpType()))
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout, helpType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
typedef std::list< osg::ref_ptr<gsc::CaptureSettings> > CaptureSettingsList;
|
||||
CaptureSettingsList frameCaptureList;
|
||||
|
||||
osg::ref_ptr<gsc::CaptureSettings> fc = new gsc::CaptureSettings;
|
||||
|
||||
double duration = 0.0;
|
||||
double fps = 0.0f;
|
||||
unsigned int nframes = 0;
|
||||
|
||||
bool readCaptureSettings = false;
|
||||
std::string filename;
|
||||
if (arguments.read("--cs",filename))
|
||||
{
|
||||
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename);
|
||||
gsc::CaptureSettings* input_cs = dynamic_cast<gsc::CaptureSettings*>(object.get());
|
||||
if (input_cs) { fc = input_cs; readCaptureSettings = true; }
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"Unable to read CaptureSettings from file: "<<filename<<std::endl;
|
||||
if (object.valid()) OSG_NOTICE<<"Object read, "<<object.get()<<", className()="<<object->className()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
float screenWidth = fc->getScreenWidth()!=0.0 ? fc->getScreenWidth() : osg::DisplaySettings::instance()->getScreenWidth();
|
||||
if (arguments.read("--screen-width",screenWidth)) {}
|
||||
|
||||
float screenHeight = fc->getScreenHeight()!=0.0 ? fc->getScreenHeight() : osg::DisplaySettings::instance()->getScreenHeight();
|
||||
if (arguments.read("--screen-height",screenHeight)) {}
|
||||
|
||||
float screenDistance = fc->getScreenDistance()!=0.0 ? fc->getScreenDistance() : osg::DisplaySettings::instance()->getScreenDistance();
|
||||
if (arguments.read("--screen-distance",screenDistance)) {}
|
||||
|
||||
fc->setScreenWidth(screenWidth);
|
||||
osg::DisplaySettings::instance()->setScreenWidth(screenWidth);
|
||||
|
||||
fc->setScreenHeight(screenHeight);
|
||||
osg::DisplaySettings::instance()->setScreenHeight(screenHeight);
|
||||
|
||||
fc->setScreenDistance(screenDistance);
|
||||
osg::DisplaySettings::instance()->setScreenDistance(screenDistance);
|
||||
|
||||
bool useScreenSizeForProjectionMatrix = true;
|
||||
|
||||
if (arguments.read("-i",filename)) fc->setInputFileName(filename);
|
||||
if (arguments.read("-o",filename)) fc->setOutputFileName(filename);
|
||||
if (arguments.read("-p",filename))
|
||||
{
|
||||
osg::ref_ptr<gsc::CameraPathProperty> cpp = new gsc::CameraPathProperty;
|
||||
cpp->setAnimationPathFileName(filename);
|
||||
|
||||
double startTime = 0, endTime = 1.0f;
|
||||
if (cpp->getTimeRange(startTime, endTime))
|
||||
{
|
||||
OSG_NOTICE<<"Camera path time range "<<startTime<<", "<<endTime<<std::endl;
|
||||
if (startTime!=0.0)
|
||||
{
|
||||
cpp->resetTimeRange(0.0, endTime-startTime);
|
||||
if (cpp->getTimeRange(startTime, endTime))
|
||||
{
|
||||
OSG_NOTICE<<" new time range "<<startTime<<", "<<endTime<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<" failed to set new time range "<<startTime<<", "<<endTime<<std::endl;
|
||||
}
|
||||
}
|
||||
duration = endTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"Camera path time range "<<startTime<<", "<<endTime<<std::endl;
|
||||
}
|
||||
|
||||
fc->addUpdateProperty(cpp.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::ref_ptr<gsc::CameraProperty> cp = fc->getPropertyOfType<gsc::CameraProperty>();
|
||||
|
||||
bool newCameraProperty = false;
|
||||
bool valueSet = false;
|
||||
|
||||
if (!cp)
|
||||
{
|
||||
newCameraProperty = true;
|
||||
cp = new gsc::CameraProperty;
|
||||
|
||||
osg::ref_ptr<osg::Node> node = fc->getInputFileName().empty() ? 0 : osgDB::readNodeFile(fc->getInputFileName());
|
||||
if (node.valid())
|
||||
{
|
||||
cp->setToModel(node.get());
|
||||
valueSet = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
osg::Vec3d vec;
|
||||
while (arguments.read("--center",vec.x(), vec.y(), vec.z())) { cp->setCenter(vec); valueSet = true; }
|
||||
while (arguments.read("--eye",vec.x(), vec.y(), vec.z())) { cp->setEyePoint(vec); valueSet = true; }
|
||||
while (arguments.read("--up",vec.x(), vec.y(), vec.z())) { cp->setUpVector(vec); valueSet = true; }
|
||||
while (arguments.read("--rotation-center",vec.x(), vec.y(), vec.z())) { cp->setRotationCenter(vec); valueSet = true; }
|
||||
while (arguments.read("--rotation-axis",vec.x(), vec.y(), vec.z())) { cp->setRotationAxis(vec); valueSet = true; }
|
||||
|
||||
double speed;
|
||||
while (arguments.read("--rotation-speed",speed)) { cp->setRotationSpeed(speed); valueSet = true; }
|
||||
|
||||
if (newCameraProperty && valueSet)
|
||||
{
|
||||
fc->addUpdateProperty(cp.get());
|
||||
}
|
||||
}
|
||||
|
||||
std::string stereoMode;
|
||||
if (arguments.read("--stereo", stereoMode))
|
||||
{
|
||||
if (stereoMode=="HORIZONTAL_SPLIT") fc->setStereoMode(gsc::CaptureSettings::HORIZONTAL_SPLIT);
|
||||
else if (stereoMode=="VERTICAL_SPLIT") fc->setStereoMode(gsc::CaptureSettings::VERTICAL_SPLIT);
|
||||
else if (stereoMode=="OFF") fc->setStereoMode(gsc::CaptureSettings::OFF);
|
||||
}
|
||||
|
||||
if (arguments.read("--offscreen")) fc->setOffscreen(true);
|
||||
if (arguments.read("--screen")) fc->setOffscreen(false);
|
||||
|
||||
if (arguments.read("--flip")) fc->setOutputImageFlip(true);
|
||||
if (arguments.read("--no-flip")) fc->setOutputImageFlip(false);
|
||||
|
||||
unsigned int width = 1024;
|
||||
if (arguments.read("--width",width)) fc->setWidth(width);
|
||||
|
||||
unsigned int height = 512;
|
||||
if (arguments.read("--height",height)) fc->setHeight(height);
|
||||
|
||||
if (arguments.read("--rgb")) fc->setPixelFormat(gsc::CaptureSettings::RGB);
|
||||
if (arguments.read("--rgba")) fc->setPixelFormat(gsc::CaptureSettings::RGBA);
|
||||
|
||||
osg::Vec4 clearColor(0.0f,0.0f,0.0f,0.0f);
|
||||
while (arguments.read("--clear-color",clearColor[0],clearColor[1],clearColor[2],clearColor[3])) {}
|
||||
|
||||
|
||||
unsigned int samples = 0;
|
||||
if (arguments.read("--samples",samples)) fc->setSamples(samples);
|
||||
|
||||
unsigned int sampleBuffers = 0;
|
||||
if (arguments.read("--sampleBuffers",sampleBuffers)) fc->setSampleBuffers(sampleBuffers);
|
||||
|
||||
unsigned int ms = 0;
|
||||
if (arguments.read("--ms",ms))
|
||||
{
|
||||
fc->setSamples(ms);
|
||||
fc->setSampleBuffers(1);
|
||||
}
|
||||
|
||||
if (arguments.read("-f",fps)) fc->setFrameRate(fps);
|
||||
|
||||
if (arguments.read("-n",nframes)) fc->setNumberOfFrames(nframes);
|
||||
|
||||
if (arguments.read("-d",duration)) {}
|
||||
|
||||
|
||||
std::string key;
|
||||
double time;
|
||||
while(arguments.read("--key-down",time, key) && key.size()>=1)
|
||||
{
|
||||
OSG_NOTICE<<"keydown "<<key<<", "<<time<<std::endl;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
|
||||
event->setTime(time);
|
||||
event->setEventType(osgGA::GUIEventAdapter::KEYDOWN);
|
||||
event->setKey(key[0]);
|
||||
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
|
||||
}
|
||||
|
||||
while(arguments.read("--key-up",time, key) && key.size()>=1)
|
||||
{
|
||||
OSG_NOTICE<<"keyup "<<key<<", "<<time<<std::endl;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
|
||||
event->setTime(time);
|
||||
event->setEventType(osgGA::GUIEventAdapter::KEYUP);
|
||||
event->setKey(key[0]);
|
||||
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
|
||||
}
|
||||
|
||||
double mouse_x, mouse_y;
|
||||
while(arguments.read("--mouse-move",time, mouse_x, mouse_y))
|
||||
{
|
||||
OSG_NOTICE<<"mouse move "<<time<<", "<<mouse_x<<", "<<mouse_y<<std::endl;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
|
||||
event->setTime(time);
|
||||
event->setEventType(osgGA::GUIEventAdapter::MOVE);
|
||||
event->setX(mouse_x);
|
||||
event->setY(mouse_y);
|
||||
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
|
||||
}
|
||||
|
||||
while(arguments.read("--mouse-drag",time, mouse_x, mouse_y))
|
||||
{
|
||||
OSG_NOTICE<<"mouse drag "<<time<<", "<<mouse_x<<", "<<mouse_y<<std::endl;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
|
||||
event->setTime(time);
|
||||
event->setEventType(osgGA::GUIEventAdapter::DRAG);
|
||||
event->setX(mouse_x);
|
||||
event->setY(mouse_y);
|
||||
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
|
||||
}
|
||||
|
||||
|
||||
if (!readCaptureSettings)
|
||||
{
|
||||
if (duration!=0.0)
|
||||
{
|
||||
if (fps!=0.0) nframes = static_cast<unsigned int>(ceil(duration*fps));
|
||||
else if (nframes!=0) fps = duration/static_cast<double>(nframes);
|
||||
else
|
||||
{
|
||||
fps = 60.0;
|
||||
nframes = static_cast<unsigned int>(ceil(duration/fps));
|
||||
}
|
||||
}
|
||||
else // duration == 0.0
|
||||
{
|
||||
if (fps==0.0) fps=60.0;
|
||||
if (nframes==0) nframes=1;
|
||||
|
||||
duration = static_cast<double>(nframes)/fps;
|
||||
}
|
||||
|
||||
fc->setNumberOfFrames(nframes);
|
||||
fc->setFrameRate(fps);
|
||||
OSG_NOTICE<<"Duration="<<duration<<", FPS="<<fps<<", Number of Frames="<<nframes<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (arguments.read("--output-cs",filename))
|
||||
{
|
||||
osgDB::writeObjectFile(*fc, filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (fc.valid())
|
||||
{
|
||||
frameCaptureList.push_back(fc);
|
||||
}
|
||||
|
||||
if (frameCaptureList.empty())
|
||||
{
|
||||
OSG_NOTICE<<"No settings provided"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// setup viewer
|
||||
{
|
||||
osg::ref_ptr<osg::DisplaySettings> ds = new osg::DisplaySettings;
|
||||
|
||||
bool stereo = fc->getStereoMode()!=gsc::CaptureSettings::OFF;
|
||||
osg::DisplaySettings::StereoMode stereoMode = fc->getStereoMode()==gsc::CaptureSettings::VERTICAL_SPLIT ? osg::DisplaySettings::VERTICAL_SPLIT : osg::DisplaySettings::HORIZONTAL_SPLIT;
|
||||
double fovx_multiple = fc->getStereoMode()==gsc::CaptureSettings::HORIZONTAL_SPLIT ? 2.0 : 1;
|
||||
double fovy_multiple = fc->getStereoMode()==gsc::CaptureSettings::VERTICAL_SPLIT ? 2.0 : 1;
|
||||
ds->setStereoMode(stereoMode);
|
||||
ds->setStereo(stereo);
|
||||
|
||||
if (fc->getScreenWidth()!=0.0) ds->setScreenWidth(fc->getScreenWidth());
|
||||
if (fc->getScreenHeight()!=0.0) ds->setScreenHeight(fc->getScreenHeight());
|
||||
if (fc->getScreenDistance()!=0.0) ds->setScreenDistance(fc->getScreenDistance());
|
||||
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds.get());
|
||||
|
||||
traits->readDISPLAY();
|
||||
if (traits->displayNum<0) traits->displayNum = 0;
|
||||
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = fc->getWidth();
|
||||
traits->height = fc->getHeight();
|
||||
traits->alpha = (fc->getPixelFormat() == gsc::CaptureSettings::RGBA) ? 8 : 0;
|
||||
traits->samples = fc->getSamples();
|
||||
traits->sampleBuffers = fc->getSampleBuffers();
|
||||
traits->windowDecoration = !(fc->getOffscreen());
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
traits->pbuffer = fc->getOffscreen();
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
if (!gc)
|
||||
{
|
||||
OSG_NOTICE<<"Failed to created requested graphics context"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
viewer.getCamera()->setClearColor(clearColor);
|
||||
viewer.getCamera()->setGraphicsContext(gc.get());
|
||||
viewer.getCamera()->setDisplaySettings(ds.get());
|
||||
|
||||
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
|
||||
if (gw)
|
||||
{
|
||||
OSG_INFO<<"GraphicsWindow has been created successfully."<<std::endl;
|
||||
gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, fc->getWidth(), fc->getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"PixelBuffer has been created succseffully "<<traits->width<<", "<<traits->height<<std::endl;
|
||||
}
|
||||
|
||||
if (useScreenSizeForProjectionMatrix)
|
||||
{
|
||||
OSG_NOTICE<<"Setting projection matrix"<<std::endl;
|
||||
|
||||
double vfov = osg::RadiansToDegrees(atan2(screenHeight/2.0f,screenDistance)*2.0);
|
||||
// double hfov = osg::RadiansToDegrees(atan2(width/2.0f,distance)*2.0);
|
||||
|
||||
viewer.getCamera()->setProjectionMatrixAsPerspective( vfov*fovy_multiple, (screenWidth/screenHeight)*fovx_multiple, 0.1, 1000.0);
|
||||
|
||||
OSG_NOTICE<<"setProjectionMatrixAsPerspective( "<<vfov*fovy_multiple<<", "<<(screenWidth/screenHeight)*fovx_multiple<<", "<<0.1<<", "<<1000.0<<");"<<std::endl;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
double fovy, aspectRatio, zNear, zFar;
|
||||
viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
|
||||
|
||||
double newAspectRatio = double(traits->width) / double(traits->height);
|
||||
double aspectRatioChange = newAspectRatio / aspectRatio;
|
||||
if (aspectRatioChange != 1.0)
|
||||
{
|
||||
viewer.getCamera()->getProjectionMatrix() *= osg::Matrix::scale(fovx_multiple/aspectRatioChange,fovy_multiple,1.0);
|
||||
}
|
||||
}
|
||||
|
||||
// set up stereo masks
|
||||
viewer.getCamera()->setCullMask(0xffffffff);
|
||||
viewer.getCamera()->setCullMaskLeft(0x00000001);
|
||||
viewer.getCamera()->setCullMaskRight(0x00000002);
|
||||
|
||||
viewer.getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
|
||||
|
||||
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
|
||||
|
||||
viewer.getCamera()->setDrawBuffer(buffer);
|
||||
viewer.getCamera()->setReadBuffer(buffer);
|
||||
}
|
||||
|
||||
std::string outputPath = osgDB::getFilePath(fc->getOutputFileName());
|
||||
if (!outputPath.empty())
|
||||
{
|
||||
osgDB::FileType type = osgDB::fileType(outputPath);
|
||||
switch(type)
|
||||
{
|
||||
case(osgDB::FILE_NOT_FOUND):
|
||||
if (!osgDB::makeDirectory(outputPath))
|
||||
{
|
||||
OSG_NOTICE<<"Error: could not create directory ["<<outputPath<<"]."<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
OSG_NOTICE<<"Created directory ["<<outputPath<<"]."<<std::endl;
|
||||
break;
|
||||
case(osgDB::REGULAR_FILE):
|
||||
OSG_NOTICE<<"Error: filepath for output files is regular file, not a directory as required."<<std::endl;
|
||||
return 1;
|
||||
case(osgDB::DIRECTORY):
|
||||
OSG_NOTICE<<"Valid path["<<outputPath<<"] provided for output files."<<std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum pixelFormat = (fc->getPixelFormat()==gsc::CaptureSettings::RGBA) ? GL_RGBA : GL_RGB;
|
||||
|
||||
|
||||
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
viewer.realize();
|
||||
|
||||
// set up screen shot
|
||||
osg::ref_ptr<ScreenShot> screenShot = new ScreenShot(pixelFormat, fc->getOutputImageFlip());;
|
||||
{
|
||||
|
||||
osgViewer::Viewer::Cameras cameras;
|
||||
viewer.getCameras(cameras);
|
||||
if (cameras.size()>1)
|
||||
{
|
||||
unsigned int cameraNum = 0;
|
||||
for(osgViewer::Viewer::Cameras::iterator itr = cameras.begin();
|
||||
itr != cameras.end();
|
||||
++itr, ++cameraNum)
|
||||
{
|
||||
osg::Camera* camera = *itr;
|
||||
camera->setFinalDrawCallback(screenShot.get());
|
||||
screenShot->_cameraNumMap[camera] = cameraNum;
|
||||
}
|
||||
}
|
||||
else if (cameras.size()==1)
|
||||
{
|
||||
osg::Camera* camera = cameras.front();
|
||||
camera->setFinalDrawCallback(screenShot.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"No usable Cameras created."<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(CaptureSettingsList::iterator itr = frameCaptureList.begin();
|
||||
itr != frameCaptureList.end();
|
||||
++itr)
|
||||
{
|
||||
gsc::CaptureSettings* fc = itr->get();
|
||||
screenShot->_frameCapture = fc;
|
||||
|
||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(fc->getInputFileName());
|
||||
if (!model) break;
|
||||
|
||||
viewer.setSceneData(model.get());
|
||||
|
||||
double simulationTime = 0.0;
|
||||
|
||||
for(unsigned int i=0; i<fc->getNumberOfFrames(); ++i)
|
||||
{
|
||||
OSG_NOTICE<<"fc.getOutputFileName("<<i<<")="<<fc->getOutputFileName(i)<<std::endl;
|
||||
|
||||
viewer.advance(simulationTime);
|
||||
|
||||
gsc::CaptureSettings::Properties& pl = fc->getProperties();
|
||||
for(gsc::CaptureSettings::Properties::iterator plitr = pl.begin();
|
||||
plitr != pl.end();
|
||||
++plitr)
|
||||
{
|
||||
(*plitr)->update(&viewer);
|
||||
}
|
||||
|
||||
viewer.eventTraversal();
|
||||
viewer.updateTraversal();
|
||||
viewer.renderingTraversals();
|
||||
|
||||
// advance simulationTime and number of frames rendered
|
||||
simulationTime += 1.0/fc->getFrameRate();
|
||||
}
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Object> object = new osgGA::StateSetManipulator;
|
||||
osg::ref_ptr<osgGA::StateSetManipulator> ss = dynamic_cast<osgGA::StateSetManipulator*>(object.get());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
namespace osgfxbrowser {
|
||||
|
||||
Frame::Frame()
|
||||
: osg::Geode(),
|
||||
: osg::Geode(),
|
||||
bgcolor_(0.5f, 0.5f, 0.5f, 1.0f),
|
||||
rect_(0, 0, 100, 100),
|
||||
caption_("Frame")
|
||||
@@ -108,8 +108,7 @@ osg::Geometry *Frame::build_quad(const Rect &rect, const osg::Vec4 &color, bool
|
||||
clr->push_back(osg::Vec4(black, 0));
|
||||
}
|
||||
|
||||
geo->setColorArray(clr.get());
|
||||
geo->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
geo->setColorArray(clr.get(), osg::Array::BIND_PER_VERTEX);
|
||||
|
||||
geo->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, shadow? 12: 4));
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ ProcessPass::ProcessPass(osg::TextureRectangle *in_tex,
|
||||
_TextureHeight(height)
|
||||
{
|
||||
_RootGroup = new osg::Group;
|
||||
|
||||
|
||||
_InTexture = in_tex;
|
||||
_OutTexture = out_tex;
|
||||
|
||||
|
||||
_Camera = new osg::Camera;
|
||||
setupCamera();
|
||||
_Camera->addChild(createTexturedQuad().get());
|
||||
@@ -47,7 +47,7 @@ ProcessPass::~ProcessPass()
|
||||
osg::ref_ptr<osg::Group> ProcessPass::createTexturedQuad()
|
||||
{
|
||||
osg::ref_ptr<osg::Group> top_group = new osg::Group;
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Geode> quad_geode = new osg::Geode;
|
||||
|
||||
osg::ref_ptr<osg::Vec3Array> quad_coords = new osg::Vec3Array; // vertex coords
|
||||
@@ -72,19 +72,18 @@ osg::ref_ptr<osg::Group> ProcessPass::createTexturedQuad()
|
||||
quad_geom->setVertexArray(quad_coords.get());
|
||||
quad_geom->setTexCoordArray(0, quad_tcoords.get());
|
||||
quad_geom->addPrimitiveSet(quad_da.get());
|
||||
quad_geom->setColorArray(quad_colors.get());
|
||||
quad_geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
quad_geom->setColorArray(quad_colors.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
_StateSet = quad_geom->getOrCreateStateSet();
|
||||
_StateSet->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
_StateSet->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||
|
||||
|
||||
_StateSet->setTextureAttributeAndModes(0, _InTexture.get(), osg::StateAttribute::ON);
|
||||
|
||||
|
||||
_StateSet->addUniform(new osg::Uniform("textureIn", 0));
|
||||
|
||||
|
||||
quad_geode->addDrawable(quad_geom.get());
|
||||
|
||||
|
||||
top_group->addChild(quad_geode.get());
|
||||
|
||||
return top_group;
|
||||
@@ -94,7 +93,7 @@ void ProcessPass::setupCamera()
|
||||
{
|
||||
// clearing
|
||||
_Camera->setClearMask(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
// projection and view
|
||||
_Camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
|
||||
_Camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
@@ -118,7 +117,7 @@ void ProcessPass::setShader(std::string filename)
|
||||
return;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
fshader->loadShaderSourceFromFile(foundFile);
|
||||
|
||||
_FragmentProgram = 0;
|
||||
@@ -135,7 +134,7 @@ GameOfLifePass::GameOfLifePass(osg::Image *in_image)
|
||||
{
|
||||
_TextureWidth = in_image->s();
|
||||
_TextureHeight = in_image->t();
|
||||
|
||||
|
||||
_RootGroup = new osg::Group;
|
||||
|
||||
_BranchSwith[0] = new osg::Switch;
|
||||
@@ -149,11 +148,11 @@ GameOfLifePass::GameOfLifePass(osg::Image *in_image)
|
||||
|
||||
createOutputTextures();
|
||||
_InOutTextureLife[0]->setImage(in_image);
|
||||
|
||||
|
||||
_ProcessPass[0] = new ProcessPass(_InOutTextureLife[0].get(),
|
||||
_InOutTextureLife[1].get(),
|
||||
_TextureWidth, _TextureHeight);
|
||||
|
||||
|
||||
// For the other pass, the input/output textures are flipped
|
||||
_ProcessPass[1] = new ProcessPass(_InOutTextureLife[1].get(),
|
||||
_InOutTextureLife[0].get(),
|
||||
@@ -194,7 +193,7 @@ void GameOfLifePass::createOutputTextures()
|
||||
{
|
||||
for (int i=0; i<2; i++) {
|
||||
_InOutTextureLife[i] = new osg::TextureRectangle;
|
||||
|
||||
|
||||
_InOutTextureLife[i]->setTextureSize(_TextureWidth, _TextureHeight);
|
||||
_InOutTextureLife[i]->setInternalFormat(GL_RGBA);
|
||||
_InOutTextureLife[i]->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST);
|
||||
|
||||
@@ -46,10 +46,10 @@ osg::Node* createScene(osg::Image *start_im)
|
||||
|
||||
// create quad to display image on
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
||||
|
||||
|
||||
// each geom will contain a quad
|
||||
osg::ref_ptr<osg::DrawArrays> da = new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
|
||||
@@ -58,7 +58,7 @@ osg::Node* createScene(osg::Image *start_im)
|
||||
tcoords->push_back(osg::Vec2(width, 0));
|
||||
tcoords->push_back(osg::Vec2(width, height));
|
||||
tcoords->push_back(osg::Vec2(0, height));
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Vec3Array> vcoords = new osg::Vec3Array; // vertex coords
|
||||
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
|
||||
|
||||
@@ -67,25 +67,24 @@ osg::Node* createScene(osg::Image *start_im)
|
||||
vcoords->push_back(osg::Vec3d(width, 0, 0));
|
||||
vcoords->push_back(osg::Vec3d(width, 0, height));
|
||||
vcoords->push_back(osg::Vec3d(0, 0, height));
|
||||
|
||||
|
||||
geom->setVertexArray(vcoords.get());
|
||||
geom->setTexCoordArray(0,tcoords.get());
|
||||
geom->addPrimitiveSet(da.get());
|
||||
geom->setColorArray(colors.get());
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setColorArray(colors.get(), osg::Array::BIND_OVERALL);
|
||||
geomss = geom->getOrCreateStateSet();
|
||||
geomss->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
|
||||
geode->addDrawable(geom.get());
|
||||
|
||||
|
||||
topnode->addChild(geode.get());
|
||||
|
||||
|
||||
// create the ping pong processing passes
|
||||
golpass = new GameOfLifePass(start_im);
|
||||
topnode->addChild(golpass->getRoot().get());
|
||||
|
||||
// attach the output of the processing to the geom
|
||||
geomss->setTextureAttributeAndModes(0,
|
||||
geomss->setTextureAttributeAndModes(0,
|
||||
golpass->getOutputTexture().get(),
|
||||
osg::StateAttribute::ON);
|
||||
return topnode;
|
||||
@@ -119,14 +118,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
// load the image
|
||||
osg::ref_ptr<osg::Image> startIm = osgDB::readImageFile(startName);
|
||||
|
||||
|
||||
if (!startIm) {
|
||||
std::cout << "Could not load start image.\n";
|
||||
return(1);
|
||||
}
|
||||
|
||||
osg::Node* scene = createScene(startIm.get());
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
@@ -145,7 +144,7 @@ int main(int argc, char *argv[])
|
||||
// flip the textures after we've completed a frame
|
||||
golpass->flip();
|
||||
// attach the proper output to view
|
||||
geomss->setTextureAttributeAndModes(0,
|
||||
geomss->setTextureAttributeAndModes(0,
|
||||
golpass->getOutputTexture().get(),
|
||||
osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osggeodemo.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgGA )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osggeodemo)
|
||||
@@ -1,152 +0,0 @@
|
||||
// Geo demo written by Geoff Michel, November 2002.
|
||||
/* OpenSceneGraph example, osggeodemo.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/FileNameUtils>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// currently not a satisfactory solution, but this is early days for the
|
||||
// geo loader and having direct links with it.
|
||||
#include "../../src/osgPlugins/geo/osgGeoAnimation.h"
|
||||
|
||||
|
||||
//== event trapper gets events
|
||||
|
||||
class geodemoEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
geodemoEventHandler( ) { mouse_x=mouse_y=0;}
|
||||
virtual ~geodemoEventHandler( ) {}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
|
||||
{
|
||||
mouse_x=ea.getX();
|
||||
mouse_y=ea.getY();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
inline float getMouseX(void) {return mouse_x;};
|
||||
inline float getMouseY(void) {return mouse_y;};
|
||||
|
||||
private:
|
||||
float mouse_x, mouse_y;
|
||||
};
|
||||
|
||||
static geodemoEventHandler *ghand=NULL;
|
||||
inline double DEG2RAD(const double val) { return val*0.0174532925199432957692369076848861;}
|
||||
inline double RAD2DEG(const double val) { return val*57.2957795130823208767981548141052;}
|
||||
|
||||
double dodynamics(const double /*time*/, const double val, const std::string name)
|
||||
{ // Each local variable named 'name' declared in the geo modeller is passed into here.
|
||||
// its current value is val; returns new value. Time - elapsed time
|
||||
static double heading,speed; // these are only required for my 'dynamics'
|
||||
if (name == "xpos") {
|
||||
return (val+speed*sin(heading));
|
||||
// std::cout << " nx " << (*itr->getValue()) ;
|
||||
} else if (name == "ypos") {
|
||||
return (val+speed*cos(heading));
|
||||
// std::cout << " ny " << (*itr->getValue()) ;
|
||||
} else if (name == "sped") {
|
||||
speed=(0.00025*(ghand->getMouseY()-300)); // (*itr->getValue());
|
||||
return (speed);
|
||||
} else if (name == "heading") {
|
||||
heading-= 0.01*DEG2RAD(ghand->getMouseX()-400); // =DEG2RAD(*itr->getValue());
|
||||
return (RAD2DEG(heading));
|
||||
} else if (name == "conerot") {
|
||||
return ((ghand->getMouseX()-400));
|
||||
} else if (name == "planrot") {
|
||||
return ((ghand->getMouseY()-300)/200.0);
|
||||
} else if (name == "secint" || name == "minutehand"|| name == "hourhand") {
|
||||
// std::cout << " updating " << name << " " << val << std::endl;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
// load the nodes from the commandline arguments.
|
||||
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
|
||||
if (!rootnode)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Please specify a geo model filename on the command line."<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// run optimization over the scene graph
|
||||
osgUtil::Optimizer optimzer;
|
||||
optimzer.optimize(rootnode);
|
||||
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer.setSceneData( rootnode );
|
||||
|
||||
geoHeader *gh = dynamic_cast<geoHeader *>(rootnode);
|
||||
if (gh)
|
||||
{ // it is a geo file, so set function to update its animation variables.
|
||||
ghand=new geodemoEventHandler();
|
||||
gh->setUserUpdate(dodynamics);
|
||||
viewer.addEventHandler(ghand);
|
||||
}
|
||||
else
|
||||
{ // maybe a group with geo models below.
|
||||
osg::Group *gpall=dynamic_cast<osg::Group *>(rootnode);
|
||||
if (gpall)
|
||||
{
|
||||
int nchild=gpall->getNumChildren();
|
||||
for (int i=0; i<nchild; i++)
|
||||
{
|
||||
osg::Node *nod=gpall->getChild(i);
|
||||
gh = dynamic_cast<geoHeader *>(nod);
|
||||
if (gh)
|
||||
{
|
||||
ghand=new geodemoEventHandler();
|
||||
gh->setUserUpdate(dodynamics);
|
||||
viewer.addEventHandler(ghand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
@@ -37,10 +37,11 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
// This demo illustrates how to create the various different types of geometry that
|
||||
// the osg::Geometry class can represent. This demo uses the OpenGL red book diagram of different
|
||||
// OpenGL Primitives as a template for all the equivalent OpenSceneGraph Primitives. The OpenSceneGraph
|
||||
// wraps OpenGL very thinly and therefore uses all the same enum and naming conventions. The coordinate data is also
|
||||
// the osg::Geometry class can represent. This demo uses the OpenGL red book diagram of different
|
||||
// OpenGL Primitives as a template for all the equivalent OpenSceneGraph Primitives. The OpenSceneGraph
|
||||
// wraps OpenGL very thinly and therefore uses all the same enum and naming conventions. The coordinate data is also
|
||||
// wrapped around OpenGL's vertex arrays and draw arrays/elements calls. Familiarity with
|
||||
// OpenGL will help you understand the osg::Geometry class which encapsulate all this, or if you
|
||||
// havn't learned OpenGL yet, learning osg::Geometry will help you understand how OpenGL
|
||||
@@ -50,7 +51,7 @@
|
||||
// a draw method for drawing objects in the scene. osg::Geometry contains all the vertex, normal
|
||||
// color and texture coordinate arrays required to specify the coordinates of your objects, and the
|
||||
// primitives join these coordinates together as the points, lines or surfaces that you will see
|
||||
// rendered on your screen.
|
||||
// rendered on your screen.
|
||||
//
|
||||
// This demo is split into two functions, the createScene() function which creates the scene graph
|
||||
// with the various primitives in it, and the main() which sets up a basic viewer window and
|
||||
@@ -59,7 +60,7 @@
|
||||
|
||||
struct NormalPrint
|
||||
{
|
||||
void operator() (const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec3& v3, bool) const
|
||||
void operator() (const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec3& v3, bool) const
|
||||
{
|
||||
osg::Vec3 normal = (v2-v1)^(v3-v2);
|
||||
normal.normalize();
|
||||
@@ -71,10 +72,10 @@ struct NormalPrint
|
||||
void printTriangles(const std::string& name, osg::Drawable& drawable)
|
||||
{
|
||||
std::cout<<name<<std::endl;
|
||||
|
||||
|
||||
osg::TriangleFunctor<NormalPrint> tf;
|
||||
drawable.accept(tf);
|
||||
|
||||
|
||||
std::cout<<std::endl;
|
||||
}
|
||||
|
||||
@@ -93,9 +94,9 @@ osg::Node* createScene()
|
||||
{
|
||||
// create Geometry object to store all the vertices and points primitive.
|
||||
osg::Geometry* pointsGeom = new osg::Geometry();
|
||||
|
||||
|
||||
// create a Vec3Array and add to it all my coordinates.
|
||||
// Like all the *Array variants (see include/osg/Array) , Vec3Array is derived from both osg::Array
|
||||
// Like all the *Array variants (see include/osg/Array) , Vec3Array is derived from both osg::Array
|
||||
// and std::vector<>. osg::Array's are reference counted and hence sharable,
|
||||
// which std::vector<> provides all the convenience, flexibility and robustness
|
||||
// of the most popular of all STL containers.
|
||||
@@ -105,30 +106,28 @@ osg::Node* createScene()
|
||||
vertices->push_back(osg::Vec3(-0.873376, 9.18133e-09, 0.832179));
|
||||
vertices->push_back(osg::Vec3(-0.836299, -2.15188e-09, 0.885735));
|
||||
vertices->push_back(osg::Vec3(-0.790982, 9.18133e-09, 0.959889));
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
pointsGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// create the color of the geometry, one single for the whole geometry.
|
||||
// for consistency of design even one single color must added as an element
|
||||
// in a color array.
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
// add a white color, colors take the form r,g,b,a with 0.0 off, 1.0 full on.
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
||||
|
||||
|
||||
// pass the color array to points geometry, note the binding to tell the geometry
|
||||
// that only use one color for the whole object.
|
||||
pointsGeom->setColorArray(colors);
|
||||
pointsGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
|
||||
pointsGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// set the normal in the same way color.
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||
pointsGeom->setNormalArray(normals);
|
||||
pointsGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
pointsGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// create and add a DrawArray Primitive (see include/osg/Primitive). The first
|
||||
@@ -137,8 +136,8 @@ osg::Node* createScene()
|
||||
// parameter is the index position into the vertex array of the first point
|
||||
// to draw, and the third parameter is the number of points to draw.
|
||||
pointsGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS,0,vertices->size()));
|
||||
|
||||
|
||||
|
||||
|
||||
// add the points geometry to the geode.
|
||||
geode->addDrawable(pointsGeom);
|
||||
}
|
||||
@@ -147,7 +146,7 @@ osg::Node* createScene()
|
||||
{
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* linesGeom = new osg::Geometry();
|
||||
|
||||
|
||||
// this time we'll preallocate the vertex array to the size we
|
||||
// need and then simple set them as array elements, 8 points
|
||||
// makes 4 line segments.
|
||||
@@ -161,39 +160,37 @@ osg::Node* createScene()
|
||||
(*vertices)[6].set(-1.07936, 9.18133e-09, 0.317217);
|
||||
(*vertices)[7].set(-0.700348, 9.18133e-09, 0.362533);
|
||||
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
linesGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
// set the colors as before, plus using the above
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
||||
linesGeom->setColorArray(colors);
|
||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// set the normal in the same way color.
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||
linesGeom->setNormalArray(normals);
|
||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,8));
|
||||
|
||||
|
||||
|
||||
|
||||
// add the points geometry to the geode.
|
||||
geode->addDrawable(linesGeom);
|
||||
}
|
||||
|
||||
|
||||
// create LINE_STRIP
|
||||
{
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* linesGeom = new osg::Geometry();
|
||||
|
||||
// this time we'll preallocate the vertex array to the size
|
||||
|
||||
// this time we'll preallocate the vertex array to the size
|
||||
// and then use an iterator to fill in the values, a bit perverse
|
||||
// but does demonstrate that we have just a standard std::vector underneath.
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(5);
|
||||
@@ -203,29 +200,27 @@ osg::Node* createScene()
|
||||
(vitr++)->set(0.164788, -2.15188e-09, 0.366653);
|
||||
(vitr++)->set(-0.0288379, -2.15188e-09, 0.333695);
|
||||
(vitr++)->set(-0.0453167, -2.15188e-09, 0.280139);
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
linesGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
// set the colors as before, plus using the above
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
||||
linesGeom->setColorArray(colors);
|
||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// set the normal in the same way color.
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||
linesGeom->setNormalArray(normals);
|
||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,5));
|
||||
|
||||
|
||||
|
||||
|
||||
// add the points geometry to the geode.
|
||||
geode->addDrawable(linesGeom);
|
||||
}
|
||||
@@ -234,9 +229,9 @@ osg::Node* createScene()
|
||||
{
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* linesGeom = new osg::Geometry();
|
||||
|
||||
|
||||
// this time we'll a C arrays to initialize the vertices.
|
||||
|
||||
|
||||
osg::Vec3 myCoords[] =
|
||||
{
|
||||
osg::Vec3(0.741546, -2.15188e-09, 0.453167),
|
||||
@@ -246,33 +241,31 @@ osg::Node* createScene()
|
||||
osg::Vec3(0.968129, -2.15188e-09, 0.337815),
|
||||
osg::Vec3(0.869256, -2.15188e-09, 0.531441)
|
||||
};
|
||||
|
||||
|
||||
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
linesGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
// set the colors as before, plus using the above
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
||||
linesGeom->setColorArray(colors);
|
||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// set the normal in the same way color.
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||
linesGeom->setNormalArray(normals);
|
||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,numCoords));
|
||||
|
||||
|
||||
|
||||
|
||||
// add the points geometry to the geode.
|
||||
geode->addDrawable(linesGeom);
|
||||
}
|
||||
@@ -300,17 +293,17 @@ osg::Node* createScene()
|
||||
// According to the OpenGL diagram vertices should be specified in a clockwise direction.
|
||||
// In reality you need to specify coords for polygons in a anticlockwise direction
|
||||
// for their front face to be pointing towards you; get this wrong and you could
|
||||
// find back face culling removing the wrong faces of your models. The OpenGL diagram
|
||||
// find back face culling removing the wrong faces of your models. The OpenGL diagram
|
||||
// is just plain wrong, but it's a nice diagram so we'll keep it for now!
|
||||
|
||||
// create POLYGON
|
||||
{
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* polyGeom = new osg::Geometry();
|
||||
|
||||
|
||||
// this time we'll use C arrays to initialize the vertices.
|
||||
// note, anticlockwise ordering.
|
||||
// note II, OpenGL polygons must be convex, planar polygons, otherwise
|
||||
// note II, OpenGL polygons must be convex, planar polygons, otherwise
|
||||
// undefined results will occur. If you have concave polygons or ones
|
||||
// that cross over themselves then use the osgUtil::Tessellator to fix
|
||||
// the polygons into a set of valid polygons.
|
||||
@@ -322,30 +315,28 @@ osg::Node* createScene()
|
||||
osg::Vec3(-0.766264, 0.0f, -0.0576758),
|
||||
osg::Vec3(-0.980488, 0.0f, -0.094753)
|
||||
};
|
||||
|
||||
|
||||
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
polyGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
// use the shared color array.
|
||||
polyGeom->setColorArray(shared_colors.get());
|
||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// use the shared normal array.
|
||||
polyGeom->setNormalArray(shared_normals.get());
|
||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,numCoords));
|
||||
|
||||
printTriangles("Polygon",*polyGeom);
|
||||
|
||||
|
||||
// add the points geometry to the geode.
|
||||
geode->addDrawable(polyGeom);
|
||||
}
|
||||
@@ -355,7 +346,7 @@ osg::Node* createScene()
|
||||
{
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* polyGeom = new osg::Geometry();
|
||||
|
||||
|
||||
// note, anticlockwise ordering.
|
||||
osg::Vec3 myCoords[] =
|
||||
{
|
||||
@@ -369,29 +360,27 @@ osg::Node* createScene()
|
||||
osg::Vec3(0.164788, 0.0f, -0.0453167),
|
||||
osg::Vec3(0.13595, 0.0f, -0.255421)
|
||||
};
|
||||
|
||||
|
||||
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
polyGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
// use the shared color array.
|
||||
polyGeom->setColorArray(shared_colors.get());
|
||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// use the shared normal array.
|
||||
polyGeom->setNormalArray(shared_normals.get());
|
||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,numCoords));
|
||||
|
||||
|
||||
|
||||
|
||||
printTriangles("Quads",*polyGeom);
|
||||
|
||||
// add the points geometry to the geode.
|
||||
@@ -402,7 +391,7 @@ osg::Node* createScene()
|
||||
{
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* polyGeom = new osg::Geometry();
|
||||
|
||||
|
||||
// note, first coord at top, second at bottom, reverse to that buggy OpenGL image..
|
||||
osg::Vec3 myCoords[] =
|
||||
{
|
||||
@@ -418,29 +407,27 @@ osg::Node* createScene()
|
||||
osg::Vec3(1.11232, -2.15188e-09, 0.0123591),
|
||||
osg::Vec3(1.12468, 9.18133e-09, -0.164788),
|
||||
};
|
||||
|
||||
|
||||
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
polyGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
// use the shared color array.
|
||||
polyGeom->setColorArray(shared_colors.get());
|
||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// use the shared normal array.
|
||||
polyGeom->setNormalArray(shared_normals.get());
|
||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,numCoords));
|
||||
|
||||
|
||||
|
||||
|
||||
printTriangles("Quads strip",*polyGeom);
|
||||
|
||||
// add the points geometry to the geode.
|
||||
@@ -451,7 +438,7 @@ osg::Node* createScene()
|
||||
{
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* polyGeom = new osg::Geometry();
|
||||
|
||||
|
||||
// note, first coord at top, second at bottom, reverse to that buggy OpenGL image..
|
||||
osg::Vec3 myCoords[] =
|
||||
{
|
||||
@@ -467,7 +454,7 @@ osg::Node* createScene()
|
||||
osg::Vec3(-1.067, 9.18133e-09, -0.609715),
|
||||
|
||||
// TRIANGLE STRIP 6 vertices, v6..v11
|
||||
// note defined top point first,
|
||||
// note defined top point first,
|
||||
// then anticlockwise for the next two points,
|
||||
// then alternating to bottom there after.
|
||||
osg::Vec3(-0.160668, -2.15188e-09, -0.531441),
|
||||
@@ -486,46 +473,44 @@ osg::Node* createScene()
|
||||
osg::Vec3(0.840418, -2.15188e-09, -0.506723),
|
||||
|
||||
};
|
||||
|
||||
|
||||
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
|
||||
|
||||
|
||||
// pass the created vertex array to the points geometry object.
|
||||
polyGeom->setVertexArray(vertices);
|
||||
|
||||
|
||||
// use the shared color array.
|
||||
polyGeom->setColorArray(shared_colors.get());
|
||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// use the shared normal array.
|
||||
polyGeom->setNormalArray(shared_normals.get());
|
||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,6));
|
||||
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,6,6));
|
||||
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_FAN,12,5));
|
||||
|
||||
|
||||
// polygon stipple
|
||||
osg::StateSet* stateSet = new osg::StateSet();
|
||||
polyGeom->setStateSet(stateSet);
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||
osg::PolygonStipple* polygonStipple = new osg::PolygonStipple;
|
||||
stateSet->setAttributeAndModes(polygonStipple,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||
#endif
|
||||
|
||||
|
||||
printTriangles("Triangles/Strip/Fan",*polyGeom);
|
||||
|
||||
// add the points geometry to the geode.
|
||||
geode->addDrawable(polyGeom);
|
||||
}
|
||||
|
||||
return geode;
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
|
||||
@@ -542,33 +527,33 @@ class MyTransformCallback : public osg::NodeCallback
|
||||
|
||||
virtual void operator() (osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>(node);
|
||||
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>(node);
|
||||
if (nv && transform && nv->getFrameStamp())
|
||||
{
|
||||
double time = nv->getFrameStamp()->getSimulationTime();
|
||||
transform->setMatrix(osg::Matrix::translate(0.0f,1.0f+cosf(time*_angular_velocity),0.0f));
|
||||
}
|
||||
|
||||
|
||||
// must continue subgraph traversal.
|
||||
traverse(node,nv);
|
||||
|
||||
traverse(node,nv);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
float _angular_velocity;
|
||||
|
||||
};
|
||||
|
||||
|
||||
osg::Node* createBackground()
|
||||
{
|
||||
{
|
||||
|
||||
// we'll create a texture mapped quad to sit behind the Geometry
|
||||
// we'll create a texture mapped quad to sit behind the Geometry
|
||||
osg::Image* image = osgDB::readImageFile("Images/primitives.gif");
|
||||
if (!image) return NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
// create Geometry object to store all the vertices and lines primitive.
|
||||
osg::Geometry* polyGeom = new osg::Geometry();
|
||||
|
||||
@@ -588,15 +573,13 @@ osg::Node* createBackground()
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
polyGeom->setColorArray(colors);
|
||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
polyGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
// set the normal in the same way color.
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||
polyGeom->setNormalArray(normals);
|
||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
polyGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
osg::Vec2 myTexCoords[] =
|
||||
{
|
||||
@@ -625,11 +608,11 @@ osg::Node* createBackground()
|
||||
|
||||
// There are three variants of the DrawElements osg::Primitive, UByteDrawElements which
|
||||
// contains unsigned char indices, UShortDrawElements which contains unsigned short indices,
|
||||
// and UIntDrawElements which contains ... unsigned int indices.
|
||||
// The first parameter to DrawElements is
|
||||
// and UIntDrawElements which contains ... unsigned int indices.
|
||||
// The first parameter to DrawElements is
|
||||
polyGeom->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP,numIndices,myIndices));
|
||||
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
// StateSet to contain the Texture2D StateAttribute.
|
||||
osg::StateSet* stateset = new osg::StateSet;
|
||||
|
||||
@@ -641,7 +624,7 @@ osg::Node* createBackground()
|
||||
|
||||
polyGeom->setStateSet(stateset);
|
||||
|
||||
|
||||
|
||||
// create the Geode (Geometry Node) to contain all our osg::Geometry objects.
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
@@ -651,7 +634,7 @@ osg::Node* createBackground()
|
||||
//return geode;
|
||||
|
||||
// create a transform to move the background back and forward with.
|
||||
|
||||
|
||||
osg::MatrixTransform* transform = new osg::MatrixTransform();
|
||||
transform->setUpdateCallback(new MyTransformCallback(1.0f));
|
||||
transform->addChild(geode);
|
||||
|
||||
@@ -141,8 +141,7 @@ public:
|
||||
SomePoints()
|
||||
{
|
||||
osg::Vec4Array* cAry = new osg::Vec4Array;
|
||||
setColorArray( cAry );
|
||||
setColorBinding( osg::Geometry::BIND_OVERALL );
|
||||
setColorArray( cAry, osg::Array::BIND_OVERALL );
|
||||
cAry->push_back( osg::Vec4(1,1,1,1) );
|
||||
|
||||
osg::Vec3Array* vAry = new osg::Vec3Array;
|
||||
|
||||
@@ -395,8 +395,7 @@ osg::Node* createTrackModel(Track* track, const osg::Vec4& colour)
|
||||
|
||||
osg::ref_ptr<osg::Vec4Array> colours = new osg::Vec4Array;
|
||||
colours->push_back(colour);
|
||||
geometry->setColorArray(colours.get());
|
||||
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geometry->setColorArray(colours.get(), osg::Array::BIND_OVERALL);
|
||||
|
||||
geometry->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP, 0, points.size()));
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Node *makeBase( void )
|
||||
c = 0;
|
||||
(*coords)[c].set(0.0f,0.0f,0.0f);
|
||||
(*tcoords)[c].set(0.0f,0.0f);
|
||||
|
||||
|
||||
for( i = 0; i <= 18; i++ )
|
||||
{
|
||||
theta = osg::DegreesToRadians((float)i * 20.0);
|
||||
@@ -61,8 +61,7 @@ Node *makeBase( void )
|
||||
|
||||
geom->setTexCoordArray( 0, tcoords );
|
||||
|
||||
geom->setColorArray( colors );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
geom->setColorArray( colors, Array::BIND_OVERALL );
|
||||
|
||||
geom->addPrimitiveSet( new DrawArrays(PrimitiveSet::TRIANGLE_FAN,0,19) );
|
||||
|
||||
@@ -81,7 +80,7 @@ Node *makeBase( void )
|
||||
// clear the depth to the far plane.
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
depth->setFunction(osg::Depth::ALWAYS);
|
||||
depth->setRange(1.0,1.0);
|
||||
depth->setRange(1.0,1.0);
|
||||
dstate->setAttributeAndModes(depth,StateAttribute::ON );
|
||||
|
||||
dstate->setRenderBinDetails(-1,"RenderBin");
|
||||
|
||||
@@ -58,8 +58,8 @@ Node *makeSky( void )
|
||||
Vec3Array& coords = *(new Vec3Array(19*nlev));
|
||||
Vec4Array& colors = *(new Vec4Array(19*nlev));
|
||||
Vec2Array& tcoords = *(new Vec2Array(19*nlev));
|
||||
|
||||
|
||||
|
||||
|
||||
int ci = 0;
|
||||
|
||||
for( i = 0; i < nlev; i++ )
|
||||
@@ -104,12 +104,11 @@ Node *makeSky( void )
|
||||
|
||||
geom->addPrimitiveSet(drawElements);
|
||||
}
|
||||
|
||||
|
||||
geom->setVertexArray( &coords );
|
||||
geom->setTexCoordArray( 0, &tcoords );
|
||||
|
||||
geom->setColorArray( &colors );
|
||||
geom->setColorBinding( Geometry::BIND_PER_VERTEX );
|
||||
geom->setColorArray( &colors, Array::BIND_PER_VERTEX );
|
||||
|
||||
|
||||
Texture2D *tex = new Texture2D;
|
||||
@@ -121,12 +120,12 @@ Node *makeSky( void )
|
||||
dstate->setTextureAttribute(0, new TexEnv );
|
||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||
dstate->setMode( GL_CULL_FACE, StateAttribute::ON );
|
||||
|
||||
|
||||
|
||||
// clear the depth to the far plane.
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
depth->setFunction(osg::Depth::ALWAYS);
|
||||
depth->setRange(1.0,1.0);
|
||||
depth->setRange(1.0,1.0);
|
||||
dstate->setAttributeAndModes(depth,StateAttribute::ON );
|
||||
|
||||
dstate->setRenderBinDetails(-2,"RenderBin");
|
||||
|
||||
@@ -94,7 +94,7 @@ Node *makeTerrain( void )
|
||||
Vec3Array& v = *(new Vec3Array(m*n));
|
||||
Vec2Array& t = *(new Vec2Array(m*n));
|
||||
Vec4Array& col = *(new Vec4Array(1));
|
||||
|
||||
|
||||
col[0][0] = col[0][1] = col[0][2] = col[0][3] = 1.0f;
|
||||
|
||||
for( i = 0; i < m * n; i++ )
|
||||
@@ -112,8 +112,7 @@ Node *makeTerrain( void )
|
||||
geom->setVertexArray( &v );
|
||||
geom->setTexCoordArray( 0, &t );
|
||||
|
||||
geom->setColorArray( &col );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
geom->setColorArray( &col, Array::BIND_OVERALL );
|
||||
|
||||
for( i = 0; i < m-2; i++ )
|
||||
{
|
||||
|
||||
@@ -166,10 +166,10 @@ static Geometry *makeTree( _tree *tree, StateSet *dstate )
|
||||
{
|
||||
float vv[][3] =
|
||||
{
|
||||
{ -tree->w/2.0, 0.0, 0.0 },
|
||||
{ tree->w/2.0, 0.0, 0.0 },
|
||||
{ tree->w/2.0, 0.0, 2 * tree->h },
|
||||
{ -tree->w/2.0, 0.0, 2 * tree->h },
|
||||
{ -tree->w/2.0f, 0.0f, 0.0f },
|
||||
{ tree->w/2.0f, 0.0f, 0.0f },
|
||||
{ tree->w/2.0f, 0.0f, 2.0f * tree->h },
|
||||
{ -tree->w/2.0f, 0.0f, 2.0f * tree->h },
|
||||
};
|
||||
|
||||
Vec3Array& v = *(new Vec3Array(4));
|
||||
@@ -198,8 +198,7 @@ static Geometry *makeTree( _tree *tree, StateSet *dstate )
|
||||
|
||||
geom->setTexCoordArray( 0, &t );
|
||||
|
||||
geom->setColorArray( &l );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
geom->setColorArray( &l, Array::BIND_OVERALL );
|
||||
|
||||
geom->addPrimitiveSet( new DrawArrays(PrimitiveSet::QUADS,0,4) );
|
||||
|
||||
@@ -238,7 +237,7 @@ Node *makeTrees( void )
|
||||
tex->setImage(osgDB::readImageFile("Images/tree0.rgba"));
|
||||
|
||||
StateSet *dstate = new StateSet;
|
||||
|
||||
|
||||
dstate->setTextureAttributeAndModes(0, tex, StateAttribute::ON );
|
||||
dstate->setTextureAttribute(0, new TexEnv );
|
||||
|
||||
@@ -249,7 +248,7 @@ Node *makeTrees( void )
|
||||
dstate->setAttributeAndModes( alphaFunc, StateAttribute::ON );
|
||||
|
||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||
|
||||
|
||||
dstate->setRenderingHint( StateSet::TRANSPARENT_BIN );
|
||||
|
||||
int tt[] = { 15, 30, 45, 58, 72, 75, 93, 96, 105, -1 };
|
||||
|
||||
@@ -46,7 +46,7 @@ osg::Camera* createHUD()
|
||||
// set the projection matrix
|
||||
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
|
||||
|
||||
// set the view matrix
|
||||
// set the view matrix
|
||||
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
camera->setViewMatrix(osg::Matrix::identity());
|
||||
|
||||
@@ -58,7 +58,7 @@ osg::Camera* createHUD()
|
||||
|
||||
// we don't want the camera to grab event focus from the viewers main camera(s).
|
||||
camera->setAllowEventFocus(false);
|
||||
|
||||
|
||||
|
||||
|
||||
// add to this camera a subgraph to render
|
||||
@@ -84,7 +84,7 @@ osg::Camera* createHUD()
|
||||
text->setText("Head Up Displays are simple :-)");
|
||||
|
||||
position += delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
@@ -96,7 +96,7 @@ osg::Camera* createHUD()
|
||||
text->setText("All you need to do is create your text in a subgraph.");
|
||||
|
||||
position += delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
@@ -109,7 +109,7 @@ osg::Camera* createHUD()
|
||||
"to create an orthographic projection.\n");
|
||||
|
||||
position += delta;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
osgText::Text* text = new osgText::Text;
|
||||
@@ -121,7 +121,7 @@ osg::Camera* createHUD()
|
||||
"it remains independent from any external model view matrices.");
|
||||
|
||||
position += delta;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
osgText::Text* text = new osgText::Text;
|
||||
@@ -132,7 +132,7 @@ osg::Camera* createHUD()
|
||||
text->setText("And set the Camera's clear mask to just clear the depth buffer.");
|
||||
|
||||
position += delta;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
osgText::Text* text = new osgText::Text;
|
||||
@@ -144,7 +144,7 @@ osg::Camera* createHUD()
|
||||
"to make sure it's drawn last.");
|
||||
|
||||
position += delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
@@ -166,13 +166,11 @@ osg::Camera* createHUD()
|
||||
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
|
||||
geom->setNormalArray(normals);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0,0.8f,0.2f));
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
|
||||
|
||||
@@ -196,14 +194,14 @@ struct SnapImage : public osg::Camera::DrawCallback
|
||||
_filename(filename),
|
||||
_snapImage(false)
|
||||
{
|
||||
_image = new osg::Image;
|
||||
_image = new osg::Image;
|
||||
}
|
||||
|
||||
virtual void operator () (osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
|
||||
if (!_snapImage) return;
|
||||
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Camera callback"<<std::endl;
|
||||
|
||||
osg::Camera* camera = renderInfo.getCurrentCamera();
|
||||
@@ -217,10 +215,10 @@ struct SnapImage : public osg::Camera::DrawCallback
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE);
|
||||
osgDB::writeImageFile(*_image, _filename);
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Taken screenshot, and written to '"<<_filename<<"'"<<std::endl;
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Taken screenshot, and written to '"<<_filename<<"'"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
_snapImage = false;
|
||||
}
|
||||
|
||||
@@ -259,7 +257,7 @@ struct SnapeImageHandler : public osgGA::GUIEventHandler
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int _key;
|
||||
osg::ref_ptr<SnapImage> _snapImage;
|
||||
};
|
||||
@@ -273,11 +271,11 @@ int main( int argc, char **argv )
|
||||
|
||||
// read the scene from the list of file specified commandline args.
|
||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
||||
|
||||
|
||||
// if not loaded assume no arguments passed in, try use default model instead.
|
||||
if (!scene) scene = osgDB::readNodeFile("dumptruck.osgt");
|
||||
|
||||
|
||||
|
||||
|
||||
if (!scene)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"No model loaded"<<std::endl;
|
||||
@@ -291,16 +289,16 @@ int main( int argc, char **argv )
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
// create a HUD as slave camera attached to the master view.
|
||||
|
||||
|
||||
viewer.setUpViewAcrossAllScreens();
|
||||
|
||||
osgViewer::Viewer::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
|
||||
|
||||
if (windows.empty()) return 1;
|
||||
|
||||
|
||||
osg::Camera* hudCamera = createHUD();
|
||||
|
||||
|
||||
// set up cameras to render on the first window available.
|
||||
hudCamera->setGraphicsContext(windows[0]);
|
||||
hudCamera->setViewport(0,0,windows[0]->getTraits()->width, windows[0]->getTraits()->height);
|
||||
@@ -327,21 +325,21 @@ int main( int argc, char **argv )
|
||||
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
// now create the HUD camera's view
|
||||
|
||||
|
||||
osgViewer::Viewer::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
|
||||
|
||||
if (windows.empty()) return 1;
|
||||
|
||||
|
||||
osg::Camera* hudCamera = createHUD();
|
||||
|
||||
|
||||
// set up cameras to render on the first window available.
|
||||
hudCamera->setGraphicsContext(windows[0]);
|
||||
hudCamera->setViewport(0,0,windows[0]->getTraits()->width, windows[0]->getTraits()->height);
|
||||
|
||||
|
||||
osgViewer::View* hudView = new osgViewer::View;
|
||||
hudView->setCamera(hudCamera);
|
||||
|
||||
|
||||
viewer.addView(hudView);
|
||||
|
||||
return viewer.run();
|
||||
@@ -351,18 +349,18 @@ int main( int argc, char **argv )
|
||||
{
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
|
||||
SnapImage* postDrawCallback = new SnapImage("PostDrawCallback.png");
|
||||
viewer.getCamera()->setPostDrawCallback(postDrawCallback);
|
||||
viewer.getCamera()->setPostDrawCallback(postDrawCallback);
|
||||
viewer.addEventHandler(new SnapeImageHandler('p',postDrawCallback));
|
||||
|
||||
|
||||
SnapImage* finalDrawCallback = new SnapImage("FinalDrawCallback.png");
|
||||
viewer.getCamera()->setFinalDrawCallback(finalDrawCallback);
|
||||
viewer.getCamera()->setFinalDrawCallback(finalDrawCallback);
|
||||
viewer.addEventHandler(new SnapeImageHandler('f',finalDrawCallback));
|
||||
|
||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||
|
||||
// add the HUD subgraph.
|
||||
// add the HUD subgraph.
|
||||
if (scene.valid()) group->addChild(scene.get());
|
||||
group->addChild(createHUD());
|
||||
|
||||
@@ -371,5 +369,5 @@ int main( int argc, char **argv )
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
@@ -36,6 +39,32 @@
|
||||
#include <iostream>
|
||||
|
||||
|
||||
static osgDB::DirectoryContents getSuitableFiles(osg::ArgumentParser& arguments)
|
||||
{
|
||||
osgDB::DirectoryContents files;
|
||||
for(int i=1; i<arguments.argc(); ++i)
|
||||
{
|
||||
if (osgDB::fileType(arguments[i]) == osgDB::DIRECTORY)
|
||||
{
|
||||
const std::string& directory = arguments[i];
|
||||
osgDB::DirectoryContents dc = osgDB::getSortedDirectoryContents(directory);
|
||||
|
||||
for(osgDB::DirectoryContents::iterator itr = dc.begin(); itr != dc.end(); ++itr)
|
||||
{
|
||||
std::string full_file_name = directory + "/" + (*itr);
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(full_file_name);
|
||||
if ((ext == "jpg") || (ext == "png") || (ext == "gif") || (ext == "rgb") || (ext == "dds") )
|
||||
{
|
||||
files.push_back(full_file_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
files.push_back(arguments[i]);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
@@ -69,13 +98,20 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
|
||||
double length = -1.0;
|
||||
while (arguments.read("--length",length)) {}
|
||||
|
||||
if (arguments.argc()>1)
|
||||
double fps = 30.0;
|
||||
while (arguments.read("--fps",fps)) {}
|
||||
|
||||
osgDB::DirectoryContents files = getSuitableFiles(arguments);
|
||||
if (!files.empty())
|
||||
{
|
||||
for(int i=1; i<arguments.argc(); ++i)
|
||||
for(osgDB::DirectoryContents::iterator itr = files.begin();
|
||||
itr != files.end();
|
||||
++itr)
|
||||
{
|
||||
const std::string& filename = *itr;
|
||||
if (preLoad)
|
||||
{
|
||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(arguments[i]);
|
||||
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filename);
|
||||
if (image.valid())
|
||||
{
|
||||
imageSequence->addImage(image.get());
|
||||
@@ -83,8 +119,9 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
|
||||
}
|
||||
else
|
||||
{
|
||||
imageSequence->addImageFile(arguments[i]);
|
||||
imageSequence->addImageFile(filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (length>0.0)
|
||||
@@ -93,10 +130,8 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int maxNum = osg::maximum(imageSequence->getFileNames().size(),
|
||||
imageSequence->getImages().size());
|
||||
|
||||
imageSequence->setLength(float(maxNum)*0.1f);
|
||||
unsigned int maxNum = imageSequence->getNumImageData();
|
||||
imageSequence->setLength(double(maxNum)*(1.0/fps));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -171,11 +206,48 @@ public:
|
||||
|
||||
void set(osg::Node* node);
|
||||
|
||||
void setTrackMouse(bool tm)
|
||||
{
|
||||
if (tm==_trackMouse) return;
|
||||
|
||||
_trackMouse = tm;
|
||||
|
||||
std::cout << "tracking mouse: " << (_trackMouse ? "ON" : "OFF") << std::endl;
|
||||
|
||||
for(ImageStreamList::iterator itr=_imageStreamList.begin();
|
||||
itr!=_imageStreamList.end();
|
||||
++itr)
|
||||
{
|
||||
if ((*itr)->getStatus()==osg::ImageStream::PLAYING)
|
||||
{
|
||||
(*itr)->pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
(*itr)->play();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool getTrackMouse() const { return _trackMouse; }
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv);
|
||||
|
||||
virtual void getUsage(osg::ApplicationUsage& usage) const;
|
||||
|
||||
typedef std::vector< osg::observer_ptr<osg::ImageStream> > ImageStreamList;
|
||||
|
||||
struct ImageStreamPlaybackSpeedData {
|
||||
double fps;
|
||||
unsigned char* lastData;
|
||||
double timeStamp, lastOutput;
|
||||
|
||||
ImageStreamPlaybackSpeedData() : fps(0), lastData(NULL), timeStamp(0), lastOutput(0) {}
|
||||
|
||||
};
|
||||
|
||||
typedef std::vector< ImageStreamPlaybackSpeedData > ImageStreamPlayBackSpeedList;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -240,6 +312,7 @@ protected:
|
||||
bool _playToggle;
|
||||
bool _trackMouse;
|
||||
ImageStreamList _imageStreamList;
|
||||
ImageStreamPlayBackSpeedList _imageStreamPlayBackSpeedList;
|
||||
|
||||
};
|
||||
|
||||
@@ -253,6 +326,7 @@ void MovieEventHandler::set(osg::Node* node)
|
||||
FindImageStreamsVisitor fisv(_imageStreamList);
|
||||
node->accept(fisv);
|
||||
}
|
||||
_imageStreamPlayBackSpeedList.resize(_imageStreamList.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -260,6 +334,53 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
{
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::FRAME):
|
||||
{
|
||||
double t = ea.getTime();
|
||||
bool printed(false);
|
||||
|
||||
ImageStreamPlayBackSpeedList::iterator fps_itr = _imageStreamPlayBackSpeedList.begin();
|
||||
for(ImageStreamList::iterator itr=_imageStreamList.begin();
|
||||
itr!=_imageStreamList.end();
|
||||
++itr, ++fps_itr)
|
||||
{
|
||||
if (((*itr)->getStatus()==osg::ImageStream::PLAYING) && ((*itr)->data() != (*fps_itr).lastData))
|
||||
{
|
||||
ImageStreamPlaybackSpeedData& data(*fps_itr);
|
||||
double dt = (data.timeStamp > 0) ? t - data.timeStamp : 1/60.0;
|
||||
data.lastData = (*itr)->data();
|
||||
data.fps = (*fps_itr).fps * 0.8 + 0.2 * (1/dt);
|
||||
data.timeStamp = t;
|
||||
|
||||
if (t-data.lastOutput > 1)
|
||||
{
|
||||
std::cout << data.fps << " ";
|
||||
data.lastOutput = t;
|
||||
printed = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (printed)
|
||||
std::cout << std::endl;
|
||||
}
|
||||
break;
|
||||
case(osgGA::GUIEventAdapter::MOVE):
|
||||
{
|
||||
if (_trackMouse)
|
||||
{
|
||||
for(ImageStreamList::iterator itr=_imageStreamList.begin();
|
||||
itr!=_imageStreamList.end();
|
||||
++itr)
|
||||
{
|
||||
double dt = (*itr)->getLength() * ((1.0+ea.getXnormalized()) / 2.0);
|
||||
(*itr)->seek(dt);
|
||||
std::cout << "seeking to " << dt << " length: " <<(*itr)->getLength() << std::endl;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey()=='p')
|
||||
@@ -312,6 +433,12 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 'i')
|
||||
{
|
||||
setTrackMouse(!_trackMouse);
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -319,10 +446,13 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MovieEventHandler::getUsage(osg::ApplicationUsage& usage) const
|
||||
{
|
||||
usage.addKeyboardMouseBinding("i","toggle interactive mode, scrub via mouse-move");
|
||||
usage.addKeyboardMouseBinding("p","Play/Pause movie");
|
||||
usage.addKeyboardMouseBinding("r","Restart movie");
|
||||
usage.addKeyboardMouseBinding("l","Toggle looping of movie");
|
||||
@@ -347,6 +477,9 @@ int main(int argc, char **argv)
|
||||
// pass the model to the MovieEventHandler so it can pick out ImageStream's to manipulate.
|
||||
MovieEventHandler* meh = new MovieEventHandler();
|
||||
meh->set( viewer.getSceneData() );
|
||||
|
||||
if (arguments.read("--track-mouse")) meh->setTrackMouse(true);
|
||||
|
||||
viewer.addEventHandler( meh );
|
||||
|
||||
viewer.addEventHandler( new osgViewer::StatsHandler());
|
||||
|
||||
@@ -43,7 +43,7 @@ typedef NodeContainer::iterator NodeIterator;
|
||||
NodeContainer nodes;
|
||||
|
||||
//
|
||||
osg::Group * Root = 0;
|
||||
osg::ref_ptr<osg::Group> Root = 0;
|
||||
|
||||
const int HOUSES_SIZE = 25000; // total number of houses
|
||||
double XDim = 5000.0f; // area dimension +/- XDim
|
||||
@@ -81,11 +81,11 @@ void CreateHouses()
|
||||
};
|
||||
|
||||
// use the same color, normal and indices for all houses.
|
||||
osg::Vec4Array* colors = new osg::Vec4Array(1);
|
||||
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(1);
|
||||
(*colors)[0] = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// normals
|
||||
osg::Vec3Array * normals = new osg::Vec3Array(16);
|
||||
osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array(16);
|
||||
(*normals)[0] = osg::Vec3( 0.0f, -0.0f, -1.0f);
|
||||
(*normals)[1] = osg::Vec3( 0.0f, -0.0f, -1.0f);
|
||||
(*normals)[2] = osg::Vec3( 0.0f, -1.0f, 0.0f);
|
||||
@@ -104,10 +104,10 @@ void CreateHouses()
|
||||
(*normals)[15] = osg::Vec3(-0.707107f, 0.0f, 0.707107f);
|
||||
|
||||
// coordIndices
|
||||
osg::UByteArray* coordIndices = new osg::UByteArray(48,indices);
|
||||
osg::ref_ptr<osg::UByteArray> coordIndices = new osg::UByteArray(48,indices);
|
||||
|
||||
// share the primitive set.
|
||||
osg::PrimitiveSet* primitives = new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,48);
|
||||
// share the primitive set.
|
||||
osg::PrimitiveSet* primitives = new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,48);
|
||||
|
||||
for (int q = 0; q < HOUSES_SIZE; q++)
|
||||
{
|
||||
@@ -120,11 +120,11 @@ void CreateHouses()
|
||||
* 2 * ZDim) - ZDim;
|
||||
|
||||
float scale = 10.0f;
|
||||
|
||||
osg::Vec3 offset(xPos,yPos,0.0f);
|
||||
|
||||
osg::Vec3 offset(xPos,yPos,0.0f);
|
||||
|
||||
// coords
|
||||
osg::Vec3Array* coords = new osg::Vec3Array(10);
|
||||
osg::ref_ptr<osg::Vec3Array> coords = new osg::Vec3Array(10);
|
||||
(*coords)[0] = osg::Vec3( 0.5f, -0.7f, 0.0f);
|
||||
(*coords)[1] = osg::Vec3( 0.5f, 0.7f, 0.0f);
|
||||
(*coords)[2] = osg::Vec3(-0.5f, 0.7f, 0.0f);
|
||||
@@ -143,23 +143,23 @@ void CreateHouses()
|
||||
|
||||
|
||||
// create geometry
|
||||
osg::Geometry * geometry = new osg::Geometry();
|
||||
|
||||
geometry->addPrimitiveSet(primitives);
|
||||
|
||||
geometry->setVertexArray(coords);
|
||||
geometry->setVertexIndices(coordIndices);
|
||||
|
||||
geometry->setColorArray(colors);
|
||||
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geometry->setNormalArray(normals);
|
||||
geometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
osg::ref_ptr<deprecated_osg::Geometry> geometry = new deprecated_osg::Geometry();
|
||||
|
||||
osg::Geode * geode = new osg::Geode();
|
||||
geode->addDrawable(geometry);
|
||||
|
||||
nodes.push_back(geode);
|
||||
geometry->addPrimitiveSet(primitives);
|
||||
|
||||
geometry->setVertexArray(coords.get());
|
||||
geometry->setVertexIndices(coordIndices.get());
|
||||
|
||||
geometry->setColorArray(colors.get());
|
||||
geometry->setColorBinding(deprecated_osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geometry->setNormalArray(normals.get());
|
||||
geometry->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
||||
geode->addDrawable(geometry.get());
|
||||
|
||||
nodes.push_back(geode.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,14 +187,14 @@ void LayoutAsGrid()
|
||||
{
|
||||
osg::Node * node = nodeIter->get();
|
||||
osg::Vec3 center = node->getBound().center();
|
||||
|
||||
|
||||
int x = (int)floor((center.x() - xGridStart) / xGridSize);
|
||||
int z = (int)floor((center.y() - yGridStart) / yGridSize);
|
||||
|
||||
groups[z * GridX + x]->addChild(node);
|
||||
}
|
||||
|
||||
// add nodes to building root
|
||||
|
||||
// add nodes to building root
|
||||
for (i = 0; i < GridX * GridY; i++)
|
||||
{
|
||||
osg::StateSet * stateset = new osg::StateSet();
|
||||
@@ -205,7 +205,7 @@ void LayoutAsGrid()
|
||||
0.5f + (static_cast<double> (rand()) / (2.0*static_cast<double> (RAND_MAX))),
|
||||
0.5f + (static_cast<double> (rand()) / ( 2.0*static_cast<double>(RAND_MAX))),
|
||||
1.0f);
|
||||
|
||||
|
||||
material->setAmbient(osg::Material::FRONT_AND_BACK, color);
|
||||
material->setDiffuse(osg::Material::FRONT_AND_BACK, color);
|
||||
stateset->setAttributeAndModes(material, osg::StateAttribute::ON);
|
||||
@@ -244,14 +244,14 @@ int main( int argc, char **argv )
|
||||
|
||||
|
||||
// load the nodes from the commandline arguments.
|
||||
osg::Node* model = osgDB::readNodeFiles(arguments);
|
||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
||||
if (model)
|
||||
{
|
||||
// the osgSim::InsertImpostorsVisitor used lower down to insert impostors
|
||||
// only operators on subclass of Group's, if the model top node is not
|
||||
// a group then it won't be able to insert an impostor. We therefore
|
||||
// manually insert an impostor above the model.
|
||||
if (dynamic_cast<osg::Group*>(model)==0)
|
||||
if (dynamic_cast<osg::Group*>(model.get())==0)
|
||||
{
|
||||
const osg::BoundingSphere& bs = model->getBound();
|
||||
if (bs.valid())
|
||||
@@ -260,7 +260,7 @@ int main( int argc, char **argv )
|
||||
osgSim::Impostor* impostor = new osgSim::Impostor;
|
||||
|
||||
// standard LOD settings
|
||||
impostor->addChild(model);
|
||||
impostor->addChild(model.get());
|
||||
impostor->setRange(0,0.0f,1e7f);
|
||||
impostor->setCenter(bs.center());
|
||||
|
||||
@@ -278,9 +278,9 @@ int main( int argc, char **argv )
|
||||
// we would know about it, other than by following the parent path
|
||||
// up from model. This is really what should be done, but I'll pass
|
||||
// on it right now as it requires a getRoots() method to be added to
|
||||
// osg::Node, and we're about to make a release so no new features!
|
||||
osg::Group* rootnode = new osg::Group;
|
||||
rootnode->addChild(model);
|
||||
// osg::Node, and we're about to make a release so no new features!
|
||||
osg::ref_ptr<osg::Group> rootnode = new osg::Group;
|
||||
rootnode->addChild(model.get());
|
||||
|
||||
|
||||
// now insert impostors in the model using the InsertImpostorsVisitor.
|
||||
@@ -304,7 +304,7 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
// add model to viewer.
|
||||
viewer.setSceneData(model);
|
||||
viewer.setSceneData(model.get());
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
5
examples/osgkeystone/CMakeLists.txt
Normal file
5
examples/osgkeystone/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
SET(TARGET_SRC
|
||||
osgkeystone.cpp )
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgkeystone)
|
||||
111
examples/osgkeystone/osgkeystone.cpp
Normal file
111
examples/osgkeystone/osgkeystone.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* OpenSceneGraph example, osganimate.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <osg/Notify>
|
||||
#include <osg/io_utils>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/TexMat>
|
||||
#include <osg/Stencil>
|
||||
#include <osg/PolygonStipple>
|
||||
#include <osg/ValueObject>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osgViewer/config/SingleWindow>
|
||||
#include <osgViewer/config/SingleScreen>
|
||||
#include <osgViewer/config/WoWVxDisplay>
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
// initialize the viewer.
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
osg::DisplaySettings* ds = viewer.getDisplaySettings() ? viewer.getDisplaySettings() : osg::DisplaySettings::instance().get();
|
||||
ds->readCommandLine(arguments);
|
||||
|
||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
||||
|
||||
if (!model)
|
||||
{
|
||||
OSG_NOTICE<<"No models loaded, please specify a model file on the command line"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
OSG_NOTICE<<"Stereo "<<ds->getStereo()<<std::endl;
|
||||
OSG_NOTICE<<"StereoMode "<<ds->getStereoMode()<<std::endl;
|
||||
|
||||
viewer.setSceneData(model.get());
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
|
||||
// add the stats handler
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
// add camera manipulator
|
||||
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
|
||||
|
||||
OSG_NOTICE<<"KeystoneFileNames.size()="<<ds->getKeystoneFileNames().size()<<std::endl;
|
||||
for(osg::DisplaySettings::FileNames::iterator itr = ds->getKeystoneFileNames().begin();
|
||||
itr != ds->getKeystoneFileNames().end();
|
||||
++itr)
|
||||
{
|
||||
OSG_NOTICE<<" keystone filename = "<<*itr<<std::endl;
|
||||
}
|
||||
|
||||
ds->setKeystoneHint(true);
|
||||
|
||||
if (!ds->getKeystoneFileNames().empty())
|
||||
{
|
||||
for(osg::DisplaySettings::Objects::iterator itr = ds->getKeystones().begin();
|
||||
itr != ds->getKeystones().end();
|
||||
++itr)
|
||||
{
|
||||
osgViewer::Keystone* keystone = dynamic_cast<osgViewer::Keystone*>(itr->get());
|
||||
if (keystone)
|
||||
{
|
||||
std::string filename;
|
||||
keystone->getUserValue("filename",filename);
|
||||
OSG_NOTICE<<"Loaded keystone "<<filename<<", "<<keystone<<std::endl;
|
||||
|
||||
ds->getKeystones().push_back(keystone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewer.apply(new osgViewer::SingleScreen(0));
|
||||
|
||||
viewer.realize();
|
||||
|
||||
while(!viewer.done())
|
||||
{
|
||||
viewer.advance();
|
||||
viewer.eventTraversal();
|
||||
viewer.updateTraversal();
|
||||
viewer.renderingTraversals();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
|
||||
|
||||
std::string pick(float x, float y);
|
||||
std::string pick(const osgGA::GUIEventAdapter& event);
|
||||
|
||||
void highlight(const std::string& name)
|
||||
{
|
||||
@@ -83,15 +83,15 @@ bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapte
|
||||
case(osgGA::GUIEventAdapter::FRAME):
|
||||
case(osgGA::GUIEventAdapter::MOVE):
|
||||
{
|
||||
//osg::notify(osg::NOTICE)<<"MOVE "<<ea.getX()<<ea.getY()<<std::endl;
|
||||
std::string picked_name = pick(ea.getX(),ea.getY());
|
||||
// osg::notify(osg::NOTICE)<<"MOVE "<<ea.getX()<<", "<<ea.getY()<<std::endl;
|
||||
std::string picked_name = pick(ea);
|
||||
highlight(picked_name);
|
||||
return false;
|
||||
}
|
||||
case(osgGA::GUIEventAdapter::PUSH):
|
||||
{
|
||||
//osg::notify(osg::NOTICE)<<"PUSH "<<ea.getX()<<ea.getY()<<std::endl;
|
||||
std::string picked_name = pick(ea.getX(),ea.getY());
|
||||
// osg::notify(osg::NOTICE)<<"PUSH "<<ea.getX()<<", "<<ea.getY()<<std::endl;
|
||||
std::string picked_name = pick(ea);
|
||||
if (!picked_name.empty())
|
||||
{
|
||||
runApp(picked_name);
|
||||
@@ -108,10 +108,10 @@ bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapte
|
||||
}
|
||||
|
||||
|
||||
std::string PickHandler::pick(float x, float y)
|
||||
std::string PickHandler::pick(const osgGA::GUIEventAdapter& event)
|
||||
{
|
||||
osgUtil::LineSegmentIntersector::Intersections intersections;
|
||||
if (_viewer->computeIntersections(x, y, intersections))
|
||||
if (_viewer->computeIntersections(event, intersections))
|
||||
{
|
||||
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
|
||||
hitr != intersections.end();
|
||||
|
||||
@@ -50,34 +50,34 @@ class ModelTransformCallback : public osg::NodeCallback
|
||||
_period = 4.0f;
|
||||
_range = bs.radius()*0.5f;
|
||||
}
|
||||
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osg::PositionAttitudeTransform* pat = dynamic_cast<osg::PositionAttitudeTransform*>(node);
|
||||
const osg::FrameStamp* frameStamp = nv->getFrameStamp();
|
||||
if (pat && frameStamp)
|
||||
{
|
||||
if (_firstTime==0.0)
|
||||
if (_firstTime==0.0)
|
||||
{
|
||||
_firstTime = frameStamp->getSimulationTime();
|
||||
}
|
||||
|
||||
|
||||
double phase = (frameStamp->getSimulationTime()-_firstTime)/_period;
|
||||
phase -= floor(phase);
|
||||
phase *= (2.0 * osg::PI);
|
||||
|
||||
|
||||
osg::Quat rotation;
|
||||
rotation.makeRotate(phase,1.0f,1.0f,1.0f);
|
||||
|
||||
pat->setAttitude(rotation);
|
||||
|
||||
|
||||
pat->setAttitude(rotation);
|
||||
|
||||
pat->setPosition(osg::Vec3(0.0f,0.0f,sin(phase))*_range);
|
||||
}
|
||||
|
||||
// must traverse the Node's subgraph
|
||||
|
||||
// must traverse the Node's subgraph
|
||||
traverse(node,nv);
|
||||
}
|
||||
|
||||
|
||||
double _firstTime;
|
||||
double _period;
|
||||
double _range;
|
||||
@@ -88,7 +88,7 @@ class ModelTransformCallback : public osg::NodeCallback
|
||||
osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
|
||||
{
|
||||
osg::Group* lightGroup = new osg::Group;
|
||||
|
||||
|
||||
float modelSize = bb.radius();
|
||||
|
||||
// create a spot light.
|
||||
@@ -101,13 +101,13 @@ osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
|
||||
myLight1->setSpotExponent(50.0f);
|
||||
myLight1->setDirection(osg::Vec3(1.0f,1.0f,-1.0f));
|
||||
|
||||
osg::LightSource* lightS1 = new osg::LightSource;
|
||||
osg::LightSource* lightS1 = new osg::LightSource;
|
||||
lightS1->setLight(myLight1);
|
||||
lightS1->setLocalStateSetModes(osg::StateAttribute::ON);
|
||||
lightS1->setLocalStateSetModes(osg::StateAttribute::ON);
|
||||
|
||||
lightS1->setStateSetModes(*rootStateSet,osg::StateAttribute::ON);
|
||||
lightGroup->addChild(lightS1);
|
||||
|
||||
|
||||
|
||||
// create a local light.
|
||||
osg::Light* myLight2 = new osg::Light;
|
||||
@@ -119,15 +119,15 @@ osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
|
||||
myLight2->setLinearAttenuation(2.0f/modelSize);
|
||||
myLight2->setQuadraticAttenuation(2.0f/osg::square(modelSize));
|
||||
|
||||
osg::LightSource* lightS2 = new osg::LightSource;
|
||||
osg::LightSource* lightS2 = new osg::LightSource;
|
||||
lightS2->setLight(myLight2);
|
||||
lightS2->setLocalStateSetModes(osg::StateAttribute::ON);
|
||||
lightS2->setLocalStateSetModes(osg::StateAttribute::ON);
|
||||
|
||||
lightS2->setStateSetModes(*rootStateSet,osg::StateAttribute::ON);
|
||||
|
||||
|
||||
osg::MatrixTransform* mt = new osg::MatrixTransform();
|
||||
{
|
||||
// set up the animation path
|
||||
// set up the animation path
|
||||
osg::AnimationPath* animationPath = new osg::AnimationPath;
|
||||
animationPath->insert(0.0,osg::AnimationPath::ControlPoint(bb.corner(0)));
|
||||
animationPath->insert(1.0,osg::AnimationPath::ControlPoint(bb.corner(1)));
|
||||
@@ -139,30 +139,30 @@ osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
|
||||
animationPath->insert(7.0,osg::AnimationPath::ControlPoint(bb.corner(7)));
|
||||
animationPath->insert(8.0,osg::AnimationPath::ControlPoint(bb.corner(0)));
|
||||
animationPath->setLoopMode(osg::AnimationPath::SWING);
|
||||
|
||||
|
||||
mt->setUpdateCallback(new osg::AnimationPathCallback(animationPath));
|
||||
}
|
||||
|
||||
|
||||
// create marker for point light.
|
||||
osg::Geometry* marker = new osg::Geometry;
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array;
|
||||
vertices->push_back(osg::Vec3(0.0,0.0,0.0));
|
||||
marker->setVertexArray(vertices);
|
||||
marker->addPrimitiveSet(new osg::DrawArrays(GL_POINTS,0,1));
|
||||
|
||||
|
||||
osg::StateSet* stateset = new osg::StateSet;
|
||||
osg::Point* point = new osg::Point;
|
||||
point->setSize(4.0f);
|
||||
stateset->setAttribute(point);
|
||||
|
||||
|
||||
marker->setStateSet(stateset);
|
||||
|
||||
|
||||
osg::Geode* markerGeode = new osg::Geode;
|
||||
markerGeode->addDrawable(marker);
|
||||
|
||||
|
||||
mt->addChild(lightS2);
|
||||
mt->addChild(markerGeode);
|
||||
|
||||
|
||||
lightGroup->addChild(mt);
|
||||
|
||||
return lightGroup;
|
||||
@@ -173,57 +173,56 @@ osg::Geometry* createWall(const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec
|
||||
|
||||
// create a drawable for occluder.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
|
||||
geom->setStateSet(stateset);
|
||||
|
||||
unsigned int noXSteps = 100;
|
||||
unsigned int noYSteps = 100;
|
||||
|
||||
|
||||
osg::Vec3Array* coords = new osg::Vec3Array;
|
||||
coords->reserve(noXSteps*noYSteps);
|
||||
|
||||
|
||||
|
||||
|
||||
osg::Vec3 dx = (v2-v1)/((float)noXSteps-1.0f);
|
||||
osg::Vec3 dy = (v3-v1)/((float)noYSteps-1.0f);
|
||||
|
||||
|
||||
unsigned int row;
|
||||
osg::Vec3 vRowStart = v1;
|
||||
for(row=0;row<noYSteps;++row)
|
||||
{
|
||||
osg::Vec3 v = vRowStart;
|
||||
for(unsigned int col=0;col<noXSteps;++col)
|
||||
for(unsigned int col=0;col<noXSteps;++col)
|
||||
{
|
||||
coords->push_back(v);
|
||||
v += dx;
|
||||
}
|
||||
vRowStart+=dy;
|
||||
}
|
||||
|
||||
|
||||
geom->setVertexArray(coords);
|
||||
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array(1);
|
||||
(*colors)[0].set(1.0f,1.0f,1.0f,1.0f);
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
|
||||
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
for(row=0;row<noYSteps-1;++row)
|
||||
{
|
||||
osg::DrawElementsUShort* quadstrip = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP);
|
||||
quadstrip->reserve(noXSteps*2);
|
||||
for(unsigned int col=0;col<noXSteps;++col)
|
||||
for(unsigned int col=0;col<noXSteps;++col)
|
||||
{
|
||||
quadstrip->push_back((row+1)*noXSteps+col);
|
||||
quadstrip->push_back(row*noXSteps+col);
|
||||
}
|
||||
}
|
||||
geom->addPrimitiveSet(quadstrip);
|
||||
}
|
||||
|
||||
// create the normals.
|
||||
|
||||
// create the normals.
|
||||
osgUtil::SmoothingVisitor::smooth(*geom);
|
||||
|
||||
|
||||
return geom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -240,12 +239,12 @@ osg::Node* createRoom(osg::Node* loadedModel)
|
||||
|
||||
osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform();
|
||||
pat->setPivotPoint(loaded_bs.center());
|
||||
|
||||
|
||||
pat->setUpdateCallback(new ModelTransformCallback(loaded_bs));
|
||||
pat->addChild(loadedModel);
|
||||
|
||||
|
||||
bs = pat->getBound();
|
||||
|
||||
|
||||
root->addChild(pat);
|
||||
|
||||
}
|
||||
@@ -263,7 +262,7 @@ osg::Node* createRoom(osg::Node* loadedModel)
|
||||
|
||||
osg::StateSet* wall = new osg::StateSet;
|
||||
wall->setMode(GL_CULL_FACE,osg::StateAttribute::ON);
|
||||
|
||||
|
||||
osg::StateSet* floor = new osg::StateSet;
|
||||
floor->setMode(GL_CULL_FACE,osg::StateAttribute::ON);
|
||||
|
||||
@@ -271,7 +270,7 @@ osg::Node* createRoom(osg::Node* loadedModel)
|
||||
roof->setMode(GL_CULL_FACE,osg::StateAttribute::ON);
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
|
||||
|
||||
// create front side.
|
||||
geode->addDrawable(createWall(bb.corner(0),
|
||||
bb.corner(4),
|
||||
@@ -308,12 +307,12 @@ osg::Node* createRoom(osg::Node* loadedModel)
|
||||
roof));
|
||||
|
||||
root->addChild(geode);
|
||||
|
||||
|
||||
root->addChild(createLights(bb,rootStateSet));
|
||||
|
||||
return root;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
@@ -325,20 +324,20 @@ int main( int argc, char **argv )
|
||||
|
||||
// load the nodes from the commandline arguments.
|
||||
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
|
||||
|
||||
|
||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||
if (!loadedModel) loadedModel = osgDB::readNodeFile("glider.osgt");
|
||||
|
||||
|
||||
// create a room made of foor walls, a floor, a roof, and swinging light fitting.
|
||||
osg::Node* rootnode = createRoom(loadedModel);
|
||||
|
||||
// run optimization over the scene graph
|
||||
osgUtil::Optimizer optimzer;
|
||||
optimzer.optimize(rootnode);
|
||||
|
||||
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer.setSceneData( rootnode );
|
||||
|
||||
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
class MyBillboardTransform : public osg::PositionAttitudeTransform
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
MyBillboardTransform():
|
||||
_axis(0.0f,0.0f,1.0f),
|
||||
_normal(0.0f,-1.0f,0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
|
||||
{
|
||||
osg::Quat billboardRotation;
|
||||
@@ -75,15 +75,15 @@ class MyBillboardTransform : public osg::PositionAttitudeTransform
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void setAxis(const osg::Vec3& axis) { _axis = axis; }
|
||||
|
||||
void setNormal(const osg::Vec3& normal) { _normal = normal; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual ~MyBillboardTransform() {}
|
||||
|
||||
|
||||
osg::Vec3 _axis;
|
||||
osg::Vec3 _normal;
|
||||
};
|
||||
@@ -99,18 +99,18 @@ osg::Geometry* createWing(const osg::Vec3& left, const osg::Vec3& nose, const os
|
||||
osg::Vec3 left_to_right = right-left;
|
||||
osg::Vec3 mid = (right+left)*0.5f;
|
||||
osg::Vec3 mid_to_nose = (nose-mid)*chordRatio*0.5f;
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array;
|
||||
vertices->push_back(left);
|
||||
//vertices->push_back(mid+mid_to_nose);
|
||||
|
||||
|
||||
unsigned int noSteps = 40;
|
||||
for(unsigned int i=1;i<noSteps;++i)
|
||||
{
|
||||
float ratio = (float)i/(float)noSteps;
|
||||
vertices->push_back(left + left_to_right*ratio + mid_to_nose* (cosf((ratio-0.5f)*osg::PI*2.0f)+1.0f));
|
||||
}
|
||||
|
||||
|
||||
vertices->push_back(right);
|
||||
vertices->push_back(nose);
|
||||
|
||||
@@ -119,23 +119,21 @@ osg::Geometry* createWing(const osg::Vec3& left, const osg::Vec3& nose, const os
|
||||
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(normal);
|
||||
geom->setNormalArray(normals);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
|
||||
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(color);
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(GL_POLYGON,0,vertices->getNumElements()));
|
||||
|
||||
|
||||
osgUtil::Tessellator tessellator;
|
||||
tessellator.retessellatePolygons(*geom);
|
||||
|
||||
return geom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
osg:: Node* createTextBelow(const osg::BoundingBox& bb, const std::string& label, const std::string&)
|
||||
@@ -172,7 +170,7 @@ osg:: Node* createTextLeft(const osg::BoundingBox& bb, const std::string& label,
|
||||
std::string font("fonts/arial.ttf");
|
||||
|
||||
osgText::Text* text = new osgText::Text;
|
||||
|
||||
|
||||
text->setFont(font);
|
||||
text->setFontResolution(110,120);
|
||||
text->setAlignment(osgText::Text::RIGHT_CENTER);
|
||||
@@ -191,7 +189,7 @@ osg:: Node* createTextLeft(const osg::BoundingBox& bb, const std::string& label,
|
||||
// text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER);
|
||||
// text->setBackdropImplementation(osgText::Text::DEPTH_RANGE);
|
||||
// text->setBackdropImplementation(osgText::Text::STENCIL_BUFFER);
|
||||
|
||||
|
||||
text->setBackdropOffset(0.05f);
|
||||
text->setBackdropColor(osg::Vec4(0.0f, 0.0f, 0.5f, 1.0f));
|
||||
#endif
|
||||
@@ -227,7 +225,7 @@ osg:: Node* createTextLeft(const osg::BoundingBox& bb, const std::string& label,
|
||||
|
||||
geode->addDrawable( subscriptText );
|
||||
}
|
||||
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
@@ -244,7 +242,7 @@ osg:: Node* createGlobe(const osg::BoundingBox& bb,float ratio, const std::strin
|
||||
osg::MatrixTransform* positioner = new osg::MatrixTransform;
|
||||
positioner->setMatrix(osg::Matrix::translate(-bs.center())*osg::Matrix::scale(s,s,s)*osg::Matrix::translate(bb.center()));
|
||||
positioner->addChild(bluemarble);
|
||||
|
||||
|
||||
xform->addChild(positioner);
|
||||
}
|
||||
else
|
||||
@@ -264,14 +262,14 @@ osg:: Node* createGlobe(const osg::BoundingBox& bb,float ratio, const std::strin
|
||||
}
|
||||
|
||||
osg::Material* material = new osg::Material;
|
||||
stateset->setAttribute(material);
|
||||
stateset->setAttribute(material);
|
||||
|
||||
// the globe
|
||||
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(bb.center(),bb.radius()*ratio)));
|
||||
|
||||
xform->addChild(geode);
|
||||
}
|
||||
|
||||
|
||||
return xform;
|
||||
}
|
||||
|
||||
@@ -287,7 +285,7 @@ osg:: Node* createBox(const osg::BoundingBox& bb,float chordRatio)
|
||||
|
||||
geode->addDrawable(createWing(bb.corner(4),bb.corner(5),bb.corner(1),chordRatio,white));
|
||||
geode->addDrawable(createWing(bb.corner(1),bb.corner(0),bb.corner(4),chordRatio,white));
|
||||
|
||||
|
||||
geode->addDrawable(createWing(bb.corner(1),bb.corner(5),bb.corner(7),chordRatio,white));
|
||||
geode->addDrawable(createWing(bb.corner(7),bb.corner(3),bb.corner(1),chordRatio,white));
|
||||
|
||||
@@ -314,7 +312,7 @@ osg:: Node* createBoxNo5(const osg::BoundingBox& bb,float chordRatio)
|
||||
geode->addDrawable(createWing(bb.corner(4),bb.corner(6),bb.corner(7),chordRatio,white));
|
||||
|
||||
geode->addDrawable(createWing(bb.corner(1),bb.corner(0),bb.corner(4),chordRatio,white));
|
||||
|
||||
|
||||
geode->addDrawable(createWing(bb.corner(7),bb.corner(3),bb.corner(1),chordRatio,white));
|
||||
|
||||
// back faces
|
||||
@@ -346,7 +344,7 @@ osg:: Node* createBoxNo5No2(const osg::BoundingBox& bb,float chordRatio)
|
||||
geode->addDrawable(createWing(bb.corner(4),bb.corner(6),bb.corner(7),chordRatio,red));
|
||||
|
||||
geode->addDrawable(createWing(bb.corner(1),bb.corner(0),bb.corner(4),chordRatio,green));
|
||||
|
||||
|
||||
geode->addDrawable(createWing(bb.corner(7),bb.corner(3),bb.corner(1),chordRatio,blue));
|
||||
|
||||
return geode;
|
||||
@@ -373,27 +371,25 @@ osg:: Node* createBackdrop(const osg::Vec3& corner,const osg::Vec3& top,const os
|
||||
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(normal);
|
||||
geom->setNormalArray(normals);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,vertices->getNumElements()));
|
||||
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
geode->addDrawable(geom);
|
||||
|
||||
return geode;
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
osg::Node* createLogo(const std::string& filename, const std::string& label, const std::string& subscript)
|
||||
{
|
||||
osg::BoundingBox bb(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(100.0f,100.0f,100.0f));
|
||||
float chordRatio = 0.5f;
|
||||
float sphereRatio = 0.6f;
|
||||
float chordRatio = 0.5f;
|
||||
float sphereRatio = 0.6f;
|
||||
|
||||
// create a group to hold the whole model.
|
||||
osg::Group* logo_group = new osg::Group;
|
||||
@@ -429,14 +425,14 @@ osg::Node* createLogo(const std::string& filename, const std::string& label, con
|
||||
// add the text to the group.
|
||||
//group->addChild(createTextBelow(bb));
|
||||
logo_group->addChild(createTextLeft(bb, label, subscript));
|
||||
|
||||
|
||||
|
||||
|
||||
// create the backdrop to render the shadow to.
|
||||
osg::Vec3 corner(-900.0f,150.0f,-100.0f);
|
||||
osg::Vec3 top(0.0f,0.0f,300.0f); top += corner;
|
||||
osg::Vec3 right(1100.0f,0.0f,0.0f); right += corner;
|
||||
|
||||
|
||||
|
||||
|
||||
// osg::Group* backdrop = new osg::Group;
|
||||
// backdrop->addChild(createBackdrop(corner,top,right));
|
||||
|
||||
@@ -462,9 +458,9 @@ int main( int argc, char **argv )
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
|
||||
osg::DisplaySettings::instance()->setMinimumNumAlphaBits(8);
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
@@ -474,23 +470,23 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->write(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
std::string label = "OpenSceneGraph";
|
||||
std::string subscript = "";
|
||||
|
||||
bool showVersion = false;
|
||||
while (arguments.read("--version")) { showVersion = true; }
|
||||
while (arguments.read("--version")) { showVersion = true; }
|
||||
if( showVersion )
|
||||
{
|
||||
label += " ";
|
||||
label += osgGetVersion();
|
||||
}
|
||||
|
||||
while (arguments.read("--label", label)) {}
|
||||
while (arguments.read("--subscript", subscript)) {}
|
||||
|
||||
while (arguments.read("--label", label)) {}
|
||||
while (arguments.read("--subscript", subscript)) {}
|
||||
|
||||
osg::ref_ptr<osg::Node> node;
|
||||
|
||||
|
||||
if (arguments.argc()>1) node = createLogo(arguments[1], label, subscript);
|
||||
else node = createLogo("", label, subscript);
|
||||
|
||||
|
||||
@@ -26,18 +26,60 @@
|
||||
#include <osgManipulator/TabBoxTrackballDragger>
|
||||
#include <osgManipulator/TabPlaneDragger>
|
||||
#include <osgManipulator/TabPlaneTrackballDragger>
|
||||
#include <osgManipulator/Scale1DDragger>
|
||||
#include <osgManipulator/Scale2DDragger>
|
||||
#include <osgManipulator/TrackballDragger>
|
||||
#include <osgManipulator/Translate1DDragger>
|
||||
#include <osgManipulator/Translate2DDragger>
|
||||
#include <osgManipulator/TranslateAxisDragger>
|
||||
#include <osgManipulator/TranslatePlaneDragger>
|
||||
#include <osgManipulator/RotateCylinderDragger>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Material>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class PlaneConstraint : public osgManipulator::Constraint
|
||||
{
|
||||
public:
|
||||
PlaneConstraint() {}
|
||||
|
||||
virtual bool constrain(osgManipulator::TranslateInLineCommand& command) const
|
||||
{
|
||||
OSG_NOTICE<<"PlaneConstraint TranslateInLineCommand "<<command.getTranslation()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
virtual bool constrain(osgManipulator::TranslateInPlaneCommand& command) const
|
||||
{
|
||||
//command.setTranslation(osg::Vec3(0.0f,0.0f,0.0f));
|
||||
OSG_NOTICE<<"PlaneConstraint TranslateInPlaneCommand "<<command.getTranslation()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
virtual bool constrain(osgManipulator::Scale1DCommand& command) const
|
||||
{
|
||||
//command.setScale(1.0f);
|
||||
OSG_NOTICE<<"PlaneConstraint Scale1DCommand"<<command.getScale()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
virtual bool constrain(osgManipulator::Scale2DCommand& command) const
|
||||
{
|
||||
//command.setScale(osg::Vec2d(1.0,1.0));
|
||||
OSG_NOTICE<<"PlaneConstraint Scale2DCommand "<<command.getScale()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
virtual bool constrain(osgManipulator::ScaleUniformCommand& command) const
|
||||
{
|
||||
OSG_NOTICE<<"PlaneConstraint ScaleUniformCommand"<<command.getScale()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
osgManipulator::Dragger* createDragger(const std::string& name)
|
||||
{
|
||||
osgManipulator::Dragger* dragger = 0;
|
||||
@@ -45,6 +87,7 @@ osgManipulator::Dragger* createDragger(const std::string& name)
|
||||
{
|
||||
osgManipulator::TabPlaneDragger* d = new osgManipulator::TabPlaneDragger();
|
||||
d->setupDefaultGeometry();
|
||||
d->addConstraint(new PlaneConstraint());
|
||||
dragger = d;
|
||||
}
|
||||
else if ("TabPlaneTrackballDragger" == name)
|
||||
@@ -83,6 +126,36 @@ osgManipulator::Dragger* createDragger(const std::string& name)
|
||||
d->setupDefaultGeometry();
|
||||
dragger = d;
|
||||
}
|
||||
else if ("TranslatePlaneDragger" == name)
|
||||
{
|
||||
osgManipulator::TranslatePlaneDragger* d = new osgManipulator::TranslatePlaneDragger();
|
||||
d->setupDefaultGeometry();
|
||||
dragger = d;
|
||||
}
|
||||
else if ("Scale1DDragger" == name)
|
||||
{
|
||||
osgManipulator::Scale1DDragger* d = new osgManipulator::Scale1DDragger();
|
||||
d->setupDefaultGeometry();
|
||||
dragger = d;
|
||||
}
|
||||
else if ("Scale2DDragger" == name)
|
||||
{
|
||||
osgManipulator::Scale2DDragger* d = new osgManipulator::Scale2DDragger();
|
||||
d->setupDefaultGeometry();
|
||||
dragger = d;
|
||||
}
|
||||
else if ("RotateCylinderDragger" == name)
|
||||
{
|
||||
osgManipulator::RotateCylinderDragger* d = new osgManipulator::RotateCylinderDragger();
|
||||
d->setupDefaultGeometry();
|
||||
dragger = d;
|
||||
}
|
||||
else if ("RotateSphereDragger" == name)
|
||||
{
|
||||
osgManipulator::RotateSphereDragger* d = new osgManipulator::RotateSphereDragger();
|
||||
d->setupDefaultGeometry();
|
||||
dragger = d;
|
||||
}
|
||||
else
|
||||
{
|
||||
osgManipulator::TabBoxDragger* d = new osgManipulator::TabBoxDragger();
|
||||
@@ -155,13 +228,13 @@ osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name, bool fix
|
||||
{
|
||||
scene->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
|
||||
|
||||
osg::MatrixTransform* selection = new osg::MatrixTransform;
|
||||
selection->addChild(scene);
|
||||
osg::MatrixTransform* transform = new osg::MatrixTransform;
|
||||
transform->addChild(scene);
|
||||
|
||||
osgManipulator::Dragger* dragger = createDragger(name);
|
||||
|
||||
osg::Group* root = new osg::Group;
|
||||
root->addChild(selection);
|
||||
root->addChild(transform);
|
||||
|
||||
if ( fixedSizeInScreen )
|
||||
{
|
||||
@@ -176,7 +249,14 @@ osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name, bool fix
|
||||
dragger->setMatrix(osg::Matrix::scale(scale, scale, scale) *
|
||||
osg::Matrix::translate(scene->getBound().center()));
|
||||
|
||||
dragger->addTransformUpdating(selection);
|
||||
if (dynamic_cast<osgManipulator::TabPlaneDragger*>(dragger))
|
||||
{
|
||||
dragger->addTransformUpdating(transform, osgManipulator::DraggerTransformCallback::HANDLE_TRANSLATE_IN_LINE);
|
||||
}
|
||||
else
|
||||
{
|
||||
dragger->addTransformUpdating(transform);
|
||||
}
|
||||
|
||||
// we want the dragger to handle it's own events automatically
|
||||
dragger->setHandleEvents(true);
|
||||
@@ -305,7 +385,7 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings.");
|
||||
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation [TabPlaneDragger,TabPlaneTrackballDragger,TrackballDragger,Translate1DDragger,Translate2DDragger,TranslateAxisDragger,TabBoxDragger]");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation [TabPlaneDragger, TabPlaneTrackballDragger, TrackballDragger, Translate1DDragger, Translate2DDragger, TranslateAxisDragger, TabBoxDragger, TranslatePlaneDragger, Scale1DDragger, Scale2DDragger, RotateCylinderDragger, RotateSphereDragger]");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--fixedDraggerSize","Fix the size of the dragger geometry in the screen space");
|
||||
|
||||
bool fixedSizeInScreen = false;
|
||||
|
||||
@@ -148,8 +148,8 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
|
||||
osgUtil::LineSegmentIntersector::Intersections intersections;
|
||||
bool foundIntersection = view==0 ? false :
|
||||
(nv==0 ? view->computeIntersections(ea.getX(), ea.getY(), intersections) :
|
||||
view->computeIntersections(ea.getX(), ea.getY(), nv->getNodePath(), intersections));
|
||||
(nv==0 ? view->computeIntersections(ea, intersections) :
|
||||
view->computeIntersections(ea, nv->getNodePath(), intersections));
|
||||
|
||||
if (foundIntersection)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user