Jump to content
  • Advertisement
Sign in to follow this  
Kram

WPF/Theory behind a 3D "bowl" effect

This topic is 3168 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone, How would one go about either using the 3D components of WPF or using a pseudo 3D effect to create a "Bowl" effect, where the user is looking down on a bowl and can drag around rectangles and have the rectangles perspective change so that it looks like they move up, down and around the bowl? I'm not after any gravity effects or anything, just when the items move, I need their perspective to be adjusted... If you are not well versed in WPF that's fine, maybe someone could point me in the right direction on more of the theory and such. Thanks for any help you can give. Mark

Share this post


Link to post
Share on other sites
Advertisement
I don´t know if I understood correctly but it looks like you want to "snap" an object to the surface of a bowl,(that you are looking at from above) so that the object looks small at the center of the screen but big when you move it away from it... is it that?

I don´t know what WPF is but I think you´re using 2D...correct? If so, you can change the scale of your rectangles using a function, something like:

rect.scale = 1.0+(distance_to_screen_center(rect)/20)^2;

or something like that, that makes the size dependant on distance to the center. Change it to suit your needs.

Share this post


Link to post
Share on other sites
Hey ArKano22,

Yeah that's sort of what I'm after, only changing the scale of the entire rectangle wont quite work, what im actually after is changing the scale of the different areas of the rectangles so that to area of the rectangle closest to the center of the bowl is smaller and the outside edges of the rectangle is larger, generating a perspective change rather than an entire scale transformation.

But you a dead on with the effect that im after :)

thanks for the help!

Share this post


Link to post
Share on other sites
In that case i think a pseudo-2D effect can work well. However you´ll need to be able to define your rectangles as 4 separate points (in fact a polygon, not a rectangle). If you´re blitting to screen or something like that things get a little bit nasty.

Let´s suppose you have 4 points. So all you have to do is to make the 4 point´s distance to the center of the rectangle depend on their distance to the center of the screen. (I think, i write this without trying it anywhere)

Just fiddling around with math you should be able to achieve the effect youré after. If you have problems i can write some pseudocode for you. cheers!

Share this post


Link to post
Share on other sites
Hey ArKano22, yeah thats what I was thinking too! At least we are on the same page, WPF does have great support for polygons (Paths as they're known). So thats a good starting point.

I would actually appreciate some pseudo code, i will of course be trying myself, but still all the help I can get now would be fantastic!

Share this post


Link to post
Share on other sites
So I have been reading and reading and it looks like what Im after is a centered "vanishing point" that my 2d objects will be moving around...

Can anyone point me in the right direction for the logic behind applying a transformation of the 4 points of my Path object so that it gives me that perspective look?

Share this post


Link to post
Share on other sites
If i have time, this afternoon (14:28 here right now) i will make some sample code for you.

One thing is left to know..Do you want your rectangles oriented to the center of the screen (one side facing the center of the bowl all the time), or aligned with the window (sides parallel to the window border)?

Share this post


Link to post
Share on other sites
Hi, actually, that's where it gets tricky, I actually need it to be orientated in any form at all. The user will be able to push and pull the rectangles all over the place.

But for now, any orientation will do just for the simple effect.

Thanks heaps for the help so far, it's greatly appreciated...

Share this post


Link to post
Share on other sites
I´ve written a bit of code as promised. In fact i made a working example using Processing (spiced up Java).

Download it from here:

http://rapidshare.com/files/295239981/RectagleBowl.zip.html

The .pde is the source code, you can open it with notepad or whatever you like, and there are 3 executables for win, mac and linux. You can move the rectangle using W,A,S,D and rotate it with Q,E. It can have any orientation.

The math i used is just some basic trig for rotations and some vector algebra for the perspective effect. If you have any questions about the code feel free to ask :)!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!