|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
I don't want an elliptic sun.... (advanced patch placement in 3d)Hi,
Probably my knowledge of trigonometry are a bit rusty, but I was not able to put a patch so that it is always orthogonal to the segment connecting the center view (nx,ny,nz=0,0,0) with its center. Imagine that I want to draw the sun in a cubic node, the sun is simply an image representing a yellow circle, and I want draw it passing azimuth and elevation to a function that place and orienting the patch so that the sun is never distorted, but always it appear perfectly circular. (You know that in the reality the sun is a sphere, so it should always appear circular from anywhere I look at it, and never should be appear elliptical ...) This would be useful if I wanted that my node can be visited at different hours of day and I want to render the idea of the time flow by the position of the sun (and possibly also the brightness of the scene). How could I do? I tried the code that follows, you can move the sun using arrow, and you can notice distorsion with elevation>45 The distorsion is due to the system used to rotate patches, as the first rotation (along x) also amends the orientation of the second axis of rotation (along y). and I believe that, in this case, the problem will disappear if you rotate first along the Y axis and then along the axis X, (perhaps the ideal would be able to choose the order of rotation axis ...) What do you think? -Andrea --------------------------------------- cubic { "front.jpg", --front "right.jpg", --right "back.jpg", --back "left.jpg", --left "top.jpg", --top "bottom.jpg" --bottom } function setpos(p,dis,az,el) local nz=math.cos(math.rad(az))*dis*math.cos(math.rad(el)) local nx=math.sin(math.rad(az))*dis*math.cos(math.rad(el)) local ny=math.sin(math.rad(el))*dis p:move{nx=nx, ny=ny ,nz=nz, anglex=el2, angley=az } end onkeydown ( function(key) local press="no" if key == pipmak.key_arrow_right then az=az+10 press="yes" end if key == pipmak.key_arrow_left then az=az-10 press="yes" end if key == pipmak.key_arrow_up then el=el+10 press="yes" end if key == pipmak.key_arrow_down then el=el-10 press="yes" end if press=="yes" then setpos(sun,di,az,el) end end ) pipmak.setverticalfov(70) -- initial position of the sun: az = 0 el = 45 di = 2 -- "sun.png" is simply a yellow circle on trasparent png 80x80 pixel sun=patch {nx=0, ny=0 ,nz=0, anchorh=40,anchorv=40, w=80, h=80,image="sun.png",visible=true } setpos(sun,di,az,el) ------------------------------------------------------------- ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Pipmak-Users mailing list Pipmak-Users@... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
|
|
Re: I don't want an elliptic sun.... (advanced patch placement in 3d)ERRATA:
in the function setpos(...) put anglex=el ... (remove"2") sorry. Andrea ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Pipmak-Users mailing list Pipmak-Users@... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
|
|
Re: I don't want an elliptic sun.... (errata2)AAArgh!!!!
in function setpos(...) anglex=-el This works! I'm apologize twice!!! ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Pipmak-Users mailing list Pipmak-Users@... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
|
|
Re: I don't want an elliptic sun.... (advanced patch placement in 3d)Andrea Viarengo wrote:
> I was not able to put a patch so that it is always orthogonal to the > segment connecting the center view (nx,ny,nz=0,0,0) with its center. I haven't had a chance to look at your code yet - I'll get to that shortly - but I wanted to mention the following right away: > (You know that in the reality the sun is a sphere, > so it should always appear circular from anywhere I look at it, > and never should be appear elliptical ...) No. That's not true. Projecting a sphere onto a plane will not get you a circle unless the projection direction is perpendicular to the plane (i.e., you're looking straight at the sun, so that, for a non-skewed camera, it is in the center of the image). Think about it! (The same thing said a bit more verbosely: <http://tag.povray.org/povQandT/misconceptions.html#perspectivespheres>.) -Christian ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Pipmak-Users mailing list Pipmak-Users@... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
|
|
Re: I don't want an elliptic sun.... (advanced patch placement in 3d)Andrea Viarengo wrote:
> I tried the code that follows, you can move the sun using arrow, > and you can notice distorsion with elevation>45 > > The distorsion is due to the system used to rotate patches, as > the first rotation (along x) also amends the orientation of > the second axis of rotation (along y). > > and I believe that, in this case, the problem will disappear if you > rotate first along the Y axis and then along the axis X, (perhaps > the ideal would be able to choose the order of rotation axis ...) Yes, you're right. Swapping the default order to Y first, then X would be easy. I wonder if there are any other applications that would be made more difficult by that? I agree that the application of orienting a patch to the viewer given azimuth and elevation is a useful one and should be made easy. Doing this would break backwards compatibility with 0.2.7, however. (I guess we could still do it, as there probably aren't many people using X and Y rotation yet.) Implementing an arbitrarily specifiable rotation order would be a bit more involved (though it may be worth it - I'll look into it). We could also introduce another property "anglex2", so that rotation would happen in the order anglex, angley, anglex2, angle. Opinions, anyone? In the current system, you can't get away without doing some trigonometry. Going through the cartesian coordinates seems easiest: x = cos el sin az = sin dl y = sin el = cos dl sin bz z = -cos el cos az = -cos dl cos bz Here's what I've come up with, modifying your example, and it seems to work well: function setpos(p,dis,az,el) local nz=-math.cos(math.rad(az))*math.cos(math.rad(el)) local nx=math.sin(math.rad(az))*math.cos(math.rad(el)) local ny=math.sin(math.rad(el)) local dl = math.deg(math.asin(nx)) local bz = math.deg(math.atan2(ny, -nz)) pipmak.printinplace("az ", az, " el ", el, " bz ", bz," dl ",dl) p:move{nx=nx, ny=ny, nz=nz, anglex=bz, angley=-dl } pipmak.setviewdirection(az, el) end -Christian ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Pipmak-Users mailing list Pipmak-Users@... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
|
|
Re: I don't want an elliptic sun.... (advanced patch placement in 3d)Great Chriss!!
It works well!! What do you think about adding to methods "patch" and "move" the optional parameter: rotationorder = one of {"xya","yxa","xay",....} with a default value rotationorder="xya", so that the backwards compatibility was not compromised. I think it isn't too difficult to implement. You're right about the perspective of a sphere, but did not want to do things too complicated!! Thank you Andrea P.S. I will try to put this example in the Wiki, because I think it could be interesting for others. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Pipmak-Users mailing list Pipmak-Users@... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |
| Free embeddable forum powered by Nabble | Forum Help |