Il 3D sta diventando di massima importanza nella comunicazione visuale che il web impone oggigiorno.
Penso sia assolutamente il futuro dell'interfaccia da qui a breve.
Per condividere i nostri ambienti, oggetti e personaggi tridimensionali attraverso internet abbiamo un disperato bisogno
di plug-ins che si occupino del gravoso processo di rendering magari, ripeto ed enfatizzo "magari!", appoggiandosi
sull'hardware dei nostri ninja PC's. Suvvia! Siamo o no nel 2008?!...
Recentemente Adobe® è uscita allo scoperto in tal senso proponendo la nuova versione del Flash Player (la 10 in beta)
e la tecnologia
Astro in esso contenuta, con tanto di rendering 3D GPU-based!
Gran roba, allettante davvero.
Purtroppo Silverlight non sembra mostrare la stessa volontà di perseguire tale strada (almeno per ora non si sente nulla, vediamo che succede nel
prossimo futuro), d'altra parte le enormi possibilità di estensibilità permesse dal DLR e da Visual Studio come IDE possono far venire in testa
a qualcuno di cimentarsi con il puro software rendering per produrre qualche effettuccio tridimensionale... "qualcuno" annovera anche me adesso!
E' la prima volta che provo a creare un engine 3D per il rendering real-time e devo ammetterlo: è davvero divertente.
Ci sono talmente tanti aspetti di cui tenere conto e tanta matematica da tirare in ballo che un progetto di tal fatta non può non
risultare intrigante e coinvolgente!
Nel diagramma sopra c'è un estratto di ciò che sono riuscito a mettere insieme, mancano
le struct relative a vettori, matrici, quaternioni e così via ma quelle sono piuttosto simili a quelle che trovate nell'assembly
PresentationCore del .Net 3 e riguardano aspetti di matematica/geometria ormai comuni e noti ai più.
Come primo esempio applicativo di questo mio embrionale engine
è possibile visionare il seguente link (figura sotto).
Relazioni gerarchiche tra elementi, trasformazioni affini, movimenti di camera, luce direzionale sono aspetti
gestiti e trattati in tale micro-applicativo.
Penso sia utile rendervi informati sul fatto che il sistema di coordinate che ho adottato è levogiro: con
l'asse x che corre da sinistra a destra lungo lo schermo, l'asse y dal basso in alto mentre l'asse z esce perpendicolarmente dal piano
individuato dal monitor.
Instruzioni per l'uso:
- utilizzare le frecce destra e sinistra per ruotare il gruppo di poliedri attorno all'asse y.
- utilizzare le frecce su e giù per muovere la camera lungo una circonferenza il cui piano è sovrapposto a quello yz.
Dati di riscontro sulla "situazione" complessiva della camera sono evidenziati in alto a sinistra nell'interfaccia.
- è possibile testare aspetti interattivi di roll-over sul dodecaedro per vederne mutare il materiale.
Ok, "dov'è il codice?" direte voi... mi piacerebbe davvero postarne, ma:
- Non riesco a risolvere un problema di memory leaking che mi fa uscire pazzo...
- Potete sempre hack-are lo xap file! ;)
Memory leak issue:
il problema è riscontrabile dal fatto che la memoria utilizzata dall'istanza del browser nella quale corre
l'applicazione si gonfia di diversi kB ogni qual volta che una trasformazione occorre. Poiché, per quanto ne so,
non esistono performance tool per Silverlight, ho tradotto tutta la mia libreria per il porting su WPF e, meraviglia, tutto
sembra funzionare correttamente, anche utilizzando WPFPerf non riesco ad individuare i "pozzi" che vado cercando!
Spero si tratti di un problema di questa prima beta e che venga risolto nelle successive release.
Come prova per ciò che dico, vi propongo la medesima versione (compilata in debug mode) dell'applicativo Silverlight
in WPF (distribuita via ClickOnce).
Notate come il mio engine, se eseguito in debug mode, mostri alcuni utili elementi quali
- gli spigoli delle varie facce (segmenti neri),
- il view frustum (rettangolo rosso),
- le normali alle singole facce (vedi linee rosse sulle facce del dodecaedro),
- le congiungenti il punto di vista della camera ed i baricentri delle facce del solido
(linee verdi sempre relative al dodecaedro)
- informazioni numeriche con le coordinate dei baricentri nel sistema di riderimento assoluto e la distanza dall'"occhio" della camera.
Step successivi nello sviluppo di questo Pacem.Silverlight3D engine:
- gestione della mappatura delle textures (bitmaps),
- migliorare gli aspetti di performance.
A presto...
Take care. Bye.
Feedbacks
-
Re: Silverlight 3D engine
Mateusz Kierepka (domenica 25 maggio 2008 22.53)
“Nice! Btw. there is already project for 3D engine made in SilverLight on Codeplex - http://www.codeplex.com/Kit3D”
-
Re: Silverlight 3D engine
CMerighi (domenica 25 maggio 2008 23.21)
“Thanks Mateusz!
Thank you also for pointing me to the Kit3D project. I just wanted (and still) to measure myself with 3D development to better understand what's behind this wonderworld...”
-
Re: Silverlight 3D engine
Whizzkkid (lunedì 26 maggio 2008 1.14)
“Nice work, Though you might get a nicer rotation effect if you use an 'easeOut' method rather than an easeInOut everytime you press and hold the cursorkeys.
Also, I've created a 3d texturemapping routine that might help you out with your next steps :)”
-
Re: Silverlight 3D engine
Whizzkid (lunedì 26 maggio 2008 3.41)
“Oh yeah, the texture mapping I made can be found here :
http://whizzkid74.blogspot.com/2008/04/texturemapping-in-silverlight-20b.html”
-
Re: Silverlight 3D engine
CMerighi (lunedì 26 maggio 2008 4.31)
“Hi Whizzkid,
I've already seen the work of yours and fell in love with it... stunning effect! That will surely point me to the right direction!... thanks!”
-
Re: Silverlight 3D engine
Martin K. (sabato 12 luglio 2008 13.12)
“I think your 3D engine and Demo is AWESOME !.. one of the best looking 3D demo's i've seen
there aren't many 3D apps in Silverlight yet... but i really hope that the future will make it easy to make 3D homepages !
I've made some semi 3D stuff here:
http://mdk2002.dyndns.org/Vector4_3
and some nice/funny stuff:
http://mdk2002.dyndns.org/HappyBirthday
http://mdk2002.dyndns.org/Critters
basically some kind of particle system :)
also check out www.bubblemark.com”
-
Re: Silverlight 3D engine
Roger Guess (giovedì 17 luglio 2008 12.15)
“Wow...
Any chance you have the demo updated for Silverlight 2?
Thanks!”
-
Re: Silverlight 3D engine
Roger Guess (giovedì 17 luglio 2008 12.31)
“So you also have the memory leak in the WPF version? Interesting. I have a memory leak with MediaElements in Silverlight 2 and have not taken the time to port to WPF for things like CLR profiling.
I'd still love a peek at the code though.. ;)”
-
Re: Silverlight 3D engine
CMerighi (venerdì 18 luglio 2008 1.02)
“Hi Roger,
the memory leak issue is solved (and it didn't appear in WPF), it was about reusing brushes, shapes along their dynamic generation: looks like they weren't "disposed" by the runtime...
Now I'm struggling with performance matters (expecially with texture coordinates in meshes with thousands nodes) and with interactive functionalities (I'd like to avoid HitTest calculation and use standard UIElement events).
I did hope to deliver some code earlier, but I'm working on it...
See you soon!”
-
Re: Silverlight 3D engine
Asger (martedì 12 agosto 2008 14.04)
“Any news on publishing the code? :)”
-
Re: Silverlight 3D engine
CMerighi (domenica 31 agosto 2008 23.54)
“...I'm waiting for the final release of SL2, to adjust the actual code and posting it all. Thanks for your interest!”
-
Re: Silverlight 3D engine
g2 (giovedì 18 settembre 2008 0.30)
“Hi,
I am new to silverlight but i wanted to used Silverlight to render graph on large no. of values.(in a range of million). Is the engine of silverlight good enough for this.. what are the limitation.
thank you.”
-
Re: Silverlight 3D engine
CMerighi (martedì 23 settembre 2008 6.33)
“Hi,
It may depend on what you have to do with all that load of stuff. If you need real-time manipulation, well... million of nodes are, AFAIK, pretty unmanageable also via unmanaged code. If it's about a one shot rendering process ...better announce it with a preloader! :)
I think that a 3D engine in SL managed code (software rendered) can bear a few (FEW) thousands of nodes, and it also depends on the type of textures, light algorithms you consider to use.”
-
Re: Silverlight 3D engine
xos (lunedì 6 ottobre 2008 15.25)
“Have you seen this Incredible 3D Engine for Flash Player ?”
-
Re: Silverlight 3D engine
xos (lunedì 6 ottobre 2008 15.27)
“the Sophie 3D Engine url: http://www.sophie3d.com”
-
Re: Silverlight 3D engine
cokkiy (domenica 30 novembre 2008 12.18)
“Scott say 3D will be supported in Silverlight V3.”
-
Re: Silverlight 3D engine
CMerighi (domenica 30 novembre 2008 15.00)
“Yep. I know it. Can barely stand the waiting!...”
-
Re: Silverlight 3D engine
C Chierchio (martedì 2 dicembre 2008 21.56)
“Just tried looking at the 3D sample app, but informed that it doesn't support Silverlight 2..”
-
Re: Silverlight 3D engine
Simbu Aarumugam (lunedì 29 dicembre 2008 11.22)
“Where i can get your source code from your site..Because i want apply the directional light and ambiant light in my silverlight application please give the solution
In Kit 3D have DirectionalLight.cs file but it was Comments
But I remove the Comments it throws the errors how can we achieve AmbientLight, DirectionalLight in silverlight application .
And one more requirement is how can we rotate the object by mouse .like Kit 3D Tiger rotating by StoryBoard .I want to rotate the tiger by mouse drag(when I am dragging the mouse that tiger will rotated among with Mouse
Here WPF code for DirectionalLight and AmbientLight
<ModelVisual3D x:Name="AmbientLightContainer">
<ModelVisual3D.Content>
<AmbientLight x:Name="AmbientLight" Color="Blue"/>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D x:Name="DirectionalLightContainer">
<ModelVisual3D.Content>
<DirectionalLight Direction="0,0,-1" x:Name="DirectionalLight">
<DirectionalLight.Transform>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="3"/>
</DirectionalLight.Transform>
</DirectionalLight>
</ModelVisual3D.Content>
</ModelVisual3D>”
-
Re: Silverlight 3D engine
Simbu Aarumugam (lunedì 29 dicembre 2008 11.22)
“Where i can get your source code from your site..Because i want apply the directional light and ambiant light in my silverlight application please give the solution
In Kit 3D have DirectionalLight.cs file but it was Comments
But I remove the Comments it throws the errors how can we achieve AmbientLight, DirectionalLight in silverlight application .
And one more requirement is how can we rotate the object by mouse .like Kit 3D Tiger rotating by StoryBoard .I want to rotate the tiger by mouse drag(when I am dragging the mouse that tiger will rotated among with Mouse
Here WPF code for DirectionalLight and AmbientLight
<ModelVisual3D x:Name="AmbientLightContainer">
<ModelVisual3D.Content>
<AmbientLight x:Name="AmbientLight" Color="Blue"/>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D x:Name="DirectionalLightContainer">
<ModelVisual3D.Content>
<DirectionalLight Direction="0,0,-1" x:Name="DirectionalLight">
<DirectionalLight.Transform>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="3"/>
</DirectionalLight.Transform>
</DirectionalLight>
</ModelVisual3D.Content>
</ModelVisual3D>”
-
Re: Silverlight 3D engine
balu (domenica 18 gennaio 2009 22.06)
“hi
how can i create different shapes in this.i am looking to create complex 3d shapes.i am using kit3d dll.
regards
balu”
-
Re: Silverlight 3D engine
Heretic (mercoledì 6 maggio 2009 18.58)
“New fast 3d engine very cool http://infinity3d-engine.com”