Compare commits
512 Commits
OpenSceneG
...
OpenSceneG
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2f01f0ead | ||
|
|
1d9eab8406 | ||
|
|
0d8673a9a4 | ||
|
|
b62716d679 | ||
|
|
146c140be1 | ||
|
|
a7c67fe287 | ||
|
|
ce24d0c76f | ||
|
|
28438c5dbf | ||
|
|
cf5f000ea1 | ||
|
|
c46db2fa15 | ||
|
|
a1ae24af83 | ||
|
|
73b5712a7a | ||
|
|
38542c3986 | ||
|
|
5fe003d1a2 | ||
|
|
b3ecb8f38f | ||
|
|
c40f395e22 | ||
|
|
3460fc5e26 | ||
|
|
e928efc7a4 | ||
|
|
90eaf41007 | ||
|
|
f0da77042a | ||
|
|
1dc06b4553 | ||
|
|
3b3776df85 | ||
|
|
55d5a4d28a | ||
|
|
441b0c34bd | ||
|
|
caeed02f52 | ||
|
|
43a243c161 | ||
|
|
ce79b7efd5 | ||
|
|
f6c5cd184a | ||
|
|
8ae27117d3 | ||
|
|
e3e4f6614c | ||
|
|
65e3591ed2 | ||
|
|
0296cbf9c1 | ||
|
|
d32effbdbc | ||
|
|
65ac804b7d | ||
|
|
7086aeeebc | ||
|
|
69eddaa7bb | ||
|
|
c6fcb62ab1 | ||
|
|
38d33c7685 | ||
|
|
e55a992767 | ||
|
|
48f19b72bd | ||
|
|
4cf73d4c87 | ||
|
|
a5ed021066 | ||
|
|
3c0e3af233 | ||
|
|
8907919fce | ||
|
|
368a45eec0 | ||
|
|
7ca2f597e6 | ||
|
|
e99f94c5aa | ||
|
|
40ded29902 | ||
|
|
91900254f0 | ||
|
|
f8729af8b2 | ||
|
|
4ef1864432 | ||
|
|
41ce67600e | ||
|
|
7679b96b30 | ||
|
|
6eccf540e6 | ||
|
|
9aab68b140 | ||
|
|
1df542c119 | ||
|
|
5b263f583f | ||
|
|
41efd25660 | ||
|
|
6df0110d0c | ||
|
|
63789c81b9 | ||
|
|
b23316838a | ||
|
|
5e504026a5 | ||
|
|
308bb5a797 | ||
|
|
e485c780c1 | ||
|
|
5c007029ae | ||
|
|
af498b6e1f | ||
|
|
2640fd1456 | ||
|
|
dcd7fd837f | ||
|
|
bfbc73785a | ||
|
|
1e9b4f7855 | ||
|
|
92092d6996 | ||
|
|
18ad07160d | ||
|
|
d743eb2d95 | ||
|
|
501b3241c6 | ||
|
|
61d0bc4eaf | ||
|
|
b8ddf1f786 | ||
|
|
43eacc4cbc | ||
|
|
3a94dd7b25 | ||
|
|
1c4b8a1d15 | ||
|
|
d8cbd49471 | ||
|
|
6d822cbf45 | ||
|
|
a6369fb617 | ||
|
|
caad9d26e1 | ||
|
|
e725f30d81 | ||
|
|
d11d5b819a | ||
|
|
a4f79e7a37 | ||
|
|
9f3783929a | ||
|
|
10d59e73f6 | ||
|
|
0726624a86 | ||
|
|
bd68958877 | ||
|
|
cf2c9da74d | ||
|
|
54c579fcae | ||
|
|
da70320707 | ||
|
|
82b0f004e9 | ||
|
|
1dc8983a76 | ||
|
|
5c36fbb18f | ||
|
|
6630dcf15c | ||
|
|
3bfaee3654 | ||
|
|
ece7b57df2 | ||
|
|
609315caa5 | ||
|
|
1e128aed1d | ||
|
|
55a9ea19d7 | ||
|
|
5fb9673382 | ||
|
|
7ea3632dfc | ||
|
|
cf69352873 | ||
|
|
1f7b27f851 | ||
|
|
8bc8b6b5e9 | ||
|
|
c8fd1e4627 | ||
|
|
e091d65c91 | ||
|
|
acfa793032 | ||
|
|
ae5883dd23 | ||
|
|
41dc911166 | ||
|
|
4c787abfd7 | ||
|
|
c583dbe3c5 | ||
|
|
6a83c9e641 | ||
|
|
e19f23021f | ||
|
|
e433762105 | ||
|
|
8051c48e56 | ||
|
|
f6eaa58c56 | ||
|
|
97b66b877d | ||
|
|
69de74aedf | ||
|
|
cb1c916e25 | ||
|
|
d5cc0e966f | ||
|
|
290adbe7ab | ||
|
|
89428f743a | ||
|
|
d6e24c0dc2 | ||
|
|
86ab5a2392 | ||
|
|
0b39152321 | ||
|
|
c88bcc4506 | ||
|
|
5caf64e5c7 | ||
|
|
2aff52be23 | ||
|
|
eac9831723 | ||
|
|
34af300957 | ||
|
|
0c5d6da793 | ||
|
|
b2fe3d475b | ||
|
|
0f135d6d35 | ||
|
|
45e98d5f18 | ||
|
|
23945bb506 | ||
|
|
4d0e86f1e2 | ||
|
|
a933587753 | ||
|
|
c15ec121f4 | ||
|
|
0137047429 | ||
|
|
d8f875ec9e | ||
|
|
b89a1480fc | ||
|
|
be33fbc66b | ||
|
|
b63ce0dee9 | ||
|
|
0bd4d303e3 | ||
|
|
041afdc303 | ||
|
|
66cc306f18 | ||
|
|
9819217136 | ||
|
|
291d253161 | ||
|
|
175c3ce806 | ||
|
|
884b3b7aa2 | ||
|
|
c51e893ba4 | ||
|
|
5e83ae4821 | ||
|
|
98763cc4c5 | ||
|
|
bea07b5f72 | ||
|
|
269a3956e3 | ||
|
|
409cdd0b28 | ||
|
|
b9a4752694 | ||
|
|
91983cbe71 | ||
|
|
8e7e6529be | ||
|
|
18e688ea5f | ||
|
|
7409f1fb99 | ||
|
|
c747c7dbd6 | ||
|
|
c7a72c8435 | ||
|
|
ed6322630f | ||
|
|
00e00f4e00 | ||
|
|
9704ded891 | ||
|
|
b13a1957b0 | ||
|
|
14b0ef597b | ||
|
|
b20d542317 | ||
|
|
92b1e7d53f | ||
|
|
4b84acbec6 | ||
|
|
0372825d9b | ||
|
|
a2447d493c | ||
|
|
9e7a944639 | ||
|
|
c2156f12ff | ||
|
|
c9f6a3f7ca | ||
|
|
efc7ff6b02 | ||
|
|
177a8ec2ec | ||
|
|
dbf5e6c6f5 | ||
|
|
4330993f1f | ||
|
|
8414a16e52 | ||
|
|
be11672769 | ||
|
|
d80632bc81 | ||
|
|
39d0788d5b | ||
|
|
bd845a7b23 | ||
|
|
7b73a58728 | ||
|
|
de19fb3737 | ||
|
|
07e94c8ce0 | ||
|
|
027158b441 | ||
|
|
d730559ade | ||
|
|
c83bc830cd | ||
|
|
408eceac24 | ||
|
|
2415b8e4b1 | ||
|
|
ecb8d5f8ab | ||
|
|
a97afbb009 | ||
|
|
3304646c4c | ||
|
|
13faad13e8 | ||
|
|
76063a94bd | ||
|
|
5ae1eb711a | ||
|
|
86e998f64c | ||
|
|
1bc6d0bae4 | ||
|
|
8d1ef9906a | ||
|
|
4ba3f3c1a1 | ||
|
|
99f6865d4d | ||
|
|
a8c3bc2116 | ||
|
|
817f316e2a | ||
|
|
f4d2d1241d | ||
|
|
b0f21e9a39 | ||
|
|
4328bdacc2 | ||
|
|
712dbacda3 | ||
|
|
667be8bb57 | ||
|
|
9a9ffbe229 | ||
|
|
2f895b839e | ||
|
|
63c283ad03 | ||
|
|
71e7a65cca | ||
|
|
f6650dd3bf | ||
|
|
a98daccd03 | ||
|
|
bf8f2eec85 | ||
|
|
fb3bd9c921 | ||
|
|
eabe2faf7e | ||
|
|
5b1b648ef5 | ||
|
|
b74083ad15 | ||
|
|
020d7a5651 | ||
|
|
281437336c | ||
|
|
0ea44d5c6d | ||
|
|
0a16f653ef | ||
|
|
5ce34fd7f3 | ||
|
|
5817d4c83e | ||
|
|
cb5fb828d0 | ||
|
|
06a0ca8d06 | ||
|
|
48f1291c7f | ||
|
|
8a4db98e2b | ||
|
|
b2d131c143 | ||
|
|
0798e64872 | ||
|
|
f9ab446512 | ||
|
|
09f63eebbb | ||
|
|
b0bede80c5 | ||
|
|
a981202953 | ||
|
|
1273c814d1 | ||
|
|
9489eef1cf | ||
|
|
056a9bc491 | ||
|
|
54202aae0d | ||
|
|
cc6ac2704e | ||
|
|
5050b9b5b1 | ||
|
|
607f92e1fa | ||
|
|
9a73a3f461 | ||
|
|
85ef819827 | ||
|
|
0da0127857 | ||
|
|
a3ce9f680a | ||
|
|
6827104532 | ||
|
|
616f64cf2c | ||
|
|
a86c3dd314 | ||
|
|
f8ac71d7e5 | ||
|
|
bdb2a6b9d7 | ||
|
|
f6d342af6f | ||
|
|
9c4fd5ec82 | ||
|
|
1694cf9625 | ||
|
|
dee0c92ffc | ||
|
|
41d15384cc | ||
|
|
bb7368a321 | ||
|
|
4f97cdca96 | ||
|
|
e043b0339b | ||
|
|
120c9e54fe | ||
|
|
de4a4042f7 | ||
|
|
ef4dafaea1 | ||
|
|
5196b09672 | ||
|
|
bb886e8c94 | ||
|
|
94db040884 | ||
|
|
7f43f55a44 | ||
|
|
94af61ed01 | ||
|
|
57a18ff112 | ||
|
|
0390243ed9 | ||
|
|
c1dc079f56 | ||
|
|
502f1a3330 | ||
|
|
6dee57bfee | ||
|
|
06b97c030b | ||
|
|
aa59790ce1 | ||
|
|
5e7a7f6b3c | ||
|
|
a8fd0ddfca | ||
|
|
cde5e45ac7 | ||
|
|
ac6140a33d | ||
|
|
9d0e273a15 | ||
|
|
ffc8123a73 | ||
|
|
3c82058c68 | ||
|
|
2f41234793 | ||
|
|
65ecea4e4a | ||
|
|
fe66501c47 | ||
|
|
57e7aa31fa | ||
|
|
9291d9699f | ||
|
|
17521f338a | ||
|
|
16d31fb85c | ||
|
|
a102361e81 | ||
|
|
e4e89101b6 | ||
|
|
1c6d46d07c | ||
|
|
c931dd5fd9 | ||
|
|
f2925791ca | ||
|
|
d8d0f65e81 | ||
|
|
21f65054a0 | ||
|
|
2cf3785e51 | ||
|
|
4c443bf843 | ||
|
|
856ec41610 | ||
|
|
60a62b11df | ||
|
|
c2930e5ec1 | ||
|
|
113805c78a | ||
|
|
abc2499e2d | ||
|
|
2861ca6d1a | ||
|
|
768f248961 | ||
|
|
932608f804 | ||
|
|
babe9f6de0 | ||
|
|
d57a16e023 | ||
|
|
4cd437d7d4 | ||
|
|
e5a365afee | ||
|
|
0e475106dc | ||
|
|
ece6c2f672 | ||
|
|
845fbf2358 | ||
|
|
7366daca91 | ||
|
|
9b04594126 | ||
|
|
8248b6fac9 | ||
|
|
b778fcd994 | ||
|
|
e3b7b2f617 | ||
|
|
58db6fd81a | ||
|
|
8f03255f71 | ||
|
|
1049bd2939 | ||
|
|
1c6193ba78 | ||
|
|
1fc50423c6 | ||
|
|
0ac8f5e556 | ||
|
|
f4b549ba8f | ||
|
|
b34c3e3ba2 | ||
|
|
2ec9fa7ea9 | ||
|
|
f94bfa7589 | ||
|
|
eecd3e9257 | ||
|
|
80d17ca944 | ||
|
|
3eb6e67bfa | ||
|
|
c11f5a3441 | ||
|
|
81986f4387 | ||
|
|
0cad7018a6 | ||
|
|
175bb58b58 | ||
|
|
4c3a13c3a1 | ||
|
|
6d0f828524 | ||
|
|
f528ba8937 | ||
|
|
2ab30dd1b8 | ||
|
|
9b9e4cd7c8 | ||
|
|
cb6640a65e | ||
|
|
d9aa750f0d | ||
|
|
5eb2bc4851 | ||
|
|
c346f5b943 | ||
|
|
1b36cfc928 | ||
|
|
cc6740176f | ||
|
|
20131db751 | ||
|
|
6be13512ff | ||
|
|
3111fccb3f | ||
|
|
8fa79e8c7e | ||
|
|
59d3e0ceb7 | ||
|
|
6dec61842d | ||
|
|
f38be8c7a8 | ||
|
|
5faeead2c6 | ||
|
|
3d9d666b02 | ||
|
|
2faf38f68f | ||
|
|
fc9efa2972 | ||
|
|
1b9fac45e1 | ||
|
|
c7821ddfe3 | ||
|
|
593dfe3193 | ||
|
|
5967236c06 | ||
|
|
4542c04046 | ||
|
|
31ddff443a | ||
|
|
6b4e2fbdf2 | ||
|
|
fee5bc9f8c | ||
|
|
9394238720 | ||
|
|
952e644016 | ||
|
|
3740052c23 | ||
|
|
4a0a45ad92 | ||
|
|
3eae87854b | ||
|
|
ff267d1ad6 | ||
|
|
14fcf4f8b3 | ||
|
|
a4433e9af4 | ||
|
|
1ed0e0a861 | ||
|
|
e8eec312a1 | ||
|
|
c3adce3ef4 | ||
|
|
fb1a34a8c5 | ||
|
|
5ec2969330 | ||
|
|
035f49c0b3 | ||
|
|
8c60ea437f | ||
|
|
de69a4a3d8 | ||
|
|
da95b907f1 | ||
|
|
51e07f1e66 | ||
|
|
ea5ca995e3 | ||
|
|
04c1dee7a2 | ||
|
|
610a76b210 | ||
|
|
b132aed217 | ||
|
|
e40d346fbb | ||
|
|
166ac4a7d3 | ||
|
|
d4aaa31549 | ||
|
|
f9fab3c3b0 | ||
|
|
06ad036da1 | ||
|
|
1f0edca631 | ||
|
|
af19e71024 | ||
|
|
f7ce35c5ee | ||
|
|
0a58c6e280 | ||
|
|
a28588a84c | ||
|
|
65156475f6 | ||
|
|
ee470f2445 | ||
|
|
b1f943cef8 | ||
|
|
6831940851 | ||
|
|
14ab33cc29 | ||
|
|
b2535d55c6 | ||
|
|
03749d5e34 | ||
|
|
92ffe6f74a | ||
|
|
f753ff6a5a | ||
|
|
ecf0b58a19 | ||
|
|
4d7e8b12ae | ||
|
|
751c638015 | ||
|
|
4ed9940e71 | ||
|
|
35435c3146 | ||
|
|
095da72020 | ||
|
|
691a49d0fa | ||
|
|
55f3b67dbb | ||
|
|
bdc8a72aae | ||
|
|
8779813837 | ||
|
|
b93539ee09 | ||
|
|
c58a2235bb | ||
|
|
0d38a66bbb | ||
|
|
2e53a2e95e | ||
|
|
6a9551ebfb | ||
|
|
44c07b9fad | ||
|
|
4d04f3f645 | ||
|
|
aaa0b156ff | ||
|
|
26e8ba27ca | ||
|
|
c407866f30 | ||
|
|
d70228c98d | ||
|
|
e8f8c0c147 | ||
|
|
f70b6d0993 | ||
|
|
a4499b482b | ||
|
|
7099068914 | ||
|
|
4c379a2848 | ||
|
|
50ec07b734 | ||
|
|
2b84aa7760 | ||
|
|
c4c165099c | ||
|
|
9e2fe92ef1 | ||
|
|
a7de33ee55 | ||
|
|
6931ae4878 | ||
|
|
a484b95d3c | ||
|
|
dedc99f036 | ||
|
|
d1fa520349 | ||
|
|
7a98691704 | ||
|
|
5aa3db15a3 | ||
|
|
601217025f | ||
|
|
0434d29ad4 | ||
|
|
70bbb06dd5 | ||
|
|
afc722d43b | ||
|
|
7f0b3144ea | ||
|
|
dd628a9829 | ||
|
|
e7d7c1dcc2 | ||
|
|
1522002b47 | ||
|
|
e5a6b1a834 | ||
|
|
19d1a563fe | ||
|
|
c7a316e445 | ||
|
|
efda16ac56 | ||
|
|
3873f50214 | ||
|
|
aee902720e | ||
|
|
bb94377f20 | ||
|
|
7dd9ea7a30 | ||
|
|
c80313ccd0 | ||
|
|
79dddef778 | ||
|
|
f2a50164b9 | ||
|
|
847a7c1644 | ||
|
|
604d1a6355 | ||
|
|
74af1b8351 | ||
|
|
ddc26afa16 | ||
|
|
87788c2360 | ||
|
|
0ee2466f23 | ||
|
|
7d2efa886d | ||
|
|
15ff70d298 | ||
|
|
4953e23ab5 | ||
|
|
7a0442a388 | ||
|
|
49c15572a9 | ||
|
|
eac3dc1963 | ||
|
|
64b8e3062f | ||
|
|
a1952f2538 | ||
|
|
14470e12c4 | ||
|
|
60a0e13b2a | ||
|
|
97ff495a9c | ||
|
|
c0a8c9dd53 | ||
|
|
8fea401d79 | ||
|
|
6321579050 | ||
|
|
746d916fce | ||
|
|
1a78eb8159 | ||
|
|
350b25c49b | ||
|
|
77bf21eef7 | ||
|
|
c4b3e32436 | ||
|
|
1e506da145 | ||
|
|
b9947a8189 | ||
|
|
5f088ef914 | ||
|
|
6c154441e2 | ||
|
|
581b1c322e | ||
|
|
4a315e47fe | ||
|
|
1b3468413d | ||
|
|
1d78ea2983 | ||
|
|
e8a65e4cff | ||
|
|
4677fe20a7 | ||
|
|
1de128de27 | ||
|
|
69b778c2ad | ||
|
|
9f72c9392e | ||
|
|
fadc115066 | ||
|
|
78b6ada743 | ||
|
|
ac69f49b55 | ||
|
|
2f293ed60a | ||
|
|
5b4a7424f0 | ||
|
|
d4309ce69a | ||
|
|
c8c1e1107e |
97
AUTHORS.txt
97
AUTHORS.txt
@@ -1,6 +1,6 @@
|
||||
OpenSceneGraph Library 1.9.9
|
||||
OpenSceneGraph Library 2.2.0
|
||||
|
||||
264 Contributors:
|
||||
281 Contributors:
|
||||
|
||||
Firstname Surname
|
||||
-----------------
|
||||
@@ -11,10 +11,11 @@ Mike Weiblen
|
||||
Eric Wing
|
||||
Brede Johansen
|
||||
Geoff Michel
|
||||
Farshid Lashkari
|
||||
Paul Martz
|
||||
Bob Kuehne
|
||||
Farshid Lashkari
|
||||
Stephan Huber
|
||||
Bob Kuehne
|
||||
Martin Lavery
|
||||
Ulrich Hertlein
|
||||
Eric Sokolowsky
|
||||
Tree
|
||||
@@ -22,25 +23,28 @@ Mike Wittman
|
||||
Luigi Calori
|
||||
Trajce Nikolov
|
||||
Pavel Moloshtan
|
||||
Martin Lavery
|
||||
Tom Jolley
|
||||
Mathias Fr<46>hlich
|
||||
Norman Vine
|
||||
David Callu
|
||||
Alberto Farre
|
||||
Roger James
|
||||
Andr<EFBFBD> Garneau
|
||||
Ruben Lopez
|
||||
Randall Hopper
|
||||
Roger James
|
||||
Olaf Flebbe
|
||||
Gideon May
|
||||
Don Tidrow
|
||||
Romano Jos<6F> Magacho da Silva
|
||||
Michael Gronager
|
||||
Daniel Sj<53>lie
|
||||
Colin McDonald
|
||||
Chris Hanson
|
||||
Daniel Sj<53>lie
|
||||
Jean-Sebastien Guay
|
||||
David Spilling
|
||||
Andy Skinner
|
||||
Per Fahlberg
|
||||
Mathias Fr<46>hlich
|
||||
Joran Jessurun
|
||||
Anr<EFBFBD> Garneau
|
||||
Frederic Marmond
|
||||
David Fries
|
||||
Boris Bralo
|
||||
@@ -48,30 +52,40 @@ Yefei He
|
||||
Sondra Iverson
|
||||
Rune Schmidt Jensen
|
||||
Neil Salter
|
||||
Mike Connell
|
||||
Jeremy Moles
|
||||
Jason Daly
|
||||
Jason Beverage
|
||||
David Spilling
|
||||
David Callu
|
||||
Ben Discoe
|
||||
Sasa Bistrovic
|
||||
Rainer Oder
|
||||
Mike Connell
|
||||
Paul Melis
|
||||
Martin Naylor
|
||||
Martin Aumueller
|
||||
Markus Trenkwalder
|
||||
Loic Dachary
|
||||
Joakim Simonsson
|
||||
Jeremy Moles
|
||||
Jan Peciva
|
||||
Jan Ciger
|
||||
Gordon Tomlinson
|
||||
Brad Colbert
|
||||
Art Tevs
|
||||
Andreas Ekstrand
|
||||
Vivek Rajan
|
||||
Stephane Simon
|
||||
Sherman Wilcox
|
||||
Sean Spicer
|
||||
Ravi Mathur
|
||||
Nikolaus Hanekamp
|
||||
Michael Platings
|
||||
Loic Dachary
|
||||
Michael Hartman
|
||||
Laurens Voerman
|
||||
Joseph Steel
|
||||
John Shue
|
||||
David Guthrie
|
||||
Corbin Holtz
|
||||
Brad Christiansen
|
||||
Adrian Egli
|
||||
Toshiyuki Takahei
|
||||
Thom DeCarlo
|
||||
Terry Welsh
|
||||
@@ -79,25 +93,24 @@ Simon Julier
|
||||
Sebastien Grignard
|
||||
Romano Magacho
|
||||
Paul de Repentigny
|
||||
Nikolaus Hanekamp
|
||||
Michael Hartman
|
||||
Mihai Radu
|
||||
Luc Frauciel
|
||||
Leandro Motta Barros
|
||||
Laurens Voerman
|
||||
Jos<EFBFBD> Delport
|
||||
Carlo Camporesi
|
||||
Bryan Thrall
|
||||
Bruce Clay
|
||||
Brad Colbert
|
||||
Brad Christiansen
|
||||
Alberto Barbati
|
||||
Vladimir Shabanov
|
||||
Uwe Woessner
|
||||
Sohey Yamamoto
|
||||
Serge Lages
|
||||
Phil Atkin
|
||||
Paul Melis
|
||||
Mattias Linde
|
||||
Mathieu Marache
|
||||
Maria Ten
|
||||
Ken Sewell
|
||||
Julian Ortiz
|
||||
John Shue
|
||||
John Kelso
|
||||
Jeremy Bell
|
||||
James French
|
||||
@@ -106,20 +119,23 @@ Donn Mielcarek
|
||||
Domenico Mangieri
|
||||
Daniel Larimer
|
||||
Charles Cole
|
||||
Bryan Thrall
|
||||
Andre Garneau
|
||||
Blake Williams
|
||||
Antoine Hue
|
||||
Anders Backman
|
||||
Ali Botorabi
|
||||
Zach Deedler
|
||||
Yuzhong Shen
|
||||
Tugkan Calapoglu
|
||||
Tony Horrobin
|
||||
Tim Daoust
|
||||
Thibault Genessay
|
||||
Terrex
|
||||
Steve Lunsford
|
||||
Stephan Eilemann
|
||||
Stanislav Blinov
|
||||
Roland Smeenk
|
||||
Riccardo Corsi
|
||||
Rafa Giatan
|
||||
Philip Lowman
|
||||
Peter Hrenka
|
||||
Perry Miller
|
||||
@@ -131,12 +147,9 @@ Mathew May
|
||||
Martijn Kragtwijk
|
||||
Kevin Moiule
|
||||
Keith Steffen
|
||||
Jos<EFBFBD> Delport
|
||||
Joseph Winston
|
||||
John Aughey
|
||||
Johan Nouvel
|
||||
Jean-Sebastien Guay
|
||||
Jan Ciger
|
||||
Igor Kravtchenko
|
||||
Gerrick Bivins
|
||||
George Tarantilis
|
||||
@@ -145,13 +158,11 @@ Fabio Mierlo
|
||||
Edgar Ellis
|
||||
David Ergo
|
||||
Daniel Trstenjak
|
||||
Blake Williams
|
||||
Antoine Hue
|
||||
Andy Skinner
|
||||
Csaba Halasz
|
||||
Andrew Sampson
|
||||
Andrew Lorino
|
||||
Andreas Goebel
|
||||
Anders Backman
|
||||
Alberto Luaces
|
||||
Zbigniew Sroczynski
|
||||
Yuri Vilmanis
|
||||
Wojciech Lewandowski
|
||||
@@ -167,30 +178,32 @@ Vaclav Bilek
|
||||
Tyge
|
||||
Troy Yee
|
||||
Tino Schwarze
|
||||
Tim Moore
|
||||
Thom Carlo
|
||||
Tery Welsh
|
||||
Tanguy Fautr<74>
|
||||
Sylvan Marie
|
||||
Sylvain Marie
|
||||
Sherman Wilcox
|
||||
Shane Arnott
|
||||
Sebastien Kuntz
|
||||
Rudolf Wiedemann
|
||||
Ronny Krueger
|
||||
Robert Swain
|
||||
Rick Pingry
|
||||
Reinhard Sainitzer
|
||||
Rein Kadijk
|
||||
Rafa Giatan
|
||||
Radu Mihai
|
||||
Ralf Kern
|
||||
Qing Shen
|
||||
Philipp Siemoleit
|
||||
Paul Fredrikson
|
||||
Parag Chaudhur
|
||||
Orhun Birsoy
|
||||
Ole-Morten Duesund
|
||||
Nicolas Brodu
|
||||
Nathan Cournia
|
||||
Morné Pistorius
|
||||
Morn<EFBFBD> Pistorius
|
||||
Mirko Viviani
|
||||
Mikkel Gjøl
|
||||
Mihai Radu
|
||||
Michael Polak
|
||||
Michael Morrison
|
||||
Michael Logan
|
||||
@@ -199,13 +212,12 @@ Mauricio Hofmam
|
||||
Matthew May
|
||||
Matt Green
|
||||
Matt Burke
|
||||
Mathias Froelich
|
||||
Mathia Walker
|
||||
Mason Menninger
|
||||
Martin Spott
|
||||
Martin Amueller
|
||||
Mario Valle
|
||||
Marin Lavery
|
||||
Maria Ten
|
||||
Louis Hamilton
|
||||
Lewis Harmon
|
||||
Kristopher Bixler
|
||||
@@ -220,16 +232,16 @@ Joakim Simmonsson
|
||||
Jay Zuckerman
|
||||
Jason Howlett
|
||||
Jason Ballenger
|
||||
Jan Peciva
|
||||
J.E. Hoffmann
|
||||
Henrique Bucher
|
||||
Gustavo Wagner
|
||||
Guillaume Millet
|
||||
Graeme Harkness
|
||||
Glenn Waldrom
|
||||
Gian Lorenzetto
|
||||
George Papagiannakis
|
||||
Gary Quinn
|
||||
Frauciel Luc
|
||||
Galen Faidley
|
||||
Frashid Lashkari
|
||||
Frank Warmerdam
|
||||
Frank Lindeman
|
||||
@@ -248,23 +260,28 @@ Donny Cipperly
|
||||
Dean Iverson
|
||||
David Jung
|
||||
David Gurhrie
|
||||
Dan Minor
|
||||
Clay Fowler
|
||||
Chuck Sembroski
|
||||
Chuck Seberion
|
||||
Chris McGlone
|
||||
Carlos Garcea
|
||||
Bruno Herbelin
|
||||
Brian Keener
|
||||
Brandon Hamm
|
||||
Brad Anderegg
|
||||
Bora Utka
|
||||
Blasius Czink
|
||||
Ben van Basten
|
||||
Bart Gallet
|
||||
Axel Volley
|
||||
Andrew Reyonolds
|
||||
Andreas Jochens
|
||||
Almalric Alexandre
|
||||
Allen Bierbaum
|
||||
Alexandre Amalric
|
||||
Alberto Jaspe
|
||||
Alan Purvis
|
||||
Alan Ott
|
||||
Alan Harris
|
||||
Adrian Egli
|
||||
Adam Richard
|
||||
|
||||
104
CMakeLists.txt
104
CMakeLists.txt
@@ -15,14 +15,25 @@ ENDIF(WIN32)
|
||||
PROJECT(OpenSceneGraph)
|
||||
|
||||
SET(OPENSCENEGRAPH_MAJOR_VERSION 2)
|
||||
SET(OPENSCENEGRAPH_MINOR_VERSION 0)
|
||||
SET(OPENSCENEGRAPH_MINOR_VERSION 2)
|
||||
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
|
||||
SET(OPENSCENEGRAPH_SOVERSION 11)
|
||||
SET(OPENSCENEGRAPH_SOVERSION 25)
|
||||
|
||||
SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION})
|
||||
|
||||
SET(OSG_PLUGINS osgPlugins-${OPENSCENEGRAPH_VERSION})
|
||||
|
||||
SET(OSG_PLUGIN_PREFIX "")
|
||||
|
||||
IF (CYGWIN)
|
||||
SET(OSG_PLUGIN_PREFIX "cygwin_")
|
||||
ENDIF(CYGWIN)
|
||||
|
||||
IF(MINGW)
|
||||
SET(OSG_PLUGIN_PREFIX "mingw_")
|
||||
ENDIF(MINGW)
|
||||
|
||||
|
||||
# We want to build SONAMES shared librariess
|
||||
SET(OPENSCENEGRAPH_SONAMES TRUE)
|
||||
SET(OPENTHREADS_SONAMES TRUE)
|
||||
@@ -87,14 +98,64 @@ INCLUDE_DIRECTORIES(
|
||||
#ADD_DEFINITIONS(-D)
|
||||
# Platform specific definitions
|
||||
|
||||
IF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
|
||||
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT OFF)
|
||||
|
||||
IF (CMAKE_SYSTEM MATCHES "AIX.*")
|
||||
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON)
|
||||
ENDIF(CMAKE_SYSTEM MATCHES "AIX.*")
|
||||
|
||||
IF (APPLE)
|
||||
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON)
|
||||
ENDIF(APPLE)
|
||||
|
||||
ENDIF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
|
||||
OPTION(OSG_GLU_TESS_CALLBACK_TRIPLEDOT "Set to ON to build build with (...) version of GLU tesselator callback" ${DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT})
|
||||
|
||||
IF (OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
ADD_DEFINITIONS(-DGLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
ENDIF(OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
|
||||
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
#needed for net plugin
|
||||
SET (OSG_SOCKET_LIBS wsock32.lib)
|
||||
SET (OSG_SOCKET_LIBS wsock32)
|
||||
# Both Cygwin and Msys need -DNOMINMAX ???
|
||||
IF(UNIX)
|
||||
ADD_DEFINITIONS(-DNOMINMAX)
|
||||
ENDIF(UNIX)
|
||||
########################################################################################################
|
||||
# the foolowing options are MSVC specific,
|
||||
# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
|
||||
# fron bin folder without requiring installation step.
|
||||
# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
|
||||
# it also use a hack to get rid of Debug and Release folder in MSVC projects
|
||||
# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
|
||||
#
|
||||
# the second option disable incremental linking in debug build , that is enabled by default by CMake
|
||||
##########################################################################################################
|
||||
|
||||
IF(MSVC)
|
||||
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
MESSAGE("Warning: disabling versioned options 2.4.6 exibits inconsintencies in .pdb naming, at least under MSVC, suggested upgrading at least to 2.4.7")
|
||||
SET(OSG_MSVC_VERSIONED_DLL OFF)
|
||||
SET(OSG_MSVC_DEBUG_INCREMENTAL_LINK ON)
|
||||
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
OPTION(OSG_MSVC_VERSIONED_DLL "Set to ON to build OpenSceneGraph with versioned dll names" ON)
|
||||
MARK_AS_ADVANCED(OSG_MSVC_VERSIONED_DLL)
|
||||
OPTION(OSG_MSVC_DEBUG_INCREMENTAL_LINK "Set to OFF to build OpenSceneGraph without incremental linking in debug (release is off by default)" ON)
|
||||
MARK_AS_ADVANCED(OSG_MSVC_DEBUG_INCREMENTAL_LINK)
|
||||
IF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
|
||||
ENDIF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
|
||||
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
ENDIF(MSVC)
|
||||
ENDIF(WIN32)
|
||||
|
||||
########################################################################################################
|
||||
@@ -140,6 +201,7 @@ FIND_PACKAGE(FreeType)
|
||||
FIND_PACKAGE(FLTK)
|
||||
FIND_PACKAGE(GLUT)
|
||||
FIND_PACKAGE(SDL)
|
||||
FIND_PACKAGE(FOX)
|
||||
FIND_PACKAGE(Inventor)
|
||||
FIND_PACKAGE(Jasper)
|
||||
FIND_PACKAGE(COLLADA)
|
||||
@@ -147,15 +209,33 @@ FIND_PACKAGE(Xine)
|
||||
FIND_PACKAGE(OpenVRML)
|
||||
FIND_PACKAGE(Performer)
|
||||
FIND_PACKAGE(ZLIB)
|
||||
|
||||
# SET(DESIRED_QT_VERSION 3)
|
||||
# FIND_PACKAGE(Qt)
|
||||
FIND_PACKAGE(Qt3)
|
||||
FIND_PACKAGE(Qt4)
|
||||
FIND_PACKAGE(GDAL)
|
||||
|
||||
SET(wxWidgets_USE_LIBS base core gl net)
|
||||
FIND_PACKAGE(wxWidgets)
|
||||
|
||||
# To select a specific version of QT define DESIRED_QT_VERSION
|
||||
# via cmake -DDESIRED_QT_VERSION=4
|
||||
IF (DESIRED_QT_VERSION)
|
||||
|
||||
IF (DESIRED_QT_VERSION MATCHES 4)
|
||||
FIND_PACKAGE(Qt4)
|
||||
ELSE(DESIRED_QT_VERSION MATCHES 4)
|
||||
FIND_PACKAGE(Qt3)
|
||||
ENDIF(DESIRED_QT_VERSION MATCHES 4)
|
||||
|
||||
ELSE(DESIRED_QT_VERSION)
|
||||
|
||||
FIND_PACKAGE(Qt4)
|
||||
|
||||
IF (NOT QT4_FOUND)
|
||||
FIND_PACKAGE(Qt3)
|
||||
ENDIF(NOT QT4_FOUND)
|
||||
|
||||
ENDIF(DESIRED_QT_VERSION)
|
||||
|
||||
|
||||
|
||||
# Platform specific:
|
||||
# (We can approach this one of two ways. We can try to FIND everything
|
||||
# and simply check if we found the packages before actually building
|
||||
@@ -216,7 +296,9 @@ SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
|
||||
#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
|
||||
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
|
||||
MAKE_DIRECTORY(${OUTPUT_LIBDIR})
|
||||
MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
|
||||
IF(NOT MSVC)
|
||||
MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
|
||||
ENDIF(NOT MSVC)
|
||||
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
|
||||
|
||||
|
||||
@@ -289,13 +371,15 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# errors instead of warnings for certain issues, including superfluous
|
||||
# semicolons and commas, and the use of long long. -fpermissive seems
|
||||
# to be the workaround.
|
||||
SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wnewline-eof -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive")
|
||||
SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive")
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
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
|
||||
SET(OSG_AGGRESSIVE_WARNING_FLAGS "/Wall /W4")
|
||||
|
||||
|
||||
ELSE(MSVC)
|
||||
# CMake lacks an elseif, so other non-gcc, non-VS compilers need
|
||||
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
|
||||
|
||||
@@ -52,7 +52,7 @@ ENDMACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGS
|
||||
|
||||
MACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
|
||||
FIND_DEPENDENCY(TIFF tiff.h libtiff ${OSG_3RDPARTY_BIN} "D")
|
||||
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype219;freetype234MT" ${OSG_3RDPARTY_BIN} "_D")
|
||||
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype219;freetype234;freetype234MT" ${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 "")
|
||||
|
||||
74
CMakeModules/FindFOX.cmake
Normal file
74
CMakeModules/FindFOX.cmake
Normal file
@@ -0,0 +1,74 @@
|
||||
# Locate gdal
|
||||
# This module defines
|
||||
# FOX_LIBRARY
|
||||
# FOX_FOUND, if false, do not try to link to gdal
|
||||
# FOX_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# $FOX_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$FOX_DIR
|
||||
#
|
||||
# Created by Robert Osfield.
|
||||
|
||||
FIND_PATH(FOX_INCLUDE_DIR fx.h
|
||||
$ENV{FOX_DIR}/include/fox-1.6
|
||||
$ENV{FOX_DIR}/fox-1.6
|
||||
$ENV{OSGDIR}/include/fox-1.6
|
||||
$ENV{OSGDIR}/fox-1.6
|
||||
$ENV{OSG_ROOT}/include/fox-1.6
|
||||
~/Library/Frameworks/fox-1.6
|
||||
/Library/Frameworks/fox-1.6
|
||||
/usr/local/include/fox-1.6
|
||||
/usr/include/fox-1.6
|
||||
/sw/include/fox-1.6 # Fink
|
||||
/opt/local/include/fox-1.6 # DarwinPorts
|
||||
/opt/csw/include/fox-1.6 # Blastwave
|
||||
/opt/include/fox-1.6
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include/fox-1.6
|
||||
/usr/freeware/include/fox-1.6
|
||||
$ENV{FOX_DIR}/include
|
||||
$ENV{FOX_DIR}
|
||||
$ENV{OSGDIR}/include
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/include
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/sw/include # Fink
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include # Blastwave
|
||||
/opt/include
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
|
||||
/usr/freeware/include
|
||||
)
|
||||
|
||||
MACRO(FIND_FOX_LIBRARY MYLIBRARY MYLIBRARYNAME)
|
||||
|
||||
FIND_LIBRARY(${MYLIBRARY}
|
||||
NAMES ${MYLIBRARYNAME}
|
||||
PATHS
|
||||
$ENV{FOX_DIR}/lib
|
||||
$ENV{FOX_DIR}
|
||||
$ENV{OSGDIR}/lib
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
ENDMACRO(FIND_FOX_LIBRARY LIBRARY LIBRARYNAME)
|
||||
|
||||
FIND_FOX_LIBRARY(FOX_LIBRARY FOX-1.6)
|
||||
|
||||
SET(FOX_FOUND "NO")
|
||||
IF(FOX_LIBRARY AND FOX_INCLUDE_DIR)
|
||||
SET(FOX_FOUND "YES")
|
||||
ENDIF(FOX_LIBRARY AND FOX_INCLUDE_DIR)
|
||||
58
CMakeModules/FindGDAL.cmake
Normal file
58
CMakeModules/FindGDAL.cmake
Normal file
@@ -0,0 +1,58 @@
|
||||
# Locate gdal
|
||||
# This module defines
|
||||
# GDAL_LIBRARY
|
||||
# GDAL_FOUND, if false, do not try to link to gdal
|
||||
# GDAL_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# $GDAL_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$GDAL_DIR
|
||||
#
|
||||
# Created by Robert Osfield.
|
||||
|
||||
FIND_PATH(GDAL_INCLUDE_DIR gdal.h
|
||||
${GDAL_DIR}/include
|
||||
$ENV{GDAL_DIR}/include
|
||||
$ENV{GDAL_DIR}
|
||||
$ENV{OSGDIR}/include
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/include
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/usr/include/gdal
|
||||
/sw/include # Fink
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include # Blastwave
|
||||
/opt/include
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
|
||||
/usr/freeware/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(GDAL_LIBRARY
|
||||
NAMES gdal gdal_i gdal1.4.0 gdal1.3.2
|
||||
PATHS
|
||||
${GDAL_DIR}/lib
|
||||
$ENV{GDAL_DIR}/lib
|
||||
$ENV{GDAL_DIR}
|
||||
$ENV{OSGDIR}/lib
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
SET(GDAL_FOUND "NO")
|
||||
IF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR)
|
||||
SET(GDAL_FOUND "YES")
|
||||
ENDIF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR)
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# - Locate Inventor
|
||||
# This module defines:
|
||||
# INVENTOR_FOUND, if false, do not try to link against Inventor.
|
||||
# INVENTOR_LIBRARY, the library to link against.
|
||||
# INVENTOR_INCLUDE_DIR, where to find headers.
|
||||
# INVENTOR_LIBRARY, the library to link against.
|
||||
# INVENTOR_LIBRARY_DEBUG, the debug library to link against.
|
||||
|
||||
FIND_PATH(INVENTOR_INCLUDE_DIR Inventor/So.h
|
||||
/usr/local/include
|
||||
@@ -11,10 +12,11 @@ FIND_PATH(INVENTOR_INCLUDE_DIR Inventor/So.h
|
||||
/opt/local/include
|
||||
/opt/csw/include
|
||||
/opt/include
|
||||
$ENV{COINDIR}/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(INVENTOR_LIBRARY
|
||||
NAMES Coin
|
||||
NAMES coin2 Coin
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
@@ -22,6 +24,7 @@ FIND_LIBRARY(INVENTOR_LIBRARY
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
$ENV{COINDIR}/lib
|
||||
)
|
||||
IF(NOT INVENTOR_LIBRARY)
|
||||
# If we can't find libCoin try libInventor
|
||||
@@ -37,6 +40,23 @@ IF(NOT INVENTOR_LIBRARY)
|
||||
)
|
||||
ENDIF(NOT INVENTOR_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(INVENTOR_LIBRARY_DEBUG
|
||||
NAMES coin2d
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
$ENV{COINDIR}/lib
|
||||
)
|
||||
IF(NOT INVENTOR_LIBRARY_DEBUG)
|
||||
IF(INVENTOR_LIBRARY)
|
||||
SET(INVENTOR_LIBRARY_DEBUG INVENTOR_LIBRARY)
|
||||
ENDIF(INVENTOR_LIBRARY)
|
||||
ENDIF(NOT INVENTOR_LIBRARY_DEBUG)
|
||||
|
||||
SET(INVENTOR_FOUND "NO")
|
||||
IF(INVENTOR_INCLUDE_DIR AND INVENTOR_LIBRARY)
|
||||
SET(INVENTOR_FOUND "YES")
|
||||
|
||||
65
CMakeModules/FindOSG.cmake
Normal file
65
CMakeModules/FindOSG.cmake
Normal file
@@ -0,0 +1,65 @@
|
||||
# Locate gdal
|
||||
# This module defines
|
||||
# OSG_LIBRARY
|
||||
# OSG_FOUND, if false, do not try to link to gdal
|
||||
# OSG_INCLUDE_DIR, where to find the headers
|
||||
#
|
||||
# $OSG_DIR is an environment variable that would
|
||||
# correspond to the ./configure --prefix=$OSG_DIR
|
||||
#
|
||||
# Created by Robert Osfield.
|
||||
|
||||
FIND_PATH(OSG_INCLUDE_DIR osg/Node
|
||||
$ENV{OSG_DIR}/include
|
||||
$ENV{OSG_DIR}
|
||||
$ENV{OSGDIR}/include
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/include
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/sw/include # Fink
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include # Blastwave
|
||||
/opt/include
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
|
||||
/usr/freeware/include
|
||||
)
|
||||
|
||||
MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
|
||||
|
||||
FIND_LIBRARY(${MYLIBRARY}
|
||||
NAMES ${MYLIBRARYNAME}
|
||||
PATHS
|
||||
$ENV{OSG_DIR}/lib
|
||||
$ENV{OSG_DIR}
|
||||
$ENV{OSGDIR}/lib
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
ENDMACRO(FIND_OSG_LIBRARY LIBRARY LIBRARYNAME)
|
||||
|
||||
FIND_OSG_LIBRARY(OSG_LIBRARY osg)
|
||||
FIND_OSG_LIBRARY(OSGUTIL_LIBRARY osgUtil)
|
||||
FIND_OSG_LIBRARY(OSGDB_LIBRARY osgDB)
|
||||
FIND_OSG_LIBRARY(OSGTEXT_LIBRARY osgText)
|
||||
FIND_OSG_LIBRARY(OSGTERRAIN_LIBRARY osgTerrain)
|
||||
FIND_OSG_LIBRARY(OSGFX_LIBRARY osgFX)
|
||||
FIND_OSG_LIBRARY(OSGVIEWER_LIBRARY osgViewer)
|
||||
|
||||
SET(OSG_FOUND "NO")
|
||||
IF(OSG_LIBRARY AND OSG_INCLUDE_DIR)
|
||||
SET(OSG_FOUND "YES")
|
||||
ENDIF(OSG_LIBRARY AND OSG_INCLUDE_DIR)
|
||||
@@ -8,6 +8,7 @@
|
||||
# correspond to the ./configure --prefix=$OPENVRML_DIR
|
||||
#
|
||||
# Created by Robert Osfield.
|
||||
# Modified for the debug library by Jean-S<>bastien Guay.
|
||||
|
||||
FIND_PATH(OPENVRML_INCLUDE_DIR openvrml/openvrml/common.h
|
||||
$ENV{OPENVRML_DIR}/include
|
||||
@@ -47,6 +48,26 @@ FIND_LIBRARY(OPENVRML_LIBRARY
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
FIND_LIBRARY(OPENVRML_LIBRARY_DEBUG
|
||||
NAMES openvrmld
|
||||
PATHS
|
||||
$ENV{OPENVRML_DIR}/lib
|
||||
$ENV{OPENVRML_DIR}
|
||||
$ENV{OSGDIR}/lib
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
SET(OPENVRML_FOUND "NO")
|
||||
IF(OPENVRML_LIBRARY AND OPENVRML_INCLUDE_DIR)
|
||||
SET(OPENVRML_FOUND "YES")
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
# Created by Robert Osfield.
|
||||
|
||||
FIND_PATH(PERFORMER_INCLUDE_DIR Performer/pfdu.h
|
||||
$ENV{PFROOT}/include
|
||||
$ENV{PFROOT}
|
||||
$ENV{PERFORMER_DIR}/include
|
||||
$ENV{PERFORMER_DIR}
|
||||
$ENV{OSGDIR}/include
|
||||
@@ -27,25 +29,51 @@ FIND_PATH(PERFORMER_INCLUDE_DIR Performer/pfdu.h
|
||||
/usr/freeware/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(PERFORMER_LIBRARY
|
||||
NAMES pf
|
||||
PATHS
|
||||
$ENV{PERFORMER_DIR}/lib
|
||||
$ENV{PERFORMER_DIR}
|
||||
$ENV{OSGDIR}/lib
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
IF(MSVC)
|
||||
FIND_LIBRARY(PERFORMER_LIBRARY
|
||||
NAMES libpf
|
||||
PATHS
|
||||
$ENV{PFROOT}/lib
|
||||
$ENV{PFROOT}
|
||||
$ENV{PERFORMER_DIR}/lib
|
||||
$ENV{PERFORMER_DIR}
|
||||
$ENV{OSGDIR}/lib
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
ELSE(MSVC)
|
||||
FIND_LIBRARY(PERFORMER_LIBRARY
|
||||
NAMES pf
|
||||
PATHS
|
||||
$ENV{PFROOT}/lib
|
||||
$ENV{PFROOT}
|
||||
$ENV{PERFORMER_DIR}/lib
|
||||
$ENV{PERFORMER_DIR}
|
||||
$ENV{OSGDIR}/lib
|
||||
$ENV{OSGDIR}
|
||||
$ENV{OSG_ROOT}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
ENDIF(MSVC)
|
||||
|
||||
SET(PERFORMER_FOUND "NO")
|
||||
IF(PERFORMER_LIBRARY AND PERFORMER_INCLUDE_DIR)
|
||||
|
||||
@@ -21,6 +21,9 @@ SOURCE_GROUP(
|
||||
FILES ${LIB_PUBLIC_HEADERS}
|
||||
)
|
||||
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
HANDLE_MSVC_DLL()
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
INSTALL(
|
||||
TARGETS ${LIB_NAME}
|
||||
|
||||
@@ -22,7 +22,17 @@ ENDMACRO(LINK_WITH_VARIABLES TRGTNAME)
|
||||
|
||||
MACRO(LINK_INTERNAL TRGTNAME)
|
||||
FOREACH(LINKLIB ${ARGN})
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
#when using versioned names, the .dll name differ from .lib name, there is a problem with that:
|
||||
#CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX for computing linkage info to use into projects,
|
||||
# so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies
|
||||
#to library targets used
|
||||
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
|
||||
ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
ENDFOREACH(LINKLIB)
|
||||
ENDMACRO(LINK_INTERNAL TRGTNAME)
|
||||
|
||||
@@ -82,16 +92,21 @@ MACRO(SETUP_LINK_LIBRARIES)
|
||||
ENDIF(TO_INSERT)
|
||||
ENDFOREACH(LINKLIB)
|
||||
|
||||
FOREACH(LINKLIB ${TARGET_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ENDFOREACH(LINKLIB)
|
||||
|
||||
# FOREACH(LINKLIB ${TARGET_LIBRARIES})
|
||||
# TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
# ENDFOREACH(LINKLIB)
|
||||
LINK_INTERNAL(${TARGET_TARGETNAME} ${TARGET_LIBRARIES})
|
||||
FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${LINKLIB})
|
||||
ENDFOREACH(LINKLIB)
|
||||
IF(TARGET_LIBRARIES_VARS)
|
||||
LINK_WITH_VARIABLES(${TARGET_TARGETNAME} ${TARGET_LIBRARIES_VARS})
|
||||
ENDIF(TARGET_LIBRARIES_VARS)
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
#when using full path name to specify linkage, it seems that already linked libs must be specified
|
||||
LINK_EXTERNAL(${TARGET_TARGETNAME} ${OPENGL_LIBRARIES})
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
ENDMACRO(SETUP_LINK_LIBRARIES)
|
||||
|
||||
############################################################################################
|
||||
@@ -121,9 +136,28 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
|
||||
ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H})
|
||||
ENDIF(DYNAMIC_OPENSCENEGRAPH)
|
||||
|
||||
#not sure if needed, but for plugins only msvc need the d suffix
|
||||
#not sure if needed, but for plugins only Msvc need the d suffix
|
||||
IF(NOT MSVC)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
|
||||
ELSE(NOT MSVC)
|
||||
IF(OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
|
||||
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
|
||||
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
|
||||
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
|
||||
#changing bin to something else breaks this hack
|
||||
#the dll are placed in bin/${OSG_PLUGINS}
|
||||
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/")
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES IMPORT_PREFIX "../")
|
||||
ELSE(OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
#in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
|
||||
#here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
|
||||
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
|
||||
ENDIF(OSG_MSVC_VERSIONED_DLL)
|
||||
ENDIF(NOT MSVC)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
|
||||
|
||||
@@ -131,7 +165,7 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
|
||||
|
||||
#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
|
||||
IF(WIN32)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION bin )
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib/${OSG_PLUGINS} LIBRARY DESTINATION bin/${OSG_PLUGINS} )
|
||||
ELSE(WIN32)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} )
|
||||
ENDIF(WIN32)
|
||||
@@ -189,7 +223,9 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})
|
||||
|
||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../")
|
||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||
SETUP_LINK_LIBRARIES()
|
||||
|
||||
ENDMACRO(SETUP_EXE)
|
||||
@@ -240,3 +276,33 @@ MACRO(SETUP_COMMANDLINE_EXAMPLE EXAMPLE_NAME)
|
||||
SETUP_EXAMPLE(${EXAMPLE_NAME} 1)
|
||||
|
||||
ENDMACRO(SETUP_COMMANDLINE_EXAMPLE)
|
||||
|
||||
# Takes two optional arguments -- osg prefix and osg version
|
||||
MACRO(HANDLE_MSVC_DLL)
|
||||
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
|
||||
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
|
||||
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
|
||||
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
|
||||
#changing bin to something else breaks this hack
|
||||
#the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
|
||||
|
||||
# LIB_PREFIX: use "osg" by default, else whatever we've been given.
|
||||
IF(${ARGC} GREATER 0)
|
||||
SET(LIB_PREFIX ${ARGV0})
|
||||
ELSE(${ARGC} GREATER 0)
|
||||
SET(LIB_PREFIX osg)
|
||||
ENDIF(${ARGC} GREATER 0)
|
||||
|
||||
# LIB_SOVERSION: use OSG's soversion by default, else whatever we've been given
|
||||
IF(${ARGC} GREATER 1)
|
||||
SET(LIB_SOVERSION ${ARGV1})
|
||||
ELSE(${ARGC} GREATER 1)
|
||||
SET(LIB_SOVERSION ${OPENSCENEGRAPH_SOVERSION})
|
||||
ENDIF(${ARGC} GREATER 1)
|
||||
|
||||
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-")
|
||||
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
|
||||
|
||||
# SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-")
|
||||
# SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
|
||||
ENDMACRO(HANDLE_MSVC_DLL)
|
||||
|
||||
58
NEWS.txt
58
NEWS.txt
@@ -1,6 +1,62 @@
|
||||
OSG News
|
||||
========
|
||||
|
||||
= OpenSceneGraph 2.2 release adds support for advanced displays, soft and parallel split shadow maps and easier builds =
|
||||
|
||||
PERTHSHIRE, Scotland - 4th October 2007 - !OpenSceneGraph Professional Services announces the release of !OpenSceneGraph 2.2, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. !OpenSceneGraph 2.2 written entirely in Standard C++ and built upon OpenGL, offers developers working in the visual simulation, game development, virtual reality, scientific visualization and modeling markets - a real-time visualization tool which eclipses commercial scene graph toolkits in functionality, stability and performance. !OpenSceneGraph 2.2 runs on all Microsoft Windows platforms, Apple OS/X, GNU/Linux, IRIX, Solaris, HP-UX, AIX and !FreeBSD operating systems.
|
||||
|
||||
=== Open-source development delivers industry-leading features and performance ===
|
||||
The !OpenSceneGraph 2.2 release is the culmination of 8 years of work by the lead developers and the open-source community that has grown up around the project. The real-time graphics industry and academia embraced it from the very beginning, deploying it in real-world applications, and actively participating in its development, testing and refinement. The end result is a high-quality library with a feature set relevant to application developers' needs.
|
||||
|
||||
=== Updates include: ===
|
||||
|
||||
* Improved build support under Windows including versioning of dll's to avoid problems with mixing !OpenSceneGraph versions on a single system.
|
||||
* Support for Texture2DArray and integer texture OpenGL extensions.
|
||||
* Support for spherical displays.
|
||||
* Support for checkerboard stereo displays.
|
||||
* Soft Shadows and Parallel Split Shadow Maps now supported.
|
||||
* Viewer configuration file support
|
||||
* Writer support for Inventor, OBJ 3D formats
|
||||
* Writer support for HDR imagery
|
||||
* Viewer Configuration file support
|
||||
* Unification of threading models and viewer event handlers so that all now work for both Viewer and !CompositeViewer classes.
|
||||
* GDAL plugin for support for a wide range of geospatial imagery and digital elevation maps formats.
|
||||
* A wide range of build and bug fixes.
|
||||
|
||||
=== Downloads and Licensing ===
|
||||
!OpenSceneGraph is open-source so full source code is provided, and can be copied, modified and used free of charge for commercial and non-commercial use. Access to the source allows end users greater flexibility in how they develop, debug and deploy their applications. They gain productivity and freedom by being able to leverage the tool chain in accordance with their own release cycles. Downloads of binaries and source can be found in the [http://www.openscenegraph.org/projects/osg/wiki/Downloads Downloads] section of the openscenegraph.org website. [Downloads Downloads]
|
||||
|
||||
!OpenSceneGraph is released under the [http://www.openscenegraph.org/projects/osg/wiki/Legal OpenSceneGraph Public License], which is based on the Lesser GNU Public License (LGPL), permitting the software to be used free of charge across the full spectrum of commercial and open-source applications. Furthermore, it allows both static and dynamic linking of the !OpenSceneGraph libraries without restricting the licensing of the user's software.
|
||||
|
||||
=== !OpenSceneGraph Books now available ===
|
||||
|
||||
The !OpenSceneGraph Quick Start Guide is now available in Chinese as well as English, and alongside the Reference Manual books can be found at [http://www.osgbooks.com OsgBooks].
|
||||
|
||||
=== Professional support and services ===
|
||||
!OpenSceneGraph project is backed up with professional services by [http://openscenegraph.com OpenSceneGraph Professional Services], based in Scotland, and [http://www.skew-matrix.com Skew-Matrix] and [http://www.blue-newt.com Blue-Newt Software] both based in the USA.
|
||||
|
||||
* Confidential Professional Support
|
||||
* Bespoke development
|
||||
* Consultancy
|
||||
* Training
|
||||
|
||||
=== Community support and contributions ===
|
||||
The diverse and growing community of over 1700 developers is centered around the public osg-users mailing list, where members discuss how best to use !OpenSceneGraph, provide mutual support, and coordinate development of new features and bug fixes. Members of this community come from many different countries with backgrounds ranging from some of the world's largest aerospace companies, game companies, and visual simulation specialists to university researchers, students and hobbyists.
|
||||
|
||||
The !OpenSceneGraph project owes a great deal to the community for its development and support, in particular we wish to thank the [http://www.openscenegraph.org/projects/osg/wiki/Support/Contributors/TwoPointTwo 282 individuals] from around the world that have directly contributed to the development and refinement of the !OpenSceneGraph code base.
|
||||
|
||||
----
|
||||
|
||||
About !OpenSceneGraph:[[BR]]
|
||||
!OpenSceneGraph Project was founded in September 1999 by Don Burns and Robert Osfield.
|
||||
Further information, screenshots, downloads, documentation, and support links can be found on the !OpenSceneGraph project website http://www.openscenegraph.org.
|
||||
|
||||
About !OpenSceneGraph Professional Services:[[BR]]
|
||||
!OpenSceneGraph Professional Services, founded by project lead Robert Osfield in April 2001, is based in Callander, Perhshire, Scotland, and provides professional services on top of !OpenSceneGraph. Further information about the services it provides can be found at http://www.openscenegraph.com.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
!!![=OpenSceneGraph=] 2.0 release improves ease-of-use and scalability, introducing new osgViewer, osgShadow and osgManipulator libraries, new build system, improved multi-core, multi-GPU support.
|
||||
|
||||
@@ -57,6 +113,8 @@ The [=OpenSceneGraph=] project owes a great deal to the community for its develo
|
||||
Robert Osfield\\
|
||||
Project Lead and Proprietor [=OpenSceneGraph=] Professional Services
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
!!![=OpenSceneGraph=] 1.2 release introduces Windows 64bit and AIX support, COLLADA support, processor affinity and texture atlas builder.
|
||||
|
||||
|
||||
32
README.txt
32
README.txt
@@ -10,7 +10,7 @@ For the impatient, read the simplified build notes below.
|
||||
|
||||
Robert Osfield.
|
||||
Project Lead.
|
||||
15th June 2007.
|
||||
3rd October 2007.
|
||||
|
||||
--
|
||||
|
||||
@@ -24,7 +24,10 @@ 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.
|
||||
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
|
||||
@@ -32,10 +35,10 @@ 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
|
||||
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
|
||||
@@ -44,22 +47,23 @@ 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
|
||||
cd build
|
||||
cmake ../OpenSceneGraph -DCMAKE_BUILD_TYPE=Release
|
||||
make
|
||||
sudo make install
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../OpenSceneGraph -DCMAKE_BUILD_TYPE=Release
|
||||
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
|
||||
system should help guide you through the process:
|
||||
|
||||
http://www.openscenegraph.com/index.php?page=Build.CMake
|
||||
http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio
|
||||
|
||||
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.
|
||||
|
||||
For further details on compilation, installation and platform-specific
|
||||
information read "Getting Started" at http://www.openscenegraph.org,
|
||||
under "Documentation".
|
||||
information read "Getting Started" guide:
|
||||
|
||||
http://www.openscenegraph.org/projects/osg/wiki/Support/GettingStarted
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# script. This just copies all the already built binaries
|
||||
# into a structure that is near-ready for distribution.
|
||||
#
|
||||
# Usage: You should run this from the directory above the 3-projects
|
||||
# Usage: You should run this from the directory above the OSG-projects
|
||||
# ("AnyDirectory" in the picture below)
|
||||
# bash OpenSceneGraph/Xcode/Misc/ArrangeDMG.sh
|
||||
#
|
||||
@@ -40,12 +40,14 @@
|
||||
# CpMac is deprecated now that cp works properly in Tiger
|
||||
#COPY="/Developer/Tools/CpMac -r"
|
||||
COPY="/bin/cp -R"
|
||||
SVN="svn"
|
||||
#COPY="mv -f"
|
||||
|
||||
#BUILDACTION="clean build"
|
||||
#CONFIGURATION="Development"
|
||||
CONFIGURATION="Deployment"
|
||||
|
||||
GDAL_LOCATION="/Library/Frameworks"
|
||||
#GDAL_LOCATION="/Library/Frameworks"
|
||||
|
||||
# Clean up from previous builds?
|
||||
echo "Deleteing PackageDir to begin anew"
|
||||
@@ -65,17 +67,20 @@ mkdir -p PackageDir/XcodeTemplates
|
||||
|
||||
mkdir -p PackageDir/Resources
|
||||
|
||||
mkdir -p PackageDir/.background
|
||||
|
||||
|
||||
# Everything should be built now. Move all the things to be distrubuted
|
||||
# to the PackageDir with the appropriate layout.
|
||||
|
||||
echo "Copying Frameworks..."
|
||||
|
||||
$COPY OpenThreads/Xcode/OpenThreads/build/$CONFIGURATION/OpenThreads.framework PackageDir/Frameworks
|
||||
$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/osg*.framework PackageDir/Frameworks/
|
||||
#$COPY OpenThreads/Xcode/OpenThreads/build/$CONFIGURATION/OpenThreads.framework PackageDir/Frameworks
|
||||
#$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/osg*.framework PackageDir/Frameworks/
|
||||
$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/*.framework PackageDir/Frameworks/
|
||||
|
||||
# Copy the gdal framework
|
||||
$COPY $GDAL_LOCATION/gdal.framework PackageDir/Frameworks
|
||||
#$COPY $GDAL_LOCATION/gdal.framework PackageDir/Frameworks
|
||||
|
||||
echo "Copying PlugIns..."
|
||||
$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/*.so PackageDir/PlugIns/
|
||||
@@ -86,14 +91,18 @@ $COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/*.app PackageDir/
|
||||
echo "Copying Xcode templates..."
|
||||
$COPY OpenSceneGraph/Xcode/XcodeTemplates PackageDir
|
||||
# If we are in CVS, all the CVS junk got copied in so we need to remove it
|
||||
find -d PackageDir/XcodeTemplates -name CVS -exec rm -rf {} \;
|
||||
#find -d PackageDir/XcodeTemplates -name CVS -exec rm -rf {} \;
|
||||
find -d PackageDir/XcodeTemplates -name .svn -exec rm -rf {} \;
|
||||
|
||||
|
||||
echo "Copying License and ReadMe files..."
|
||||
$COPY OpenThreads/COPYING.txt PackageDir/LICENSE_OpenThreads.txt
|
||||
#$COPY OpenThreads/COPYING.txt PackageDir/LICENSE_OpenThreads.txt
|
||||
$COPY OpenSceneGraph/LICENSE.txt PackageDir/LICENSE_OSG.txt
|
||||
$COPY OpenSceneGraph/Xcode/OSX_OSG_README.rtf PackageDir
|
||||
|
||||
# Copy the background image and .DS_Store for 'fancy' DMG
|
||||
$COPY OpenSceneGraph/Xcode/Packaging/Resources/instlogo.pdf PackageDir/.background
|
||||
$COPY OpenSceneGraph/Xcode/Misc/DSStoreForDMG PackageDir/.DS_Store
|
||||
|
||||
|
||||
# Sorry, I think this is bourne only
|
||||
@@ -108,21 +117,40 @@ echo "Setting up symbolic links for the .app's..."
|
||||
)
|
||||
done
|
||||
)
|
||||
#echo ""
|
||||
|
||||
echo "Testing for OpenSceneGraph-Data..."
|
||||
|
||||
|
||||
# Not sure how to find the OSG data, so it has to be done manually
|
||||
# Would Spotlight help?
|
||||
echo "Next, you must (manually) copy all the OSG-data to PackageDir/Resources and the LICENCE_GDAL.rtf to PackageDir."
|
||||
# If OpenSceneGraph-Data/ resides next to OpenSceneGraph/, then use it
|
||||
if [ -d OpenSceneGraph-Data ]; then
|
||||
echo "Found OpenSceneGraph-Data and will copy into PackageDir/Resources."
|
||||
# Determine if it is a subversion copy or not; we don't want the repo info
|
||||
if [ -d OpenSceneGraph-Data/.svn ]; then
|
||||
$SVN export --force OpenSceneGraph-Data PackageDir/Resources
|
||||
else
|
||||
$COPY OpenSceneGraph-Data PackageDir/Resources
|
||||
fi
|
||||
|
||||
echo "Looking up location for OpenSceneGraph-Data"
|
||||
#/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl
|
||||
/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single
|
||||
echo "Looking up location for LICENSE_GDAL.rtf"
|
||||
/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single LICENSE_GDAL.rtf
|
||||
echo "Creating DMG using:"
|
||||
echo "hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg"
|
||||
/usr/bin/hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg
|
||||
|
||||
echo "After you copy the remaining resources, you will want to package up the DMG. You can use the following line as the basis:"
|
||||
echo "hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg"
|
||||
else
|
||||
# Not sure how to find the OSG data, so it has to be done manually
|
||||
# Would Spotlight help?
|
||||
#echo "Next, you must (manually) copy all the OSG-data to PackageDir/Resources and the LICENCE_GDAL.rtf to PackageDir."
|
||||
echo "Did not find OpenSceneGraph-Data/ aside OpenSceneGraph/."
|
||||
echo "Next, you must (manually) copy all the OSG-data to PackageDir/Resources."
|
||||
|
||||
echo "Looking up possible location for OpenSceneGraph-Data"
|
||||
#/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl
|
||||
/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single
|
||||
#echo "Looking up location for LICENSE_GDAL.rtf"
|
||||
#/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single LICENSE_GDAL.rtf
|
||||
|
||||
echo "After you copy the remaining resources, you will want to package up the DMG. You can use the following line as the basis:"
|
||||
echo "hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg"
|
||||
fi
|
||||
|
||||
|
||||
# Now we want to package up everything into a .dmg
|
||||
|
||||
BIN
Xcode/Misc/DSStoreForDMG
Normal file
BIN
Xcode/Misc/DSStoreForDMG
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
|
||||
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf440
|
||||
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Oblique;
|
||||
\f3\fmodern\fcharset77 Courier;\f4\fnil\fcharset77 Monaco;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
@@ -15,24 +15,49 @@ This is the readme for the entire OpenThreads/OpenSceneGraph distribution for th
|
||||
\
|
||||
The source code is available at {\field{\*\fldinst{HYPERLINK "http://www.openscenegraph.org/"}}{\fldrslt http://www.openscenegraph.org/}}\
|
||||
\
|
||||
Also included is a framework for GDAL. You can get the source code and the full GDAL package at {\field{\*\fldinst{HYPERLINK "http://www.gdal.org/"}}{\fldrslt http://www.gdal.org/}}\
|
||||
\
|
||||
\
|
||||
|
||||
\f0\b What's New in this release:
|
||||
\f0\b \
|
||||
Quick Start:
|
||||
\f1\b0 \
|
||||
Screencasts of how to install and get going with OSG for Mac OS X can be found here:\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
{\field{\*\fldinst{HYPERLINK "http://www.openscenegraph.org/projects/osg/wiki/Support/TipsAndTricks"}}{\fldrslt \cf0 http://www.openscenegraph.org/projects/osg/wiki/Support/TipsAndTricks}}\
|
||||
\
|
||||
\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 What's New in this release:
|
||||
\f1\b0 \
|
||||
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\ql\qnatural\pardirnatural
|
||||
\ls1\ilvl0\cf0 {\listtext \'a5 }Dwarf debugging format\
|
||||
{\listtext \'a5 }osgsimpleviewerCocoa and osgsimpleviewerSDL\
|
||||
\ls1\ilvl0\cf0 {\listtext \'a5 }OpenThreads now uses Subversion 'externals' to make it look like part of the OSG source distribution.\
|
||||
{\listtext \'a5 }Producer has been removed from the distribution. osgViewer is supposed to replace it. The Mac OS X backend is currently Carbon based.\
|
||||
{\listtext \'a5 }GDAL has been removed as it is no longer a dependency.\
|
||||
{\listtext \'a5 }osgviewerCocoa (previously osgsimpleviewerCocoa in CVS) is an example program demonstrating tight integration between OpenSceneGraph and Cocoa. It demonstrates many of the things you should consider in building a first-class OS X application that uses OSG.\
|
||||
{\listtext \'a5 }Dwarf debugging format\
|
||||
{\listtext \'a5 }osgsimpleviewerSDL\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
\cf0 \
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Notes for 1.2 release:\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
\f0\b Notes for 2.0 release:\
|
||||
|
||||
\f1\b0 \cf0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
|
||||
\f1\b0 OSG has changed its versioning number scheme. 2.0 is the stable release following 1.2.\
|
||||
\
|
||||
Producer has been removed from the distribution with osgViewer as its intended replacement.\
|
||||
\
|
||||
GDAL has also been removed from the distribution as it is no longer a dependency.\
|
||||
\
|
||||
OSG is in the process to moving to a new CMake based build system. Once the remaining Mac OS X support needed is implemented in CMake, the Xcode projects will be removed in favor of the new unified CMake system.\
|
||||
\
|
||||
With Leopard on the horizon, the need to deal with 64-bit readiness and deprecated APIs is becoming more critical. In a nutshell, we need a Cocoa based version of osgViewer, and the QuickTime plugin needs to be replaced. Currently, there is a new ImageIO based plugin to assume the image reading/writing duties of the old qt plugin. We are in need of a QTKit based plugin to assume the movie responsibilities of the old plugin. And we are in need of volunteers to write the Cocoa osgViewer backend. Currently, the example osgviewerCocoa demonstrates a lot of similar functionality and could be used as a reference. However, the example needs to be turned 'inside-out'. The example is an NSView class that contains OSG classes; the osgViewer needs to be the opposite where the OSG class needs to contain the NSView class.\
|
||||
\
|
||||
\
|
||||
\
|
||||
|
||||
\f0\b Notes for 1.2 release:\
|
||||
|
||||
\f1\b0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
|
||||
\
|
||||
Since the 1.1 release, we have learned of serious problems (freezing of the window manager) on the (Intel) MacBook Pros using osgText. We believe the problem is with a serious driver bug for ATI in OS X 10.4.7. We believe the bug affects the ATI Radeon X1600. (You can get this string by calling glGetString(GL_RENDERER) when you have a valid OpenGL Context. The string returned to us on affected MacBook Pros is "ATI Radeon X1600 OpenGL Engine".)\
|
||||
\
|
||||
@@ -98,16 +123,16 @@ Don't forget to link against Carbon (-framework Carbon) if you use Gestalt.\
|
||||
\
|
||||
If you are affected by this, please file a bug report at {\field{\*\fldinst{HYPERLINK "https://bugreport.apple.com"}}{\fldrslt https://bugreport.apple.com}}. Apple lives and dies by the bug report system. If anything is to get done, it must be in the bug reporter. And they keep count of how many people file the same bug, so duplicates are good.\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f2\i (Note: We believe this has been fixed in 10.4.8)
|
||||
\f2\i \cf0 (Note: We believe this has been fixed in 10.4.8)
|
||||
\f1\i0 \
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Notes for 1.1 release:\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f1\b0 \cf0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
|
||||
\f1\b0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
|
||||
The Xcode projects are also set to build as Universal Binaries for both Development and Deployment\
|
||||
targets. If you do not need this and want to save build time, you should change the architecture option\
|
||||
to your desired setting (most likely to $(NATIVE_ARCH)). It is overridden in the top-level "OpenSceneGraph" project in the Group & Files panel. Don't forget to change OpenThreads \
|
||||
@@ -128,9 +153,8 @@ PlugIns, the file size shrunk from about 1GB to about 100MB.\
|
||||
We have stopped maintaining the Xcode 1.5/2.0 projects.\
|
||||
\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Notes for 1.0 release:
|
||||
\f0\b Notes for 1.0 release:
|
||||
\f1\b0 \
|
||||
These projects were primarily developed with gcc 4.0.1 under Tiger 10.4.3 using Xcode 2.2. Starting with gcc 4.0, Apple no longer statically links in the C++ runtime. Apple has made available the g++ 4.0 dynamic runtime for Panther under the 10.3.9 release. To run under Panther, your system must have this update (or you must recompile the binaries for your system).\
|
||||
\
|
||||
@@ -230,9 +254,8 @@ Also remember that OSG will still respond to standard OSG environmental variable
|
||||
\
|
||||
|
||||
\f0\b Prebinding Addresses:\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f1\b0 \cf0 \
|
||||
\f1\b0 \
|
||||
These are now obsolete. Prebinding is now disabled. The old addresses were:\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
@@ -315,9 +338,8 @@ If you are compiling under Xcode 1.5 and are using our Xcode 1.5/2.0 projects, t
|
||||
{\listtext \'a5 }I noticed that for some reason, Xcode has problems compiling the Carbon header with the OpenThreads framework when autovectorization and precompiled headers were enabled. You might try disabling precompiled headers if it is not already. If the problem persists, you may also need to delete the entry that enables autovectorization. In the Groups and Files panel (left side panel), open the Info inspector for the project (top item) and click on the Build tab. Scroll down to the bottom, and remove the autovectorization option. \
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
\cf0 \
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Universal Binaries:
|
||||
\f0\b Universal Binaries:
|
||||
\f1\b0 \
|
||||
\
|
||||
Be aware, when building you're own Universal Binaries and you use the 10.4 SDK, you must explicitly\
|
||||
@@ -361,4 +383,4 @@ On the topic of feature requests, another potentially useful thing to have is a
|
||||
ewing 2121 - at - yahoo (in the commercial domain)\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
{\field{\*\fldinst{HYPERLINK "http://www.create.ucsb.edu/OSG/"}}{\fldrslt \cf0 http://www.create.ucsb.edu/OSG/}}\
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,24 +1,24 @@
|
||||
echo Copy Examples
|
||||
cp -r ../OpenSceneGraph/build/Development/*.app Binary/Examples/
|
||||
cp -r ../OpenSceneGraph/build/Deployment/*.app Binary/Examples/
|
||||
|
||||
echo Copy Applications
|
||||
mv Binary/Examples/osgviewer.app Binary/Applications
|
||||
mv Binary/Examples/osgarchive.app Binary/Applications
|
||||
mv Binary/Examples/osgversion.app Binary/Applications
|
||||
mv Binary/Examples/osgconv.app Binary/Applications
|
||||
mv Binary/Applications/osgviewer.app/Contents/MacOS/osgviewer Binary/Applications
|
||||
mv Binary/Applications/osgarchive.app/Contents/MacOS/osgarchive Binary/Applications
|
||||
mv Binary/Applications/osgversion.app/Contents/MacOS/osgversion Binary/Applications
|
||||
mv Binary/Applications/osgconv.app/Contents/MacOS/osgconv Binary/Applications
|
||||
rm -rf Binary/Applications/osg*.app
|
||||
cp Binary/Applications/*.app Binary/Applictions/Bundles/
|
||||
cp Binary/Applications/osgviewer.app/Contents/MacOS/osgviewer Binary/Applications
|
||||
cp Binary/Applications/osgarchive.app/Contents/MacOS/osgarchive Binary/Applications
|
||||
cp Binary/Applications/osgversion.app/Contents/MacOS/osgversion Binary/Applications
|
||||
cp Binary/Applications/osgconv.app/Contents/MacOS/osgconv Binary/Applications
|
||||
mv Binary/Applications/osg*.app Binary/Applications/Bundles/
|
||||
|
||||
|
||||
echo Copy Frameworks
|
||||
cp -r ../OpenSceneGraph/build/Development/*.framework Binary/Frameworks/
|
||||
cp -r ../OpenSceneGraph/build/Deployment/*.framework Binary/Frameworks/
|
||||
|
||||
echo Copy Plugins
|
||||
cp ../OpenSceneGraph/build/Development/*.so Binary/Plugins/
|
||||
cp ../OpenSceneGraph/build/Development/osgtext Binary/Plugins/
|
||||
cp ../OpenSceneGraph/build/Development/osgpick Binary/Plugins/
|
||||
cp ../OpenSceneGraph/build/Deployment/*.so Binary/Plugins/
|
||||
|
||||
echo Copying Complete
|
||||
|
||||
@@ -28,4 +28,5 @@ open OpenSceneGraph.pmproj
|
||||
open Packages/Examples.pmproj
|
||||
open Packages/PlugIns.pmproj
|
||||
open Packages/Frameworks.pmproj
|
||||
open Packages/Applications.pmproj
|
||||
open Packages/ApplicationsBundles.pmproj
|
||||
open Packages/ApplicationsCmdline.pmproj
|
||||
|
||||
BIN
Xcode/Packaging/Packages/ApplicationsBundles.pmproj
Normal file
BIN
Xcode/Packaging/Packages/ApplicationsBundles.pmproj
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,7 @@
|
||||
\f0\b\fs24 \cf0 OpenSceneGraph on Mac OS X
|
||||
\f1\b0 \
|
||||
\
|
||||
This is the readme for the entire OpenThreads/OpenSceneGraph distribution for the OS X frameworks and Xcode projects. This readme was originally written for the binary distribution, but there is a lot of useful information in here so it has also been included with the source code in the Xcode section. This was sync'd with the OSG 1.2 release.\
|
||||
This is the readme for the entire OpenThreads/OpenSceneGraph distribution for the OS X frameworks and Xcode projects. This readme was originally written for the binary distribution, but there is a lot of useful information in here so it has also been included with the source code in the Xcode section. This was sync'd with the OSG 2.0 release.\
|
||||
\
|
||||
The source code is available at {\field{\*\fldinst{HYPERLINK "http://www.openscenegraph.org/"}}{\fldrslt http://www.openscenegraph.org/}}\
|
||||
\
|
||||
@@ -21,18 +21,42 @@ Also included is a framework for GDAL. You can get the source code and the full
|
||||
|
||||
\f0\b What's New in this release:
|
||||
\f1\b0 \
|
||||
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
\ls1\ilvl0\cf0 The theme for the 2.0 release has been making the OpenSceneGraph easier to use, yet more flexible and powerful.\
|
||||
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\ql\qnatural\pardirnatural
|
||||
\ls1\ilvl0\cf0 {\listtext \'a5 }Dwarf debugging format\
|
||||
{\listtext \'a5 }osgsimpleviewerCocoa and osgsimpleviewerSDL\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
\cf0 \
|
||||
\ls1\ilvl0\cf0 \
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
|
||||
\cf0 Features include:\
|
||||
\
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li400\fi-400\ql\qnatural\pardirnatural
|
||||
\cf0 * New unified build system using CMake, which simplifies the build process, automatically detecting installed dependencies and providing build configuration as well as support for a wide range of development tools.\
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
|
||||
\cf0 * New libraries:\
|
||||
* osgViewer - replacing Producer as a windowing toolkit\
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li760\fi-760\ql\qnatural\pardirnatural
|
||||
\cf0 * osgManipulator - provides a set of interactive manipulators for scaling, rotating and moving objects in the scene.\
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
|
||||
\cf0 * osgShadow - provides an extensible framework for adding dynamic shadows to your scene. \
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li400\fi-400\ql\qnatural\pardirnatural
|
||||
\cf0 * New low-level extensible intersection framework that includes support for line, plane and polytope intersections.\
|
||||
* New high-level intersection classes that support paged databases, LineOfSight, HeightAboveTerrain and ElevationSlice.\
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
|
||||
\cf0 * View-dependent overlay\
|
||||
* what does this do? \
|
||||
* Plugins\
|
||||
* Improvements to the OpenFlight, COLLADA and AC3D? plugins\
|
||||
* New TXF texture font reader. \
|
||||
* Easier 3rd party windowing integration\
|
||||
* With examples showing integration with GLUT, SDL, Qt, WxWidgets and MFC. \
|
||||
* OpenThreads is moved into the core of OpenSceneGraph and is no longer an external dependency.\
|
||||
* Producer is no longer a dependency \
|
||||
\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Notes for 1.2 release:\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f1\b0 \cf0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
|
||||
\f1\b0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
|
||||
\
|
||||
Since the 1.1 release, we have learned of serious problems (freezing of the window manager) on the (Intel) MacBook Pros using osgText. We believe the problem is with a serious driver bug for ATI in OS X 10.4.7. We believe the bug affects the ATI Radeon X1600. (You can get this string by calling glGetString(GL_RENDERER) when you have a valid OpenGL Context. The string returned to us on affected MacBook Pros is "ATI Radeon X1600 OpenGL Engine".)\
|
||||
\
|
||||
@@ -98,16 +122,16 @@ Don't forget to link against Carbon (-framework Carbon) if you use Gestalt.\
|
||||
\
|
||||
If you are affected by this, please file a bug report at {\field{\*\fldinst{HYPERLINK "https://bugreport.apple.com"}}{\fldrslt https://bugreport.apple.com}}. Apple lives and dies by the bug report system. If anything is to get done, it must be in the bug reporter. And they keep count of how many people file the same bug, so duplicates are good.\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f2\i (Note: We believe this has been fixed in 10.4.8)
|
||||
\f2\i \cf0 (Note: We believe this has been fixed in 10.4.8)
|
||||
\f1\i0 \
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Notes for 1.1 release:\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f1\b0 \cf0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
|
||||
\f1\b0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
|
||||
The Xcode projects are also set to build as Universal Binaries for both Development and Deployment\
|
||||
targets. If you do not need this and want to save build time, you should change the architecture option\
|
||||
to your desired setting (most likely to $(NATIVE_ARCH)). It is overridden in the top-level "OpenSceneGraph" project in the Group & Files panel. Don't forget to change OpenThreads \
|
||||
@@ -128,9 +152,8 @@ PlugIns, the file size shrunk from about 1GB to about 100MB.\
|
||||
We have stopped maintaining the Xcode 1.5/2.0 projects.\
|
||||
\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Notes for 1.0 release:
|
||||
\f0\b Notes for 1.0 release:
|
||||
\f1\b0 \
|
||||
These projects were primarily developed with gcc 4.0.1 under Tiger 10.4.3 using Xcode 2.2. Starting with gcc 4.0, Apple no longer statically links in the C++ runtime. Apple has made available the g++ 4.0 dynamic runtime for Panther under the 10.3.9 release. To run under Panther, your system must have this update (or you must recompile the binaries for your system).\
|
||||
\
|
||||
@@ -230,9 +253,8 @@ Also remember that OSG will still respond to standard OSG environmental variable
|
||||
\
|
||||
|
||||
\f0\b Prebinding Addresses:\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f1\b0 \cf0 \
|
||||
\f1\b0 \
|
||||
These are now obsolete. Prebinding is now disabled. The old addresses were:\
|
||||
\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
@@ -315,9 +337,8 @@ If you are compiling under Xcode 1.5 and are using our Xcode 1.5/2.0 projects, t
|
||||
{\listtext \'a5 }I noticed that for some reason, Xcode has problems compiling the Carbon header with the OpenThreads framework when autovectorization and precompiled headers were enabled. You might try disabling precompiled headers if it is not already. If the problem persists, you may also need to delete the entry that enables autovectorization. In the Groups and Files panel (left side panel), open the Info inspector for the project (top item) and click on the Build tab. Scroll down to the bottom, and remove the autovectorization option. \
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
\cf0 \
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b \cf0 Universal Binaries:
|
||||
\f0\b Universal Binaries:
|
||||
\f1\b0 \
|
||||
\
|
||||
Be aware, when building you're own Universal Binaries and you use the 10.4 SDK, you must explicitly\
|
||||
@@ -361,4 +382,4 @@ On the topic of feature requests, another potentially useful thing to have is a
|
||||
ewing 2121 - at - yahoo (in the commercial domain)\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
{\field{\*\fldinst{HYPERLINK "http://www.create.ucsb.edu/OSG/"}}{\fldrslt \cf0 http://www.create.ucsb.edu/OSG/}}\
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,9 @@
|
||||
\fs24 \
|
||||
\
|
||||
This installer will install the OpenSceneGraph Applications, Examples, Frameworks and Plugins in:\
|
||||
/usr/local/bin\
|
||||
/OpenSceneGraph/Examples\
|
||||
/usr/local/bin (Executable Applications) \
|
||||
/Applications/OpenSceneGraph/Applications/ (Bundled Applications)\
|
||||
/Applications/OpenSceneGraph/Examples/\
|
||||
/Library/Frameworks\
|
||||
/Library/Application\\ Support/OpenSceneGraph/PlugIns/\
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <OpenThreads/Mutex>
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
#include <OpenThreads/ReentrantMutex>
|
||||
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/AnimationPath>
|
||||
@@ -146,7 +147,6 @@
|
||||
#include <osg/TriangleFunctor>
|
||||
#include <osg/TriangleIndexFunctor>
|
||||
#include <osg/Uniform>
|
||||
#include <osg/UnitTestFramework>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec2b>
|
||||
#include <osg/Vec2d>
|
||||
@@ -186,7 +186,6 @@
|
||||
#include <osgDB/ParameterOutput>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/ReaderWriter>
|
||||
#include <osgDB/ReentrantMutex>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/SharedStateManager>
|
||||
#include <osgDB/Version>
|
||||
@@ -213,11 +212,9 @@
|
||||
#include <osgGA/GUIActionAdapter>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include <osgGA/GUIEventHandler>
|
||||
#include <osgGA/GUIEventHandlerVisitor>
|
||||
#include <osgGA/KeySwitchMatrixManipulator>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
#include <osgGA/NodeTrackerManipulator>
|
||||
#include <osgGA/SetSceneViewVisitor>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgGA/TerrainManipulator>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
@@ -319,8 +316,10 @@
|
||||
* you should comment out this block.
|
||||
*/
|
||||
#include <osgTerrain/Export>
|
||||
#include <osgTerrain/HeightFieldNode>
|
||||
#include <osgTerrain/HeightFieldRenderer>
|
||||
#include <osgTerrain/Layer>
|
||||
#include <osgTerrain/Locator>
|
||||
#include <osgTerrain/TerrainNode>
|
||||
#include <osgTerrain/GeometryTechnique>
|
||||
#include <osgTerrain/Version>
|
||||
|
||||
#include <osgText/Export>
|
||||
|
||||
@@ -17,6 +17,7 @@ SET(OPENSCENEGRAPH_APPLICATION_DIR ${PROJECT_SOURCE_DIR})
|
||||
SET(TARGET_DEFAULT_PREFIX "application_")
|
||||
SET(TARGET_DEFAULT_LABEL_PREFIX "Applications")
|
||||
SET(TARGET_COMMON_LIBRARIES
|
||||
OpenThreads
|
||||
osg
|
||||
osgDB
|
||||
osgUtil
|
||||
|
||||
@@ -58,6 +58,12 @@ Node* OrientationConverter::convert( Node *node )
|
||||
transform->setDataVariance(osg::Object::STATIC);
|
||||
transform->setMatrix( C * R * S * T );
|
||||
|
||||
if (!S.isIdentity())
|
||||
{
|
||||
// Add a normalize state. This will be removed if the FlattenStaticTransformsVisitor works
|
||||
transform->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
root->addChild(transform);
|
||||
transform->addChild(node);
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgUtil/SmoothingVisitor>
|
||||
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "OrientationConverter.h"
|
||||
@@ -51,12 +53,17 @@ class MyGraphicsContext {
|
||||
}
|
||||
|
||||
if (_gc.valid())
|
||||
|
||||
|
||||
{
|
||||
_gc->realize();
|
||||
_gc->makeCurrent();
|
||||
std::cout<<"Realized window"<<std::endl;
|
||||
if (dynamic_cast<osgViewer::GraphicsWindow*>(_gc.get()))
|
||||
{
|
||||
std::cout<<"Realized graphics window for OpenGL operations."<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Realized pbuffer for OpenGL operations."<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,7 +671,7 @@ int main( int argc, char **argv )
|
||||
}
|
||||
}
|
||||
|
||||
osgDB::ReaderWriter::WriteResult result = osgDB::Registry::instance()->writeNode(*root,fileNameOut);
|
||||
osgDB::ReaderWriter::WriteResult result = osgDB::Registry::instance()->writeNode(*root,fileNameOut,osgDB::Registry::instance()->getOptions());
|
||||
if (result.success())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Data written to '"<<fileNameOut<<"'."<< std::endl;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgversion.cpp )
|
||||
#### end var setup ###
|
||||
|
||||
SET(TARGET_COMMON_LIBRARIES
|
||||
OpenThreads
|
||||
osg
|
||||
)
|
||||
|
||||
SETUP_COMMANDLINE_APPLICATION(osgversion)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <osg/Version>
|
||||
#include <osg/ArgumentParser>
|
||||
#include <osg/ApplicationUsage>
|
||||
#include <OpenThreads/Version>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
@@ -33,6 +34,7 @@ bool validName(const std::string& first)
|
||||
|
||||
if (first.size()>=2 && (first[1]<'a' || first[1]>'z') && (first[1]!='.') && (first[1]!=',')) return false;
|
||||
|
||||
if (first=="Xcode") return false;
|
||||
if (first=="Added") return false;
|
||||
if (first=="Camera") return false;
|
||||
if (first=="CameraNode") return false;
|
||||
@@ -49,6 +51,9 @@ bool validName(const std::string& first)
|
||||
if (first=="SpotExponent") return false;
|
||||
if (first=="Framstamp") return false;
|
||||
if (first=="Stats") return false;
|
||||
if (first=="Group") return false;
|
||||
if (first=="Texture") return false;
|
||||
if (first=="Texture2DArray") return false;
|
||||
if (first=="Creator") return false;
|
||||
if (first=="CullVisitor") return false;
|
||||
if (first=="Drawable") return false;
|
||||
@@ -198,6 +203,8 @@ bool validName(const std::string& first)
|
||||
if (first=="CullVistor") return false;
|
||||
if (first=="SimpleViewer") return false;
|
||||
if (first=="TexMat(Matrix") return false;
|
||||
if (first=="GraphicsWindowX11") return false;
|
||||
if (first=="OperationThread") return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -209,6 +216,17 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="") return "";
|
||||
if (name=="") return "";
|
||||
#endif
|
||||
if (name=="Martsz") return "Martz";
|
||||
if (name=="Froenlich") return "Fr<EFBFBD>hlich";
|
||||
if (name=="Froelich") return "Fr<EFBFBD>hlich";
|
||||
if (name=="Fruciel") return "Frauciel";
|
||||
if (name=="Hebelin") return "Herbelin";
|
||||
if (name=="Jea-Sebastien") return "Jean-Sebastien";
|
||||
if (name=="Robet") return "Robert";
|
||||
if (name=="Morné") return "Morn<EFBFBD>";
|
||||
if (name=="Adndre") return "Andre";
|
||||
if (name=="Mellis") return "Melis";
|
||||
if (name=="Rajce") return "Trajce";
|
||||
if (name=="Trastenjak") return "Trstenjak";
|
||||
if (name=="Baverage") return "Beverage";
|
||||
if (name=="Bistroviae") return "Bistrovic";
|
||||
@@ -258,6 +276,7 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="Moloshton") return "Moloshtan";
|
||||
if (name=="Moule") return "Moiule";
|
||||
if (name=="Nicklov") return "Nikolov";
|
||||
if (name=="Nickolov") return "Nikolov";
|
||||
if (name=="Olad") return "Olaf";
|
||||
if (name=="Olar") return "Olaf";
|
||||
if (name=="Oritz") return "Ortiz";
|
||||
@@ -283,9 +302,10 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="Yefrei") return "Yefei";
|
||||
if (name=="Yfei") return "Yefei";
|
||||
if (name=="Antonoine") return "Antoine";
|
||||
if (name=="Antione") return "Antoine";
|
||||
if (name=="Andew") return "Andrew";
|
||||
if (name=="Daneil") return "Daniel";
|
||||
if (name=="André") return "Anr<EFBFBD>";
|
||||
if (name=="André") return "Andr<EFBFBD>";
|
||||
if (name=="García") return "Garcea";
|
||||
if (name=="Sjölie") return "Sj<EFBFBD>lie";
|
||||
if (name=="José") return "Jos<EFBFBD>";
|
||||
@@ -293,6 +313,9 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="Froehlich") return "Fr<EFBFBD>hlich";
|
||||
if (name=="Eileman") return "Eilemann";
|
||||
if (name=="Skinnder") return "Skinner";
|
||||
if (name=="Mihair") return "Mihai";
|
||||
if (name=="Mahai") return "Mihai";
|
||||
|
||||
if (name=="SimpleViewer") return "";
|
||||
|
||||
return name;
|
||||
@@ -300,6 +323,26 @@ std::string typoCorrection(const std::string& name)
|
||||
|
||||
void nameCorrection(NamePair& name)
|
||||
{
|
||||
if (name.first=="Radu" && name.second=="Mihai")
|
||||
{
|
||||
name.first = "Mihai";
|
||||
name.second = "Radu";
|
||||
}
|
||||
if (name.first=="Art" && name.second=="Trevs")
|
||||
{
|
||||
name.first = "Art";
|
||||
name.second = "Tevs";
|
||||
}
|
||||
if (name.first=="Tim" && name.second=="More")
|
||||
{
|
||||
name.first = "Tim";
|
||||
name.second = "Moore";
|
||||
}
|
||||
if (name.first=="Andre" && name.second=="Garneau")
|
||||
{
|
||||
name.first = "Andr<EFBFBD>";
|
||||
name.second = "Garneau";
|
||||
}
|
||||
if (name.first=="Eric" && name.second=="Hammil")
|
||||
{
|
||||
name.first = "Chris";
|
||||
@@ -377,6 +420,11 @@ void nameCorrection(NamePair& name)
|
||||
name.first = "Trajce";
|
||||
name.second = "Nikolov";
|
||||
}
|
||||
if (name.first=="Frauciel" && name.second=="Luc")
|
||||
{
|
||||
name.first = "Luc";
|
||||
name.second = "Frauciel";
|
||||
}
|
||||
}
|
||||
|
||||
void lastValidCharacter(const std::string& name, unsigned int& pos,char c)
|
||||
@@ -601,6 +649,7 @@ void buildContributors(NameMap& names)
|
||||
++names[NamePair("Marco","Jez")];
|
||||
++names[NamePair("Mike","Weiblen")];
|
||||
++names[NamePair("Geoff","Michel")];
|
||||
++names[NamePair("Ben","van Basten")];
|
||||
|
||||
// contributors that don't appear in the ChangeLog due to their contributions
|
||||
// being before CVS started for the OSG, or before the name logging began.
|
||||
@@ -620,6 +669,9 @@ int main( int argc, char **argv)
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--entries","Print out number of entries into the ChangeLog file for each contributor.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--version-number","Print out version number only");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--soversion-number","Print out shared object version number only");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--openthreads-version-number","Print out version number for OpenThreads only");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--openthreads-soversion-number","Print out shared object version number for OpenThreads only");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-r <file> or --read <file>","Read the ChangeLog to generate an estimated contributors list.");
|
||||
|
||||
if (arguments.read("--version-number"))
|
||||
@@ -628,6 +680,63 @@ int main( int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--major-number"))
|
||||
{
|
||||
std::cout<<OPENSCENEGRAPH_MAJOR_VERSION<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--minor-number"))
|
||||
{
|
||||
std::cout<<OPENSCENEGRAPH_MINOR_VERSION<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--patch-number"))
|
||||
{
|
||||
std::cout<<OPENSCENEGRAPH_PATCH_VERSION<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--soversion-number"))
|
||||
{
|
||||
std::cout<<osgGetSOVersion()<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.read("--openthreads-version-number"))
|
||||
{
|
||||
std::cout<<OpenThreadsGetVersion()<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.read("--openthreads-major-number"))
|
||||
{
|
||||
std::cout<<OPENTHREADS_MAJOR_VERSION<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--openthreads-minor-number"))
|
||||
{
|
||||
std::cout<<OPENTHREADS_MINOR_VERSION<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--openthreads-patch-number"))
|
||||
{
|
||||
std::cout<<OPENTHREADS_PATCH_VERSION<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.read("--openthreads-soversion-number"))
|
||||
{
|
||||
std::cout<<OpenThreadsGetSOVersion()<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout<<osgGetLibraryName()<< " "<< osgGetVersion()<<std::endl<<std::endl;
|
||||
|
||||
bool printContributors = false;
|
||||
|
||||
@@ -143,5 +143,8 @@ int main(int argc, char** argv)
|
||||
|
||||
viewer.setSceneData( loadedModel.get() );
|
||||
|
||||
return viewer.run();
|
||||
viewer.realize();
|
||||
|
||||
viewer.run();
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgcubemap)
|
||||
ADD_SUBDIRECTORY(osgdelaunay)
|
||||
ADD_SUBDIRECTORY(osgdepthpartition)
|
||||
ADD_SUBDIRECTORY(osgdepthshadow)
|
||||
ADD_SUBDIRECTORY(osgdepthpeeling)
|
||||
ADD_SUBDIRECTORY(osgdistortion)
|
||||
ADD_SUBDIRECTORY(osgfadetext)
|
||||
ADD_SUBDIRECTORY(osgforest)
|
||||
@@ -70,7 +70,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgsequence)
|
||||
ADD_SUBDIRECTORY(osgshaders)
|
||||
ADD_SUBDIRECTORY(osgshaderterrain)
|
||||
ADD_SUBDIRECTORY(osgshadowtexture)
|
||||
ADD_SUBDIRECTORY(osgshadow)
|
||||
ADD_SUBDIRECTORY(osgshape)
|
||||
ADD_SUBDIRECTORY(osgsimplifier)
|
||||
@@ -105,6 +104,10 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgviewerSDL)
|
||||
ENDIF(SDL_FOUND)
|
||||
|
||||
IF (FOX_FOUND)
|
||||
ADD_SUBDIRECTORY(osgviewerFOX)
|
||||
ENDIF(FOX_FOUND)
|
||||
|
||||
IF (wxWidgets_FOUND)
|
||||
ADD_SUBDIRECTORY(osgviewerWX)
|
||||
ENDIF(wxWidgets_FOUND)
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <osgViewer/CompositeViewer>
|
||||
|
||||
@@ -136,15 +137,19 @@ int main( int argc, char **argv )
|
||||
if (!scene) return 1;
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::CompositeViewer viewer;
|
||||
osgViewer::CompositeViewer viewer(arguments);
|
||||
|
||||
|
||||
|
||||
|
||||
if (arguments.read("-1"))
|
||||
{
|
||||
{
|
||||
osgViewer::View* view = new osgViewer::View;
|
||||
view->setSceneData(osgDB::readNodeFile("fountain.osg"));
|
||||
|
||||
|
||||
view->addEventHandler( new osgViewer::StatsHandler );
|
||||
|
||||
view->setUpViewAcrossAllScreens();
|
||||
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
viewer.addView(view);
|
||||
@@ -179,6 +184,9 @@ int main( int argc, char **argv )
|
||||
view->setSceneData(scene.get());
|
||||
view->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
view->addEventHandler( new osgViewer::StatsHandler );
|
||||
|
||||
|
||||
// add the handler for doing the picking
|
||||
view->addEventHandler(new PickHandler());
|
||||
}
|
||||
@@ -237,6 +245,12 @@ int main( int argc, char **argv )
|
||||
statesetManipulator->setStateSet(view->getCamera()->getOrCreateStateSet());
|
||||
|
||||
view->addEventHandler( statesetManipulator.get() );
|
||||
|
||||
view->addEventHandler( new osgViewer::StatsHandler );
|
||||
view->addEventHandler( new osgViewer::HelpHandler );
|
||||
view->addEventHandler( new osgViewer::WindowSizeHandler );
|
||||
view->addEventHandler( new osgViewer::ThreadingHandler );
|
||||
view->addEventHandler( new osgViewer::RecordCameraPathHandler );
|
||||
}
|
||||
|
||||
// view two
|
||||
@@ -268,10 +282,11 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
while (arguments.read("-s")) { viewer.setThreadingModel(osgViewer::CompositeViewer::SingleThreaded); }
|
||||
while (arguments.read("-g")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerContext); }
|
||||
while (arguments.read("-c")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerCamera); }
|
||||
while (arguments.read("-g")) { viewer.setThreadingModel(osgViewer::CompositeViewer::CullDrawThreadPerContext); }
|
||||
while (arguments.read("-c")) { viewer.setThreadingModel(osgViewer::CompositeViewer::CullThreadPerCameraDrawThreadPerContext); }
|
||||
|
||||
// run the viewer's main frame loop
|
||||
return viewer.run();
|
||||
|
||||
15
examples/osgdepthpeeling/CMakeLists.txt
Normal file
15
examples/osgdepthpeeling/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
SET(TARGET_SRC
|
||||
DePee.cpp
|
||||
DePeePass.cpp
|
||||
Utility.cpp
|
||||
osgdepthpeeling.cpp
|
||||
)
|
||||
|
||||
SET(TARGET_H
|
||||
DePee.h
|
||||
DePeePass.h
|
||||
Utility.h
|
||||
)
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgdepthpeeling)
|
||||
669
examples/osgdepthpeeling/DePee.cpp
Normal file
669
examples/osgdepthpeeling/DePee.cpp
Normal file
@@ -0,0 +1,669 @@
|
||||
/*
|
||||
Steffen Frey
|
||||
Fachpraktikum Graphik-Programmierung 2007
|
||||
Institut fuer Visualisierung und Interaktive Systeme
|
||||
Universitaet Stuttgart
|
||||
*/
|
||||
|
||||
//export OSG_NOTIFY_LEVEL=DEBUG_INFO
|
||||
|
||||
#include "DePee.h"
|
||||
|
||||
#include <osg/GLExtensions>
|
||||
#include <osg/Node>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Projection>
|
||||
#include <osg/Geode>
|
||||
|
||||
#include "Utility.h"
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Geometry>
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
|
||||
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 subraph and removing depth peeling steps!!!
|
||||
//That's why it is done here
|
||||
osg::StateSet* stateset = _parent->getOrCreateStateSet();
|
||||
stateset->setTextureAttributeAndModes(1, _normalDepthMap0.get(), osg::StateAttribute::ON);
|
||||
stateset->setTextureAttributeAndModes(2, _normalDepthMap1.get(), osg::StateAttribute::ON);
|
||||
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();
|
||||
|
||||
//render head up display
|
||||
(void) createHUD();
|
||||
}
|
||||
|
||||
DePee::~DePee()
|
||||
{
|
||||
}
|
||||
|
||||
void DePee::setSketchy(bool sketchy)
|
||||
{
|
||||
_sketchy->set(sketchy);
|
||||
_isSketchy = sketchy;
|
||||
}
|
||||
|
||||
void DePee::setCrayon(bool crayon)
|
||||
{
|
||||
if(_isCrayon != crayon)
|
||||
{
|
||||
_isCrayon = crayon;
|
||||
createMap(NOISE_MAP);
|
||||
}
|
||||
}
|
||||
|
||||
void DePee::setSketchiness(double sketchiness)
|
||||
{
|
||||
_sketchiness->set((float)sketchiness);
|
||||
}
|
||||
|
||||
void DePee::setColored(bool colored)
|
||||
{
|
||||
if(colored == !_isColored)
|
||||
{
|
||||
if(colored)
|
||||
{
|
||||
(void) createMap(COLOR_MAP, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dePeePasses.back()->remRenderPass(COLOR_MAP);
|
||||
}
|
||||
_colored->set(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);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dePeePasses.back()->remRenderPass(EDGE_MAP);
|
||||
}
|
||||
|
||||
for(unsigned int i=0; i < n; i++)
|
||||
{
|
||||
addDePeePass();
|
||||
}
|
||||
}
|
||||
_edgy->set(edgy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DePee::setFPS(double* fps)
|
||||
{
|
||||
_fps = fps;
|
||||
}
|
||||
|
||||
unsigned int DePee::getNumberOfRenderPasses()
|
||||
{
|
||||
unsigned int n = 0;
|
||||
for(unsigned int i=0; i < _dePeePasses.size();i++)
|
||||
n += _dePeePasses.at(i)->Cameras.size();
|
||||
// add one pass for final rendering pass and one for hud
|
||||
return n+2;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool DePee::remDePeePass()
|
||||
{
|
||||
if(_dePeePasses.size() < 2)
|
||||
return false;
|
||||
|
||||
_parent->removeChild(_dePeePasses.back()->root.get());
|
||||
delete _dePeePasses.back();
|
||||
_dePeePasses.pop_back();
|
||||
|
||||
_renderToFirst = !_renderToFirst;
|
||||
|
||||
if(_isColored)
|
||||
{
|
||||
(void) createMap(COLOR_MAP, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//create noise map with values ranging from 0 to 255
|
||||
bool DePee::createNoiseMap()
|
||||
{
|
||||
{
|
||||
osg::StateSet* stateset = _parent->getOrCreateStateSet();
|
||||
_noiseMap = new osg::Texture2D;
|
||||
_noiseMap->setTextureSize(_width, _height);
|
||||
_noiseMap->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
|
||||
_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++)
|
||||
data[y*_width + x] = (unsigned char) (0.5 * 255.0 + Utility::getNoise(x, y, random) * 0.5 * 255.0);
|
||||
|
||||
//if style isn't crayon style, smooth the noise map
|
||||
if(!_isCrayon)
|
||||
{
|
||||
for(unsigned i=0; i < 4; i++)
|
||||
{
|
||||
for(unsigned y=0; y < _height; y++)
|
||||
for(unsigned x=0; x < _width; x++)
|
||||
tmpData[y*_width + x] = (unsigned char)Utility::smoothNoise(_width, _height,x,y, data);
|
||||
|
||||
for(unsigned y=0; y < _height; y++)
|
||||
for(unsigned x=0; x < _width; x++)
|
||||
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,
|
||||
osg::Image::USE_NEW_DELETE);
|
||||
_noiseMap->setImage(image);
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
_hudText->setFont(timesFont);
|
||||
_hudText->setPosition(position);
|
||||
_hudText->setText("Head Up Display");
|
||||
_hudText->setColor(osg::Vec4(0.5, 0.5, 0.5, 1.0));
|
||||
_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));
|
||||
vertices->push_back(osg::Vec3(bb.xMin(),bb.yMin(),depth));
|
||||
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);
|
||||
|
||||
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->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);
|
||||
}
|
||||
|
||||
osg::Camera* camera = new osg::Camera;
|
||||
|
||||
// set the projection matrix
|
||||
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
|
||||
|
||||
// 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::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:
|
||||
return createEdgeMap(first);
|
||||
case NOISE_MAP:
|
||||
return createNoiseMap();
|
||||
case NORMAL_DEPTH_MAP:
|
||||
case COLOR_MAP:
|
||||
return createNormalDepthColorMap(mapMode, 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);
|
||||
|
||||
osg::MatrixTransform* screenAlignedModelViewMatrix = new osg::MatrixTransform;
|
||||
screenAlignedModelViewMatrix->setMatrix(osg::Matrix::identity());
|
||||
|
||||
// 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
|
||||
// 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))
|
||||
{
|
||||
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);
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
stateset->addUniform(new osg::Uniform("normalDepthMap", 2));
|
||||
}
|
||||
|
||||
_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 |
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
|
||||
{
|
||||
DePeePass* pass;
|
||||
|
||||
pass = _dePeePasses.back();
|
||||
|
||||
pass->newRenderPass(mapMode);
|
||||
|
||||
//
|
||||
// setup camera
|
||||
//
|
||||
|
||||
// set up the background color and clear mask
|
||||
pass->Cameras[mapMode]->setClearColor(osg::Vec4(0.f,0.f,1.f,1.f));
|
||||
pass->Cameras[mapMode]->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
const osg::BoundingSphere& bs = _subgraph->getBound();
|
||||
if (!bs.valid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float znear = 1.0f*bs.radius();
|
||||
float zfar = 3.0f*bs.radius();
|
||||
|
||||
// 2:1 aspect ratio as per flag geomtry 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));
|
||||
// set viewport
|
||||
pass->Cameras[mapMode]->setViewport(0,0,_texWidth,_texHeight);
|
||||
|
||||
// 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 |
|
||||
osg::StateAttribute::OFF);
|
||||
|
||||
switch(mapMode)
|
||||
{
|
||||
case NORMAL_DEPTH_MAP:
|
||||
|
||||
_renderToFirst = !_renderToFirst;
|
||||
|
||||
if(_renderToFirst)
|
||||
{
|
||||
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _normalDepthMap0.get());
|
||||
stateset->addUniform(new osg::Uniform("normalDepthMap", 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
stateset->addUniform(new osg::Uniform("normalDepthMap", 2));
|
||||
}
|
||||
pass->Cameras[mapMode]->setClearColor(osg::Vec4(1.f,1.f,1.f,1.f));
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool DePee::updateHUDText()
|
||||
{
|
||||
if(!_fps)
|
||||
return false;
|
||||
std::string str;
|
||||
std::string tmp = Utility::toString(*_fps);
|
||||
unsigned i = tmp.find_first_of('.');
|
||||
tmp = tmp.substr(0, i + 3);
|
||||
_hudText->setText(Utility::toString(_dePeePasses.size())
|
||||
+ " Depth Peeling Pass" + (_dePeePasses.size() == 1 ? " " : "es ")
|
||||
+ "((a)dd; (r)emove) "
|
||||
+ (_isEdgy ? "+" : "-") + "(E)dgy " +
|
||||
+ (_isSketchy ? "+" : "-") + "(S)ketchy " +
|
||||
+ (_isColored ? "+" : "-") + "(C)olored " +
|
||||
+ "-> "+Utility::toString(getNumberOfRenderPasses())+ " Rendering Passes "
|
||||
+ "@ "
|
||||
+ tmp + " fps");
|
||||
return true;
|
||||
}
|
||||
170
examples/osgdepthpeeling/DePee.h
Normal file
170
examples/osgdepthpeeling/DePee.h
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
Steffen Frey
|
||||
Fachpraktikum Graphik-Programmierung 2007
|
||||
Institut fuer Visualisierung und Interaktive Systeme
|
||||
Universitaet Stuttgart
|
||||
*/
|
||||
|
||||
#ifndef _DEPEE_H_
|
||||
#define _DEPEE_H_
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Camera>
|
||||
#include <osg/Group>
|
||||
#include <osg/Texture2D>
|
||||
#include <osgText/Text>
|
||||
#include <string>
|
||||
#include <stack>
|
||||
|
||||
#include "DePeePass.h"
|
||||
|
||||
/*!
|
||||
The DePee class is main class for setting up and managing depth peeling.
|
||||
A DePee object can be seen as a virtual node, that has one parent and one child. The rendering of every child and subchil of this child is managed by the the DePee node. Besides that, it handles a head up display.
|
||||
*/
|
||||
class DePee : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
The constructor is initialized by giving it a parent and child node (subgraph), as well as the width and height in pixels of the output window. Additionally a subgraph can be added whose children aren't depth peeled but combined with de depth peeled scene
|
||||
*/
|
||||
DePee(osg::Group* parent, osg::Group* subgraph, unsigned width, unsigned height);
|
||||
/*!
|
||||
Takes care of clean removal of DePee
|
||||
*/
|
||||
~DePee();
|
||||
|
||||
/*!
|
||||
The head up display shows information like internal status and current frames per second. This function needs to be called in the rendering loop to keep the information updated.
|
||||
*/
|
||||
bool updateHUDText();
|
||||
|
||||
/*!
|
||||
Sets whether sketchiness is activated or deactivated
|
||||
*/
|
||||
void setSketchy(bool sketchy);
|
||||
|
||||
/*!
|
||||
If sketchiness is enabled, sets whether a crayon should be used
|
||||
*/
|
||||
void setCrayon(bool crayon);
|
||||
|
||||
/*!
|
||||
Sets whether color display is activated or deactivated
|
||||
*/
|
||||
void setColored(bool colored);
|
||||
|
||||
/*!
|
||||
Sets whether edges are displayed or not
|
||||
*/
|
||||
void setEdgy(bool edgy);
|
||||
|
||||
/*!
|
||||
Sets how sketchy lines and colors should be displayed (standard is 1.0)
|
||||
*/
|
||||
void setSketchiness(double sketchiness);
|
||||
|
||||
/*!
|
||||
Set the pointer to the double variable containing the current fps for displaying it on the head up display
|
||||
*/
|
||||
void setFPS(double* fps);
|
||||
|
||||
/*!
|
||||
Add a depth peeling pass and adjust the render passes accordingly
|
||||
*/
|
||||
bool addDePeePass();
|
||||
|
||||
/*!
|
||||
Remove a depth peeling pass and adjust the render passes accordingly
|
||||
*/
|
||||
bool remDePeePass();
|
||||
|
||||
private:
|
||||
/*!
|
||||
Create a map. This is a function for convenience and calls either
|
||||
createNoiseMap(), createEdgeMap() or createNormalDepthColorMap().
|
||||
Apart from NOISE_MAP, for every texture generation
|
||||
one rendering pass is needed.
|
||||
The boolean first is used to indicate whether this rendering pass
|
||||
belongs to the first depth peeling pass.
|
||||
*/
|
||||
bool createMap(MapMode mapMode, bool first=false);
|
||||
|
||||
/*!
|
||||
Creates a two dimensional noise map and initalizes _noiseMap with it
|
||||
*/
|
||||
bool createNoiseMap();
|
||||
|
||||
/*!
|
||||
Depending on the chosen MapMode, it either creates a new rendering
|
||||
pass for creaeting a normal, depth or color map. The created rendering
|
||||
pass is added to the current depth peeling pass.
|
||||
*/
|
||||
bool createNormalDepthColorMap(MapMode mapMode, bool first);
|
||||
|
||||
/*!
|
||||
Create an edge map. A previous depth and normal rendering pass in this
|
||||
depth peeling pass is required for that.
|
||||
*/
|
||||
bool createEdgeMap(bool first);
|
||||
|
||||
/*!
|
||||
Creates the final rendering pass for depth peeling. Color and edge map are
|
||||
added up here and sketchiness is applied.
|
||||
*/
|
||||
bool createFinal();
|
||||
|
||||
/*!
|
||||
Create the rendering pass for the head up display
|
||||
*/
|
||||
bool createHUD();
|
||||
|
||||
/*
|
||||
Returns the number of rendering passes of the depth peeling object
|
||||
*/
|
||||
unsigned int getNumberOfRenderPasses();
|
||||
|
||||
|
||||
unsigned _texWidth;
|
||||
unsigned _texHeight;
|
||||
unsigned _width;
|
||||
unsigned _height;
|
||||
|
||||
osg::ref_ptr<osg::Group> _parent;
|
||||
osg::ref_ptr<osg::Group> _subgraph;
|
||||
osg::ref_ptr<osg::Texture2D> _noiseMap;
|
||||
osg::ref_ptr<osg::Texture2D> _normalDepthMap0;
|
||||
osg::ref_ptr<osg::Texture2D> _normalDepthMap1;
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> _edgeMap;
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> _colorMap;
|
||||
|
||||
osg::ref_ptr<osg::Geode> _quadGeode;
|
||||
|
||||
osgText::Text* _hudText;
|
||||
double* _fps;
|
||||
|
||||
std::vector<DePeePass*> _dePeePasses;
|
||||
|
||||
osg::Uniform* _sketchy;
|
||||
osg::Uniform* _colored;
|
||||
osg::Uniform* _edgy;
|
||||
osg::Uniform* _sketchiness;
|
||||
|
||||
bool _isSketchy;
|
||||
bool _isColored;
|
||||
bool _isEdgy;
|
||||
bool _isCrayon;
|
||||
|
||||
osg::Camera* _colorCamera;
|
||||
|
||||
//shader programs
|
||||
osg::ref_ptr<osg::Program> _normalDepthMapProgram;
|
||||
osg::ref_ptr<osg::Program> _colorMapProgram;
|
||||
osg::ref_ptr<osg::Program> _edgeMapProgram;
|
||||
|
||||
bool _renderToFirst;
|
||||
};
|
||||
|
||||
#endif
|
||||
49
examples/osgdepthpeeling/DePeePass.cpp
Normal file
49
examples/osgdepthpeeling/DePeePass.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Steffen Frey
|
||||
Fachpraktikum Graphik-Programmierung 2007
|
||||
Institut fuer Visualisierung und Interaktive Systeme
|
||||
Universitaet Stuttgart
|
||||
*/
|
||||
|
||||
#include "DePeePass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
|
||||
DePeePass::DePeePass()
|
||||
{
|
||||
root = new osg::Group;
|
||||
}
|
||||
|
||||
DePeePass::~DePeePass()
|
||||
{
|
||||
root->releaseGLObjects();
|
||||
assert(Cameras.size() == settingNodes.size());
|
||||
while(!Cameras.empty())
|
||||
{
|
||||
remRenderPass((*Cameras.begin()).first);
|
||||
}
|
||||
}
|
||||
|
||||
void DePeePass::newRenderPass(MapMode mapMode)
|
||||
{
|
||||
Cameras[mapMode] = new osg::Camera;
|
||||
settingNodes[mapMode] = new osg::Group;
|
||||
root->addChild(Cameras[mapMode].get());
|
||||
Cameras[mapMode]->addChild(settingNodes[mapMode].get());
|
||||
}
|
||||
|
||||
void DePeePass::remRenderPass(MapMode mapMode)
|
||||
{
|
||||
assert(Cameras.find(mapMode) != Cameras.end());
|
||||
Cameras[mapMode]->releaseGLObjects();
|
||||
settingNodes[mapMode]->releaseGLObjects();
|
||||
|
||||
Cameras[mapMode]->removeChild(settingNodes[mapMode].get());
|
||||
//setting Nodes have exactly one child
|
||||
assert(settingNodes[mapMode]->getNumChildren() == 1);
|
||||
settingNodes[mapMode]->removeChild(0,1);
|
||||
|
||||
Cameras.erase(Cameras.find(mapMode));
|
||||
settingNodes.erase(settingNodes.find(mapMode));
|
||||
}
|
||||
56
examples/osgdepthpeeling/DePeePass.h
Normal file
56
examples/osgdepthpeeling/DePeePass.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Steffen Frey
|
||||
Fachpraktikum Graphik-Programmierung 2007
|
||||
Institut fuer Visualisierung und Interaktive Systeme
|
||||
Universitaet Stuttgart
|
||||
*/
|
||||
|
||||
#ifndef _DEPEEPASS_H_
|
||||
#define _DEPEEPASS_H_
|
||||
|
||||
#include <map>
|
||||
#include <osg/Node>
|
||||
#include <osg/Camera>
|
||||
#include <osg/Group>
|
||||
|
||||
/*!
|
||||
MapMode specifies the kind of texture maps that can be generated for later
|
||||
usage
|
||||
*/
|
||||
enum MapMode {NORMAL_DEPTH_MAP, COLOR_MAP, EDGE_MAP, NOISE_MAP};
|
||||
|
||||
/*!
|
||||
DePeePass can be seen as a mera data structure and typically used by
|
||||
the class DePee. It represents one depth peeling pass and is initialized
|
||||
by functions in the DePee class, but cleans itself up.
|
||||
Please note, that no texture generation mode is allowed to appear twice
|
||||
*/
|
||||
class DePeePass
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructor
|
||||
*/
|
||||
DePeePass();
|
||||
|
||||
/*!
|
||||
Desctructor cleans the whole depth peeling pass
|
||||
*/
|
||||
~DePeePass();
|
||||
|
||||
/*!
|
||||
Make data structure ready for incorporating a new rendering pass
|
||||
*/
|
||||
void newRenderPass(MapMode mapMode);
|
||||
|
||||
/*!
|
||||
Clean up the specified rendering pass
|
||||
*/
|
||||
void remRenderPass(MapMode mapMode);
|
||||
|
||||
osg::ref_ptr<osg::Group> root;
|
||||
std::map<MapMode, osg::ref_ptr<osg::Camera> > Cameras;
|
||||
std::map<MapMode, osg::ref_ptr<osg::Group> > settingNodes;
|
||||
};
|
||||
|
||||
#endif
|
||||
152
examples/osgdepthpeeling/Utility.cpp
Normal file
152
examples/osgdepthpeeling/Utility.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
Steffen Frey
|
||||
Fachpraktikum Graphik-Programmierung 2007
|
||||
Institut fuer Visualisierung und Interaktive Systeme
|
||||
Universitaet Stuttgart
|
||||
*/
|
||||
|
||||
#include "Utility.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Geode>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
bool Utility::readFile(char* fName, std::string& s)
|
||||
{
|
||||
std::string foundFile = osgDB::findDataFile(fName);
|
||||
if (foundFile.empty()) return false;
|
||||
|
||||
std::ifstream is;//(fName);
|
||||
is.open(foundFile.c_str());
|
||||
if (is.fail())
|
||||
{
|
||||
std::cerr << "Could not open " << fName << " for reading.\n";
|
||||
return false;
|
||||
}
|
||||
char ch = is.get();
|
||||
while (!is.eof())
|
||||
{
|
||||
s += ch;
|
||||
ch = is.get();
|
||||
}
|
||||
is.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Utility::toString(double d)
|
||||
{
|
||||
std::stringstream ostr;
|
||||
ostr << d;
|
||||
return ostr.str();
|
||||
}
|
||||
|
||||
osg::Program* Utility::createProgram(std::string vs, std::string fs)
|
||||
{
|
||||
//setup shader
|
||||
std::string vertSource;
|
||||
if(!readFile((char*)vs.c_str(), vertSource))
|
||||
{
|
||||
printf("shader source not found\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string fragSource;
|
||||
if(!readFile((char*)fs.c_str(), fragSource))
|
||||
{
|
||||
printf("shader source not found\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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() ) );
|
||||
return program;
|
||||
}
|
||||
|
||||
double Utility::getNoise(unsigned x, unsigned y, unsigned random)
|
||||
{
|
||||
int n = x + y * 57 + random * 131;
|
||||
n = (n<<13) ^ n;
|
||||
double noise = (1.0f - ( (n * (n * n * 15731 + 789221) +
|
||||
1376312589)&0x7fffffff)* 0.000000000931322574615478515625f);
|
||||
return noise;
|
||||
}
|
||||
|
||||
double Utility::smoothNoise(unsigned width, unsigned height, unsigned x, unsigned y, unsigned char* noise)
|
||||
{
|
||||
assert(noise);
|
||||
|
||||
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]
|
||||
+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)
|
||||
{
|
||||
texture2D->setInternalFormat(GL_RGBA32F_ARB);
|
||||
texture2D->setSourceFormat(GL_RGBA);
|
||||
}
|
||||
else if(accuracy == 8)
|
||||
{
|
||||
texture2D->setInternalFormat(GL_RGBA);
|
||||
}
|
||||
texture2D->setSourceType(GL_FLOAT);
|
||||
texture2D->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
|
||||
texture2D->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
|
||||
return texture2D;
|
||||
}
|
||||
|
||||
osg::Geode* Utility::getCanvasQuad(unsigned width, unsigned height, double depth)
|
||||
{
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array;
|
||||
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);
|
||||
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
geode->addDrawable(quad);
|
||||
|
||||
return geode;
|
||||
|
||||
}
|
||||
57
examples/osgdepthpeeling/Utility.h
Normal file
57
examples/osgdepthpeeling/Utility.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Steffen Frey
|
||||
Fachpraktikum Graphik-Programmierung 2007
|
||||
Institut fuer Visualisierung und Interaktive Systeme
|
||||
Universitaet Stuttgart
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _UTILITY_H_
|
||||
#define _UTILITY_H_
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <osg/Program>
|
||||
#include <osg/Texture2D>
|
||||
|
||||
namespace Utility
|
||||
{
|
||||
/*!
|
||||
Reads a file and returns a string
|
||||
*/
|
||||
bool readFile(char* fName, std::string& s);
|
||||
|
||||
/*!
|
||||
Converts a number to a string
|
||||
*/
|
||||
std::string toString(double d);
|
||||
|
||||
/*!
|
||||
Create a osg shader program consisting of a vertex shader and a
|
||||
fragment shader
|
||||
*/
|
||||
osg::Program* createProgram(std::string vs, std::string fs);
|
||||
|
||||
/*!
|
||||
This is a random generator to generate noise patterns.
|
||||
The returned values range from -1 to 1
|
||||
*/
|
||||
double getNoise(unsigned x, unsigned y, unsigned random);
|
||||
|
||||
/*!
|
||||
Returns a smoothed noise version of the value that is read from the noise
|
||||
texture
|
||||
*/
|
||||
double smoothNoise(unsigned width, unsigned height, unsigned x, unsigned y, unsigned char* noise);
|
||||
|
||||
/*!
|
||||
Creates a two dimensional color texture and apply some standard settings
|
||||
*/
|
||||
osg::Texture2D* newColorTexture2D(unsigned width, unsigned height, unsigned accuracy);
|
||||
|
||||
/*!
|
||||
Get a quad with screen size in order to show a texture full screen
|
||||
*/
|
||||
osg::Geode* getCanvasQuad(unsigned width, unsigned height, double depth=-1);
|
||||
}
|
||||
#endif
|
||||
328
examples/osgdepthpeeling/osgdepthpeeling.cpp
Normal file
328
examples/osgdepthpeeling/osgdepthpeeling.cpp
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
Steffen Frey
|
||||
Fachpraktikum Graphik-Programmierung 2007
|
||||
Institut fuer Visualisierung und Interaktive Systeme
|
||||
Universitaet Stuttgart
|
||||
*/
|
||||
|
||||
#include <osg/GLExtensions>
|
||||
#include <osg/Node>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Notify>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/AnimationPath>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "DePee.h"
|
||||
|
||||
/*!
|
||||
Handles keyboard events.
|
||||
Maintains a copy of the DePee object and part of its internal state
|
||||
Used for example to set sketchiness, color, add or remove a depth peeling pass
|
||||
*/
|
||||
class KeyboardEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
KeyboardEventHandler(DePee* dePee)
|
||||
{
|
||||
_apc = 0;
|
||||
_dePee = dePee;
|
||||
_sketchy = false;
|
||||
_sketchiness = 1.0;
|
||||
_colored = false;
|
||||
_edgy = true;
|
||||
_crayon = false;
|
||||
_dePee->setSketchy(_sketchy);
|
||||
_dePee->setColored(_colored);
|
||||
}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
|
||||
{
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Space)
|
||||
{
|
||||
if(_apc)
|
||||
_apc->setPause(!_apc->getPause());
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 'a')
|
||||
{
|
||||
_dePee->addDePeePass();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 'r')
|
||||
{
|
||||
_dePee->remDePeePass();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 'c')
|
||||
{
|
||||
_colored = !_colored;
|
||||
_dePee->setColored(_colored);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 's')
|
||||
{
|
||||
_sketchy = !_sketchy;
|
||||
_dePee->setSketchy(_sketchy);
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (ea.getKey() == 'e')
|
||||
{
|
||||
_edgy = !_edgy;
|
||||
_dePee->setEdgy(_edgy);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 'f')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == '+')
|
||||
{
|
||||
_sketchiness += 0.5;
|
||||
_dePee->setSketchiness(_sketchiness);
|
||||
}
|
||||
else if (ea.getKey() == '-')
|
||||
{
|
||||
_sketchiness -= 0.5;
|
||||
if(_sketchiness < 0.0)
|
||||
_sketchiness = 0.0;
|
||||
_dePee->setSketchiness(_sketchiness);
|
||||
}
|
||||
|
||||
else if (ea.getKey() == 'y')
|
||||
{
|
||||
_crayon = !_crayon;
|
||||
_dePee->setCrayon(_crayon);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void registerAnimationPathCallback(osg::AnimationPathCallback* apc)
|
||||
{
|
||||
_apc = apc;
|
||||
}
|
||||
private:
|
||||
DePee* _dePee;
|
||||
bool _sketchy;
|
||||
bool _colored;
|
||||
bool _edgy;
|
||||
bool _crayon;
|
||||
double _sketchiness;
|
||||
osg::AnimationPathCallback* _apc;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
Handles mouse events.
|
||||
Maintains a copy of the DePee object and part of its internal state
|
||||
Used to rotate the object
|
||||
*/
|
||||
class MouseEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
MouseEventHandler(DePee* dePee)
|
||||
{
|
||||
_dePee = dePee;
|
||||
}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
|
||||
{
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
//mouse
|
||||
case(osgGA::GUIEventAdapter::DRAG):
|
||||
{
|
||||
rotate(ea.getXnormalized(), ea.getYnormalized());
|
||||
break;
|
||||
}
|
||||
case(osgGA::GUIEventAdapter::MOVE):
|
||||
_prevX = ea.getXnormalized();
|
||||
_prevY = ea.getYnormalized();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void registerModelGroupTransform(osg::MatrixTransform* modelGroupTransform)
|
||||
{
|
||||
_modelGroupTransform = modelGroupTransform;
|
||||
_rotCenter = modelGroupTransform->getBound().center();
|
||||
}
|
||||
private:
|
||||
void rotate(float x, float y)
|
||||
{
|
||||
osg::Matrixd baseMatrix = _modelGroupTransform->getMatrix();
|
||||
|
||||
osg::Matrixd preTransMatrix;
|
||||
osg::Matrixd postTransMatrix;
|
||||
osg::Matrixd rotMatrixX;
|
||||
osg::Matrixd rotMatrixZ;
|
||||
|
||||
preTransMatrix.makeTranslate(_rotCenter);
|
||||
postTransMatrix.makeTranslate(-_rotCenter);
|
||||
|
||||
rotMatrixZ.makeRotate((x - _prevX) * 3., osg::Vec3d(0.0, 0.0,1.0));
|
||||
|
||||
baseMatrix.preMult(preTransMatrix);
|
||||
baseMatrix.preMult(rotMatrixZ);
|
||||
baseMatrix.preMult(postTransMatrix);
|
||||
|
||||
rotMatrixX.makeRotate(-(y - _prevY) * 3., (baseMatrix * osg::Vec3d(1.0, 0.0,0.0)));
|
||||
|
||||
baseMatrix.preMult(preTransMatrix);
|
||||
baseMatrix.preMult(rotMatrixX);
|
||||
baseMatrix.preMult(postTransMatrix);
|
||||
|
||||
_modelGroupTransform->setMatrix(baseMatrix);
|
||||
|
||||
_prevX = x;
|
||||
_prevY = y;
|
||||
};
|
||||
|
||||
DePee* _dePee;
|
||||
|
||||
float _prevX;
|
||||
float _prevY;
|
||||
|
||||
osg::Vec3 _rotCenter;
|
||||
osg::MatrixTransform* _modelGroupTransform;
|
||||
};
|
||||
|
||||
|
||||
|
||||
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()->setDescription(arguments.getApplicationName()+" is the example which demonstrates Depth Peeling");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" filename");
|
||||
|
||||
|
||||
// construct the viewer
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
// any option left unread are converted into errors to write out later.
|
||||
arguments.reportRemainingOptionsAsUnrecognized();
|
||||
|
||||
// report any errors if they have occured when parsing the program aguments.
|
||||
if (arguments.errors())
|
||||
{
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arguments.argc()<=1 || arguments.argc() > 3)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//only displays a textured quad
|
||||
viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
|
||||
// read the model to do depth peeling with
|
||||
osg::Node* loadedModel = osgDB::readNodeFile(arguments.argv()[1]);
|
||||
|
||||
if (!loadedModel)
|
||||
return 1;
|
||||
|
||||
// create a transform to spin the model.
|
||||
osg::MatrixTransform* modelGroupTransform = new osg::MatrixTransform;
|
||||
osg::Group* modelGroup = new osg::Group;
|
||||
modelGroupTransform->addChild(modelGroup);
|
||||
modelGroup->addChild(loadedModel);
|
||||
|
||||
osg::Group* rootNode = new osg::Group();
|
||||
|
||||
// add model to the viewer.
|
||||
viewer.setSceneData(rootNode);
|
||||
|
||||
// Depth peel example only works on a single graphics context right now
|
||||
// so open up viewer on single screen to prevent problems
|
||||
viewer.setUpViewOnSingleScreen(0);
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
unsigned int width = 1280;
|
||||
unsigned int height = 1280;
|
||||
osgViewer::Viewer::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
if (!windows.empty())
|
||||
{
|
||||
width = windows.front()->getTraits()->width;
|
||||
height = windows.front()->getTraits()->height;
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<DePee> dePee = new DePee(rootNode,
|
||||
modelGroupTransform,
|
||||
width,
|
||||
height);
|
||||
|
||||
//create event handlers
|
||||
KeyboardEventHandler* keyboardEventHandler = new KeyboardEventHandler(dePee.get());
|
||||
MouseEventHandler* mouseEventHandler = new MouseEventHandler(dePee.get());
|
||||
viewer.addEventHandler(keyboardEventHandler);
|
||||
viewer.addEventHandler(mouseEventHandler);
|
||||
|
||||
//viewer.setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
osg::StateSet* stateset = modelGroupTransform->getOrCreateStateSet();
|
||||
|
||||
stateset->setMode(GL_BLEND, osg::StateAttribute::OFF);
|
||||
|
||||
//create new animation callback for autmatic object rotation
|
||||
osg::AnimationPathCallback* apc = new osg::AnimationPathCallback(modelGroupTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
||||
apc->setPause(true);
|
||||
modelGroupTransform->setUpdateCallback(apc);
|
||||
|
||||
keyboardEventHandler->registerAnimationPathCallback(apc);
|
||||
mouseEventHandler->registerModelGroupTransform(modelGroupTransform);
|
||||
|
||||
//setup stuff that is necessary for measuring fps
|
||||
osg::Timer_t current_tick, previous_tick = 1;
|
||||
double* fps = new double;
|
||||
dePee->setFPS(fps);
|
||||
|
||||
while(!viewer.done())
|
||||
{
|
||||
current_tick = osg::Timer::instance()->tick();
|
||||
|
||||
*fps = 1.0/osg::Timer::instance()->delta_s(previous_tick,current_tick);
|
||||
dePee->updateHUDText();
|
||||
|
||||
previous_tick = current_tick;
|
||||
|
||||
// fire off the cull and draw traversals of the scene.
|
||||
viewer.frame();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgdepthshadow.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgShadow )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgdepthshadow)
|
||||
@@ -1,521 +0,0 @@
|
||||
/* OpenSceneGraph example, osgdepthshadow.
|
||||
*
|
||||
* 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 <osgViewer/Viewer>
|
||||
|
||||
#include <osg/Projection>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexGen>
|
||||
#include <osg/Geode>
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/PolygonOffset>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Light>
|
||||
#include <osg/LightSource>
|
||||
#include <osg/PolygonOffset>
|
||||
#include <osg/CullFace>
|
||||
#include <osg/Material>
|
||||
#include <osg/TexEnvCombine>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/AnimationPath>
|
||||
#include <osg/TexGenNode>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgShadow/ShadowedScene>
|
||||
#include <osgShadow/ShadowMap>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
class LightTransformCallback: public osg::NodeCallback
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
LightTransformCallback(float angular_velocity, float height, float radius):
|
||||
_angular_velocity(angular_velocity),
|
||||
_height(height),
|
||||
_radius(radius),
|
||||
_previous_traversal_number(-1),
|
||||
_previous_time(-1.0f),
|
||||
_angle(0)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(Node* node, NodeVisitor* nv);
|
||||
|
||||
protected:
|
||||
|
||||
float _angular_velocity;
|
||||
float _height;
|
||||
float _radius;
|
||||
int _previous_traversal_number;
|
||||
double _previous_time;
|
||||
float _angle;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
LightTransformCallback::operator()(Node* node, NodeVisitor* nv)
|
||||
{
|
||||
MatrixTransform* transform = dynamic_cast<MatrixTransform*>(node);
|
||||
if (nv && transform)
|
||||
{
|
||||
const FrameStamp* fs = nv->getFrameStamp();
|
||||
if (!fs) return; // not frame stamp, no handle on the time so can't move.
|
||||
|
||||
double new_time = fs->getSimulationTime();
|
||||
if (nv->getTraversalNumber() != _previous_traversal_number)
|
||||
{
|
||||
_angle += _angular_velocity * (new_time - _previous_time);
|
||||
|
||||
Matrix matrix = Matrix::rotate(atan(_height / _radius), -X_AXIS) *
|
||||
Matrix::rotate(PI_2, Y_AXIS) *
|
||||
Matrix::translate(Vec3(_radius, 0, 0)) *
|
||||
Matrix::rotate(_angle, Y_AXIS) *
|
||||
Matrix::translate(Vec3(0, _height, 0));
|
||||
|
||||
// update the specified transform
|
||||
transform->setMatrix(matrix);
|
||||
|
||||
_previous_traversal_number = nv->getTraversalNumber();
|
||||
}
|
||||
|
||||
_previous_time = new_time;
|
||||
}
|
||||
|
||||
// must call any nested node callbacks and continue subgraph traversal.
|
||||
traverse(node,nv);
|
||||
|
||||
}
|
||||
|
||||
|
||||
ref_ptr<MatrixTransform> _create_lights()
|
||||
{
|
||||
ref_ptr<MatrixTransform> transform_0 = new MatrixTransform;
|
||||
|
||||
// create a spot light.
|
||||
ref_ptr<Light> light_0 = new Light;
|
||||
light_0->setLightNum(0);
|
||||
light_0->setPosition(Vec4(0, 0, 0, 1.0f));
|
||||
light_0->setAmbient(Vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
light_0->setDiffuse(Vec4(1.0f, 0.8f, 0.8f, 1.0f));
|
||||
light_0->setSpotCutoff(60.0f);
|
||||
light_0->setSpotExponent(2.0f);
|
||||
|
||||
ref_ptr<LightSource> light_source_0 = new LightSource;
|
||||
light_source_0->setLight(light_0.get());
|
||||
light_source_0->setLocalStateSetModes(StateAttribute::ON);
|
||||
transform_0->setUpdateCallback(new LightTransformCallback(inDegrees(90.0f), 8, 5));
|
||||
transform_0->addChild(light_source_0.get());
|
||||
|
||||
ref_ptr<Geode> geode = new Geode;
|
||||
|
||||
ref_ptr<ShapeDrawable> shape;
|
||||
ref_ptr<TessellationHints> hints = new TessellationHints;
|
||||
hints->setDetailRatio(0.3f);
|
||||
shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 0.0f), 0.15f), hints.get());
|
||||
shape->setColor(Vec4(1.0f, 0.5f, 0.5f, 1.0f));
|
||||
geode->addDrawable(shape.get());
|
||||
shape = new ShapeDrawable(new Cylinder(Vec3(0.0f, 0.0f, -0.4f), 0.05f, 0.8f), hints.get());
|
||||
shape->setColor(Vec4(1.0f, 0.5f, 0.5f, 1.0f));
|
||||
geode->addDrawable(shape.get());
|
||||
|
||||
|
||||
geode->getOrCreateStateSet()->setMode(GL_LIGHTING, StateAttribute::OFF);
|
||||
transform_0->addChild(geode.get());
|
||||
|
||||
return transform_0;
|
||||
}
|
||||
|
||||
ref_ptr<Group> _create_scene()
|
||||
{
|
||||
ref_ptr<Group> scene = new Group;
|
||||
ref_ptr<Geode> geode_1 = new Geode;
|
||||
scene->addChild(geode_1.get());
|
||||
|
||||
ref_ptr<Geode> geode_2 = new Geode;
|
||||
ref_ptr<MatrixTransform> transform_2 = new MatrixTransform;
|
||||
transform_2->addChild(geode_2.get());
|
||||
transform_2->setUpdateCallback(new osg::AnimationPathCallback(Vec3(0, 0, 0), Y_AXIS, inDegrees(45.0f)));
|
||||
scene->addChild(transform_2.get());
|
||||
|
||||
ref_ptr<Geode> geode_3 = new Geode;
|
||||
ref_ptr<MatrixTransform> transform_3 = new MatrixTransform;
|
||||
transform_3->addChild(geode_3.get());
|
||||
transform_3->setUpdateCallback(new osg::AnimationPathCallback(Vec3(0, 0, 0), Y_AXIS, inDegrees(-22.5f)));
|
||||
scene->addChild(transform_3.get());
|
||||
|
||||
const float radius = 0.8f;
|
||||
const float height = 1.0f;
|
||||
ref_ptr<TessellationHints> hints = new TessellationHints;
|
||||
hints->setDetailRatio(2.0f);
|
||||
ref_ptr<ShapeDrawable> shape;
|
||||
|
||||
shape = new ShapeDrawable(new Box(Vec3(0.0f, -2.0f, 0.0f), 10, 0.1f, 10), hints.get());
|
||||
shape->setColor(Vec4(0.5f, 0.5f, 0.7f, 1.0f));
|
||||
geode_1->addDrawable(shape.get());
|
||||
|
||||
shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 0.0f), radius * 2), hints.get());
|
||||
shape->setColor(Vec4(0.8f, 0.8f, 0.8f, 1.0f));
|
||||
geode_1->addDrawable(shape.get());
|
||||
|
||||
shape = new ShapeDrawable(new Sphere(Vec3(-3.0f, 0.0f, 0.0f), radius), hints.get());
|
||||
shape->setColor(Vec4(0.6f, 0.8f, 0.8f, 1.0f));
|
||||
geode_2->addDrawable(shape.get());
|
||||
|
||||
shape = new ShapeDrawable(new Box(Vec3(3.0f, 0.0f, 0.0f), 2 * radius), hints.get());
|
||||
shape->setColor(Vec4(0.4f, 0.9f, 0.3f, 1.0f));
|
||||
geode_2->addDrawable(shape.get());
|
||||
|
||||
shape = new ShapeDrawable(new Cone(Vec3(0.0f, 0.0f, -3.0f), radius, height), hints.get());
|
||||
shape->setColor(Vec4(0.2f, 0.5f, 0.7f, 1.0f));
|
||||
geode_2->addDrawable(shape.get());
|
||||
|
||||
shape = new ShapeDrawable(new Cylinder(Vec3(0.0f, 0.0f, 3.0f), radius, height), hints.get());
|
||||
shape->setColor(Vec4(1.0f, 0.3f, 0.3f, 1.0f));
|
||||
geode_2->addDrawable(shape.get());
|
||||
|
||||
shape = new ShapeDrawable(new Box(Vec3(0.0f, 3.0f, 0.0f), 2, 0.1f, 2), hints.get());
|
||||
shape->setColor(Vec4(0.8f, 0.8f, 0.4f, 1.0f));
|
||||
geode_3->addDrawable(shape.get());
|
||||
|
||||
// material
|
||||
ref_ptr<Material> matirial = new Material;
|
||||
matirial->setColorMode(Material::DIFFUSE);
|
||||
matirial->setAmbient(Material::FRONT_AND_BACK, Vec4(0, 0, 0, 1));
|
||||
matirial->setSpecular(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
|
||||
matirial->setShininess(Material::FRONT_AND_BACK, 64.0f);
|
||||
scene->getOrCreateStateSet()->setAttributeAndModes(matirial.get(), StateAttribute::ON);
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
|
||||
class UpdateCameraAndTexGenCallback : public osg::NodeCallback
|
||||
{
|
||||
public:
|
||||
|
||||
UpdateCameraAndTexGenCallback(osg::MatrixTransform* light_transform, osg::Camera* Camera, osg::TexGenNode* texgenNode):
|
||||
_light_transform(light_transform),
|
||||
_Camera(Camera),
|
||||
_texgenNode(texgenNode)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
// first update subgraph to make sure objects are all moved into postion
|
||||
traverse(node,nv);
|
||||
|
||||
// now compute the camera's view and projection matrix to point at the shadower (the camera's children)
|
||||
osg::BoundingSphere bs;
|
||||
for(unsigned int i=0; i<_Camera->getNumChildren(); ++i)
|
||||
{
|
||||
bs.expandBy(_Camera->getChild(i)->getBound());
|
||||
}
|
||||
|
||||
if (!bs.valid())
|
||||
{
|
||||
osg::notify(osg::WARN) << "bb invalid"<<_Camera.get()<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
osg::Vec3 position = _light_transform->getMatrix().getTrans();
|
||||
|
||||
float centerDistance = (position-bs.center()).length();
|
||||
|
||||
float znear = centerDistance-bs.radius();
|
||||
float zfar = centerDistance+bs.radius();
|
||||
float zNearRatio = 0.001f;
|
||||
if (znear<zfar*zNearRatio) znear = zfar*zNearRatio;
|
||||
|
||||
#if 0
|
||||
// hack to illustrate the precision problems of excessive gap between near far range.
|
||||
znear = 0.00001*zfar;
|
||||
#endif
|
||||
float top = (bs.radius()/centerDistance)*znear;
|
||||
float right = top;
|
||||
|
||||
_Camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
|
||||
_Camera->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
|
||||
_Camera->setViewMatrixAsLookAt(position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f));
|
||||
|
||||
// compute the matrix which takes a vertex from local coords into tex coords
|
||||
// will use this later to specify osg::TexGen..
|
||||
osg::Matrix MVPT = _Camera->getViewMatrix() *
|
||||
_Camera->getProjectionMatrix() *
|
||||
osg::Matrix::translate(1.0,1.0,1.0) *
|
||||
osg::Matrix::scale(0.5f,0.5f,0.5f);
|
||||
|
||||
_texgenNode->getTexGen()->setMode(osg::TexGen::EYE_LINEAR);
|
||||
_texgenNode->getTexGen()->setPlanesFromMatrix(MVPT);
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~UpdateCameraAndTexGenCallback() {}
|
||||
|
||||
osg::ref_ptr<osg::MatrixTransform> _light_transform;
|
||||
osg::ref_ptr<osg::Camera> _Camera;
|
||||
osg::ref_ptr<osg::TexGenNode> _texgenNode;
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// fragment shader
|
||||
//
|
||||
char fragmentShaderSource_noBaseTexture[] =
|
||||
"uniform sampler2DShadow shadowTexture; \n"
|
||||
"uniform vec2 ambientBias; \n"
|
||||
"\n"
|
||||
"void main(void) \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = gl_Color * (ambientBias.x + shadow2DProj( shadowTexture, gl_TexCoord[0] ) * ambientBias.y); \n"
|
||||
"}\n";
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// fragment shader
|
||||
//
|
||||
char fragmentShaderSource_withBaseTexture[] =
|
||||
"uniform sampler2D baseTexture; \n"
|
||||
"uniform sampler2DShadow shadowTexture; \n"
|
||||
"uniform vec2 ambientBias; \n"
|
||||
"\n"
|
||||
"void main(void) \n"
|
||||
"{ \n"
|
||||
" vec4 color = gl_Color * texture2D( baseTexture, gl_TexCoord[0].xy ); \n"
|
||||
" gl_FragColor = color * (ambientBias.x + shadow2DProj( shadowTexture, gl_TexCoord[1] ) * ambientBias.y); \n"
|
||||
"}\n";
|
||||
|
||||
|
||||
osg::Group* createShadowedScene(osg::Node* shadowed,osg::MatrixTransform* light_transform, unsigned int unit)
|
||||
{
|
||||
osg::Group* group = 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_DEPTH_COMPONENT);
|
||||
texture->setShadowComparison(true);
|
||||
texture->setShadowTextureMode(Texture::LUMINANCE);
|
||||
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.
|
||||
{
|
||||
|
||||
// create the camera
|
||||
osg::Camera* camera = new osg::Camera;
|
||||
|
||||
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
|
||||
camera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
|
||||
// set viewport
|
||||
camera->setViewport(0,0,tex_width,tex_height);
|
||||
|
||||
osg::StateSet* _local_stateset = camera->getOrCreateStateSet();
|
||||
|
||||
_local_stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
|
||||
|
||||
float factor = 0.0f;
|
||||
float units = 1.0f;
|
||||
|
||||
ref_ptr<PolygonOffset> polygon_offset = new PolygonOffset;
|
||||
polygon_offset->setFactor(factor);
|
||||
polygon_offset->setUnits(units);
|
||||
_local_stateset->setAttribute(polygon_offset.get(), StateAttribute::ON | StateAttribute::OVERRIDE);
|
||||
_local_stateset->setMode(GL_POLYGON_OFFSET_FILL, StateAttribute::ON | StateAttribute::OVERRIDE);
|
||||
|
||||
ref_ptr<CullFace> cull_face = new CullFace;
|
||||
cull_face->setMode(CullFace::FRONT);
|
||||
_local_stateset->setAttribute(cull_face.get(), StateAttribute::ON | StateAttribute::OVERRIDE);
|
||||
_local_stateset->setMode(GL_CULL_FACE, StateAttribute::ON | StateAttribute::OVERRIDE);
|
||||
|
||||
|
||||
// set the camera to render before the main camera.
|
||||
camera->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||
|
||||
// tell the camera to use OpenGL frame buffer object where supported.
|
||||
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
|
||||
|
||||
// attach the texture and use it as the color buffer.
|
||||
camera->attach(osg::Camera::DEPTH_BUFFER, texture);
|
||||
|
||||
// add subgraph to render
|
||||
camera->addChild(shadowed);
|
||||
|
||||
group->addChild(camera);
|
||||
|
||||
// create the texgen node to project the tex coords onto the subgraph
|
||||
osg::TexGenNode* texgenNode = new osg::TexGenNode;
|
||||
texgenNode->setTextureUnit(unit);
|
||||
group->addChild(texgenNode);
|
||||
|
||||
// set an update callback to keep moving the camera and tex gen in the right direction.
|
||||
group->setUpdateCallback(new UpdateCameraAndTexGenCallback(light_transform, camera, texgenNode));
|
||||
}
|
||||
|
||||
|
||||
// set the shadowed subgraph so that it uses the texture and tex gen settings.
|
||||
{
|
||||
osg::Group* shadowedGroup = new osg::Group;
|
||||
shadowedGroup->addChild(shadowed);
|
||||
group->addChild(shadowedGroup);
|
||||
|
||||
osg::StateSet* stateset = shadowedGroup->getOrCreateStateSet();
|
||||
stateset->setTextureAttributeAndModes(unit,texture,osg::StateAttribute::ON);
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_S,osg::StateAttribute::ON);
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_T,osg::StateAttribute::ON);
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_R,osg::StateAttribute::ON);
|
||||
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_Q,osg::StateAttribute::ON);
|
||||
|
||||
osg::Program* program = new osg::Program;
|
||||
stateset->setAttribute(program);
|
||||
|
||||
if (unit==0)
|
||||
{
|
||||
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource_noBaseTexture);
|
||||
program->addShader(fragment_shader);
|
||||
|
||||
osg::Uniform* shadowTextureSampler = new osg::Uniform("shadowTexture",(int)unit);
|
||||
stateset->addUniform(shadowTextureSampler);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource_withBaseTexture);
|
||||
program->addShader(fragment_shader);
|
||||
|
||||
osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0);
|
||||
stateset->addUniform(baseTextureSampler);
|
||||
|
||||
osg::Uniform* shadowTextureSampler = new osg::Uniform("shadowTexture",(int)unit);
|
||||
stateset->addUniform(shadowTextureSampler);
|
||||
}
|
||||
|
||||
osg::Uniform* ambientBias = new osg::Uniform("ambientBias",osg::Vec2(0.3f,1.2f));
|
||||
stateset->addUniform(ambientBias);
|
||||
|
||||
}
|
||||
|
||||
// add the shadower and shadowed.
|
||||
group->addChild(light_transform);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
ArgumentParser arguments(&argc, argv);
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " is the example which demonstrates using of GL_ARB_shadow extension implemented in osg::Texture class");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help", "Display this information");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--with-base-texture", "Adde base texture to shadowed model.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--no-base-texture", "Adde base texture to shadowed model.");
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
bool withBaseTexture = true;
|
||||
while(arguments.read("--with-base-texture")) { withBaseTexture = true; }
|
||||
while(arguments.read("--no-base-texture")) { withBaseTexture = false; }
|
||||
|
||||
// if user request help write it out to cout.
|
||||
if (arguments.read("-h") || arguments.read("--help"))
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.read("--sm"))
|
||||
{
|
||||
osgShadow::ShadowMap* sm = new osgShadow::ShadowMap;
|
||||
sm->setTextureUnit( withBaseTexture ? 1 : 0 );
|
||||
|
||||
osg::ref_ptr<osgShadow::ShadowedScene> shadowedScene = new osgShadow::ShadowedScene(sm);
|
||||
|
||||
|
||||
ref_ptr<Group> created_scene = _create_scene();
|
||||
if (!created_scene.valid()) return 1;
|
||||
|
||||
shadowedScene->addChild(_create_scene().get());
|
||||
|
||||
|
||||
ref_ptr<MatrixTransform> scene = new MatrixTransform;
|
||||
scene->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(125.0),1.0,0.0,0.0));
|
||||
|
||||
scene->addChild(_create_lights().get());
|
||||
scene->addChild(shadowedScene.get());
|
||||
|
||||
if (withBaseTexture)
|
||||
{
|
||||
scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")), osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
viewer.setSceneData(scene.get());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ref_ptr<MatrixTransform> scene = new MatrixTransform;
|
||||
scene->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(125.0),1.0,0.0,0.0));
|
||||
|
||||
ref_ptr<Group> created_scene = _create_scene();
|
||||
if (!created_scene.valid()) return 1;
|
||||
|
||||
ref_ptr<MatrixTransform> light_transform = _create_lights();
|
||||
if (!light_transform.valid()) return 1;
|
||||
|
||||
ref_ptr<Group> shadowedScene;
|
||||
|
||||
if (withBaseTexture)
|
||||
{
|
||||
scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")), osg::StateAttribute::ON);
|
||||
shadowedScene = createShadowedScene(created_scene.get(),light_transform.get(),1);
|
||||
}
|
||||
else
|
||||
{
|
||||
shadowedScene = createShadowedScene(created_scene.get(),light_transform.get(),0);
|
||||
}
|
||||
|
||||
scene->addChild(shadowedScene.get());
|
||||
|
||||
viewer.setSceneData(scene.get());
|
||||
}
|
||||
|
||||
// viewer.setUpViewOnSingleScreen();
|
||||
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
@@ -698,6 +698,16 @@ int main(int argc, char** argv)
|
||||
viewer.setSceneData( distortionNode );
|
||||
}
|
||||
|
||||
while (arguments.read("--sky-light"))
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
// load the nodes from the commandline arguments.
|
||||
if (!viewer.getSceneData())
|
||||
|
||||
@@ -38,9 +38,9 @@ std::string createLibraryNameForWrapper(const std::string& ext)
|
||||
#if defined(WIN32)
|
||||
// !! recheck evolving Cygwin DLL extension naming protocols !! NHV
|
||||
#ifdef __CYGWIN__
|
||||
return "cygosgwrapper_"+ext+".dll";
|
||||
return "cygwin_osgwrapper_"+ext+".dll";
|
||||
#elif defined(__MINGW32__)
|
||||
return "libosgwrapper_"+ext+".dll";
|
||||
return "mingw_osgwrapper_"+ext+".dll";
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
return "osgwrapper_"+ext+"d.dll";
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osg/MatrixTransform>
|
||||
@@ -358,6 +359,7 @@ void KeyboardModel::createKeyboard()
|
||||
|
||||
|
||||
|
||||
|
||||
class KeyboardEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
@@ -367,6 +369,34 @@ public:
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
|
||||
{
|
||||
|
||||
#if 1
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Mouse "<<ea.getButtonMask()<<std::endl;
|
||||
|
||||
#define PRINT(mask) osg::notify(osg::NOTICE)<<#mask<<" ="<<(ea.getModKeyMask() & mask)<<std::endl;
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
case(osgGA::GUIEventAdapter::KEYUP):
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<std::endl;
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_SHIFT);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_SHIFT);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_ALT);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_ALT);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_CTRL);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_CTRL);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_META);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_META);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_NUM_LOCK);
|
||||
PRINT(osgGA::GUIEventAdapter::MODKEY_CAPS_LOCK);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
@@ -395,6 +425,8 @@ int main(int , char **)
|
||||
|
||||
osg::ref_ptr<KeyboardModel> keyboardModel = new KeyboardModel;
|
||||
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
|
||||
viewer.addEventHandler(new KeyboardEventHandler(keyboardModel.get()));
|
||||
viewer.setSceneData( keyboardModel->getScene() );
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ int runApp(std::string xapp)
|
||||
} // end printList()
|
||||
|
||||
|
||||
void readConfFile(char* confFile) // read confFile 1
|
||||
void readConfFile(const char* confFile) // read confFile 1
|
||||
{
|
||||
osg::notify(osg::INFO) << "Start reading confFile" << std::endl;
|
||||
|
||||
@@ -418,6 +418,7 @@ int main( int argc, char **argv )
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osg::ref_ptr<osgText::Text> updateText = new osgText::Text;
|
||||
updateText->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
// add the handler for doing the picking
|
||||
viewer.addEventHandler(new PickHandler(&viewer,updateText.get()));
|
||||
|
||||
@@ -267,14 +267,16 @@ void MovieEventHandler::getUsage(osg::ApplicationUsage& usage) const
|
||||
}
|
||||
|
||||
|
||||
osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,float height, osg::Image* image, bool useTextureRectangle)
|
||||
osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,float height, osg::Image* image, bool useTextureRectangle, bool xyPlane, bool option_flip)
|
||||
{
|
||||
bool flip = image->getOrigin()==osg::Image::TOP_LEFT;
|
||||
if (option_flip) flip = !flip;
|
||||
|
||||
if (useTextureRectangle)
|
||||
{
|
||||
osg::Geometry* pictureQuad = osg::createTexturedQuadGeometry(pos,
|
||||
osg::Vec3(width,0.0f,0.0f),
|
||||
osg::Vec3(0.0f,0.0f,height),
|
||||
xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height),
|
||||
0.0f, flip ? image->t() : 0.0, image->s(), flip ? 0.0 : image->t());
|
||||
|
||||
osg::TextureRectangle* texture = new osg::TextureRectangle(image);
|
||||
@@ -292,7 +294,7 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo
|
||||
{
|
||||
osg::Geometry* pictureQuad = osg::createTexturedQuadGeometry(pos,
|
||||
osg::Vec3(width,0.0f,0.0f),
|
||||
osg::Vec3(0.0f,0.0f,height),
|
||||
xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height),
|
||||
0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f);
|
||||
|
||||
osg::Texture2D* texture = new osg::Texture2D(image);
|
||||
@@ -309,324 +311,6 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo
|
||||
}
|
||||
}
|
||||
|
||||
class DomeModel
|
||||
{
|
||||
public:
|
||||
|
||||
DomeModel(osg::ArgumentParser& arguments):
|
||||
sphere_radius(1.0),
|
||||
collar_radius(0.45),
|
||||
rotationDegrees(180.0),
|
||||
distance(0.0),
|
||||
flip(false),
|
||||
texcoord_flip(false)
|
||||
{
|
||||
if (arguments.read("--radius", sphere_radius)) {}
|
||||
if (arguments.read("--collar", collar_radius)) {}
|
||||
if (arguments.read("--rotation", rotationDegrees)) {}
|
||||
|
||||
distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
|
||||
if (arguments.read("--distance", distance)) {}
|
||||
|
||||
if (arguments.read("--flip")) { flip = true; }
|
||||
}
|
||||
|
||||
double sphere_radius;
|
||||
double collar_radius;
|
||||
double rotationDegrees;
|
||||
double distance;
|
||||
bool flip;
|
||||
bool texcoord_flip;
|
||||
|
||||
};
|
||||
|
||||
|
||||
osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, DomeModel& domeModel)
|
||||
{
|
||||
osg::Vec3d center(0.0,0.0,0.0);
|
||||
osg::Vec3d eye(0.0,0.0,0.0);
|
||||
|
||||
bool centerProjection = false;
|
||||
|
||||
osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, domeModel.distance);
|
||||
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Projector position = "<<projector<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"distance = "<<domeModel.distance<<std::endl;
|
||||
|
||||
|
||||
// create the quad to visualize.
|
||||
osg::Geometry* geometry = new osg::Geometry();
|
||||
|
||||
geometry->setSupportsDisplayList(false);
|
||||
|
||||
osg::Vec3 xAxis(widthVector);
|
||||
float width = widthVector.length();
|
||||
xAxis /= width;
|
||||
|
||||
osg::Vec3 yAxis(heightVector);
|
||||
float height = heightVector.length();
|
||||
yAxis /= height;
|
||||
|
||||
int noSteps = 160;
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array;
|
||||
osg::Vec2Array* texcoords = new osg::Vec2Array;
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
|
||||
osg::Vec3 bottom = origin;
|
||||
osg::Vec3 dx = xAxis*(width/((float)(noSteps-2)));
|
||||
osg::Vec3 dy = yAxis*(height/((float)(noSteps-1)));
|
||||
|
||||
osg::Vec3 top = origin + yAxis*height;
|
||||
|
||||
osg::Vec3d screenCenter = origin + widthVector*0.5f + heightVector*0.5f;
|
||||
float screenRadius = heightVector.length() * 0.5f;
|
||||
|
||||
double rotation = osg::DegreesToRadians(domeModel.rotationDegrees);
|
||||
|
||||
osg::Vec3 cursor = bottom;
|
||||
int i,j;
|
||||
|
||||
int midSteps = noSteps/2;
|
||||
|
||||
for(i=0;i<midSteps;++i)
|
||||
{
|
||||
osg::Vec3 cursor = bottom+dy*(float)i;
|
||||
for(j=0;j<midSteps;++j)
|
||||
{
|
||||
osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
|
||||
double theta = atan2(delta.x(), -delta.y());
|
||||
theta += 2*osg::PI;
|
||||
|
||||
double phi = osg::PI_2 * delta.length() / screenRadius;
|
||||
if (phi > osg::PI_2) phi = osg::PI_2;
|
||||
|
||||
double f = domeModel.distance * sin(phi);
|
||||
double e = domeModel.distance * cos(phi) + sqrt( domeModel.sphere_radius*domeModel.sphere_radius - f*f);
|
||||
double l = e * cos(phi);
|
||||
double h = e * sin(phi);
|
||||
double gamma = atan2(h, l-domeModel.distance);
|
||||
|
||||
osg::Vec2 texcoord(theta/(2.0*osg::PI), 1.0-gamma/osg::PI);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"cursor = "<<cursor<< " theta = "<<theta<< "phi="<<phi<<" gamma = "<<gamma<<" texcoord="<<texcoord<<std::endl;
|
||||
|
||||
if (domeModel.flip)
|
||||
vertices->push_back(osg::Vec3(cursor.x(), top.y()-(cursor.y()-origin.y()),cursor.z()));
|
||||
else
|
||||
vertices->push_back(cursor);
|
||||
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
texcoords->push_back( domeModel.texcoord_flip ? osg::Vec2(texcoord.x(), 1.0f - texcoord.y()) : texcoord);
|
||||
|
||||
if (j+1<midSteps) cursor += dx;
|
||||
}
|
||||
|
||||
for(;j<noSteps;++j)
|
||||
{
|
||||
osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
|
||||
double theta = atan2(delta.x(), -delta.y());
|
||||
double phi = osg::PI_2 * delta.length() / screenRadius;
|
||||
if (phi > osg::PI_2) phi = osg::PI_2;
|
||||
|
||||
double f = domeModel.distance * sin(phi);
|
||||
double e = domeModel.distance * cos(phi) + sqrt( domeModel.sphere_radius*domeModel.sphere_radius - f*f);
|
||||
double l = e * cos(phi);
|
||||
double h = e * sin(phi);
|
||||
double gamma = atan2(h, l-domeModel.distance);
|
||||
|
||||
osg::Vec2 texcoord(theta/(2.0*osg::PI), 1.0-gamma/osg::PI);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"cursor = "<<cursor<< " theta = "<<theta<< "phi="<<phi<<" gamma = "<<gamma<<" texcoord="<<texcoord<<std::endl;
|
||||
|
||||
if (domeModel.flip)
|
||||
vertices->push_back(osg::Vec3(cursor.x(), top.y()-(cursor.y()-origin.y()),cursor.z()));
|
||||
else
|
||||
vertices->push_back(cursor);
|
||||
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
texcoords->push_back( domeModel.texcoord_flip ? osg::Vec2(texcoord.x(), 1.0f - texcoord.y()) : texcoord);
|
||||
|
||||
cursor += dx;
|
||||
}
|
||||
// osg::notify(osg::NOTICE)<<std::endl;
|
||||
}
|
||||
|
||||
for(;i<noSteps;++i)
|
||||
{
|
||||
osg::Vec3 cursor = bottom+dy*(float)i;
|
||||
for(j=0;j<noSteps;++j)
|
||||
{
|
||||
osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
|
||||
double theta = atan2(delta.x(), -delta.y());
|
||||
if (theta<0.0) theta += 2*osg::PI;
|
||||
double phi = osg::PI_2 * delta.length() / screenRadius;
|
||||
if (phi > osg::PI_2) phi = osg::PI_2;
|
||||
|
||||
double f = domeModel.distance * sin(phi);
|
||||
double e = domeModel.distance * cos(phi) + sqrt( domeModel.sphere_radius*domeModel.sphere_radius - f*f);
|
||||
double l = e * cos(phi);
|
||||
double h = e * sin(phi);
|
||||
double gamma = atan2(h, l-domeModel.distance);
|
||||
|
||||
osg::Vec2 texcoord(theta/(2.0*osg::PI), 1.0-gamma/osg::PI);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"cursor = "<<cursor<< " theta = "<<theta<< "phi="<<phi<<" gamma = "<<gamma<<" texcoord="<<texcoord<<std::endl;
|
||||
|
||||
if (domeModel.flip)
|
||||
vertices->push_back(osg::Vec3(cursor.x(), top.y()-(cursor.y()-origin.y()),cursor.z()));
|
||||
else
|
||||
vertices->push_back(cursor);
|
||||
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
texcoords->push_back( domeModel.texcoord_flip ? osg::Vec2(texcoord.x(), 1.0f - texcoord.y()) : texcoord);
|
||||
|
||||
cursor += dx;
|
||||
}
|
||||
|
||||
// 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->setTexCoordArray(0,texcoords);
|
||||
|
||||
for(i=0;i<noSteps-1;++i)
|
||||
{
|
||||
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP);
|
||||
for(j=0;j<noSteps;++j)
|
||||
{
|
||||
elements->push_back(j+(i+1)*noSteps);
|
||||
elements->push_back(j+(i)*noSteps);
|
||||
}
|
||||
geometry->addPrimitiveSet(elements);
|
||||
}
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
|
||||
void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
|
||||
{
|
||||
// enforce single threading right now to avoid double buffering of RTT texture
|
||||
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
if (!wsi)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int screenNum = 0;
|
||||
while (arguments.read("--screen",screenNum)) {}
|
||||
|
||||
|
||||
unsigned int width, height;
|
||||
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(screenNum), width, height);
|
||||
|
||||
while (arguments.read("--width",width)) {}
|
||||
while (arguments.read("--height",height)) {}
|
||||
|
||||
DomeModel domeModel(arguments);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->screenNum = screenNum;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
|
||||
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
if (!gc)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"GraphicsWindow has not been created successfully."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
osg::Texture* texture = 0;
|
||||
for(int i=1;i<arguments.argc() && !texture;++i)
|
||||
{
|
||||
if (arguments.isString(i))
|
||||
{
|
||||
osg::Image* image = osgDB::readImageFile(arguments[i]);
|
||||
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
|
||||
if (imagestream) imagestream->play();
|
||||
|
||||
if (image)
|
||||
{
|
||||
domeModel.texcoord_flip = image->getOrigin()==osg::Image::TOP_LEFT;
|
||||
|
||||
#if 1
|
||||
texture = new osg::TextureRectangle(image);
|
||||
#else
|
||||
texture = new osg::Texture2D(image);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!texture)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// distortion correction set up.
|
||||
{
|
||||
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), domeModel) );
|
||||
|
||||
// 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);
|
||||
texture->setMaxAnisotropy(16.0f);
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
#if 1
|
||||
osg::TexMat* texmat = new osg::TexMat;
|
||||
texmat->setScaleByTextureRectangleSize(true);
|
||||
stateset->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON);
|
||||
#endif
|
||||
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
|
||||
camera->setGraphicsContext(gc.get());
|
||||
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
|
||||
camera->setClearColor( osg::Vec4(0.1,0.1,1.0,1.0) );
|
||||
camera->setViewport(new osg::Viewport(0, 0, width, height));
|
||||
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
|
||||
camera->setDrawBuffer(buffer);
|
||||
camera->setReadBuffer(buffer);
|
||||
camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
|
||||
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(), true);
|
||||
|
||||
viewer.setSceneData(geode);
|
||||
}
|
||||
|
||||
|
||||
viewer.getCamera()->setNearFarRatio(0.0001f);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
@@ -639,13 +323,14 @@ int main(int argc, char** argv)
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--texture2D","Use Texture2D rather than TextureRectangle.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--shader","Use shaders to post process the video.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--dome","Use full dome distortion correction.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--interactive","Use camera manipulator to allow movement around movie.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--flip","Flip the movie so top becomes bottom.");
|
||||
|
||||
bool useTextureRectangle = true;
|
||||
bool useShader = false;
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
if (arguments.argc()<=1)
|
||||
{
|
||||
@@ -663,89 +348,89 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool fullscreen = !arguments.read("--interactive");
|
||||
bool flip = arguments.read("--flip");
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||
|
||||
if (arguments.read("--dome") || arguments.read("--puffer") )
|
||||
{
|
||||
setDomeCorrection(viewer, arguments);
|
||||
}
|
||||
else
|
||||
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
|
||||
if (useShader)
|
||||
{
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||
osg::Vec3 pos(0.0f,0.0f,0.0f);
|
||||
//useTextureRectangle = false;
|
||||
|
||||
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
static const char *shaderSourceTextureRec = {
|
||||
"uniform vec4 cutoff_color;\n"
|
||||
"uniform samplerRect movie_texture;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 texture_color = textureRect(movie_texture, gl_TexCoord[0]); \n"
|
||||
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
||||
" gl_FragColor = texture_color;\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
if (useShader)
|
||||
static const char *shaderSourceTexture2D = {
|
||||
"uniform vec4 cutoff_color;\n"
|
||||
"uniform sampler2D movie_texture;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 texture_color = texture2D(movie_texture, gl_TexCoord[0]); \n"
|
||||
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
||||
" gl_FragColor = texture_color;\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
osg::Program* program = new osg::Program;
|
||||
|
||||
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
|
||||
useTextureRectangle ? shaderSourceTextureRec : shaderSourceTexture2D));
|
||||
|
||||
stateset->addUniform(new osg::Uniform("cutoff_color",osg::Vec4(0.1f,0.1f,0.1f,1.0f)));
|
||||
stateset->addUniform(new osg::Uniform("movie_texture",0));
|
||||
|
||||
stateset->setAttribute(program);
|
||||
|
||||
}
|
||||
|
||||
osg::Vec3 pos(0.0f,0.0f,0.0f);
|
||||
osg::Vec3 topleft = pos;
|
||||
osg::Vec3 bottomright = pos;
|
||||
|
||||
bool xyPlane = fullscreen;
|
||||
|
||||
for(int i=1;i<arguments.argc();++i)
|
||||
{
|
||||
if (arguments.isString(i))
|
||||
{
|
||||
//useTextureRectangle = false;
|
||||
osg::Image* image = osgDB::readImageFile(arguments[i]);
|
||||
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
|
||||
if (imagestream) imagestream->play();
|
||||
|
||||
static const char *shaderSourceTextureRec = {
|
||||
"uniform vec4 cutoff_color;\n"
|
||||
"uniform samplerRect movie_texture;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 texture_color = textureRect(movie_texture, gl_TexCoord[0]); \n"
|
||||
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
||||
" gl_FragColor = texture_color;\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
static const char *shaderSourceTexture2D = {
|
||||
"uniform vec4 cutoff_color;\n"
|
||||
"uniform sampler2D movie_texture;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 texture_color = texture2D(movie_texture, gl_TexCoord[0]); \n"
|
||||
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
||||
" gl_FragColor = texture_color;\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
osg::Program* program = new osg::Program;
|
||||
|
||||
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
|
||||
useTextureRectangle ? shaderSourceTextureRec : shaderSourceTexture2D));
|
||||
|
||||
stateset->addUniform(new osg::Uniform("cutoff_color",osg::Vec4(0.1f,0.1f,0.1f,1.0f)));
|
||||
stateset->addUniform(new osg::Uniform("movie_texture",0));
|
||||
|
||||
stateset->setAttribute(program);
|
||||
|
||||
}
|
||||
|
||||
for(int i=1;i<arguments.argc();++i)
|
||||
{
|
||||
if (arguments.isString(i))
|
||||
if (image)
|
||||
{
|
||||
osg::Image* image = osgDB::readImageFile(arguments[i]);
|
||||
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
|
||||
if (imagestream) imagestream->play();
|
||||
geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip));
|
||||
|
||||
bottomright = pos + osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f);
|
||||
|
||||
if (image)
|
||||
{
|
||||
geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle));
|
||||
|
||||
pos.z() += image->t()*1.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Unable to read file "<<arguments[i]<<std::endl;
|
||||
}
|
||||
pos.y() += image->t()*1.5f;
|
||||
}
|
||||
}
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(geode.get());
|
||||
|
||||
if (viewer.getSceneData()==0)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout);
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
std::cout<<"Unable to read file "<<arguments[i]<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(geode.get());
|
||||
|
||||
if (viewer.getSceneData()==0)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// pass the model to the MovieEventHandler so it can pick out ImageStream's to manipulate.
|
||||
MovieEventHandler* meh = new MovieEventHandler();
|
||||
@@ -762,10 +447,22 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
viewer.realize();
|
||||
|
||||
viewer.getCamera()->setViewMatrix(osg::Matrix::identity());
|
||||
viewer.getCamera()->setProjectionMatrixAsOrtho2D(topleft.x(),bottomright.x(),topleft.y(),bottomright.y());
|
||||
|
||||
// create the windows and run the threads.
|
||||
return viewer.run();
|
||||
|
||||
|
||||
while(!viewer.done())
|
||||
{
|
||||
viewer.frame();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// create the windows and run the threads.
|
||||
return viewer.run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--texture-rectangle","Use osg::TextureRectangle for doing the render to texure to.");
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
// if user request help write it out to cout.
|
||||
if (arguments.read("-h") || arguments.read("--help"))
|
||||
|
||||
@@ -258,20 +258,17 @@ osg::Node* createScene()
|
||||
return scene;
|
||||
}
|
||||
|
||||
class TestSupportOperation: public osg::Operation
|
||||
class TestSupportOperation: public osg::GraphicsOperation
|
||||
{
|
||||
public:
|
||||
|
||||
TestSupportOperation():
|
||||
osg::Operation("TestSupportOperation",false),
|
||||
osg::GraphicsOperation("TestSupportOperation",false),
|
||||
_supported(true),
|
||||
_errorMessage() {}
|
||||
|
||||
virtual void operator () (osg::Object* object)
|
||||
virtual void operator () (osg::GraphicsContext* gc)
|
||||
{
|
||||
osg::GraphicsContext* gc = dynamic_cast<osg::GraphicsContext*>(object);
|
||||
if (!gc) return;
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
|
||||
unsigned int contextID = gc->getState()->getContextID();
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include <osgShadow/ShadowVolume>
|
||||
#include <osgShadow/ShadowTexture>
|
||||
#include <osgShadow/ShadowMap>
|
||||
#include <osgShadow/SoftShadowMap>
|
||||
#include <osgShadow/ParallelSplitShadowMap>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
@@ -490,9 +492,22 @@ int main(int argc, char** argv)
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--noUpdate", "Disable the updating the of light source.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--base", "Add a base geometry to test shadows.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--sv", "Select ShadowVolume implementation.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--ssm", "Select SoftShadowMap implementation.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
|
||||
// arguments.getApplicationUsage()->addCommandLineOption("--pssm", "Select ParallelSplitShadowMap implementation.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--pssm", "Select ParallelSplitShadowMap implementation.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--mapcount", "ParallelSplitShadowMap texture count.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--mapres", "ParallelSplitShadowMap texture resolution.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--debug-color", "ParallelSplitShadowMap display debugging color (only the first 3 maps are color r=0,g=1,b=2.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--minNearSplit", "ParallelSplitShadowMap shadow map near offset.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--maxFarDist", "ParallelSplitShadowMap max far distance to shadow.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--moveVCamFactor", "ParallelSplitShadowMap move the virtual frustum behind the real camera, (also back ground object can cast shadow).");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--NVidea", "ParallelSplitShadowMap set default PolygonOffset for NVidea.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Factor", "ParallelSplitShadowMap set PolygonOffset factor.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Unit", "ParallelSplitShadowMap set PolygonOffset unit.");//ADEGLI
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--CullFaceFront", "ParallelSplitShadowMap add a cull face: front.");//ADEGLI
|
||||
|
||||
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-1", "Use test model one.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-2", "Use test model two.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-3", "Use test model three.");
|
||||
@@ -501,7 +516,7 @@ int main(int argc, char** argv)
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
// if user request help write it out to cout.
|
||||
if (arguments.read("-h") || arguments.read("--help"))
|
||||
@@ -562,31 +577,8 @@ int main(int argc, char** argv)
|
||||
// add stats
|
||||
viewer.addEventHandler( new osgViewer::StatsHandler() );
|
||||
|
||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
||||
if (model.valid())
|
||||
{
|
||||
model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
model = createTestModel(arguments);
|
||||
}
|
||||
|
||||
// get the bounds of the model.
|
||||
osg::ComputeBoundsVisitor cbbv;
|
||||
model->accept(cbbv);
|
||||
osg::BoundingBox bb = cbbv.getBoundingBox();
|
||||
|
||||
osg::Vec4 lightpos;
|
||||
|
||||
if (postionalLight)
|
||||
{
|
||||
lightpos.set(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius() ,1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightpos.set(0.5f,0.25f,0.8f,0.0f);
|
||||
}
|
||||
// add the record camera path handler
|
||||
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
|
||||
|
||||
|
||||
osg::ref_ptr<osgShadow::ShadowedScene> shadowedScene = new osgShadow::ShadowedScene;
|
||||
@@ -612,18 +604,99 @@ int main(int argc, char** argv)
|
||||
osg::ref_ptr<osgShadow::ShadowTexture> st = new osgShadow::ShadowTexture;
|
||||
shadowedScene->setShadowTechnique(st.get());
|
||||
}
|
||||
#if 0
|
||||
else if (arguments.read("--pssm"))
|
||||
{
|
||||
osg::ref_ptr<osgShadow::ParallelSplitShadowMap> pssm = new osgShadow::ParallelSplitShadowMap;
|
||||
int mapcount = 3;
|
||||
while (arguments.read("--mapcount", mapcount));
|
||||
osg::ref_ptr<osgShadow::ParallelSplitShadowMap> pssm = new osgShadow::ParallelSplitShadowMap(NULL,mapcount);
|
||||
|
||||
int mapres = 1024;
|
||||
while (arguments.read("--mapres", mapres))
|
||||
pssm->setTextureResolution(mapres);
|
||||
|
||||
while (arguments.read("--debug-color")) { pssm->setDebugColorOn(); }
|
||||
|
||||
|
||||
int minNearSplit=0;
|
||||
while (arguments.read("--minNearSplit", minNearSplit))
|
||||
if ( minNearSplit > 0 ) {
|
||||
pssm->setMinNearDistanceForSplits(minNearSplit);
|
||||
std::cout << "ParallelSplitShadowMap : setMinNearDistanceForSplits(" << minNearSplit <<")" << std::endl;
|
||||
}
|
||||
|
||||
int maxfardist = 0;
|
||||
while (arguments.read("--maxFarDist", maxfardist))
|
||||
if ( maxfardist > 0 ) {
|
||||
pssm->setMaxFarDistance(maxfardist);
|
||||
std::cout << "ParallelSplitShadowMap : setMaxFarDistance(" << maxfardist<<")" << std::endl;
|
||||
}
|
||||
|
||||
int moveVCamFactor = 0;
|
||||
while (arguments.read("--moveVCamFactor", moveVCamFactor))
|
||||
if ( maxfardist > 0 ) {
|
||||
pssm->setMoveVCamBehindRCamFactor(moveVCamFactor);
|
||||
std::cout << "ParallelSplitShadowMap : setMoveVCamBehindRCamFactor(" << moveVCamFactor<<")" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
double polyoffsetfactor = -0.02;
|
||||
double polyoffsetunit = 1.0;
|
||||
while (arguments.read("--PolyOffset-Factor", polyoffsetfactor));
|
||||
while (arguments.read("--PolyOffset-Unit", polyoffsetunit));
|
||||
pssm->setPolygonOffset(osg::Vec2(polyoffsetfactor,polyoffsetunit)); //ATI Radeon
|
||||
|
||||
if (arguments.read("--NVidea")){
|
||||
//pssm->setPolygonOffset(osg::Vec2(-0.02,1.0)); //ATI Radeon
|
||||
pssm->setPolygonOffset(osg::Vec2(10.0f,20.0f)); //NVidea
|
||||
}
|
||||
|
||||
if ( arguments.read("--CullFaceFront") ) {
|
||||
pssm->forceFrontCullFace();
|
||||
}
|
||||
|
||||
shadowedScene->setShadowTechnique(pssm.get());
|
||||
}
|
||||
#endif
|
||||
else if (arguments.read("--ssm"))
|
||||
{
|
||||
osg::ref_ptr<osgShadow::SoftShadowMap> sm = new osgShadow::SoftShadowMap;
|
||||
shadowedScene->setShadowTechnique(sm.get());
|
||||
}
|
||||
else /* if (arguments.read("--sm")) */
|
||||
{
|
||||
osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;
|
||||
shadowedScene->setShadowTechnique(sm.get());
|
||||
|
||||
int mapres = 1024;
|
||||
while (arguments.read("--mapres", mapres))
|
||||
sm->setTextureSize(osg::Vec2s(mapres,mapres));
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
||||
if (model.valid())
|
||||
{
|
||||
model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
model = createTestModel(arguments);
|
||||
}
|
||||
|
||||
// get the bounds of the model.
|
||||
osg::ComputeBoundsVisitor cbbv;
|
||||
model->accept(cbbv);
|
||||
osg::BoundingBox bb = cbbv.getBoundingBox();
|
||||
|
||||
osg::Vec4 lightpos;
|
||||
|
||||
if (postionalLight)
|
||||
{
|
||||
lightpos.set(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius()*2.0f ,1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightpos.set(0.5f,0.25f,0.8f,0.0f);
|
||||
}
|
||||
|
||||
|
||||
if ( arguments.read("--base"))
|
||||
{
|
||||
@@ -646,6 +719,22 @@ int main(int argc, char** argv)
|
||||
|
||||
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
|
||||
ls->getLight()->setPosition(lightpos);
|
||||
|
||||
bool spotlight = false;
|
||||
if (arguments.read("--spotLight"))
|
||||
{
|
||||
spotlight = true;
|
||||
|
||||
osg::Vec3 center = bb.center();
|
||||
osg::Vec3 lightdir = center - osg::Vec3(lightpos.x(), lightpos.y(), lightpos.z());
|
||||
lightdir.normalize();
|
||||
ls->getLight()->setDirection(lightdir);
|
||||
ls->getLight()->setSpotCutoff(25.0f);
|
||||
|
||||
//set the LightSource, only for checking, there is only 1 light in the scene
|
||||
dynamic_cast<osgShadow::ShadowMap*>(shadowedScene->getShadowTechnique())->setLight(ls.get());
|
||||
}
|
||||
|
||||
if ( arguments.read("--coloured-light"))
|
||||
{
|
||||
ls->getLight()->setAmbient(osg::Vec4(1.0,0.0,0.0,1.0));
|
||||
@@ -656,15 +745,34 @@ int main(int argc, char** argv)
|
||||
ls->getLight()->setAmbient(osg::Vec4(0.2,0.2,0.2,1.0));
|
||||
ls->getLight()->setDiffuse(osg::Vec4(0.8,0.8,0.8,1.0));
|
||||
}
|
||||
|
||||
|
||||
shadowedScene->addChild(model.get());
|
||||
shadowedScene->addChild(ls.get());
|
||||
|
||||
viewer.setSceneData(shadowedScene.get());
|
||||
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
// it is done after viewer.realize() so that the windows are already initialized
|
||||
if ( arguments.read("--debugHUD"))
|
||||
{
|
||||
osgViewer::Viewer::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
|
||||
if (windows.empty()) return 1;
|
||||
|
||||
osgShadow::ShadowMap* sm = dynamic_cast<osgShadow::ShadowMap*>(shadowedScene->getShadowTechnique());
|
||||
osg::ref_ptr<osg::Camera> hudCamera = sm->makeDebugHUD();
|
||||
|
||||
// set up cameras to rendering on the first window available.
|
||||
hudCamera->setGraphicsContext(windows[0]);
|
||||
hudCamera->setViewport(0,0,windows[0]->getTraits()->width, windows[0]->getTraits()->height);
|
||||
|
||||
viewer.addSlave(hudCamera.get(), false);
|
||||
}
|
||||
|
||||
|
||||
// osgDB::writeNodeFile(*group,"test.osg");
|
||||
|
||||
while (!viewer.done())
|
||||
@@ -674,13 +782,20 @@ int main(int argc, char** argv)
|
||||
float t = viewer.getFrameStamp()->getSimulationTime();
|
||||
if (postionalLight)
|
||||
{
|
||||
lightpos.set(bb.center().x()+sinf(t)*bb.radius(), bb.center().y() + cosf(t)*bb.radius(), bb.zMax() + bb.radius() ,1.0f);
|
||||
lightpos.set(bb.center().x()+sinf(t)*bb.radius(), bb.center().y() + cosf(t)*bb.radius(), bb.zMax() + bb.radius()*3.0f ,1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightpos.set(sinf(t),cosf(t),1.0f,0.0f);
|
||||
}
|
||||
ls->getLight()->setPosition(lightpos);
|
||||
|
||||
osg::Vec3f lightDir(-lightpos.x(),-lightpos.y(),-lightpos.z());
|
||||
if(spotlight)
|
||||
lightDir = osg::Vec3(bb.center().x()+sinf(t)*bb.radius()/2.0, bb.center().y() + cosf(t)*bb.radius()/2.0, bb.center().z())
|
||||
- osg::Vec3(lightpos.x(), lightpos.y(), lightpos.z()) ;
|
||||
lightDir.normalize();
|
||||
ls->getLight()->setDirection(lightDir);
|
||||
}
|
||||
|
||||
viewer.frame();
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC CreateShadowedScene.cpp osgshadowtexture.cpp )
|
||||
SET(TARGET_H CreateShadowedScene.h )
|
||||
SET(TARGET_ADDED_LIBRARIES osgShadow )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgshadowtexture)
|
||||
@@ -1,224 +0,0 @@
|
||||
/* OpenSceneGraph example, osgshadowtexture.
|
||||
*
|
||||
* 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/Texture2D>
|
||||
#include <osg/Material>
|
||||
#include <osg/LightSource>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Camera>
|
||||
#include <osg/TexGenNode>
|
||||
#include <osg/Notify>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include "CreateShadowedScene.h"
|
||||
|
||||
using namespace osg;
|
||||
|
||||
class UpdateCameraAndTexGenCallback : public osg::NodeCallback
|
||||
{
|
||||
public:
|
||||
|
||||
UpdateCameraAndTexGenCallback(const osg::Vec3& position, osg::Camera* Camera, osg::TexGenNode* texgenNode):
|
||||
_position(position),
|
||||
_Camera(Camera),
|
||||
_texgenNode(texgenNode)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
// first update subgraph to make sure objects are all moved into postion
|
||||
traverse(node,nv);
|
||||
|
||||
// now compute the camera's view and projection matrix to point at the shadower (the camera's children)
|
||||
osg::BoundingSphere bs;
|
||||
for(unsigned int i=0; i<_Camera->getNumChildren(); ++i)
|
||||
{
|
||||
bs.expandBy(_Camera->getChild(i)->getBound());
|
||||
}
|
||||
|
||||
if (!bs.valid())
|
||||
{
|
||||
osg::notify(osg::WARN) << "bb invalid"<<_Camera.get()<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
float centerDistance = (_position-bs.center()).length();
|
||||
|
||||
float znear = centerDistance-bs.radius();
|
||||
float zfar = centerDistance+bs.radius();
|
||||
float zNearRatio = 0.001f;
|
||||
if (znear<zfar*zNearRatio) znear = zfar*zNearRatio;
|
||||
|
||||
float top = (bs.radius()/centerDistance)*znear;
|
||||
float right = top;
|
||||
|
||||
_Camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
|
||||
_Camera->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
|
||||
_Camera->setViewMatrixAsLookAt(_position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f));
|
||||
|
||||
// compute the matrix which takes a vertex from local coords into tex coords
|
||||
// will use this later to specify osg::TexGen..
|
||||
osg::Matrix MVPT = _Camera->getViewMatrix() *
|
||||
_Camera->getProjectionMatrix() *
|
||||
osg::Matrix::translate(1.0,1.0,1.0) *
|
||||
osg::Matrix::scale(0.5f,0.5f,0.5f);
|
||||
|
||||
_texgenNode->getTexGen()->setMode(osg::TexGen::EYE_LINEAR);
|
||||
_texgenNode->getTexGen()->setPlanesFromMatrix(MVPT);
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~UpdateCameraAndTexGenCallback() {}
|
||||
|
||||
osg::Vec3 _position;
|
||||
osg::ref_ptr<osg::Camera> _Camera;
|
||||
osg::ref_ptr<osg::TexGenNode> _texgenNode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const osg::Vec3& lightPosition,float radius,unsigned int unit)
|
||||
{
|
||||
osg::Group* group = new osg::Group;
|
||||
|
||||
// add light source
|
||||
{
|
||||
osg::LightSource* lightSource = new osg::LightSource;
|
||||
lightSource->getLight()->setPosition(osg::Vec4(lightPosition,1.0f));
|
||||
lightSource->getLight()->setLightNum(0);
|
||||
|
||||
group->addChild(lightSource);
|
||||
|
||||
osg::Geode* lightgeode = new osg::Geode;
|
||||
lightgeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
lightgeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(lightPosition,radius)));
|
||||
group->addChild(lightgeode);
|
||||
}
|
||||
|
||||
osg::Vec4 ambientLightColor(0.2,0.2f,0.2f,1.0f);
|
||||
|
||||
// add the shadower and shadowed.
|
||||
group->addChild(shadower);
|
||||
group->addChild(shadowed);
|
||||
|
||||
|
||||
unsigned int tex_width = 512;
|
||||
unsigned int tex_height = 512;
|
||||
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
texture->setTextureSize(tex_width, tex_height);
|
||||
texture->setInternalFormat(GL_RGB);
|
||||
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
|
||||
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
|
||||
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER);
|
||||
texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER);
|
||||
texture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
|
||||
// set up the render to texture camera.
|
||||
{
|
||||
|
||||
// create the camera
|
||||
osg::Camera* camera = new osg::Camera;
|
||||
|
||||
camera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
|
||||
// set viewport
|
||||
camera->setViewport(0,0,tex_width,tex_height);
|
||||
|
||||
// set the camera to render before the main camera.
|
||||
camera->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||
|
||||
// tell the camera to use OpenGL frame buffer object where supported.
|
||||
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
|
||||
|
||||
// attach the texture and use it as the color buffer.
|
||||
camera->attach(osg::Camera::COLOR_BUFFER, texture);
|
||||
|
||||
// add subgraph to render
|
||||
camera->addChild(shadower);
|
||||
|
||||
osg::StateSet* stateset = camera->getOrCreateStateSet();
|
||||
|
||||
// make the material black for a shadow.
|
||||
osg::Material* material = new osg::Material;
|
||||
material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,0.0f,1.0f));
|
||||
material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,0.0f,1.0f));
|
||||
material->setEmission(osg::Material::FRONT_AND_BACK,ambientLightColor);
|
||||
material->setShininess(osg::Material::FRONT_AND_BACK,0.0f);
|
||||
stateset->setAttribute(material,osg::StateAttribute::OVERRIDE);
|
||||
|
||||
group->addChild(camera);
|
||||
|
||||
// create the texgen node to project the tex coords onto the subgraph
|
||||
osg::TexGenNode* texgenNode = new osg::TexGenNode;
|
||||
texgenNode->setTextureUnit(unit);
|
||||
group->addChild(texgenNode);
|
||||
|
||||
// set an update callback to keep moving the camera and tex gen in the right direction.
|
||||
group->setUpdateCallback(new UpdateCameraAndTexGenCallback(lightPosition, camera, texgenNode));
|
||||
}
|
||||
|
||||
// set the shadowed subgraph so that it uses the texture and tex gen settings.
|
||||
{
|
||||
osg::StateSet* stateset = shadowed->getOrCreateStateSet();
|
||||
stateset->setTextureAttributeAndModes(unit,texture,osg::StateAttribute::ON);
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_S,osg::StateAttribute::ON);
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_T,osg::StateAttribute::ON);
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_R,osg::StateAttribute::ON);
|
||||
stateset->setTextureMode(unit,GL_TEXTURE_GEN_Q,osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
|
||||
// set hud to render shadow texture, just for interest
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
osg::Geometry* geom = osg::createTexturedQuadGeometry(osg::Vec3(0,0,0),osg::Vec3(100.0,0.0,0.0),osg::Vec3(0.0,100.0,0.0));
|
||||
geom->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
geom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
geode->addDrawable(geom);
|
||||
|
||||
osg::Camera* camera = new osg::Camera;
|
||||
|
||||
// set the projection matrix
|
||||
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,100,0,100));
|
||||
|
||||
// set the view matrix
|
||||
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
camera->setViewMatrix(osg::Matrix::identity());
|
||||
|
||||
camera->setViewport(50,50,100,100);
|
||||
|
||||
// only clear the depth buffer
|
||||
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// draw subgraph after main camera view.
|
||||
camera->setRenderOrder(osg::Camera::POST_RENDER);
|
||||
|
||||
camera->addChild(geode);
|
||||
|
||||
group->addChild(camera);
|
||||
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/* -*-c++-*-
|
||||
*
|
||||
* OpenSceneGraph example, osgshadowtexture.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef CREATESHADOWEDSCENE_H
|
||||
#define CREATESHADOWEDSCENE_H
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Vec3>
|
||||
|
||||
// function to create a lightsource which contain a shadower and showed subgraph,
|
||||
// the showadowed subgrph has a cull callback to fire off a pre render to texture
|
||||
// of the shadowed subgraph.
|
||||
extern osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const osg::Vec3& lightPosition,float radius,unsigned int textureUnit=1);
|
||||
|
||||
#endif
|
||||
@@ -1,274 +0,0 @@
|
||||
/* OpenSceneGraph example, osgshadowtexture.
|
||||
*
|
||||
* 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/MatrixTransform>
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Geode>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <osgShadow/ShadowedScene>
|
||||
#include <osgShadow/ShadowVolume>
|
||||
#include <osgShadow/ShadowTexture>
|
||||
#include <osgShadow/ShadowMap>
|
||||
|
||||
// include the call which creates the shadowed subgraph.
|
||||
#include "CreateShadowedScene.h"
|
||||
|
||||
|
||||
// for the grid data..
|
||||
#include "../osghangglide/terrain_coords.h"
|
||||
|
||||
|
||||
|
||||
osg::AnimationPath* createAnimationPath(const osg::Vec3& center,float radius,double looptime)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
osg::Node* createBase(const osg::Vec3& center,float radius)
|
||||
{
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
|
||||
// set up the texture of the base.
|
||||
osg::StateSet* stateset = new osg::StateSet();
|
||||
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
|
||||
if (image)
|
||||
{
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
texture->setImage(image);
|
||||
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
geode->setStateSet( stateset );
|
||||
|
||||
|
||||
osg::HeightField* grid = new osg::HeightField;
|
||||
grid->allocate(38,39);
|
||||
grid->setOrigin(center+osg::Vec3(-radius,-radius,0.0f));
|
||||
grid->setXInterval(radius*2.0f/(float)(38-1));
|
||||
grid->setYInterval(radius*2.0f/(float)(39-1));
|
||||
|
||||
float minHeight = FLT_MAX;
|
||||
float maxHeight = -FLT_MAX;
|
||||
|
||||
|
||||
unsigned int r;
|
||||
for(r=0;r<39;++r)
|
||||
{
|
||||
for(unsigned int c=0;c<38;++c)
|
||||
{
|
||||
float h = vertex[r+c*39][2];
|
||||
if (h>maxHeight) maxHeight=h;
|
||||
if (h<minHeight) minHeight=h;
|
||||
}
|
||||
}
|
||||
|
||||
float hieghtScale = radius*0.5f/(maxHeight-minHeight);
|
||||
float hieghtOffset = -(minHeight+maxHeight)*0.5f;
|
||||
|
||||
for(r=0;r<39;++r)
|
||||
{
|
||||
for(unsigned int c=0;c<38;++c)
|
||||
{
|
||||
float h = vertex[r+c*39][2];
|
||||
grid->setHeight(c,r,(h+hieghtOffset)*hieghtScale);
|
||||
}
|
||||
}
|
||||
|
||||
geode->addDrawable(new osg::ShapeDrawable(grid));
|
||||
|
||||
osg::Group* group = new osg::Group;
|
||||
group->addChild(geode);
|
||||
|
||||
return group;
|
||||
|
||||
}
|
||||
|
||||
osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
||||
{
|
||||
float animationLength = 10.0f;
|
||||
|
||||
osg::AnimationPath* animationPath = createAnimationPath(center,radius,animationLength);
|
||||
|
||||
osg::Group* model = new osg::Group;
|
||||
|
||||
osg::Node* cessna = osgDB::readNodeFile("cessna.osg");
|
||||
if (cessna)
|
||||
{
|
||||
const osg::BoundingSphere& bs = cessna->getBound();
|
||||
|
||||
float size = radius/bs.radius()*0.3f;
|
||||
osg::MatrixTransform* positioned = new osg::MatrixTransform;
|
||||
positioned->setDataVariance(osg::Object::STATIC);
|
||||
positioned->setMatrix(osg::Matrix::translate(-bs.center())*
|
||||
osg::Matrix::scale(size,size,size)*
|
||||
osg::Matrix::rotate(osg::inDegrees(180.0f),0.0f,0.0f,2.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
osg::Node* createModel(osg::ArgumentParser& arguments)
|
||||
{
|
||||
osg::Vec3 center(0.0f,0.0f,0.0f);
|
||||
float radius = 100.0f;
|
||||
osg::Vec3 lightPosition(center+osg::Vec3(0.0f,0.0f,radius));
|
||||
|
||||
// the shadower model
|
||||
osg::Node* shadower = createMovingModel(center,radius*0.5f);
|
||||
|
||||
// the shadowed model
|
||||
osg::Node* shadowed = createBase(center-osg::Vec3(0.0f,0.0f,radius*0.25),radius);
|
||||
|
||||
if (arguments.read("--sv"))
|
||||
{
|
||||
// hint to tell viewer to request stencil buffer when setting up windows
|
||||
osg::DisplaySettings::instance()->setMinimumNumStencilBits(8);
|
||||
|
||||
osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene;
|
||||
|
||||
osg::ref_ptr<osgShadow::ShadowVolume> shadowVolume = new osgShadow::ShadowVolume;
|
||||
shadowedScene->setShadowTechnique(shadowVolume.get());
|
||||
shadowVolume->setDynamicShadowVolumes(true);
|
||||
|
||||
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
|
||||
ls->getLight()->setPosition(osg::Vec4(lightPosition,1.0));
|
||||
|
||||
shadowedScene->addChild(shadower);
|
||||
shadowedScene->addChild(shadowed);
|
||||
shadowedScene->addChild(ls.get());
|
||||
|
||||
return shadowedScene;
|
||||
|
||||
}
|
||||
else if (arguments.read("--st"))
|
||||
{
|
||||
|
||||
osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene;
|
||||
|
||||
osg::ref_ptr<osgShadow::ShadowTexture> shadowTexture = new osgShadow::ShadowTexture;
|
||||
shadowedScene->setShadowTechnique(shadowTexture.get());
|
||||
|
||||
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
|
||||
ls->getLight()->setPosition(osg::Vec4(lightPosition,1.0));
|
||||
|
||||
shadowedScene->setReceivesShadowTraversalMask(0x1);
|
||||
shadowed->setNodeMask(shadowedScene->getReceivesShadowTraversalMask());
|
||||
|
||||
shadowedScene->setCastsShadowTraversalMask(0x2);
|
||||
shadower->setNodeMask(shadowedScene->getCastsShadowTraversalMask());
|
||||
|
||||
shadowedScene->addChild(shadower);
|
||||
shadowedScene->addChild(shadowed);
|
||||
shadowedScene->addChild(ls.get());
|
||||
|
||||
return shadowedScene;
|
||||
|
||||
}
|
||||
else if (arguments.read("--sm"))
|
||||
{
|
||||
|
||||
osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene;
|
||||
|
||||
osg::ref_ptr<osgShadow::ShadowMap> shadowMap = new osgShadow::ShadowMap;
|
||||
shadowedScene->setShadowTechnique(shadowMap.get());
|
||||
|
||||
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
|
||||
ls->getLight()->setPosition(osg::Vec4(lightPosition,1.0));
|
||||
|
||||
shadowedScene->setReceivesShadowTraversalMask(0x1);
|
||||
shadowed->setNodeMask(shadowedScene->getReceivesShadowTraversalMask());
|
||||
|
||||
shadowedScene->setCastsShadowTraversalMask(0x2);
|
||||
shadower->setNodeMask(shadowedScene->getCastsShadowTraversalMask());
|
||||
|
||||
shadowedScene->addChild(shadower);
|
||||
shadowedScene->addChild(shadowed);
|
||||
shadowedScene->addChild(ls.get());
|
||||
|
||||
return shadowedScene;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// combine the models together to create one which has the shadower and the shadowed with the required callback.
|
||||
osg::Group* root = createShadowedScene(shadower,shadowed,lightPosition,radius/100.0f,1);
|
||||
return root;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
// pass the model to the viewer.
|
||||
viewer.setSceneData( createModel(arguments) );
|
||||
|
||||
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
@@ -658,7 +658,7 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
// if user request help write it out to cout.
|
||||
unsigned int testCase = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#this file is automatically generated
|
||||
|
||||
SET(TARGET_ADDED_LIBRARIES osgdb_ive osgdb_freetype )
|
||||
SET(TARGET_ADDED_LIBRARIES osgdb_ive osgdb_freetype osgdb_OpenFlight osgdb_osg )
|
||||
|
||||
SET(TARGET_SRC osgstaticviewer.cpp )
|
||||
#### end var setup ###
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
// include the plugins we need
|
||||
USE_OSGPLUGIN(ive);
|
||||
USE_OSGPLUGIN(freetype);
|
||||
USE_OSGPLUGIN(osg);
|
||||
USE_OSGPLUGIN(OpenFlight);
|
||||
|
||||
// include the platform specific GraphicsWindow implementation.
|
||||
USE_GRAPHICSWINDOW();
|
||||
|
||||
@@ -32,6 +32,123 @@
|
||||
|
||||
typedef std::vector<std::string> FileList;
|
||||
|
||||
osg::Geode* createSectorForImage(osg::Image* image, osg::TexMat* texmat, float s,float t, float radius, float height, float length)
|
||||
{
|
||||
|
||||
int numSegments = 20;
|
||||
float Theta = length/radius;
|
||||
float dTheta = Theta/(float)(numSegments-1);
|
||||
|
||||
float ThetaZero = height*s/(t*radius);
|
||||
|
||||
// set up the texture.
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
|
||||
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
|
||||
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER);
|
||||
texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER);
|
||||
texture->setResizeNonPowerOfTwoHint(false);
|
||||
texture->setImage(image);
|
||||
|
||||
// set up the drawstate.
|
||||
osg::StateSet* dstate = new osg::StateSet;
|
||||
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF);
|
||||
dstate->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
dstate->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
|
||||
dstate->setTextureAttribute(0, texmat);
|
||||
|
||||
// set up the geoset.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
geom->setStateSet(dstate);
|
||||
|
||||
osg::Vec3Array* coords = new osg::Vec3Array();
|
||||
osg::Vec2Array* tcoords = new osg::Vec2Array();
|
||||
|
||||
int i;
|
||||
float angle = -Theta/2.0f;
|
||||
for(i=0;
|
||||
i<numSegments;
|
||||
++i, angle+=dTheta)
|
||||
{
|
||||
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,height*0.5f)); // top
|
||||
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,-height*0.5f)); // bottom.
|
||||
|
||||
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,1.0f)); // top
|
||||
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,0.0f)); // bottom.
|
||||
|
||||
}
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array();
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
|
||||
osg::DrawArrays* elements = new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,coords->size());
|
||||
|
||||
|
||||
|
||||
geom->setVertexArray(coords);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitiveSet(elements);
|
||||
|
||||
// set up the geode.
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(geom);
|
||||
|
||||
return geode;
|
||||
|
||||
}
|
||||
|
||||
osg::Group * loadImages(std::string image1, std::string image2, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length) {
|
||||
osg::ref_ptr<osg::Image> imageLeft = osgDB::readImageFile(image1);
|
||||
osg::ref_ptr<osg::Image> imageRight = osgDB::readImageFile(image2);
|
||||
if (imageLeft.valid() && imageRight.valid())
|
||||
{
|
||||
float average_s = (imageLeft->s()+imageRight->s())*0.5f;
|
||||
float average_t = (imageLeft->t()+imageRight->t())*0.5f;
|
||||
osg::Geode* geodeLeft = createSectorForImage(imageLeft.get(),texmatLeft,average_s,average_t, radius, height, length);
|
||||
geodeLeft->setNodeMask(0x01);
|
||||
|
||||
osg::Geode* geodeRight = createSectorForImage(imageRight.get(),texmatRight,average_s,average_t, radius, height, length);
|
||||
geodeRight->setNodeMask(0x02);
|
||||
|
||||
osg::Group * imageGroup = new osg::Group;
|
||||
|
||||
imageGroup->addChild(geodeLeft);
|
||||
imageGroup->addChild(geodeRight);
|
||||
return imageGroup;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: Unable to load both image files, '"<<image1<<"' & '"<<image2<<"', required for stereo imaging."<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// create a switch containing a set of child each containing a
|
||||
// stereo image pair.
|
||||
osg::Switch* createScene(FileList fileList, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length)
|
||||
{
|
||||
osg::Switch* sw = new osg::Switch;
|
||||
|
||||
// load the images.
|
||||
for(unsigned int i=0;i+1<fileList.size();i+=2)
|
||||
{
|
||||
osg::Group * imageGroup = loadImages(fileList[i],fileList[i+1],texmatLeft,texmatRight, radius, height, length);
|
||||
if (imageGroup) sw->addChild(imageGroup);
|
||||
}
|
||||
|
||||
|
||||
if (sw->getNumChildren()>0)
|
||||
{
|
||||
// select first child.
|
||||
sw->setSingleChildOn(0);
|
||||
}
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
class SlideEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
@@ -43,6 +160,9 @@ public:
|
||||
|
||||
void set(osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float timePerSlide, bool autoSteppingActive);
|
||||
|
||||
void set(FileList fileList, osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length, float timePerSlide, bool autoSteppingActive);
|
||||
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&);
|
||||
|
||||
virtual void getUsage(osg::ApplicationUsage& usage) const;
|
||||
@@ -69,6 +189,9 @@ protected:
|
||||
osg::ref_ptr<osg::Switch> _switch;
|
||||
osg::ref_ptr<osg::TexMat> _texmatLeft;
|
||||
osg::ref_ptr<osg::TexMat> _texmatRight;
|
||||
float _radius;
|
||||
float _height;
|
||||
float _length;
|
||||
bool _firstTraversal;
|
||||
unsigned int _activeSlide;
|
||||
double _previousTime;
|
||||
@@ -78,6 +201,7 @@ protected:
|
||||
float _currentSeperationX;
|
||||
float _initSeperationY;
|
||||
float _currentSeperationY;
|
||||
FileList _fileList;
|
||||
|
||||
};
|
||||
|
||||
@@ -114,6 +238,35 @@ void SlideEventHandler::set(osg::Switch* sw, float offsetX, float offsetY, osg::
|
||||
|
||||
}
|
||||
|
||||
void SlideEventHandler::set(FileList fileList, osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length, float timePerSlide, bool autoSteppingActive)
|
||||
{
|
||||
_switch = sw;
|
||||
_switch->setUpdateCallback(this);
|
||||
_fileList=FileList(fileList);
|
||||
|
||||
osg::ref_ptr<osg::Group> imageGroup = loadImages(fileList[0],fileList[1],texmatLeft,texmatRight, radius, height, length);
|
||||
if (imageGroup.get())_switch->addChild(imageGroup.get());
|
||||
|
||||
_texmatLeft = texmatLeft;
|
||||
_texmatRight = texmatRight;
|
||||
|
||||
_radius=radius;
|
||||
_height=height;
|
||||
_length=length;
|
||||
|
||||
_timePerSlide = timePerSlide;
|
||||
_autoSteppingActive = autoSteppingActive;
|
||||
|
||||
_initSeperationX = offsetX;
|
||||
_currentSeperationX = _initSeperationX;
|
||||
|
||||
_initSeperationY = offsetY;
|
||||
_currentSeperationY = _initSeperationY;
|
||||
|
||||
initTexMatrices();
|
||||
}
|
||||
|
||||
|
||||
bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
|
||||
{
|
||||
switch(ea.getEventType())
|
||||
@@ -126,22 +279,22 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
_previousTime = ea.getTime();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='n')
|
||||
else if ((ea.getKey()=='n') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_Right))
|
||||
{
|
||||
nextSlide();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='p')
|
||||
else if ((ea.getKey()=='p') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_Left))
|
||||
{
|
||||
previousSlide();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='w')
|
||||
else if ((ea.getKey()=='w') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Add))
|
||||
{
|
||||
scaleImage(0.99f);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='s')
|
||||
else if ((ea.getKey()=='s') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Subtract))
|
||||
{
|
||||
scaleImage(1.01f);
|
||||
return true;
|
||||
@@ -234,22 +387,38 @@ void SlideEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
|
||||
void SlideEventHandler::nextSlide()
|
||||
{
|
||||
|
||||
if (_switch->getNumChildren()==0) return;
|
||||
|
||||
++_activeSlide;
|
||||
if (_activeSlide>=_switch->getNumChildren()) _activeSlide = 0;
|
||||
|
||||
_switch->setSingleChildOn(_activeSlide);
|
||||
if (_fileList.size()>0) {
|
||||
if (_activeSlide>= _fileList.size()/2 ) _activeSlide = 0;
|
||||
osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length);
|
||||
if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get());
|
||||
|
||||
} else {
|
||||
if (_activeSlide>=_switch->getNumChildren()) _activeSlide = 0;
|
||||
|
||||
_switch->setSingleChildOn(_activeSlide);
|
||||
}
|
||||
}
|
||||
|
||||
void SlideEventHandler::previousSlide()
|
||||
{
|
||||
if (_switch->getNumChildren()==0) return;
|
||||
|
||||
if (_activeSlide==0) _activeSlide = _switch->getNumChildren()-1;
|
||||
else --_activeSlide;
|
||||
if (_fileList.size()>0) {
|
||||
if (_activeSlide==0) _activeSlide = _fileList.size()/2-1;
|
||||
else --_activeSlide;
|
||||
osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length);
|
||||
if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get());
|
||||
} else {
|
||||
if (_activeSlide==0) _activeSlide = _switch->getNumChildren()-1;
|
||||
else --_activeSlide;
|
||||
|
||||
_switch->setSingleChildOn(_activeSlide);
|
||||
_switch->setSingleChildOn(_activeSlide);
|
||||
}
|
||||
}
|
||||
|
||||
void SlideEventHandler::scaleImage(float s)
|
||||
@@ -281,115 +450,6 @@ void SlideEventHandler::initTexMatrices()
|
||||
}
|
||||
|
||||
|
||||
osg::Geode* createSectorForImage(osg::Image* image, osg::TexMat* texmat, float s,float t, float radius, float height, float length)
|
||||
{
|
||||
|
||||
int numSegments = 20;
|
||||
float Theta = length/radius;
|
||||
float dTheta = Theta/(float)(numSegments-1);
|
||||
|
||||
float ThetaZero = height*s/(t*radius);
|
||||
|
||||
// set up the texture.
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
|
||||
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
|
||||
texture->setImage(image);
|
||||
|
||||
// set up the drawstate.
|
||||
osg::StateSet* dstate = new osg::StateSet;
|
||||
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF);
|
||||
dstate->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
|
||||
dstate->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
|
||||
dstate->setTextureAttribute(0, texmat);
|
||||
|
||||
// set up the geoset.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
geom->setStateSet(dstate);
|
||||
|
||||
osg::Vec3Array* coords = new osg::Vec3Array();
|
||||
osg::Vec2Array* tcoords = new osg::Vec2Array();
|
||||
|
||||
int i;
|
||||
float angle = -Theta/2.0f;
|
||||
for(i=0;
|
||||
i<numSegments;
|
||||
++i, angle+=dTheta)
|
||||
{
|
||||
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,height*0.5f)); // top
|
||||
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,-height*0.5f)); // bottom.
|
||||
|
||||
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,1.0f)); // top
|
||||
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,0.0f)); // bottom.
|
||||
|
||||
}
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array();
|
||||
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
|
||||
osg::DrawArrays* elements = new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,coords->size());
|
||||
|
||||
|
||||
|
||||
geom->setVertexArray(coords);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitiveSet(elements);
|
||||
|
||||
// set up the geode.
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(geom);
|
||||
|
||||
return geode;
|
||||
|
||||
}
|
||||
|
||||
// create a switch containing a set of child each containing a
|
||||
// stereo image pair.
|
||||
osg::Switch* createScene(const FileList& fileList, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length)
|
||||
{
|
||||
osg::Switch* sw = new osg::Switch;
|
||||
|
||||
// load the images.
|
||||
for(unsigned int i=0;i+1<fileList.size();i+=2)
|
||||
{
|
||||
osg::ref_ptr<osg::Image> imageLeft = osgDB::readImageFile(fileList[i]);
|
||||
osg::ref_ptr<osg::Image> imageRight = osgDB::readImageFile(fileList[i+1]);
|
||||
if (imageLeft.valid() && imageRight.valid())
|
||||
{
|
||||
float average_s = (imageLeft->s()+imageRight->s())*0.5f;
|
||||
float average_t = (imageLeft->t()+imageRight->t())*0.5f;
|
||||
|
||||
osg::Geode* geodeLeft = createSectorForImage(imageLeft.get(),texmatLeft,average_s,average_t, radius, height, length);
|
||||
geodeLeft->setNodeMask(0x01);
|
||||
|
||||
osg::Geode* geodeRight = createSectorForImage(imageRight.get(),texmatRight,average_s,average_t, radius, height, length);
|
||||
geodeRight->setNodeMask(0x02);
|
||||
|
||||
osg::ref_ptr<osg::Group> imageGroup = new osg::Group;
|
||||
|
||||
imageGroup->addChild(geodeLeft);
|
||||
imageGroup->addChild(geodeRight);
|
||||
|
||||
sw->addChild(imageGroup.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: Unable to load both image files, '"<<fileList[i]<<"' & '"<<fileList[i+1]<<"', required for stereo imaging."<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sw->getNumChildren()>0)
|
||||
{
|
||||
// select first child.
|
||||
sw->setSingleChildOn(0);
|
||||
}
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
@@ -403,6 +463,8 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-a","Enter auto advance of image pairs on start up.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-x <float>","Horizontal offset of left and right images.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-y <float>","Vertical offset of left and right images.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--disk","Keep images on disk");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-files <filename>","Load filenames from a file");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
|
||||
@@ -430,6 +492,22 @@ int main( int argc, char **argv )
|
||||
float offsetY=0.0f;
|
||||
while (arguments.read("-y",offsetY)) {}
|
||||
|
||||
bool onDisk=false;
|
||||
while (arguments.read("--disk")) { onDisk=true;}
|
||||
|
||||
std::string filename="";
|
||||
FileList fileList;
|
||||
// extract the filenames from the a file, one filename per line.
|
||||
while (arguments.read("-files",filename)) {
|
||||
std::ifstream is(filename.c_str());
|
||||
if (is) {
|
||||
std::string line;
|
||||
while (std::getline(is,line,'\n')) fileList.push_back(line);
|
||||
is.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if user request help write it out to cout.
|
||||
if (arguments.read("-h") || arguments.read("--help"))
|
||||
{
|
||||
@@ -456,7 +534,6 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
// extract the filenames from the arguments list.
|
||||
FileList fileList;
|
||||
for(int pos=1;pos<arguments.argc();++pos)
|
||||
{
|
||||
if (arguments.isString(pos)) fileList.push_back(arguments[pos]);
|
||||
@@ -487,8 +564,9 @@ int main( int argc, char **argv )
|
||||
osg::TexMat* texmatRight = new osg::TexMat;
|
||||
|
||||
// creat the scene from the file list.
|
||||
osg::ref_ptr<osg::Switch> rootNode = createScene(fileList,texmatLeft,texmatRight,radius,height,length);
|
||||
|
||||
osg::ref_ptr<osg::Switch> rootNode;
|
||||
if (!onDisk) rootNode = createScene(fileList,texmatLeft,texmatRight,radius,height,length);
|
||||
else rootNode=new osg::Switch();
|
||||
|
||||
//osgDB::writeNodeFile(*rootNode,"test.osg");
|
||||
|
||||
@@ -521,7 +599,8 @@ int main( int argc, char **argv )
|
||||
viewer.setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,radius);
|
||||
|
||||
// set up the SlideEventHandler.
|
||||
seh->set(rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,timeDelayBetweenSlides,autoSteppingActive);
|
||||
if (onDisk) seh->set(fileList,rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,radius,height,length,timeDelayBetweenSlides,autoSteppingActive);
|
||||
else seh->set(rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,timeDelayBetweenSlides,autoSteppingActive);
|
||||
|
||||
osg::Matrix homePosition;
|
||||
homePosition.makeLookAt(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f));
|
||||
|
||||
@@ -332,6 +332,22 @@ osg::Geode* createTeapot()
|
||||
|
||||
int main(int , char **)
|
||||
{
|
||||
#if 1
|
||||
|
||||
// create viewer on heap as a test, this looks to be causing problems
|
||||
// on init on some platforms, and seg fault on exit when multi-threading on linux.
|
||||
// Normal stack based version below works fine though...
|
||||
|
||||
// construct the viewer.
|
||||
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
|
||||
|
||||
// add model to viewer.
|
||||
viewer->setSceneData( createTeapot() );
|
||||
|
||||
return viewer->run();
|
||||
|
||||
#else
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
@@ -340,4 +356,6 @@ int main(int , char **)
|
||||
|
||||
// create the windows and run the threads.
|
||||
return viewer.run();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgterrain.cpp )
|
||||
SET(TARGET_SRC osgterrain.cpp)
|
||||
|
||||
SET(TARGET_ADDED_LIBRARIES osgTerrain )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgterrain)
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <OpenThreads/Block>
|
||||
|
||||
#include <osg/Group>
|
||||
#include <osg/Geode>
|
||||
#include <osg/ShapeDrawable>
|
||||
@@ -26,9 +28,12 @@
|
||||
#include <osg/ClusterCullingCallback>
|
||||
#include <osg/ArgumentParser>
|
||||
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgUtil/GLObjectsVisitor>
|
||||
|
||||
#include <osgText/FadeText>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
@@ -42,22 +47,539 @@
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
#include <osgGA/TerrainManipulator>
|
||||
|
||||
|
||||
#include <osgTerrain/TerrainNode>
|
||||
#include <osgTerrain/Terrain>
|
||||
#include <osgTerrain/GeometryTechnique>
|
||||
#include <osgTerrain/Layer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
|
||||
|
||||
|
||||
|
||||
class LoadAndCompileOperation : public osg::Operation
|
||||
{
|
||||
public:
|
||||
|
||||
LoadAndCompileOperation(const std::string& filename, GraphicsThreads& graphicsThreads, osg::RefBlockCount* block):
|
||||
Operation("Load and compile Operation", false),
|
||||
_filename(filename),
|
||||
_graphicsThreads(graphicsThreads),
|
||||
_block(block) {}
|
||||
|
||||
virtual void operator () (osg::Object* object)
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"LoadAndCompileOperation "<<_filename<<std::endl;
|
||||
|
||||
_loadedModel = osgDB::readNodeFile(_filename);
|
||||
if (_loadedModel.valid() && !_graphicsThreads.empty())
|
||||
{
|
||||
osg::ref_ptr<osgUtil::GLObjectsOperation> compileOperation = new osgUtil::GLObjectsOperation(_loadedModel.get());
|
||||
|
||||
for(GraphicsThreads::iterator gitr = _graphicsThreads.begin();
|
||||
gitr != _graphicsThreads.end();
|
||||
++gitr)
|
||||
{
|
||||
(*gitr)->add( compileOperation.get() );
|
||||
// requiresBarrier = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_block.valid()) _block->completed();
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"done LoadAndCompileOperation "<<_filename<<std::endl;
|
||||
}
|
||||
|
||||
std::string _filename;
|
||||
GraphicsThreads _graphicsThreads;
|
||||
osg::ref_ptr<osg::Node> _loadedModel;
|
||||
osg::ref_ptr<osg::RefBlockCount> _block;
|
||||
|
||||
};
|
||||
|
||||
class MasterOperation : public osg::Operation
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::set<std::string> Files;
|
||||
typedef std::map<std::string, osg::ref_ptr<osg::Node> > FilenameNodeMap;
|
||||
typedef std::vector< osg::ref_ptr<osg::Node> > Nodes;
|
||||
|
||||
|
||||
MasterOperation(const std::string& filename):
|
||||
Operation("Master reading operation",true),
|
||||
_filename(filename)
|
||||
{
|
||||
}
|
||||
|
||||
/** Set the OperationQueue that the MasterOperation can use to place tasks like file loading on for other processes to handle.*/
|
||||
void setOperationQueue(osg::OperationQueue* oq) { _operationQueue = oq; }
|
||||
|
||||
osg::OperationQueue* getOperationQueue() { return _operationQueue.get(); }
|
||||
|
||||
bool readMasterFile(Files& files) const
|
||||
{
|
||||
std::ifstream fin(_filename.c_str());
|
||||
if (fin)
|
||||
{
|
||||
osgDB::Input fr;
|
||||
fr.attach(&fin);
|
||||
|
||||
bool readFilename;
|
||||
|
||||
while(!fr.eof())
|
||||
{
|
||||
bool itrAdvanced = false;
|
||||
if (fr.matchSequence("file %s") || fr.matchSequence("file %w") )
|
||||
{
|
||||
files.insert(fr[1].getStr());
|
||||
fr += 2;
|
||||
itrAdvanced = true;
|
||||
readFilename = true;
|
||||
}
|
||||
|
||||
if (!itrAdvanced)
|
||||
{
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
|
||||
return readFilename;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool open(osg::Group* group)
|
||||
{
|
||||
Files files;
|
||||
readMasterFile(files);
|
||||
for(Files::iterator itr = files.begin();
|
||||
itr != files.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Node* model = osgDB::readNodeFile(*itr);
|
||||
if (model)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"open: Loaded file "<<*itr<<std::endl;
|
||||
group->addChild(model);
|
||||
_existingFilenameNodeMap[*itr] = model;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void operator () (osg::Object* callingObject)
|
||||
{
|
||||
// decided which method to call according to whole has called me.
|
||||
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(callingObject);
|
||||
|
||||
if (viewer) update(viewer->getSceneData());
|
||||
else load();
|
||||
}
|
||||
|
||||
void load()
|
||||
{
|
||||
//osg::notify(osg::NOTICE)<<"void load(Object)"<<std::endl;
|
||||
Files filesA;
|
||||
Files filesB;
|
||||
|
||||
readMasterFile(filesB);
|
||||
// osg::notify(osg::NOTICE)<<"First read "<<filesA.size()<<std::endl;
|
||||
|
||||
// itererate until the master file is stable
|
||||
do
|
||||
{
|
||||
OpenThreads::Thread::microSleep(100000);
|
||||
|
||||
filesB.swap(filesA);
|
||||
filesB.clear();
|
||||
readMasterFile(filesB);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"second read "<<filesB.size()<<std::endl;
|
||||
|
||||
} while (filesA!=filesB);
|
||||
|
||||
Files files;
|
||||
files.swap(filesB);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Now equal "<<files.size()<<std::endl;
|
||||
|
||||
|
||||
Files newFiles;
|
||||
Files removedFiles;
|
||||
|
||||
// find out which files are new, and which ones have been removed.
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
|
||||
for(Files::iterator fitr = files.begin();
|
||||
fitr != files.end();
|
||||
++fitr)
|
||||
{
|
||||
if (_existingFilenameNodeMap.count(*fitr)==0) newFiles.insert(*fitr);
|
||||
}
|
||||
|
||||
for(FilenameNodeMap::iterator litr = _existingFilenameNodeMap.begin();
|
||||
litr != _existingFilenameNodeMap.end();
|
||||
++litr)
|
||||
{
|
||||
if (files.count(litr->first)==0)
|
||||
{
|
||||
removedFiles.insert(litr->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!newFiles.empty() || !removedFiles.empty())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<std::endl<<std::endl<<"void operator () files.size()="<<files.size()<<std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// first load the new files.
|
||||
FilenameNodeMap nodesToAdd;
|
||||
if (!newFiles.empty())
|
||||
{
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
|
||||
GraphicsThreads threads;
|
||||
|
||||
for(unsigned int i=0; i<= osg::GraphicsContext::getMaxContextID(); ++i)
|
||||
{
|
||||
osg::GraphicsContext* gc = osg::GraphicsContext::getCompileContext(i);
|
||||
osg::GraphicsThread* gt = gc ? gc->getGraphicsThread() : 0;
|
||||
if (gt) threads.push_back(gt);
|
||||
}
|
||||
|
||||
bool requiresBarrier = false;
|
||||
|
||||
|
||||
if (_operationQueue.valid())
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"Using OperationQueue"<<std::endl;
|
||||
|
||||
_endOfLoadBlock = new osg::RefBlockCount(newFiles.size());
|
||||
|
||||
_endOfLoadBlock->reset();
|
||||
|
||||
typedef std::list< osg::ref_ptr<LoadAndCompileOperation> > LoadAndCompileList;
|
||||
LoadAndCompileList loadAndCompileList;
|
||||
|
||||
for(Files::iterator nitr = newFiles.begin();
|
||||
nitr != newFiles.end();
|
||||
++nitr)
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"Adding LoadAndCompileOperation "<<*nitr<<std::endl;
|
||||
|
||||
osg::ref_ptr<LoadAndCompileOperation> loadAndCompile = new LoadAndCompileOperation( *nitr, threads, _endOfLoadBlock.get() );
|
||||
loadAndCompileList.push_back(loadAndCompile);
|
||||
_operationQueue->add( loadAndCompile.get() );
|
||||
}
|
||||
|
||||
#if 1
|
||||
osg::ref_ptr<osg::Operation> operation;
|
||||
while ((operation=_operationQueue->getNextOperation()).valid())
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"Local running of operation"<<std::endl;
|
||||
(*operation)(0);
|
||||
}
|
||||
#endif
|
||||
// osg::notify(osg::NOTICE)<<"Waiting for completion of LoadAndCompile operations"<<std::endl;
|
||||
_endOfLoadBlock->block();
|
||||
// osg::notify(osg::NOTICE)<<"done ... Waiting for completion of LoadAndCompile operations"<<std::endl;
|
||||
|
||||
for(LoadAndCompileList::iterator litr = loadAndCompileList.begin();
|
||||
litr != loadAndCompileList.end();
|
||||
++litr)
|
||||
{
|
||||
if ((*litr)->_loadedModel.valid())
|
||||
{
|
||||
nodesToAdd[(*litr)->_filename] = (*litr)->_loadedModel;
|
||||
requiresBarrier = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for(Files::iterator nitr = newFiles.begin();
|
||||
nitr != newFiles.end();
|
||||
++nitr)
|
||||
{
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(*nitr);
|
||||
|
||||
if (loadedModel.get())
|
||||
{
|
||||
nodesToAdd[*nitr] = loadedModel;
|
||||
|
||||
osg::ref_ptr<osgUtil::GLObjectsOperation> compileOperation = new osgUtil::GLObjectsOperation(loadedModel.get());
|
||||
|
||||
for(GraphicsThreads::iterator gitr = threads.begin();
|
||||
gitr != threads.end();
|
||||
++gitr)
|
||||
{
|
||||
(*gitr)->add( compileOperation.get() );
|
||||
requiresBarrier = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (requiresBarrier)
|
||||
{
|
||||
_endOfCompilebarrier = new osg::BarrierOperation(threads.size()+1);
|
||||
_endOfCompilebarrier->setKeep(false);
|
||||
|
||||
for(GraphicsThreads::iterator gitr = threads.begin();
|
||||
gitr != threads.end();
|
||||
++gitr)
|
||||
{
|
||||
(*gitr)->add(_endOfCompilebarrier.get());
|
||||
}
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Waiting for Compile to complete"<<std::endl;
|
||||
|
||||
// wait for the graphics threads to complete.
|
||||
_endOfCompilebarrier->block();
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"done ... Waiting for Compile to complete"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool requiresBlock = false;
|
||||
|
||||
// pass the locally peppared data to MasterOperations shared data
|
||||
// so that updated thread can merge these changes with the main scene
|
||||
// graph. This merge is carried out via the update(..) method.
|
||||
if (!removedFiles.empty() || !nodesToAdd.empty())
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
_nodesToRemove.swap(removedFiles);
|
||||
_nodesToAdd.swap(nodesToAdd);
|
||||
requiresBlock = true;
|
||||
}
|
||||
|
||||
// now block so we don't try to load anything till the new data has been merged
|
||||
// otherwise _existingFilenameNodeMap will get out of sync.
|
||||
if (requiresBlock)
|
||||
{
|
||||
_updatesMergedBlock.block();
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenThreads::Thread::YieldCurrentThread();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// merge the changes with the main scene graph.
|
||||
void update(osg::Node* scene)
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"void update(Node*)"<<std::endl;
|
||||
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(scene);
|
||||
if (!group)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error, MasterOperation::update(Node*) can only work with a Group as Viewer::getSceneData()."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
|
||||
if (!_nodesToRemove.empty() || !_nodesToAdd.empty())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"update().................. "<<std::endl;
|
||||
}
|
||||
|
||||
if (!_nodesToRemove.empty())
|
||||
{
|
||||
for(Files::iterator itr = _nodesToRemove.begin();
|
||||
itr != _nodesToRemove.end();
|
||||
++itr)
|
||||
{
|
||||
FilenameNodeMap::iterator fnmItr = _existingFilenameNodeMap.find(*itr);
|
||||
if (fnmItr != _existingFilenameNodeMap.end())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<" update():removing "<<*itr<<std::endl;
|
||||
|
||||
group->removeChild(fnmItr->second.get());
|
||||
_existingFilenameNodeMap.erase(fnmItr);
|
||||
}
|
||||
}
|
||||
|
||||
_nodesToRemove.clear();
|
||||
}
|
||||
|
||||
if (!_nodesToAdd.empty())
|
||||
{
|
||||
for(FilenameNodeMap::iterator itr = _nodesToAdd.begin();
|
||||
itr != _nodesToAdd.end();
|
||||
++itr)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<" update():inserting "<<itr->first<<std::endl;
|
||||
group->addChild(itr->second.get());
|
||||
_existingFilenameNodeMap[itr->first] = itr->second;
|
||||
}
|
||||
|
||||
_nodesToAdd.clear();
|
||||
}
|
||||
|
||||
_updatesMergedBlock.release();
|
||||
|
||||
}
|
||||
|
||||
// add release implementation so that any thread cancellation can
|
||||
// work even when blocks and barriers are used.
|
||||
virtual void release()
|
||||
{
|
||||
if (_operationQueue.valid()) _operationQueue->removeAllOperations();
|
||||
|
||||
_updatesMergedBlock.release();
|
||||
if (_endOfCompilebarrier.valid()) _endOfCompilebarrier.release();
|
||||
if (_endOfLoadBlock.valid()) _endOfLoadBlock.release();
|
||||
}
|
||||
|
||||
|
||||
std::string _filename;
|
||||
|
||||
OpenThreads::Mutex _mutex;
|
||||
FilenameNodeMap _existingFilenameNodeMap;
|
||||
Files _nodesToRemove;
|
||||
FilenameNodeMap _nodesToAdd;
|
||||
OpenThreads::Block _updatesMergedBlock;
|
||||
|
||||
osg::ref_ptr<osg::BarrierOperation> _endOfCompilebarrier;
|
||||
osg::ref_ptr<osg::RefBlockCount> _endOfLoadBlock;
|
||||
|
||||
osg::ref_ptr<osg::OperationQueue> _operationQueue;
|
||||
};
|
||||
|
||||
class FilterHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
FilterHandler(osgTerrain::GeometryTechnique* gt):
|
||||
_gt(gt) {}
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
|
||||
{
|
||||
if (!_gt) return false;
|
||||
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey() == 'g')
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Gaussian"<<std::endl;
|
||||
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::GAUSSIAN);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 's')
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Smooth"<<std::endl;
|
||||
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SMOOTH);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 'S')
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Sharpen"<<std::endl;
|
||||
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SHARPEN);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == '+')
|
||||
{
|
||||
_gt->setFilterWidth(_gt->getFilterWidth()*1.1);
|
||||
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == '-')
|
||||
{
|
||||
_gt->setFilterWidth(_gt->getFilterWidth()/1.1);
|
||||
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == '>')
|
||||
{
|
||||
_gt->setFilterBias(_gt->getFilterBias()+0.1);
|
||||
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == '<')
|
||||
{
|
||||
_gt->setFilterBias(_gt->getFilterBias()-0.1);
|
||||
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
osg::observer_ptr<osgTerrain::GeometryTechnique> _gt;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LayerHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
LayerHandler(osgTerrain::Layer* layer):
|
||||
_layer(layer) {}
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
|
||||
{
|
||||
if (!_layer) return false;
|
||||
|
||||
float scale = 1.2;
|
||||
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey() == 'q')
|
||||
{
|
||||
_layer->transform(0.0, scale);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey() == 'a')
|
||||
{
|
||||
_layer->transform(0.0, 1.0f/scale);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
osg::observer_ptr<osgTerrain::Layer> _layer;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
// set up the camera manipulators.
|
||||
{
|
||||
@@ -92,14 +614,33 @@ int main(int argc, char** argv)
|
||||
// add the stats handler
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
// add the record camera path handler
|
||||
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
|
||||
|
||||
|
||||
double x = 0.0;
|
||||
double y = 0.0;
|
||||
double w = 1.0;
|
||||
double h = 1.0;
|
||||
|
||||
osg::ref_ptr<osgTerrain::TerrainNode> terrain = new osgTerrain::TerrainNode;
|
||||
osg::ref_ptr<osgTerrain::Locator> locator = new osgTerrain::EllipsoidLocator(-osg::PI, -osg::PI*0.5, 2.0*osg::PI, osg::PI, 0.0);
|
||||
unsigned int numLoadThreads = 1;
|
||||
while (arguments.read("--load-threads",numLoadThreads)) { }
|
||||
|
||||
osg::ref_ptr<MasterOperation> masterOperation;
|
||||
std::string masterFilename;
|
||||
while(arguments.read("-m",masterFilename))
|
||||
{
|
||||
masterOperation = new MasterOperation(masterFilename);
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<osgTerrain::Terrain> terrain = new osgTerrain::Terrain;
|
||||
osg::ref_ptr<osgTerrain::Locator> locator = new osgTerrain::Locator;
|
||||
osg::ref_ptr<osgTerrain::ValidDataOperator> validDataOperator = new osgTerrain::NoDataValue(0.0);
|
||||
osg::ref_ptr<osgTerrain::Layer> lastAppliedLayer;
|
||||
|
||||
locator->setCoordinateSystemType(osgTerrain::Locator::GEOCENTRIC);
|
||||
locator->setTransformAsExtents(-osg::PI, -osg::PI*0.5, osg::PI, osg::PI*0.5);
|
||||
|
||||
unsigned int layerNum = 0;
|
||||
|
||||
@@ -130,7 +671,8 @@ int main(int argc, char** argv)
|
||||
else if (arguments.read(pos, "-e",x,y,w,h))
|
||||
{
|
||||
// define the extents.
|
||||
locator = new osgTerrain::EllipsoidLocator(x,y,w,h,0);
|
||||
locator->setCoordinateSystemType(osgTerrain::Locator::GEOCENTRIC);
|
||||
locator->setTransformAsExtents(x,y,x+w,y+h);
|
||||
readParameter = true;
|
||||
}
|
||||
|
||||
@@ -140,11 +682,11 @@ int main(int argc, char** argv)
|
||||
readParameter = true;
|
||||
}
|
||||
|
||||
else if (arguments.read(pos, "--cartizian",x,y,w,h))
|
||||
else if (arguments.read(pos, "--cartesian",x,y,w,h))
|
||||
{
|
||||
// define the extents.
|
||||
locator = new osgTerrain::CartizianLocator(x,y,w,h,0);
|
||||
readParameter = true;
|
||||
locator->setCoordinateSystemType(osgTerrain::Locator::PROJECTED);
|
||||
locator->setTransformAsExtents(x,y,x+w,y+h);
|
||||
}
|
||||
|
||||
else if (arguments.read(pos, "--hf",filename))
|
||||
@@ -169,6 +711,8 @@ int main(int argc, char** argv)
|
||||
|
||||
terrain->setElevationLayer(hfl.get());
|
||||
|
||||
lastAppliedLayer = hfl.get();
|
||||
|
||||
osg::notify(osg::NOTICE)<<"created osgTerrain::HeightFieldLayer"<<std::endl;
|
||||
}
|
||||
else
|
||||
@@ -201,6 +745,8 @@ int main(int argc, char** argv)
|
||||
|
||||
terrain->setElevationLayer(imageLayer.get());
|
||||
|
||||
lastAppliedLayer = imageLayer.get();
|
||||
|
||||
osg::notify(osg::NOTICE)<<"created Elevation osgTerrain::ImageLayer"<<std::endl;
|
||||
}
|
||||
else
|
||||
@@ -232,7 +778,9 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
terrain->setColorLayer(layerNum, imageLayer.get());
|
||||
|
||||
|
||||
lastAppliedLayer = imageLayer.get();
|
||||
|
||||
osg::notify(osg::NOTICE)<<"created Color osgTerrain::ImageLayer"<<std::endl;
|
||||
}
|
||||
else
|
||||
@@ -252,12 +800,12 @@ int main(int argc, char** argv)
|
||||
if (filterName=="NEAREST")
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"--filter "<<filterName<<std::endl;
|
||||
terrain->setColorFilter(layerNum, osgTerrain::TerrainNode::NEAREST);
|
||||
terrain->setColorFilter(layerNum, osgTerrain::Terrain::NEAREST);
|
||||
}
|
||||
else if (filterName=="LINEAER")
|
||||
else if (filterName=="LINEAR")
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"--filter "<<filterName<<std::endl;
|
||||
terrain->setColorFilter(layerNum, osgTerrain::TerrainNode::LINEAR);
|
||||
terrain->setColorFilter(layerNum, osgTerrain::Terrain::LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -294,16 +842,75 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<osgTerrain::GeometryTechnique> geometryTechnique = new osgTerrain::GeometryTechnique;
|
||||
|
||||
terrain->setTerrainTechnique(geometryTechnique.get());
|
||||
|
||||
if (!terrain) return 0;
|
||||
|
||||
// return 0;
|
||||
osg::ref_ptr<osg::Group> scene = new osg::Group;
|
||||
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer.setSceneData(terrain.get());
|
||||
if (terrain.valid() && (terrain->getElevationLayer() || terrain->getColorLayer(0)))
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Terrain created"<<std::endl;
|
||||
|
||||
scene->addChild(terrain.get());
|
||||
|
||||
osg::ref_ptr<osgTerrain::GeometryTechnique> geometryTechnique = new osgTerrain::GeometryTechnique;
|
||||
terrain->setTerrainTechnique(geometryTechnique.get());
|
||||
viewer.addEventHandler(new FilterHandler(geometryTechnique.get()));
|
||||
viewer.addEventHandler(new LayerHandler(lastAppliedLayer.get()));
|
||||
}
|
||||
|
||||
if (masterOperation.valid())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Master operation created"<<std::endl;
|
||||
|
||||
masterOperation->open(scene.get());
|
||||
}
|
||||
|
||||
if (scene->getNumChildren()==0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"No model created, please specify terrain or master file on command line."<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
viewer.setSceneData(scene.get());
|
||||
|
||||
|
||||
// start operation thread if a master file has been used.
|
||||
osg::ref_ptr<osg::OperationThread> masterOperationThread;
|
||||
|
||||
typedef std::list< osg::ref_ptr<osg::OperationThread> > OperationThreadList;
|
||||
OperationThreadList generalThreadList;
|
||||
|
||||
if (masterOperation.valid())
|
||||
{
|
||||
masterOperationThread = new osg::OperationThread;
|
||||
masterOperationThread->startThread();
|
||||
|
||||
masterOperationThread->add(masterOperation.get());
|
||||
|
||||
// if (numLoadThreads>0)
|
||||
{
|
||||
osg::ref_ptr<osg::OperationQueue> operationQueue = new osg::OperationQueue;
|
||||
masterOperation->setOperationQueue(operationQueue.get());
|
||||
|
||||
for(unsigned int i=0; i<numLoadThreads; ++i)
|
||||
{
|
||||
osg::ref_ptr<osg::OperationThread> thread = new osg::OperationThread;
|
||||
thread->setOperationQueue(operationQueue.get());
|
||||
thread->startThread();
|
||||
generalThreadList.push_back(thread);
|
||||
}
|
||||
}
|
||||
|
||||
viewer.addUpdateOperation(masterOperation.get());
|
||||
}
|
||||
|
||||
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
// enable the use of compile contexts and associated threads.
|
||||
osg::DisplaySettings::instance()->setCompileContextsHint(true);
|
||||
|
||||
// realize the graphics windows.
|
||||
viewer.realize();
|
||||
|
||||
// run the viewers main loop
|
||||
return viewer.run();
|
||||
|
||||
}
|
||||
|
||||
@@ -23,11 +23,14 @@
|
||||
#include <osgDB/Registry>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/Camera>
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Sequence>
|
||||
#include <osg/PolygonMode>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgText/Font>
|
||||
#include <osgText/Text>
|
||||
@@ -474,13 +477,182 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
int main(int , char **)
|
||||
class UpdateTextOperation : public osg::Operation
|
||||
{
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
public:
|
||||
|
||||
// prepare scene.
|
||||
UpdateTextOperation(osg::Group* group):
|
||||
Operation("UpdateTextOperation", true),
|
||||
_maxNumChildren(200),
|
||||
_maxNumTextPerGeode(10),
|
||||
_group(group)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void operator () (osg::Object* callingObject)
|
||||
{
|
||||
// decided which method to call according to whole has called me.
|
||||
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(callingObject);
|
||||
|
||||
if (viewer) update();
|
||||
else load();
|
||||
}
|
||||
|
||||
void update()
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"*** Doing update"<<std::endl;
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
|
||||
if (_mergeSubgraph.valid())
|
||||
{
|
||||
_group->addChild(_mergeSubgraph.get());
|
||||
|
||||
_mergeSubgraph = 0;
|
||||
|
||||
if (_group->getNumChildren()>_maxNumChildren)
|
||||
{
|
||||
osg::Geode* geode = dynamic_cast<osg::Geode*>(_group->getChild(0));
|
||||
if (geode)
|
||||
{
|
||||
_availableSubgraph.push_back(geode);
|
||||
geode->removeDrawables(0,geode->getNumDrawables());
|
||||
}
|
||||
_group->removeChild(0,1);
|
||||
}
|
||||
|
||||
_waitOnMergeBlock.release();
|
||||
}
|
||||
}
|
||||
|
||||
void load()
|
||||
{
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Doing load"<<std::endl;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode;
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
if (!_availableSubgraph.empty())
|
||||
{
|
||||
geode = _availableSubgraph.front();
|
||||
_availableSubgraph.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
if (!geode) geode = new osg::Geode;
|
||||
|
||||
for(unsigned int i=0; i<_maxNumTextPerGeode; ++i)
|
||||
{
|
||||
osg::Vec3 position(float(rand()) / float(RAND_MAX), float(rand()) / float(RAND_MAX), float(i)/float(_maxNumTextPerGeode));
|
||||
|
||||
std::string str;
|
||||
unsigned int _numCharacters = 5;
|
||||
for(unsigned int ni=0; ni<_numCharacters;++ni)
|
||||
{
|
||||
str.push_back(char(32.0 + (float(rand())/float(RAND_MAX))*128.0f));
|
||||
}
|
||||
|
||||
osgText::Text* text = new osgText::Text;
|
||||
text->setDataVariance(osg::Object::DYNAMIC);
|
||||
text->setPosition(position);
|
||||
text->setFont("times.ttf");
|
||||
text->setText(str);
|
||||
text->setCharacterSize(0.025f);
|
||||
text->setAxisAlignment(osgText::Text::SCREEN);
|
||||
|
||||
geode->addDrawable(text);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
_mergeSubgraph = geode;
|
||||
}
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Waiting on merge"<<std::endl;
|
||||
|
||||
_waitOnMergeBlock.block();
|
||||
|
||||
}
|
||||
|
||||
virtual void release()
|
||||
{
|
||||
_waitOnMergeBlock.release();
|
||||
}
|
||||
|
||||
typedef std::list< osg::ref_ptr<osg::Geode> > AvailableList;
|
||||
|
||||
unsigned int _maxNumChildren;
|
||||
unsigned int _maxNumTextPerGeode;
|
||||
|
||||
OpenThreads::Mutex _mutex;
|
||||
osg::ref_ptr<osg::Group> _group;
|
||||
osg::ref_ptr<osg::Geode> _mergeSubgraph;
|
||||
AvailableList _availableSubgraph;
|
||||
OpenThreads::Block _waitOnMergeBlock;
|
||||
|
||||
unsigned int _counter;
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
typedef std::list< osg::ref_ptr<osg::OperationThread> > Threads;
|
||||
|
||||
Threads operationThreads;
|
||||
osg::ref_ptr<UpdateTextOperation> updateOperation;
|
||||
|
||||
unsigned int numThreads = 0;
|
||||
if (arguments.read("--mt", numThreads) || arguments.read("--mt"))
|
||||
{
|
||||
// construct a multi-threaded text updating test.
|
||||
if (numThreads==0) numThreads = 1;
|
||||
|
||||
// create a group to add everything into.
|
||||
osg::Group* mainGroup = new osg::Group;
|
||||
|
||||
for(unsigned int i=0; i<numThreads; ++i)
|
||||
{
|
||||
osg::Group* textGroup = new osg::Group;
|
||||
mainGroup->addChild(textGroup);
|
||||
|
||||
// create the background thread
|
||||
osg::OperationThread* operationThread = new osg::OperationThread;
|
||||
|
||||
operationThreads.push_back(operationThread);
|
||||
|
||||
// create the operation that will run in the background and
|
||||
// sync once per frame with the main viewer loop.
|
||||
updateOperation = new UpdateTextOperation(textGroup);
|
||||
|
||||
// add the operation to the operation thread and start it.
|
||||
operationThread->add(updateOperation.get());
|
||||
operationThread->startThread();
|
||||
|
||||
// add the operation to the viewer to sync once per frame.
|
||||
viewer.addUpdateOperation(updateOperation.get());
|
||||
|
||||
|
||||
// add a unit cube for the text to appear within.
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->getOrCreateStateSet()->setAttribute(new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE));
|
||||
geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.5f,0.5f,0.5f),1.0)));
|
||||
|
||||
mainGroup->addChild(geode);
|
||||
}
|
||||
|
||||
viewer.setSceneData(mainGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
// prepare scene.
|
||||
osg::Vec3 center(0.0f,0.0f,0.0f);
|
||||
float radius = 1.0f;
|
||||
|
||||
@@ -506,8 +678,22 @@ int main(int , char **)
|
||||
viewer.setSceneData(group);
|
||||
}
|
||||
|
||||
#if 0
|
||||
osgDB::writeNodeFile(*viewer.getSceneData(),"text.osg");
|
||||
#endif
|
||||
|
||||
return viewer.run();
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler());
|
||||
|
||||
viewer.run();
|
||||
|
||||
if (!operationThreads.empty())
|
||||
{
|
||||
for(Threads::iterator itr = operationThreads.begin();
|
||||
itr != operationThreads.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <osg/Timer>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <OpenThreads/Thread>
|
||||
|
||||
#include "UnitTestFramework.h"
|
||||
#include "performance.h"
|
||||
|
||||
@@ -275,14 +277,20 @@ void testGetQuatFromMatrix(const osg::Vec3d& scale)
|
||||
osg::Quat out_quat2;
|
||||
out_quat2 = out_mat.getRotate();
|
||||
|
||||
// If the quaternion W is <0, then we should reflect
|
||||
// to get it into the positive W
|
||||
if(out_quat1.w()<0) out_quat1 = out_quat1 * -1.0;
|
||||
if(out_quat2.w()<0) out_quat2 = out_quat2 * -1.0;
|
||||
|
||||
|
||||
// if the output quat length is not one
|
||||
// or if the component magnitudes do not match,
|
||||
// or if the components do not match,
|
||||
// something is amiss
|
||||
if (fabs(1.0-out_quat2.length()) > eps ||
|
||||
(fabs(out_quat1.x())-fabs(out_quat2.x())) > eps ||
|
||||
(fabs(out_quat1.y())-fabs(out_quat2.y())) > eps ||
|
||||
(fabs(out_quat1.z())-fabs(out_quat2.z())) > eps ||
|
||||
(fabs(out_quat1.w())-fabs(out_quat2.w())) > eps) {
|
||||
(fabs(out_quat1.x()-out_quat2.x())) > eps ||
|
||||
(fabs(out_quat1.y()-out_quat2.y())) > eps ||
|
||||
(fabs(out_quat1.z()-out_quat2.z())) > eps ||
|
||||
(fabs(out_quat1.w()-out_quat2.w())) > eps) {
|
||||
std::cout << __FUNCTION__ << " problem at: \n"
|
||||
<< " r1=" << rol1
|
||||
<< " p1=" << pit1
|
||||
@@ -375,6 +383,26 @@ void testQuat(const osg::Vec3d& quat_scale)
|
||||
osg::notify(osg::NOTICE)<<"Matrix = "<<matrix<<"rotation = "<<quat<<", expected quat = (0,0,0,1)"<<std::endl;
|
||||
}
|
||||
|
||||
class MyThread : public OpenThreads::Thread {
|
||||
public:
|
||||
void run(void) { }
|
||||
};
|
||||
|
||||
void testThreadInitAndExit()
|
||||
{
|
||||
std::cout<<"****** Running thread start and delete test ****** "<<std::endl;
|
||||
|
||||
{
|
||||
MyThread thread;
|
||||
thread.startThread();
|
||||
}
|
||||
|
||||
// add a sleep to allow the thread start to fall over it its going to.
|
||||
OpenThreads::Thread::microSleep(500000);
|
||||
|
||||
std::cout<<"pass thread start and delete test"<<std::endl<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
@@ -408,7 +436,10 @@ int main( int argc, char** argv )
|
||||
while (arguments.read("sizeof")) printSizeOfTest = true;
|
||||
|
||||
bool printQuatTest = false;
|
||||
while (arguments.read("quat")) printQuatTest = true;
|
||||
while (arguments.read("quat")) printQuatTest = true;
|
||||
|
||||
bool doTestThreadInitAndExit = false;
|
||||
while (arguments.read("thread")) doTestThreadInitAndExit = true;
|
||||
|
||||
osg::Vec3d quat_scale(1.0,1.0,1.0);
|
||||
while (arguments.read("quat_scaled", quat_scale.x(), quat_scale.y(), quat_scale.z() )) printQuatTest = true;
|
||||
@@ -495,6 +526,11 @@ int main( int argc, char** argv )
|
||||
std::cout<<std::endl;
|
||||
}
|
||||
|
||||
if (doTestThreadInitAndExit)
|
||||
{
|
||||
testThreadInitAndExit();
|
||||
}
|
||||
|
||||
std::cout<<"****** Running tests ******"<<std::endl;
|
||||
|
||||
// Global Data or Context
|
||||
|
||||
@@ -102,6 +102,7 @@ class ViewerFLTK : public osgViewer::Viewer, public AdapterWidget
|
||||
AdapterWidget(x,y,w,h,label)
|
||||
{
|
||||
getCamera()->setViewport(new osg::Viewport(0,0,w,h));
|
||||
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(w)/static_cast<double>(h), 1.0f, 10000.0f);
|
||||
getCamera()->setGraphicsContext(getGraphicsWindow());
|
||||
setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
}
|
||||
|
||||
9
examples/osgviewerFOX/CMakeLists.txt
Normal file
9
examples/osgviewerFOX/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
SET(TARGET_SRC FOX_OSG.cpp FOX_OSG_MDIView.cpp osgviewerFOX.cpp )
|
||||
|
||||
SET(TARGET_H FOX_OSG.h FOX_OSG_MDIView.h osgviewerFOX.h)
|
||||
|
||||
INCLUDE_DIRECTORIES( ${FOX_INCLUDE_DIR} )
|
||||
SET(TARGET_EXTERNAL_LIBRARIES ${FOX_LIBRARY} )
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgviewerFOX)
|
||||
193
examples/osgviewerFOX/FOX_OSG.cpp
Normal file
193
examples/osgviewerFOX/FOX_OSG.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "FOX_OSG.h"
|
||||
|
||||
// Map
|
||||
FXDEFMAP(GraphicsWindowFOX) GraphicsWindowFOX_Map[] = {
|
||||
//________Message_Type_________ ___ID___ ________Message_Handler________
|
||||
FXMAPFUNC(SEL_CONFIGURE, 0, GraphicsWindowFOX::onConfigure),
|
||||
FXMAPFUNC(SEL_KEYPRESS, 0, GraphicsWindowFOX::onKeyPress),
|
||||
FXMAPFUNC(SEL_KEYRELEASE, 0, GraphicsWindowFOX::onKeyRelease),
|
||||
FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, GraphicsWindowFOX::onLeftBtnPress),
|
||||
FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, GraphicsWindowFOX::onLeftBtnRelease),
|
||||
FXMAPFUNC(SEL_MIDDLEBUTTONPRESS, 0, GraphicsWindowFOX::onMiddleBtnPress),
|
||||
FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE, 0, GraphicsWindowFOX::onMiddleBtnRelease),
|
||||
FXMAPFUNC(SEL_RIGHTBUTTONPRESS, 0, GraphicsWindowFOX::onRightBtnPress),
|
||||
FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, 0, GraphicsWindowFOX::onRightBtnRelease),
|
||||
FXMAPFUNC(SEL_MOTION, 0, GraphicsWindowFOX::onMotion)
|
||||
};
|
||||
|
||||
FXIMPLEMENT(GraphicsWindowFOX, FXGLCanvas, GraphicsWindowFOX_Map, ARRAYNUMBER(GraphicsWindowFOX_Map))
|
||||
|
||||
GraphicsWindowFOX::GraphicsWindowFOX(FXComposite *parent, FXGLVisual *vis,
|
||||
FXObject *tgt, FXSelector sel,
|
||||
FXuint opts, FXint x, FXint y,
|
||||
FXint w, FXint h)
|
||||
: FXGLCanvas(parent, vis, tgt, sel, opts, x, y, w, h)
|
||||
{
|
||||
// default cursor to standard
|
||||
_oldCursor = new FXCursor(parent->getApp(),CURSOR_CROSS);
|
||||
|
||||
_traits = new GraphicsContext::Traits;
|
||||
_traits->x = x;
|
||||
_traits->y = y;
|
||||
_traits->width = w;
|
||||
_traits->height = h;
|
||||
_traits->windowDecoration = false;
|
||||
_traits->doubleBuffer = true;
|
||||
_traits->sharedContext = 0;
|
||||
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
void GraphicsWindowFOX::init()
|
||||
{
|
||||
if (valid())
|
||||
{
|
||||
setState( new osg::State );
|
||||
getState()->setGraphicsContext(this);
|
||||
|
||||
if (_traits.valid() && _traits->sharedContext)
|
||||
{
|
||||
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
|
||||
incrementContextIDUsageCount( getState()->getContextID() );
|
||||
}
|
||||
else
|
||||
{
|
||||
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsWindowFOX::~GraphicsWindowFOX()
|
||||
{
|
||||
}
|
||||
|
||||
void GraphicsWindowFOX::grabFocus()
|
||||
{
|
||||
// focus this window
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void GraphicsWindowFOX::grabFocusIfPointerInWindow()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void GraphicsWindowFOX::useCursor(bool cursorOn)
|
||||
{
|
||||
if (cursorOn) {
|
||||
// show the old cursor
|
||||
setDefaultCursor(_oldCursor);
|
||||
}
|
||||
else {
|
||||
setDefaultCursor(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
bool GraphicsWindowFOX::makeCurrentImplementation()
|
||||
{
|
||||
FXGLCanvas::makeCurrent();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GraphicsWindowFOX::releaseContext()
|
||||
{
|
||||
FXGLCanvas::makeNonCurrent();
|
||||
return true;
|
||||
}
|
||||
|
||||
void GraphicsWindowFOX::swapBuffersImplementation()
|
||||
{
|
||||
FXGLCanvas::swapBuffers();
|
||||
}
|
||||
|
||||
|
||||
long GraphicsWindowFOX::onConfigure(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
// set GL viewport (not called by FXGLCanvas::onConfigure on all platforms...)
|
||||
// update the window dimensions, in case the window has been resized.
|
||||
getEventQueue()->windowResize(0, 0, getWidth(), getHeight());
|
||||
resized(0, 0, getWidth(), getHeight());
|
||||
|
||||
return FXGLCanvas::onConfigure(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onKeyPress(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
int key = ((FXEvent*)ptr)->code;
|
||||
getEventQueue()->keyPress(key);
|
||||
|
||||
return FXGLCanvas::onKeyPress(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onKeyRelease(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
int key = ((FXEvent*)ptr)->code;
|
||||
getEventQueue()->keyRelease(key);
|
||||
|
||||
return FXGLCanvas::onKeyRelease(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onLeftBtnPress(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
|
||||
|
||||
FXEvent* event=(FXEvent*)ptr;
|
||||
getEventQueue()->mouseButtonPress(event->click_x, event->click_y, 1);
|
||||
|
||||
return FXGLCanvas::onLeftBtnPress(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onLeftBtnRelease(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
FXEvent* event=(FXEvent*)ptr;
|
||||
getEventQueue()->mouseButtonRelease(event->click_x, event->click_y, 1);
|
||||
|
||||
return FXGLCanvas::onLeftBtnRelease(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onMiddleBtnPress(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
|
||||
|
||||
FXEvent* event=(FXEvent*)ptr;
|
||||
getEventQueue()->mouseButtonPress(event->click_x, event->click_y, 2);
|
||||
|
||||
return FXGLCanvas::onMiddleBtnPress(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onMiddleBtnRelease(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
FXEvent* event=(FXEvent*)ptr;
|
||||
getEventQueue()->mouseButtonRelease(event->click_x, event->click_y, 2);
|
||||
|
||||
return FXGLCanvas::onMiddleBtnRelease(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onRightBtnPress(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
|
||||
|
||||
FXEvent* event=(FXEvent*)ptr;
|
||||
getEventQueue()->mouseButtonPress(event->click_x, event->click_y, 3);
|
||||
|
||||
return FXGLCanvas::onRightBtnPress(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onRightBtnRelease(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
FXEvent* event=(FXEvent*)ptr;
|
||||
getEventQueue()->mouseButtonRelease(event->click_x, event->click_y, 3);
|
||||
|
||||
return FXGLCanvas::onRightBtnRelease(sender, sel, ptr);
|
||||
}
|
||||
|
||||
long GraphicsWindowFOX::onMotion(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
FXEvent* event=(FXEvent*)ptr;
|
||||
getEventQueue()->mouseMotion(event->win_x, event->win_y);
|
||||
|
||||
return FXGLCanvas::onMotion(sender, sel, ptr);
|
||||
}
|
||||
63
examples/osgviewerFOX/FOX_OSG.h
Normal file
63
examples/osgviewerFOX/FOX_OSG.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef _FOXOSG_H_
|
||||
#define _FOXOSG_H_
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <string>
|
||||
|
||||
#include <fx.h>
|
||||
#include <fx3d.h>
|
||||
|
||||
using namespace FX;
|
||||
|
||||
class GraphicsWindowFOX: public FXGLCanvas, public osgViewer::GraphicsWindow{
|
||||
|
||||
FXDECLARE(GraphicsWindowFOX)
|
||||
|
||||
public:
|
||||
GraphicsWindowFOX(FXComposite *parent, FXGLVisual *vis,
|
||||
FXObject *tgt=NULL, FXSelector sel=0,
|
||||
FXuint opts=0, FXint x=0, FXint y=0,
|
||||
FXint w=0, FXint h=0);
|
||||
|
||||
virtual ~GraphicsWindowFOX();
|
||||
|
||||
// callback
|
||||
long onConfigure(FXObject*, FXSelector, void*);
|
||||
long onKeyPress(FXObject*, FXSelector, void*);
|
||||
long onKeyRelease(FXObject*, FXSelector, void*);
|
||||
long onLeftBtnPress(FXObject*, FXSelector, void*);
|
||||
long onLeftBtnRelease(FXObject*, FXSelector, void*);
|
||||
long onMiddleBtnPress(FXObject*, FXSelector, void*);
|
||||
long onMiddleBtnRelease(FXObject*, FXSelector, void*);
|
||||
long onRightBtnPress(FXObject*, FXSelector, void*);
|
||||
long onRightBtnRelease(FXObject*, FXSelector, void*);
|
||||
long onMotion(FXObject*, FXSelector, void*);
|
||||
|
||||
void init();
|
||||
|
||||
//
|
||||
// GraphicsWindow interface
|
||||
//
|
||||
void grabFocus();
|
||||
void grabFocusIfPointerInWindow();
|
||||
void useCursor(bool cursorOn);
|
||||
|
||||
bool makeCurrentImplementation();
|
||||
bool releaseContext();
|
||||
void swapBuffersImplementation();
|
||||
|
||||
// note implemented yet...just use dummy implementation to get working.
|
||||
virtual bool valid() const { return true; }
|
||||
virtual bool realizeImplementation() { return true; }
|
||||
virtual bool isRealizedImplementation() const { return true; }
|
||||
virtual void closeImplementation() {}
|
||||
virtual bool releaseContextImplementation() { return true; }
|
||||
|
||||
protected:
|
||||
GraphicsWindowFOX(){};
|
||||
|
||||
private:
|
||||
FXCursor* _oldCursor;
|
||||
};
|
||||
|
||||
#endif // _FOXOSG_H_
|
||||
77
examples/osgviewerFOX/FOX_OSG_MDIView.cpp
Normal file
77
examples/osgviewerFOX/FOX_OSG_MDIView.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "FOX_OSG_MDIView.h"
|
||||
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
|
||||
// Map
|
||||
FXDEFMAP(FOX_OSG_MDIView) FOX_OSG_MDIView_Map[] = {
|
||||
//________Message_Type_________ ___ID___ ________Message_Handler________
|
||||
FXMAPFUNC(SEL_CHORE, FOX_OSG_MDIView::ID_CHORE, FOX_OSG_MDIView::OnIdle)
|
||||
};
|
||||
|
||||
FXIMPLEMENT(FOX_OSG_MDIView, FXMDIChild, FOX_OSG_MDIView_Map, ARRAYNUMBER(FOX_OSG_MDIView_Map))
|
||||
|
||||
FOX_OSG_MDIView::FOX_OSG_MDIView(FXMDIClient *p, const FXString &name,
|
||||
FXIcon *ic, FXPopup *pup, FXuint opt,
|
||||
FXint x, FXint y, FXint w, FXint h)
|
||||
: FXMDIChild(p, name, ic, pup, opt, x, y, w, h)
|
||||
{
|
||||
// A visual to drag OpenGL in double-buffered mode; note the glvisual is
|
||||
// shared between all windows which need the same depths and numbers of buffers
|
||||
// Thus, while the first visual may take some time to initialize, each subsequent
|
||||
// window can be created very quickly; we need to determine grpaphics hardware
|
||||
// characteristics only once.
|
||||
FXGLVisual* glVisual=new FXGLVisual(getApp(),VISUAL_DOUBLEBUFFER|VISUAL_STEREO);
|
||||
|
||||
m_gwFox = new GraphicsWindowFOX(this, glVisual, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y, x, y, w, h );
|
||||
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer;
|
||||
viewer->getCamera()->setGraphicsContext(m_gwFox);
|
||||
viewer->getCamera()->setViewport(0,0,w,h);
|
||||
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
// FOX example does not catch the close of the graphics window, so
|
||||
// don't allow the default escape sets to done to be active.
|
||||
viewer->setKeyEventSetsDone(0);
|
||||
|
||||
// load the scene.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
|
||||
if (!loadedModel)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
// add the stats handler
|
||||
viewer->addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
viewer->setSceneData(loadedModel.get());
|
||||
|
||||
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
SetViewer(viewer);
|
||||
|
||||
getApp()->addChore(this,ID_CHORE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
FOX_OSG_MDIView::~FOX_OSG_MDIView()
|
||||
{
|
||||
getApp()->removeChore(this,ID_CHORE);
|
||||
}
|
||||
|
||||
long FOX_OSG_MDIView::OnIdle(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
m_osgViewer->frame();
|
||||
getApp()->addChore(this, ID_CHORE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void FOX_OSG_MDIView::SetViewer(osgViewer::Viewer* viewer)
|
||||
{
|
||||
m_osgViewer = viewer;
|
||||
}
|
||||
41
examples/osgviewerFOX/FOX_OSG_MDIView.h
Normal file
41
examples/osgviewerFOX/FOX_OSG_MDIView.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef _FOXOSGMDIVIEW_H_
|
||||
#define _FOXOSGMDIVIEW_H_
|
||||
|
||||
#include "FOX_OSG.h"
|
||||
|
||||
#include <fx.h>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
using namespace FX;
|
||||
|
||||
class FOX_OSG_MDIView : public FXMDIChild{
|
||||
|
||||
FXDECLARE(FOX_OSG_MDIView)
|
||||
|
||||
public:
|
||||
FOX_OSG_MDIView(FXMDIClient *p, const FXString &name,
|
||||
FXIcon *ic=NULL, FXPopup *pup=NULL, FXuint opts=0,
|
||||
FXint x=0, FXint y=0, FXint w=0, FXint h=0);
|
||||
|
||||
virtual ~FOX_OSG_MDIView();
|
||||
|
||||
enum{
|
||||
ID_CHORE=FXMDIChild::ID_LAST,
|
||||
ID_LAST
|
||||
};
|
||||
|
||||
// callback
|
||||
long OnIdle(FXObject* , FXSelector, void*);
|
||||
|
||||
void SetViewer(osgViewer::Viewer *viewer);
|
||||
|
||||
protected:
|
||||
FOX_OSG_MDIView(){};
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osgViewer::Viewer> m_osgViewer;
|
||||
GraphicsWindowFOX* m_gwFox;
|
||||
};
|
||||
|
||||
#endif // _FOXOSGMDIVIEW_H_
|
||||
75
examples/osgviewerFOX/osgviewerFOX.cpp
Normal file
75
examples/osgviewerFOX/osgviewerFOX.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "osgviewerFOX.h"
|
||||
|
||||
#include "FOX_OSG_MDIView.h"
|
||||
|
||||
/* My frame constructor */
|
||||
MainFrame::MainFrame(FXApp *app, const FXString &name, FXIcon *ic, FXIcon *mi, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb, FXint hs, FXint vs) : FXMainWindow(app, name, ic, mi, opts, x, y, w, h, pl, pr, pt, pb, hs, vs)
|
||||
{
|
||||
|
||||
|
||||
// Site where to dock
|
||||
FXDockSite* topdock=new FXDockSite(this,DOCKSITE_NO_WRAP|LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
|
||||
|
||||
// Menubar 1
|
||||
m_fxToolbarShell1=new FXToolBarShell(this,FRAME_RAISED);
|
||||
FXMenuBar* menubar=new FXMenuBar(topdock,m_fxToolbarShell1,LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
|
||||
new FXToolBarGrip(menubar,menubar,FXMenuBar::ID_TOOLBARGRIP,TOOLBARGRIP_DOUBLE);
|
||||
|
||||
// Contents
|
||||
FXHorizontalFrame *frame=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0, 4,4);
|
||||
|
||||
// Nice sunken box around GL viewer
|
||||
FXVerticalFrame *box=new FXVerticalFrame(frame,FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
|
||||
|
||||
// MDI Client
|
||||
FXMDIClient* mdiclient=new FXMDIClient(box,LAYOUT_FILL_X|LAYOUT_FILL_Y);
|
||||
|
||||
// Make MDI Window Menu
|
||||
FXMDIMenu* mdimenu=new FXMDIMenu(this,mdiclient);
|
||||
|
||||
// MDI buttons in menu:- note the message ID's!!!!!
|
||||
// Normally, MDI commands are simply sensitized or desensitized;
|
||||
// Under the menubar, however, they're hidden if the MDI Client is
|
||||
// not maximized. To do this, they must have different ID's.
|
||||
new FXMDIWindowButton(menubar,mdimenu,mdiclient,FXMDIClient::ID_MDI_MENUWINDOW,LAYOUT_LEFT|LAYOUT_CENTER_Y);
|
||||
new FXMDIDeleteButton(menubar,mdiclient,FXMDIClient::ID_MDI_MENUCLOSE,FRAME_RAISED|LAYOUT_RIGHT|LAYOUT_CENTER_Y);
|
||||
new FXMDIRestoreButton(menubar,mdiclient,FXMDIClient::ID_MDI_MENURESTORE,FRAME_RAISED|LAYOUT_RIGHT|LAYOUT_CENTER_Y);
|
||||
new FXMDIMinimizeButton(menubar,mdiclient,FXMDIClient::ID_MDI_MENUMINIMIZE,FRAME_RAISED|LAYOUT_RIGHT|LAYOUT_CENTER_Y);
|
||||
|
||||
// Make an MDI Child
|
||||
FOX_OSG_MDIView* mdichild=new FOX_OSG_MDIView(mdiclient,"FOX osgViewer", NULL, mdimenu,MDI_TRACKING|MDI_MAXIMIZED,30,30,300,200);
|
||||
mdichild->setFocus();
|
||||
|
||||
// Make it active
|
||||
mdiclient->setActiveChild(mdichild);
|
||||
|
||||
}
|
||||
|
||||
// Create and initialize
|
||||
void MainFrame::create(){
|
||||
FXMainWindow::create();
|
||||
m_fxToolbarShell1->create();
|
||||
show(PLACEMENT_SCREEN);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv){
|
||||
|
||||
// Make application
|
||||
FXApp application("OSGViewer","FoxTest");
|
||||
|
||||
// Open the display
|
||||
application.init(argc,argv);
|
||||
|
||||
// Make window
|
||||
new MainFrame(&application, "Fox Toolkit OSG Sample", NULL, NULL, DECOR_ALL, 100, 100, 800, 600);
|
||||
|
||||
// Create the application's windows
|
||||
application.create();
|
||||
|
||||
// Run the application
|
||||
return application.run();
|
||||
}
|
||||
32
examples/osgviewerFOX/osgviewerFOX.h
Normal file
32
examples/osgviewerFOX/osgviewerFOX.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _FOXSIMPLEVIEWERFOX_H_
|
||||
#define _FOXSIMPLEVIEWERFOX_H_
|
||||
|
||||
|
||||
#include <fx.h>
|
||||
|
||||
using namespace FX;
|
||||
|
||||
class MainFrame : public FXMainWindow{
|
||||
|
||||
public:
|
||||
MainFrame(FXApp *a, const FXString &name,
|
||||
FXIcon *ic=NULL, FXIcon *mi=NULL,
|
||||
FXuint opts=DECOR_ALL,
|
||||
FXint x=0, FXint y=0,
|
||||
FXint w=0, FXint h=0,
|
||||
FXint pl=0, FXint pr=0, FXint pt=0, FXint pb=0,
|
||||
FXint hs=0, FXint vs=0);
|
||||
|
||||
|
||||
// Initialize
|
||||
virtual void create();
|
||||
|
||||
protected:
|
||||
MainFrame(){};
|
||||
|
||||
private:
|
||||
// GUI elements
|
||||
FXToolBarShell* m_fxToolbarShell1;
|
||||
};
|
||||
|
||||
#endif // _FOXSIMPLEVIEWERFOX_H_
|
||||
@@ -5,49 +5,17 @@
|
||||
|
||||
|
||||
cOSG::cOSG(HWND hWnd) :
|
||||
m_hWnd(hWnd), mDone(false)
|
||||
m_hWnd(hWnd)
|
||||
{
|
||||
//
|
||||
// We must set the pixelformat before we can create the OSG Rendering Surface
|
||||
//
|
||||
PIXELFORMATDESCRIPTOR pixelFormat =
|
||||
{
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
1,
|
||||
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA,
|
||||
24,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
24,
|
||||
0,
|
||||
0,
|
||||
PFD_MAIN_PLANE,
|
||||
0,
|
||||
0, 0, 0
|
||||
};
|
||||
}
|
||||
|
||||
HDC hdc = ::GetDC(m_hWnd);
|
||||
if (hdc==0)
|
||||
{
|
||||
::DestroyWindow(m_hWnd);
|
||||
return;
|
||||
}
|
||||
cOSG::~cOSG()
|
||||
{
|
||||
mViewer->setDone(true);
|
||||
Sleep(1000);
|
||||
mViewer->stopThreading();
|
||||
|
||||
int pixelFormatIndex = ::ChoosePixelFormat(hdc, &pixelFormat);
|
||||
if (pixelFormatIndex==0)
|
||||
{
|
||||
::ReleaseDC(m_hWnd, hdc);
|
||||
::DestroyWindow(m_hWnd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!::SetPixelFormat(hdc, pixelFormatIndex, &pixelFormat))
|
||||
{
|
||||
::ReleaseDC(m_hWnd, hdc);
|
||||
::DestroyWindow(m_hWnd);
|
||||
return;
|
||||
}
|
||||
delete mViewer;
|
||||
}
|
||||
|
||||
void cOSG::InitOSG(std::string modelname)
|
||||
@@ -100,7 +68,7 @@ void cOSG::InitCameraConfig(void)
|
||||
RECT rect;
|
||||
|
||||
// Create the viewer for this window
|
||||
mViewer = new osgViewer::Viewer;
|
||||
mViewer = new osgViewer::Viewer();
|
||||
|
||||
// Add a Stats Handler to the viewer
|
||||
mViewer->addEventHandler(new osgViewer::StatsHandler);
|
||||
@@ -122,6 +90,7 @@ void cOSG::InitCameraConfig(void)
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
traits->setInheritedWindowPixelFormat = true;
|
||||
traits->inheritedWindowData = windata;
|
||||
|
||||
// Create the Graphics Context
|
||||
@@ -183,6 +152,5 @@ void cOSG::Render(void* ptr)
|
||||
// and you exit one then all stop rendering
|
||||
AfxMessageBox("Exit Rendering Thread");
|
||||
|
||||
// Set Done to indicate that thread has exited
|
||||
osg->Done(true);
|
||||
_endthread();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class cOSG
|
||||
{
|
||||
public:
|
||||
cOSG(HWND hWnd);
|
||||
~cOSG(){};
|
||||
~cOSG();
|
||||
|
||||
void InitOSG(std::string filename);
|
||||
void InitManipulators(void);
|
||||
@@ -29,13 +29,13 @@ public:
|
||||
bool Done(void) { return mDone; }
|
||||
static void Render(void* ptr);
|
||||
|
||||
osgViewer::Viewer* getViewer() { return mViewer.get(); }
|
||||
osgViewer::Viewer* getViewer() { return mViewer; }
|
||||
|
||||
private:
|
||||
bool mDone;
|
||||
std::string m_ModelName;
|
||||
HWND m_hWnd;
|
||||
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
||||
osgViewer::Viewer* mViewer;
|
||||
osg::ref_ptr<osg::Group> mRoot;
|
||||
osg::ref_ptr<osg::Node> mModel;
|
||||
osg::ref_ptr<osgGA::TrackballManipulator> trackball;
|
||||
|
||||
@@ -17,6 +17,7 @@ BEGIN_MESSAGE_MAP(CMFC_OSG_MDIView, CView)
|
||||
ON_WM_CREATE()
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_KEYDOWN()
|
||||
ON_WM_ERASEBKGND()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
CMFC_OSG_MDIView::CMFC_OSG_MDIView() :
|
||||
@@ -74,21 +75,10 @@ int CMFC_OSG_MDIView::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
|
||||
void CMFC_OSG_MDIView::OnDestroy()
|
||||
{
|
||||
// Make sure OSG was created before we try to close it.
|
||||
if(mOSG)
|
||||
{
|
||||
|
||||
// Wait while the Viewer closes
|
||||
while(!mOSG->Done())
|
||||
{
|
||||
Sleep(10); // Allow others processor time
|
||||
}
|
||||
|
||||
// Remove mOSG
|
||||
delete mOSG;
|
||||
}
|
||||
if(mOSG != 0) delete mOSG;
|
||||
|
||||
WaitForSingleObject(mThreadHandle, 1000);
|
||||
|
||||
// Destroy Window
|
||||
CView::OnDestroy();
|
||||
}
|
||||
|
||||
@@ -103,7 +93,7 @@ void CMFC_OSG_MDIView::OnInitialUpdate()
|
||||
mOSG->InitOSG(csFileName.GetString());
|
||||
|
||||
// Start the thread to do OSG Rendering
|
||||
_beginthread(&cOSG::Render, 0, mOSG);
|
||||
mThreadHandle = (HANDLE)_beginthread(&cOSG::Render, 0, mOSG);
|
||||
}
|
||||
|
||||
void CMFC_OSG_MDIView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
@@ -118,3 +108,9 @@ void CMFC_OSG_MDIView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL CMFC_OSG_MDIView::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
/* Do nothing, to avoid flashing on MSW */
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
|
||||
protected:
|
||||
cOSG* mOSG;
|
||||
HANDLE mThreadHandle;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
@@ -42,6 +43,7 @@ protected:
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in MFC_OSG_MDIView.cpp
|
||||
|
||||
@@ -146,7 +146,9 @@ class ViewerQT : public osgViewer::Viewer, public AdapterWidget
|
||||
AdapterWidget( parent, name, shareWidget, f )
|
||||
{
|
||||
getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
|
||||
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
|
||||
getCamera()->setGraphicsContext(getGraphicsWindow());
|
||||
|
||||
setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
|
||||
|
||||
@@ -32,23 +32,30 @@ bool wxOsgApp::OnInit()
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
|
||||
int *attributes = new int[6];
|
||||
attributes[0] = int(WX_GL_DOUBLEBUFFER);
|
||||
attributes[1] = WX_GL_RGBA;
|
||||
attributes[2] = WX_GL_DEPTH_SIZE;
|
||||
attributes[3] = 8;
|
||||
attributes[4] = WX_GL_STENCIL_SIZE;
|
||||
attributes[5] = 8;
|
||||
|
||||
GraphicsWindowWX* gw = new GraphicsWindowWX(frame, wxID_ANY, wxDefaultPosition,
|
||||
wxSize(width, height), wxSUNKEN_BORDER);
|
||||
|
||||
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
|
||||
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer;
|
||||
viewer->getCamera()->setGraphicsContext(gw);
|
||||
viewer->getCamera()->setViewport(0,0,width,height);
|
||||
viewer->addEventHandler(new osgViewer::StatsHandler);
|
||||
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
|
||||
// load the scene.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
|
||||
if (!loadedModel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
viewer->setSceneData(loadedModel.get());
|
||||
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
@@ -81,7 +88,7 @@ void MainFrame::SetViewer(osgViewer::Viewer *viewer)
|
||||
void MainFrame::OnIdle(wxIdleEvent &event)
|
||||
{
|
||||
_viewer->frame();
|
||||
|
||||
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
@@ -95,12 +102,12 @@ BEGIN_EVENT_TABLE(GraphicsWindowWX, wxGLCanvas)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
GraphicsWindowWX::GraphicsWindowWX(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
||||
: wxGLCanvas(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE, name)
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attributes)
|
||||
: wxGLCanvas(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE, name, attributes)
|
||||
{
|
||||
// default cursor to standard
|
||||
_oldCursor = *wxSTANDARD_CURSOR;
|
||||
|
||||
|
||||
_traits = new GraphicsContext::Traits;
|
||||
_traits->x = pos.x;
|
||||
_traits->y = pos.y;
|
||||
@@ -108,7 +115,7 @@ GraphicsWindowWX::GraphicsWindowWX(wxWindow *parent, wxWindowID id,
|
||||
_traits->height = size.y;
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::init()
|
||||
@@ -121,7 +128,7 @@ void GraphicsWindowWX::init()
|
||||
if (_traits.valid() && _traits->sharedContext)
|
||||
{
|
||||
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
|
||||
incrementContextIDUsageCount( getState()->getContextID() );
|
||||
incrementContextIDUsageCount( getState()->getContextID() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,7 +155,7 @@ void GraphicsWindowWX::OnSize(wxSizeEvent& event)
|
||||
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
|
||||
int width, height;
|
||||
GetClientSize(&width, &height);
|
||||
|
||||
|
||||
// update the window dimensions, in case the window has been resized.
|
||||
getEventQueue()->windowResize(0, 0, width, height);
|
||||
resized(0,0,width,height);
|
||||
@@ -161,12 +168,12 @@ void GraphicsWindowWX::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
|
||||
|
||||
void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
|
||||
{
|
||||
#if 1
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
getEventQueue()->keyPress(key);
|
||||
getEventQueue()->keyPress(key);
|
||||
|
||||
// propagate event
|
||||
event.Skip();
|
||||
@@ -174,12 +181,12 @@ void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
|
||||
|
||||
void GraphicsWindowWX::OnKeyUp(wxKeyEvent &event)
|
||||
{
|
||||
#if 1
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
getEventQueue()->keyRelease(key);
|
||||
getEventQueue()->keyRelease(key);
|
||||
|
||||
// propagate event
|
||||
event.Skip();
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
#include <osgViewer/Viewer>
|
||||
#include <string>
|
||||
|
||||
class GraphicsWindowWX: public wxGLCanvas, public osgViewer::GraphicsWindow
|
||||
class GraphicsWindowWX : public wxGLCanvas, public osgViewer::GraphicsWindow
|
||||
{
|
||||
public:
|
||||
GraphicsWindowWX(wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = wxT("TestGLCanvas"));
|
||||
const wxString& name = wxT("TestGLCanvas"),
|
||||
int *attributes = 0);
|
||||
|
||||
~GraphicsWindowWX();
|
||||
|
||||
@@ -30,7 +31,6 @@ public:
|
||||
//
|
||||
// GraphicsWindow interface
|
||||
//
|
||||
|
||||
void grabFocus();
|
||||
void grabFocusIfPointerInWindow();
|
||||
void useCursor(bool cursorOn);
|
||||
|
||||
@@ -44,12 +44,15 @@ int main( int argc, char **argv )
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
int xoffset = 40;
|
||||
int yoffset = 40;
|
||||
|
||||
// left window + left slave camera
|
||||
{
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = 640;
|
||||
traits->x = xoffset + 0;
|
||||
traits->y = yoffset + 0;
|
||||
traits->width = 600;
|
||||
traits->height = 480;
|
||||
traits->windowDecoration = true;
|
||||
traits->doubleBuffer = true;
|
||||
@@ -64,16 +67,16 @@ int main( int argc, char **argv )
|
||||
camera->setDrawBuffer(buffer);
|
||||
camera->setReadBuffer(buffer);
|
||||
|
||||
// add this slave camra to the viewer, with a shift left of the projection matrix
|
||||
// add this slave camera to the viewer, with a shift left of the projection matrix
|
||||
viewer.addSlave(camera.get(), osg::Matrixd::translate(1.0,0.0,0.0), osg::Matrixd());
|
||||
}
|
||||
|
||||
// left window + left slave camera
|
||||
// right window + right slave camera
|
||||
{
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->x = 640;
|
||||
traits->y = 0;
|
||||
traits->width = 640;
|
||||
traits->x = xoffset + 600;
|
||||
traits->y = yoffset + 0;
|
||||
traits->width = 600;
|
||||
traits->height = 480;
|
||||
traits->windowDecoration = true;
|
||||
traits->doubleBuffer = true;
|
||||
@@ -88,7 +91,7 @@ int main( int argc, char **argv )
|
||||
camera->setDrawBuffer(buffer);
|
||||
camera->setReadBuffer(buffer);
|
||||
|
||||
// add this slave camra to the viewer, with a shift right of the projection matrix
|
||||
// add this slave camera to the viewer, with a shift right of the projection matrix
|
||||
viewer.addSlave(camera.get(), osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd());
|
||||
}
|
||||
|
||||
|
||||
128
genwrapper.conf
128
genwrapper.conf
@@ -52,6 +52,11 @@ configure file /osg\/GraphicsContext/
|
||||
"
|
||||
end
|
||||
|
||||
configure file /osgViewer\/ViewerBase/
|
||||
emit before "#include <osgViewer/View>
|
||||
"
|
||||
end
|
||||
|
||||
#############################################################################
|
||||
|
||||
# add <io_utils> header to Plane, Quat and Vec* files
|
||||
@@ -179,22 +184,22 @@ end
|
||||
|
||||
configure file "osg/Array"
|
||||
emit after "
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2b>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3b>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4b>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2s>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3s>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4s>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4ub>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLubyte>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLbyte>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLushort>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLshort>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLuint>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLint>);
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2b>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3b>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4b>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2s>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3s>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4s>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4ub>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLubyte>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLbyte>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLushort>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLshort>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLuint>)
|
||||
STD_VECTOR_REFLECTOR(std::vector<GLint>)
|
||||
"
|
||||
end
|
||||
|
||||
@@ -203,7 +208,7 @@ end
|
||||
# StateSet and related types need some advanced tweaking
|
||||
|
||||
configure reflector "std::map< osg::StateAttribute::GLMode, osg::StateAttribute::GLModeValue >"
|
||||
replace with "STD_MAP_REFLECTOR_WITH_TYPES(std::map< osg::StateAttribute::GLMode COMMA osg::StateAttribute::GLModeValue >, osg::StateAttribute::GLMode, osg::StateAttribute::Values);"
|
||||
replace with "STD_MAP_REFLECTOR_WITH_TYPES(std::map< osg::StateAttribute::GLMode COMMA osg::StateAttribute::GLModeValue >, osg::StateAttribute::GLMode, osg::StateAttribute::Values)"
|
||||
end
|
||||
|
||||
configure reflector "osg::StateSet"
|
||||
@@ -286,6 +291,10 @@ configure reflector "OpenThreads::Block"
|
||||
object-type
|
||||
end
|
||||
|
||||
configure reflector "OpenThreads::BlockCount"
|
||||
object-type
|
||||
end
|
||||
|
||||
configure reflector "OpenThreads::Barrier"
|
||||
object-type
|
||||
end
|
||||
@@ -321,12 +330,12 @@ end
|
||||
# Doxygen doesn't parse ReadFunc and WriteFunc correctly...
|
||||
|
||||
configure reflector "osgDB::DotOsgWrapper::ReadFunc"
|
||||
replace with "TYPE_NAME_ALIAS(bool (*)(osg::Object&,osgDB::Input&), osgDB::DotOsgWrapper::ReadFunc);
|
||||
replace with "TYPE_NAME_ALIAS(bool (*)(osg::Object&,osgDB::Input&), osgDB::DotOsgWrapper::ReadFunc)
|
||||
"
|
||||
end
|
||||
|
||||
configure reflector "osgDB::DotOsgWrapper::WriteFunc"
|
||||
replace with "TYPE_NAME_ALIAS(bool (*)(const osg::Object&,osgDB::Output&), osgDB::DotOsgWrapper::WriteFunc);
|
||||
replace with "TYPE_NAME_ALIAS(bool (*)(const osg::Object&,osgDB::Output&), osgDB::DotOsgWrapper::WriteFunc)
|
||||
"
|
||||
end
|
||||
|
||||
@@ -359,6 +368,87 @@ configure reflector "osg::Drawable::Extensions"
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::BlendColor::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::BlendEquation::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::BlendFunc::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::FragmentProgram::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::Multisample::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::Point::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::ClampColor::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::Texture::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::Texture2DArray::Extensions"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
configure method "__typedef__GLboolean__APIENTRY_P1"
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::State"
|
||||
configure method "__typedef__void__APIENTRY_P1"
|
||||
replace with ""
|
||||
|
||||
@@ -33,6 +33,7 @@ class OSG_EXPORT ArgumentParser
|
||||
public:
|
||||
enum ParameterType
|
||||
{
|
||||
BOOL_PARAMETER,
|
||||
FLOAT_PARAMETER,
|
||||
DOUBLE_PARAMETER,
|
||||
INT_PARAMETER,
|
||||
@@ -42,6 +43,7 @@ class OSG_EXPORT ArgumentParser
|
||||
|
||||
union ValueUnion
|
||||
{
|
||||
bool* _bool;
|
||||
float* _float;
|
||||
double* _double;
|
||||
int* _int;
|
||||
@@ -49,6 +51,8 @@ class OSG_EXPORT ArgumentParser
|
||||
std::string* _string;
|
||||
};
|
||||
|
||||
Parameter(bool& value) { _type = BOOL_PARAMETER; _value._bool = &value; }
|
||||
|
||||
Parameter(float& value) { _type = FLOAT_PARAMETER; _value._float = &value; }
|
||||
|
||||
Parameter(double& value) { _type = DOUBLE_PARAMETER; _value._double = &value; }
|
||||
@@ -83,6 +87,9 @@ class OSG_EXPORT ArgumentParser
|
||||
/** Return true if specified parameter is a number. */
|
||||
static bool isNumber(const char* str);
|
||||
|
||||
/** Return true if specified parameter is a bool. */
|
||||
static bool isBool(const char* str);
|
||||
|
||||
public:
|
||||
|
||||
ArgumentParser(int* argc,char **argv);
|
||||
|
||||
@@ -81,21 +81,21 @@ class OSG_EXPORT BlendColor : public StateAttribute
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtenions(unsigned int contextID);
|
||||
void setupGLExtensions(unsigned int contextID);
|
||||
|
||||
void setBlendColorSupported(bool flag) { _isBlendColorSupported=flag; }
|
||||
bool isBlendColorSupported() const { return _isBlendColorSupported; }
|
||||
|
||||
void setBlendColorProc(void* ptr) { _glBlendColor = ptr; }
|
||||
void glBlendColor(GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha) const;
|
||||
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
bool _isBlendColorSupported;
|
||||
|
||||
void* _glBlendColor;
|
||||
typedef void (APIENTRY * GLBlendColorProc) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||
bool _isBlendColorSupported;
|
||||
GLBlendColorProc _glBlendColor;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -103,25 +103,26 @@ class OSG_EXPORT BlendEquation : public StateAttribute
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtenions(unsigned int contextID);
|
||||
void setupGLExtensions(unsigned int contextID);
|
||||
|
||||
void setBlendEquationSupported(bool flag) { _isBlendEquationSupported=flag; }
|
||||
bool isBlendEquationSupported() const { return _isBlendEquationSupported; }
|
||||
bool isSGIXMinMaxSupported() const { return _isSGIXMinMaxSupported; }
|
||||
bool isLogicOpSupported() const { return _isLogicOpSupported; }
|
||||
|
||||
void setBlendEquationProc(void* ptr) { _glBlendEquation = ptr; }
|
||||
void glBlendEquation(GLenum mode) const;
|
||||
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
bool _isBlendEquationSupported;
|
||||
bool _isSGIXMinMaxSupported;
|
||||
bool _isLogicOpSupported;
|
||||
typedef void (APIENTRY * GLBlendEquationProc) (GLenum mode);
|
||||
|
||||
void* _glBlendEquation;
|
||||
bool _isBlendEquationSupported;
|
||||
bool _isSGIXMinMaxSupported;
|
||||
bool _isLogicOpSupported;
|
||||
|
||||
GLBlendEquationProc _glBlendEquation;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -147,7 +147,6 @@ class OSG_EXPORT BlendFunc : public StateAttribute
|
||||
void setBlendFuncSeparateSupported(bool flag) { _isBlendFuncSeparateSupported=flag; }
|
||||
bool isBlendFuncSeparateSupported() const { return _isBlendFuncSeparateSupported; }
|
||||
|
||||
void setBlendFuncSeparateProc(void* ptr) { _glBlendFuncSeparate = ptr; }
|
||||
void glBlendFuncSeparate(GLenum sfactorRGB,
|
||||
GLenum dfactorRGB,
|
||||
GLenum sfactorAlpha,
|
||||
@@ -157,9 +156,13 @@ class OSG_EXPORT BlendFunc : public StateAttribute
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
bool _isBlendFuncSeparateSupported;
|
||||
|
||||
void* _glBlendFuncSeparate;
|
||||
typedef void (APIENTRY * GLBlendFuncSeparateProc) (GLenum sfactorRGB,
|
||||
GLenum dfactorRGB,
|
||||
GLenum sfactorAlpha,
|
||||
GLenum dfactorAlpha);
|
||||
bool _isBlendFuncSeparateSupported;
|
||||
GLBlendFuncSeparateProc _glBlendFuncSeparate;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -93,6 +93,16 @@ class OSG_EXPORT BufferObject : public Object
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "BufferObject"; }
|
||||
|
||||
/** Set what type of usage the buffer object will have. Options are:
|
||||
* GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY,
|
||||
* GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY,
|
||||
* GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.
|
||||
*/
|
||||
void setUsage(GLenum usage) { _usage = usage; }
|
||||
|
||||
/** Get the type of usage the buffer object has been set up for.*/
|
||||
GLenum getUsage() const { return _usage; }
|
||||
|
||||
struct BufferEntry
|
||||
{
|
||||
BufferEntry(): dataSize(0),offset(0) {}
|
||||
@@ -159,7 +169,7 @@ class OSG_EXPORT BufferObject : public Object
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtenions(unsigned int contextID);
|
||||
void setupGLExtensions(unsigned int contextID);
|
||||
|
||||
bool isBufferObjectSupported() const { return _glGenBuffers!=0; }
|
||||
bool isPBOSupported() const { return _isPBOSupported; }
|
||||
@@ -281,8 +291,8 @@ class OSG_EXPORT ElementBufferObject : public BufferObject
|
||||
|
||||
META_Object(osg,ElementBufferObject);
|
||||
|
||||
typedef std::pair< BufferEntry, DrawElements* > BufferEntryDrawElementstPair;
|
||||
typedef std::vector< BufferEntryDrawElementstPair > BufferEntryDrawElementsPairs;
|
||||
typedef std::pair< BufferEntry, DrawElements* > BufferEntryDrawElementsPair;
|
||||
typedef std::vector< BufferEntryDrawElementsPair > BufferEntryDrawElementsPairs;
|
||||
|
||||
unsigned int addDrawElements(osg::DrawElements* PrimitiveSet);
|
||||
void removeDrawElements(osg::DrawElements* PrimitiveSet);
|
||||
|
||||
@@ -352,13 +352,13 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
void createCameraThread();
|
||||
|
||||
/** Assign a operation thread to the camera.*/
|
||||
void setCameraThread(OperationsThread* gt);
|
||||
void setCameraThread(OperationThread* gt);
|
||||
|
||||
/** Get the operation thread assigned to this camera.*/
|
||||
OperationsThread* getCameraThread() { return _cameraThread.get(); }
|
||||
OperationThread* getCameraThread() { return _cameraThread.get(); }
|
||||
|
||||
/** Get the const operation thread assigned to this camera.*/
|
||||
const OperationsThread* getCameraThread() const { return _cameraThread.get(); }
|
||||
const OperationThread* getCameraThread() const { return _cameraThread.get(); }
|
||||
|
||||
|
||||
|
||||
@@ -373,13 +373,23 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
|
||||
|
||||
/** Set the Rendering object that is used to implement rendering of the subgraph.*/
|
||||
void setRenderingCache(unsigned int contextID, osg::Object* rc) { _renderingCache[contextID] = rc; }
|
||||
void setRenderer(osg::GraphicsOperation* rc) { _renderer = rc; }
|
||||
|
||||
/** Get the Rendering object that is used to implement rendering of the subgraph.*/
|
||||
osg::Object* getRenderingCache(unsigned int contextID) { return _renderingCache[contextID].get(); }
|
||||
osg::GraphicsOperation* getRenderer() { return _renderer.get(); }
|
||||
|
||||
/** Get the const Rendering object that is used to implement rendering of the subgraph.*/
|
||||
const osg::Object* getRenderingCache(unsigned int contextID) const { return _renderingCache[contextID].get(); }
|
||||
const osg::GraphicsOperation* getRenderer() const { return _renderer.get(); }
|
||||
|
||||
|
||||
/** Set the Rendering cache that is used for cached objects associated with rendering of subgraphs.*/
|
||||
void setRenderingCache(osg::Object* rc) { _renderingCache = rc; }
|
||||
|
||||
/** Get the Rendering cache that is used for cached objects associated with rendering of subgraphs.*/
|
||||
osg::Object* getRenderingCache() { return _renderingCache.get(); }
|
||||
|
||||
/** Get the const Rendering cache that is used for cached objects associated with rendering of subgraphs.*/
|
||||
const osg::Object* getRenderingCache() const { return _renderingCache.get(); }
|
||||
|
||||
|
||||
/** Draw callback for custom operations.*/
|
||||
@@ -467,11 +477,12 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
RenderTargetImplementation _renderTargetFallback;
|
||||
BufferAttachmentMap _bufferAttachmentMap;
|
||||
|
||||
ref_ptr<OperationsThread> _cameraThread;
|
||||
ref_ptr<OperationThread> _cameraThread;
|
||||
|
||||
ref_ptr<GraphicsContext> _graphicsContext;
|
||||
|
||||
buffered_object< ref_ptr<Object> > _renderingCache;
|
||||
ref_ptr<GraphicsOperation> _renderer;
|
||||
ref_ptr<Object> _renderingCache;
|
||||
|
||||
ref_ptr<DrawCallback> _preDrawCallback;
|
||||
ref_ptr<DrawCallback> _postDrawCallback;
|
||||
|
||||
@@ -89,21 +89,20 @@ class OSG_EXPORT ClampColor : public StateAttribute
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtenions(unsigned int contextID);
|
||||
void setupGLExtensions(unsigned int contextID);
|
||||
|
||||
void setClampColorSupported(bool flag) { _isClampColorSupported=flag; }
|
||||
bool isClampColorSupported() const { return _isClampColorSupported; }
|
||||
|
||||
void setClampColorProc(void* ptr) { _glClampColor = ptr; }
|
||||
void glClampColor(GLenum target, GLenum mode) const;
|
||||
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
bool _isClampColorSupported;
|
||||
|
||||
void* _glClampColor;
|
||||
typedef void (APIENTRY * GLClampColorProc) (GLenum target, GLenum mode);
|
||||
bool _isClampColorSupported;
|
||||
GLClampColorProc _glClampColor;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class OSG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::
|
||||
void setCreateDrawablesOnOccludeNodes(bool flag) { _createDrawables=flag; }
|
||||
bool getCreateDrawablesOnOccludeNodes() const { return _createDrawables; }
|
||||
|
||||
void setCollectedOcculderSet(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
|
||||
void setCollectedOccluderSet(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
|
||||
ShadowVolumeOccluderSet& getCollectedOccluderSet() { return _occluderSet; }
|
||||
const ShadowVolumeOccluderSet& getCollectedOccluderSet() const { return _occluderSet; }
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class OSG_EXPORT CullSettings
|
||||
unsigned int getInheritanceMask() const { return _inheritanceMask; }
|
||||
|
||||
/** Set the local cull settings values from specified CullSettings object.*/
|
||||
void setCullSettings(const CullSettings& settings) { inheritCullSettings(settings, ALL_VARIABLES); }
|
||||
void setCullSettings(const CullSettings& settings);
|
||||
|
||||
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
|
||||
virtual void inheritCullSettings(const CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }
|
||||
|
||||
@@ -31,6 +31,7 @@ class OSG_EXPORT CullStack : public osg::CullSettings
|
||||
|
||||
|
||||
CullStack();
|
||||
CullStack(const CullStack& cs);
|
||||
|
||||
~CullStack();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class OSG_EXPORT DeleteHandler
|
||||
|
||||
DeleteHandler(int numberOfFramesToRetainObjects=0);
|
||||
|
||||
virtual ~DeleteHandler() { flushAll(); }
|
||||
virtual ~DeleteHandler();
|
||||
|
||||
/** Set the number of frames to retain objects that are have been requested for deletion.
|
||||
* When set to zero objects are deleted immediately, by set to 1 there are kept around for an extra frame etc.
|
||||
@@ -71,7 +71,9 @@ class OSG_EXPORT DeleteHandler
|
||||
|
||||
protected:
|
||||
|
||||
DeleteHandler(const DeleteHandler&) {}
|
||||
DeleteHandler(const DeleteHandler&):
|
||||
_numFramesToRetainObjects(0),
|
||||
_currentFrameNumber(0) {}
|
||||
DeleteHandler operator = (const DeleteHandler&) { return *this; }
|
||||
|
||||
int _numFramesToRetainObjects;
|
||||
|
||||
@@ -36,13 +36,15 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
static DisplaySettings* instance();
|
||||
|
||||
|
||||
DisplaySettings()
|
||||
DisplaySettings():
|
||||
Referenced(true)
|
||||
{
|
||||
setDefaults();
|
||||
readEnvironmentalVariables();
|
||||
}
|
||||
|
||||
DisplaySettings(ArgumentParser& arguments)
|
||||
DisplaySettings(ArgumentParser& arguments):
|
||||
Referenced(true)
|
||||
{
|
||||
setDefaults();
|
||||
readEnvironmentalVariables();
|
||||
@@ -92,7 +94,8 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
LEFT_EYE,
|
||||
RIGHT_EYE,
|
||||
HORIZONTAL_INTERLACE,
|
||||
VERTICAL_INTERLACE
|
||||
VERTICAL_INTERLACE,
|
||||
CHECKERBOARD
|
||||
};
|
||||
|
||||
void setStereoMode(StereoMode mode) { _stereoMode = mode; }
|
||||
@@ -125,8 +128,8 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
void setSplitStereoVerticalSeparation(int s) { _splitStereoVerticalSeparation = s; }
|
||||
int getSplitStereoVerticalSeparation() const { return _splitStereoVerticalSeparation; }
|
||||
|
||||
void setSplitStereoAutoAjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
|
||||
bool getSplitStereoAutoAjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
|
||||
void setSplitStereoAutoAdjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
|
||||
bool getSplitStereoAutoAdjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
|
||||
|
||||
|
||||
void setScreenWidth(float width) { _screenWidth = width; }
|
||||
@@ -174,6 +177,12 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
void setNumMultiSamples(unsigned int samples) { _numMultiSamples = samples; }
|
||||
unsigned int getNumMultiSamples() const { return _numMultiSamples; }
|
||||
bool getMultiSamples() const { return _numMultiSamples!=0; }
|
||||
|
||||
void setCompileContextsHint(bool useCompileContexts) { _compileContextsHint = useCompileContexts; }
|
||||
bool getCompileContextsHint() const { return _compileContextsHint; }
|
||||
|
||||
void setSerializeDrawDispatch(bool serializeDrawDispatch) { _serializeDrawDispatch = serializeDrawDispatch; }
|
||||
bool getSerializeDrawDispatch() const { return _serializeDrawDispatch; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -207,6 +216,9 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
unsigned int _maxNumOfGraphicsContexts;
|
||||
|
||||
unsigned int _numMultiSamples;
|
||||
|
||||
bool _compileContextsHint;
|
||||
bool _serializeDrawDispatch;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -575,7 +575,7 @@ class OSG_EXPORT Drawable : public Object
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtenions(unsigned int contextID);
|
||||
void setupGLExtensions(unsigned int contextID);
|
||||
|
||||
void setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; }
|
||||
bool isVertexProgramSupported() const { return _isVertexProgramSupported; }
|
||||
|
||||
@@ -240,7 +240,7 @@ class OSG_EXPORT FragmentProgram : public StateAttribute
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtenions(unsigned int contextID);
|
||||
void setupGLExtensions(unsigned int contextID);
|
||||
|
||||
void setFragmentProgramSupported(bool flag) { _isFragmentProgramSupported=flag; }
|
||||
bool isFragmentProgramSupported() const { return _isFragmentProgramSupported; }
|
||||
@@ -257,11 +257,17 @@ class OSG_EXPORT FragmentProgram : public StateAttribute
|
||||
|
||||
bool _isFragmentProgramSupported;
|
||||
|
||||
void* _glBindProgram;
|
||||
void* _glGenPrograms;
|
||||
void *_glDeletePrograms;
|
||||
void* _glProgramString;
|
||||
void* _glProgramLocalParameter4fv;
|
||||
typedef void (APIENTRY * BindProgramProc) (GLenum target, GLuint id);
|
||||
typedef void (APIENTRY * GenProgramsProc) (GLsizei n, GLuint *programs);
|
||||
typedef void (APIENTRY * DeleteProgramsProc) (GLsizei n, GLuint *programs);
|
||||
typedef void (APIENTRY * ProgramStringProc) (GLenum target, GLenum format, GLsizei len, const void *string);
|
||||
typedef void (APIENTRY * ProgramLocalParameter4fvProc) (GLenum target, GLuint index, const GLfloat *params);
|
||||
|
||||
BindProgramProc _glBindProgram;
|
||||
GenProgramsProc _glGenPrograms;
|
||||
DeleteProgramsProc _glDeletePrograms;
|
||||
ProgramStringProc _glProgramString;
|
||||
ProgramLocalParameter4fvProc _glProgramLocalParameter4fv;
|
||||
};
|
||||
|
||||
/** Function to call to get the extension of a specified context.
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
|
||||
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
|
||||
#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
|
||||
#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
|
||||
@@ -105,13 +106,16 @@ namespace osg
|
||||
typedef void APIENTRY TglFramebufferTexture1DEXT(GLenum, GLenum, GLenum, GLuint, GLint);
|
||||
typedef void APIENTRY TglFramebufferTexture2DEXT(GLenum, GLenum, GLenum, GLuint, GLint);
|
||||
typedef void APIENTRY TglFramebufferTexture3DEXT(GLenum, GLenum, GLenum, GLuint, GLint, GLint);
|
||||
typedef void APIENTRY TglFramebufferTextureLayerEXT(GLenum, GLenum, GLuint, GLint, GLint);
|
||||
typedef void APIENTRY TglFramebufferRenderbufferEXT(GLenum, GLenum, GLenum, GLuint);
|
||||
typedef void APIENTRY TglGenerateMipmapEXT(GLenum);
|
||||
|
||||
typedef void APIENTRY TglRenderbufferStorageMultisampleCoverageNV(GLenum, GLuint, GLuint, GLenum, GLuint, GLuint);
|
||||
|
||||
TglBindRenderbufferEXT* glBindRenderbufferEXT;
|
||||
TglGenRenderbuffersEXT* glGenRenderbuffersEXT;
|
||||
TglDeleteRenderbuffersEXT* glDeleteRenderbuffersEXT;
|
||||
TglRenderbufferStorageEXT* glRenderbufferStorageEXT;
|
||||
TglRenderbufferStorageMultisampleCoverageNV* glRenderbufferStorageMultisampleCoverageNV;
|
||||
TglBindFramebufferEXT* glBindFramebufferEXT;
|
||||
TglDeleteFramebuffersEXT* glDeleteFramebuffersEXT;
|
||||
TglGenFramebuffersEXT* glGenFramebuffersEXT;
|
||||
@@ -119,6 +123,7 @@ namespace osg
|
||||
TglFramebufferTexture1DEXT* glFramebufferTexture1DEXT;
|
||||
TglFramebufferTexture2DEXT* glFramebufferTexture2DEXT;
|
||||
TglFramebufferTexture3DEXT* glFramebufferTexture3DEXT;
|
||||
TglFramebufferTextureLayerEXT* glFramebufferTextureLayerEXT;
|
||||
TglFramebufferRenderbufferEXT* glFramebufferRenderbufferEXT;
|
||||
TglGenerateMipmapEXT* glGenerateMipmapEXT;
|
||||
|
||||
@@ -246,6 +251,7 @@ namespace osg
|
||||
class Texture1D;
|
||||
class Texture2D;
|
||||
class Texture3D;
|
||||
class Texture2DArray;
|
||||
class TextureCubeMap;
|
||||
class TextureRectangle;
|
||||
|
||||
@@ -259,6 +265,7 @@ namespace osg
|
||||
explicit FrameBufferAttachment(Texture1D* target, int level = 0);
|
||||
explicit FrameBufferAttachment(Texture2D* target, int level = 0);
|
||||
explicit FrameBufferAttachment(Texture3D* target, int zoffset, int level = 0);
|
||||
explicit FrameBufferAttachment(Texture2DArray* target, int layer, int level = 0);
|
||||
explicit FrameBufferAttachment(TextureCubeMap* target, int face, int level = 0);
|
||||
explicit FrameBufferAttachment(TextureRectangle* target);
|
||||
explicit FrameBufferAttachment(Camera::Attachment& attachment);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
* Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
|
||||
* Copyright (C) 2004-2005 Nathan Cournia
|
||||
* Copyright (C) 2007 Art Tevs
|
||||
*
|
||||
* This application is open source and may be redistributed and/or modified
|
||||
* freely and without restriction, both in commericial and non commericial
|
||||
@@ -23,6 +24,14 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef GL_SAMPLER_2D_ARRAY_EXT
|
||||
#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0
|
||||
#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1
|
||||
#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3
|
||||
#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef GL_VERSION_2_0 //[
|
||||
#define GL_VERSION_2_0 1
|
||||
typedef char GLchar;
|
||||
@@ -255,6 +264,11 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
||||
bool getProgramInfoLog( GLuint program, std::string& result ) const;
|
||||
bool getShaderInfoLog( GLuint shader, std::string& result ) const;
|
||||
bool getAttribLocation( const char* attribName, GLuint& slot ) const;
|
||||
bool getFragDataLocation( const char* fragDataName, GLuint& slot) const;
|
||||
|
||||
//EXT_gpu_shader4 to support frag data binding
|
||||
void glBindFragDataLocation(GLuint program, GLuint colorNumber, const GLchar *name) const;
|
||||
GLint glGetFragDataLocation(GLuint program, const GLchar *name) const;
|
||||
|
||||
protected:
|
||||
~GL2Extensions() {}
|
||||
@@ -365,6 +379,9 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
||||
void* _glGetObjectParameterivARB;
|
||||
void* _glDeleteObjectARB;
|
||||
void* _glGetHandleARB;
|
||||
|
||||
void* _glBindFragDataLocation;
|
||||
void* _glGetFragDataLocation;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user