Advanced 3D shapes

Jul 24, 2007 at 12:36 PM
hi , I have a few questions :

I want to create a cube that has either an image or a movie on each of its faces ,
how can I do it using the Balder framework ?

also how can I create cylinder and paste an image that surrounds it ?

will there be a documentation of the classes and the relations between them and also how each 3D shapes is saved on a Canvas ?

thanks ,
Victor
Coordinator
Jul 24, 2007 at 8:40 PM
We're working on supporting full texturemapping with both images and movies.
Supporting simple imaging or putting a videoclip on a cube or other objects can
be done without much hazzle, the thing we want to support is real texturemapping
where you specify coordinates within an image or movie for all points in a polygon.

Silverlight does not support texturemapping directly, you have to work with the matrix
for the imagebrush to accomplish it.

Anywho.. I've written a simple tutorial for creating a spinning cube. The sample I've done
there works with triangles, this can easily be changed into using quads, that way you can
use an ImageBrush pretty much directly.
http://www.dolittle.com/blogs/einar/archive/2007/07/19/spinning-cube-in-silverlight-alpha-1-1-using-c.aspx




Aug 11, 2007 at 8:43 PM
hi Einar ,

I tried again to open your tutorial that you published here :
http://www.dolittle.com/blogs/einar/archive/2007/07/19/spinning-cube-in-silverlight-alpha-1-1-using-c.aspx

I'm getting the following warning :

Warning 1 Found conflicts between different versions of the same dependent assembly. SpinningCubeTutorial

and the testpage.html asks me to install SL Alpha.

Is this a compatibility problem between alpha and alpha refresh of SL 1.1 ?

Victor


adept wrote:
We're working on supporting full texturemapping with both images and movies.
Supporting simple imaging or putting a videoclip on a cube or other objects can
be done without much hazzle, the thing we want to support is real texturemapping
where you specify coordinates within an image or movie for all points in a polygon.

Silverlight does not support texturemapping directly, you have to work with the matrix
for the imagebrush to accomplish it.

Anywho.. I've written a simple tutorial for creating a spinning cube. The sample I've done
there works with triangles, this can easily be changed into using quads, that way you can
use an ImageBrush pretty much directly.
http://www.dolittle.com/blogs/einar/archive/2007/07/19/spinning-cube-in-silverlight-alpha-1-1-using-c.aspx






Coordinator
Aug 12, 2007 at 4:11 AM
I've forgotten to upgrade the tutorial for the refresh. I'll do that straight away.

Microsoft released an update on friday for the tools for Visual Studio that should fix your reference problem :
http://timheuer.com/blog/archive/2007/08/10/silverlight-updated-silverlight-tools-for-visual-studio.aspx




victorbar wrote:
hi Einar ,

I tried again to open your tutorial that you published here :
http://www.dolittle.com/blogs/einar/archive/2007/07/19/spinning-cube-in-silverlight-alpha-1-1-using-c.aspx

I'm getting the following warning :

Warning 1 Found conflicts between different versions of the same dependent assembly. SpinningCubeTutorial

and the testpage.html asks me to install SL Alpha.

Is this a compatibility problem between alpha and alpha refresh of SL 1.1 ?

Victor


adept wrote:
We're working on supporting full texturemapping with both images and movies.
Supporting simple imaging or putting a videoclip on a cube or other objects can
be done without much hazzle, the thing we want to support is real texturemapping
where you specify coordinates within an image or movie for all points in a polygon.

Silverlight does not support texturemapping directly, you have to work with the matrix
for the imagebrush to accomplish it.

Anywho.. I've written a simple tutorial for creating a spinning cube. The sample I've done
there works with triangles, this can easily be changed into using quads, that way you can
use an ImageBrush pretty much directly.
http://www.dolittle.com/blogs/einar/archive/2007/07/19/spinning-cube-in-silverlight-alpha-1-1-using-c.aspx







Coordinator
Aug 12, 2007 at 4:23 AM
I've updated the tutorial, it should run now.

Thanks for pointing this out to me. I completely forgot to update it.
Aug 12, 2007 at 10:23 AM
no problem - thank you for this great tutorial ,

I just have one question - I want to use ImageBrush/VideoBrush instead of coloring up the faces - and I saw where in your code it can be done (replacing the part that creates the color for every face),
but I'm not sure I know how can I apply transformations on this ImageBrush - the same transformations that are applied on every vertex of the face = I want the image to "turn" while remaining on the face .

can you tell me what is the easiest way to do that ?


adept wrote:
I've updated the tutorial, it should run now.

Thanks for pointing this out to me. I completely forgot to update it.

Coordinator
Aug 13, 2007 at 10:35 AM
This has been one of the issues we've been working on for Balder, only that we need more complex control over the texturemapping.
For your example you can get away with only one transformation that is relative to the onscreen polygon.

A good page for understanding how the Silverlight matrix works is actually looking at the following Flash related page :
http://www.senocular.com/flash/tutorials/transformmatrix/

The matrices in Silverlight and Flash works in the same way.

Hopefully I will have time to work on Balder this week and get around to implement a good solution for it there as well.


victorbar wrote:
no problem - thank you for this great tutorial ,

I just have one question - I want to use ImageBrush/VideoBrush instead of coloring up the faces - and I saw where in your code it can be done (replacing the part that creates the color for every face),
but I'm not sure I know how can I apply transformations on this ImageBrush - the same transformations that are applied on every vertex of the face = I want the image to "turn" while remaining on the face .

