Visual Stretching

Topics: User Forum
Mar 14, 2007 at 3:24 AM
Is it possible to not have your visual stretched across the 3d surface it is mapped to? I am trying to visualize a tree view and when collapsed (it is a single top level node) it renders very large as it appears to use the visual brush to paint the entire plane I am mapping it to, and when I expand the root node everything appears to "shrink" as there is now more visual data to paint with. The question is can I stop this from happening? What I want is it to look, for all appearances, that the user is interacting with a "normal" 2d control, the 3d is only something I will use for animations and transitions.
Mar 14, 2007 at 7:03 PM
To figure out how big it is, a VisualBrush computes a rectangle that fits around everything the Visual is going to draw, and then whatever is within that rectangle is what will get rendered by the brush. So, for example, say you make a canvas that is 1000 x 1000 and just put a 1x1 button in the middle. Since everything on the canvas is empty except in the middle, then the VisualBrush just will represent that middle portion.

If you want more of a "LayoutBrush" where the above would show the empty space on the canvas, a simple trick is to just put a transparent border around your 2D item. Now The VisualBrush will include this border, and because of this will pick up the empty space as well.
Mar 15, 2007 at 2:30 PM
I still could not get the VisualBrush not to stretch my visual, it just created a border and still streched my visual.

I am trying to create a listview with say 10 items and place it on a surface with this mesh:
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5"
TriangleIndices="0 1 2 2 3 0"
Normals="0,0,1 0,0,1 0,0,1 0,0,1"
TextureCoordinates="0,1 1,1 1,0 0,0" />

Can someone help me with how to make it work?
Later i want to change this square and make it a ractangle, if it matters....
Mar 16, 2007 at 4:32 AM
I think (though I haven't tried it since the reply due to lack of time) that you will need to set an explicit size on the border. If you don't it will simply size itself to the contents, which in this case you don't want. The idea is the invisible border has a set size, this keeps the visual, when painted, from having to expand to fill available space since presumably you will set your border size to be about the total size you want the visual to appear.
Mar 16, 2007 at 8:42 AM
I have tried this and it didnt work.

what did semi do the job was playing with paddings... but then you have to manually set it and test,
set and test.. this is not a real solution.

I dont know...

if you have another solution i would love to hear about it.
Mar 20, 2007 at 7:06 PM
What do you mean by stretching in this case and what are you hoping the final output looks like? Do you just want the Visual itself not to look distorted when put on the mesh? In that case you probably need to make sure your visual has the same aspect ratio as the geometry it is being placed on to. Or do you not want the Visual to size itself as it gets items added/removed? In that case you probably need to use the border trick. or are you looking to do something completely different?
Mar 21, 2007 at 10:21 AM
My problem was the ratio issue, but i solved this just like you said, came to me while driving my bike in the cold. :)

If we are talking about 3d stuff already, how do you build your 3d animations? do you use the regular keyframe tools available on blend or maybe something else? I find it difficult to create complex animation like that, if you have some tricks in your tricks box, please send me some insights.

Mar 21, 2007 at 5:29 PM
Have you looked into Electric Rain's Zam3d tool ( It is similar to Blend except dedicated exclusively to 3d modeling (and has support for animation in 3d as well).
Mar 22, 2007 at 12:07 AM
I haven't built many 3D animations myself (the ones in the Flickr demo were all done by hand), so I'm probably not the best expert on this. But I'd definitely check out Zam3D as mentioned by renacer above, and then Blend as well. If you find something else, or have thoughts on the above as far as 3D animations go, definitely make a post.