can you tell me what is the easiest way to do that ?


adept wrote:
I've updated the tutorial, it should run now.

Thanks for pointing this out to me. I completely forgot to update it.


Aug 13, 2007 at 7:54 PM
OK , the tutorial is working too , lets hope Microsoft's future releases will be more backward compatible .

10x !


adept wrote:
I've updated the tutorial, it should run now.

Thanks for pointing this out to me. I completely forgot to update it.

Aug 13, 2007 at 8:22 PM
Einar ,

can you explain in a few words the hidden line removal ?
I want to do just that for a 4 vertex face.

10x ,

victor
Coordinator
Aug 19, 2007 at 8:30 PM
Hi again,
sorry for the late reply. Been busy at work this week.
Anywho..

I assume you mean hidden face/surface removal.

I found a good article for you that explains the principals and math behind it.
The point of it is to figure out what polygons are facing away from the camera/viewport and then skip these from the drawing pipeline.

http://www.ibiblio.org/e-notes/3Dapp/Hidden.htm





victorbar wrote:
Einar ,

can you explain in a few words the hidden line removal ?
I want to do just that for a 4 vertex face.

10x ,

victor

Aug 23, 2007 at 10:23 AM
hi ,

10x for the guide ,
however I tried to apply the backface culling method of hiddent face removal on a face that consists of 4 vertexes and was unsuccessfull in it ,
I also noticed that in the tutorial you used a mised product system - but it also didn't work on a 4 vertex face.

if you have the time I will appreciate if you explain your method and I'll figure a way to apply it on a 4 vertex face.
Aug 26, 2007 at 12:47 PM

I'm trying to put an image or video brush on a rotating face using polygon.fill (I'm using the tutorial code) ,
but it doesn't work - I keep getting a black canvas.

any ideas how it can be done ?



adept wrote:
Hi again,
sorry for the late reply. Been busy at work this week.
Anywho..

I assume you mean hidden face/surface removal.

I found a good article for you that explains the principals and math behind it.
The point of it is to figure out what polygons are facing away from the camera/viewport and then skip these from the drawing pipeline.

http://www.ibiblio.org/e-notes/3Dapp/Hidden.htm





victorbar wrote:
Einar ,

can you explain in a few words the hidden line removal ?
I want to do just that for a 4 vertex face.

10x ,

victor


Aug 27, 2007 at 4:01 PM
Hi,

To put an image, I replaced the line
polygon.Fill = new SolidColorBrush(Color.FromRgb(red, green, blue));
by
polygon.Fill = new ImageBrush();
polygon.Fill.SetValue(ImageBrush.ImageSourceProperty, "mypicture.png");
and it works.

To put a video, I've done the following :
in the class "Page", I added the following object :
private MediaElement me;
which is initalized in the method "Page_Loaded" :
me = new MediaElement();
me.SetValue(MediaElement.NameProperty, "silverlightLogoLoop");
me.SetValue(MediaElement.SourceProperty, "silverlightLogoLoop.wmv");
me.SetValue(MediaElement.IsMutedProperty, "True");
me.SetValue(Polygon.OpacityProperty, "0.0");
me.SetValue(MediaElement.IsHitTestVisibleProperty, "False");
this.Children.Add(me);

Finally, in the method "spinningCubeCanvas_Render" I replaced the line
polygon.Fill = new SolidColorBrush(Color.FromRgb(red, green, blue));
by
polygon.Fill = new VideoBrush();
polygon.Fill.SetValue(VideoBrush.SourceNameProperty, "silverlightLogoLoop");
Then, it works.

Unfortunately, for both the cases, there are problems with texture coordinates which are not correct because one doesn't have the real texturemapping as mentionned previously. I'm still investigating on it.

Sincerely,
FB



victorbar wrote:

I'm trying to put an image or video brush on a rotating face using polygon.fill (I'm using the tutorial code) ,
but it doesn't work - I keep getting a black canvas.

any ideas how it can be done ?



adept wrote:
Hi again,
sorry for the late reply. Been busy at work this week.
Anywho..

I assume you mean hidden face/surface removal.

I found a good article for you that explains the principals and math behind it.
The point of it is to figure out what polygons are facing away from the camera/viewport and then skip these from the drawing pipeline.

http://www.ibiblio.org/e-notes/3Dapp/Hidden.htm





victorbar wrote:
Einar ,

can you explain in a few words the hidden line removal ?
I want to do just that for a 4 vertex face.

10x ,

victor



Aug 28, 2007 at 7:15 AM
Great - It works !

10x 4 the help FB ,

texture mapping is indeed an important issue in 3D animation in Silverlight .

Feb 20, 2008 at 4:46 PM
Edited Feb 20, 2008 at 4:50 PM
Adept - Thanks, a great guide.

Having read your tutorial, I've been struggling to find the correct image transform to apply to imageBrushes when they are painted onto a polygon - without a matrix transform, the two images painted on the two triangles lose their alignment and do not appropriately skew with perspective. Unfortunately I've been unable to work out what MatrixTransform should be applied to the ImageBrush's Transform property. One post above implies that it's not going to be possible to provide fully perspective corrected texture mapping. However, if you look at this forum entry, he seems to have managed to get a good texture mapping effect (I certainly can't see any misalignment).

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1224198&SiteID=1

I don't suppose you could enlighten me or point out where I might look for help with this issue?