Message boards :
Number crunching :
I need some help with...
Message board moderation
Author | Message |
---|---|
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
Math.. What started out as a simple addition to BDN (Boinc.NET) as a screen saver has divereted me to learing new math. There are lots of tools for doing 3D modeling. Some are free, others are very expensive. NONE put out Opengl ready code. To fix this, I started on a project to convert from MilkShapes Ascii format to direct opengl code I can import in to rendering program. (MilkShape's Ascii format is supported by a number of modeling tools) Well.. In the process of writing tools to create my own 3D editing program, I discovered how little I actually know of advanced mathmatics. Namely, Calulus. I have figured out out to import the geometry, select polygons on the screen, navigate in 3D space and do rotations in 3 axis. There is much more to be done but I have a good start. As always, I like to start with the majors and work to the minors. Here's an example of what and why I need to learn this math. If.. say you have an object in 3D space.. And this object has a convex surface such as the shape of an orange, the faces or polygons that make up this object face from the center outward in all directions, normal to the center of the object. Here is screen capture from my program. It will help explain this more: Looking at the RED polygons that are selected, you will noticed the curve and the normal of the faces to the center of the object. If you want to apply a texture to these selected faces, they need to be 'un-wrapped' so the faces are all coplanar and all the normals face straight at the viewer. You could simply use the polys the way they sit but the applied texture will be horribly distorted from being streched or compressed to fit withing the bounds of the polys. Also there is the shear angle that complely distorts the texture. I have been fighting with this problem to the point im actually getting depressed over it. I like to think of myself as someone that can figure anything out but this is got me stumped. My math is just NOT up to parr to do it. Its been over a week, 1/2 a notebook of graphing paper and still no answer. I'll get it but WHEN!!?? GRRRRRrrrrrr!!! LOL! Oh and if you didnt figure out what the image above is from.. heres the the whole model. (I didnt create it, Im just using it to test the math) If any one can help with this math.. please do! Oh.. And I lost a PSU in my Pentium D. It HAD an RAC of over 4,000. I wont be fixing this any time soon as in flat broke as ususal :( --Mike Not Ready Reading BRAIN. Abort/Retry/Fail? |
jason_gee Send message Joined: 24 Nov 06 Posts: 7489 Credit: 91,093,184 RAC: 0 |
... Hi Mike, haven't kept up with modern techniques, but efficient techniques I've seen over the years usually involve breaking the polygons into small triangles, each vertex becomes a texture coordinate, then transformed into screen space. Interpolate the texture (coords in screen space) using one of various methods, some are perspective correct, some not. Which method becomes a choice of efficiency over realism, but effectively you're then interpolating in 2D screen space, which is cheaper/easier than using complicated transforms on the texture in a 3d space (Which, I think, is where you might be pulling your hair out ? ) "Living by the wisdom of computer science doesn't sound so bad after all. And unlike most advice, it's backed up by proofs." -- Algorithms to live by: The computer science of human decisions. |
Bill Walker Send message Joined: 4 Sep 99 Posts: 3868 Credit: 2,697,267 RAC: 0 |
I'm not sure I fully understand the question, but here is a technique used way back in the last century doing vehicle simulator visuals. Sketches would help, but I don't have access to a prooper CAD package any more (and I like it that way). I think the problem is geometry, not calculus. 1. Apply the texture to each polygon in the plane of the polygon. This includes any shading and illiumination effects, in the true location of the polygon. 2. Draw vectors from features on the texture (like boundaries of a single colour area within the polygon) back to the point of view. 3. Your "viewing screen" is a plane just in front of the POV, between the POV and the object. Where each vector penetrates the viewing screen is where the originating feature of the vector will appear in the 2D image on the viewing screen. |
FiveHamlet Send message Joined: 5 Oct 99 Posts: 783 Credit: 32,638,578 RAC: 0 |
Hi Mike No help from me i'm sorry to say you know you lost me when you said Calculus.LOL I did that nearly half a century ago at school and havn't kept my hand in. I have CC on ! I am sure there are some whiz kids on here that do 3D modelling that will help, they just have to get up after the late nights they have lol. Dave |
Gundolf Jahn Send message Joined: 19 Sep 00 Posts: 3184 Credit: 446,358 RAC: 0 |
Oh and if you didn't figure out what the image above is from... here's the the whole model... Looks like a spaceship, but I can't recall from what film / game :-) Gruß, Gundolf |
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
Hi Dave :) Thanks guys for the input. The whole purpose of this is to map the texture coordinates. I understand how texture mapping works and the alignment of the vertices. The problem is unwraping the triangles in to a single plane. This IS the problem.. how to unwrap the mesh to a single plane so I can map the texture to the vertices correctly. You must bare in mind that this equation needs to work in any axis. I have pretty much already decided that some pre-testing of vertex alignment will need to be done such that if all X coordinates are equal, the rotation will occur in the Y/Z Axis. Same as if all Y coordinates are equal then the rotations will need to be in the X and Z. This is not all that hard to do using this method BUT.. looking at the sphere above.. this WONT WORK. I need to 'lay out' the mesh as if unskinning a basketball. I think I need to go about this in the opposite direction.. find the math to actually wrap a sheet around a sphere in 3 axis. If you could imagin a pie crust wraped around a orange, this is what im talking about. If I can find the math to do this, I can just reverse it (I think). Simple single axis rotation about Y. rxz=sqrt( ((x1-x2)*(x1-x2)) + ((z1-z2)*(z1-z2)) ) rx=rxz*cos(theta) rz=rxz*sin(theta) theta being the rotation angle. Heres a bit more complicated bit of code that took me a few days to figure out. It draws lines from a one radius to the next in a clock dial style and will ALWAYS face the camera lens no matter the cameras angle of orintaion. cam_x,y,z is the cameras center in world coords. Dim sx = Sin(Look_X_angle) Dim cx = Cos(Look_X_angle) Dim sy = Sin(Look_Y_angle) Dim cy = Cos(Look_Y_angle) Dim Xc, YS, x1, x2, y1, y2, z1, z2, x, y, z As Single For i As Single = 0 To PI * 2 Step PI / 36 Xc = Cos(i) * 0.1 YS = Sin(i) * 0.1 y1 = sy + (YS * cy) x1 = (cy * sx) - (Xc * cx) - ((sy * YS) * sx) z1 = (cy * cx) + (Xc * sx) - ((sy * YS) * cx) Xc = Cos(i) * 0.09 YS = Sin(i) * 0.09 y2 = sy + (YS * cy) x2 = (cy * sx) - (Xc * cx) - ((sy * YS) * sx) z2 = (cy * cx) + (Xc * sx) - ((sy * YS) * cx) Gl.glVertex3f(x1 + cam_x, y1 + cam_y, z1 + cam_z) Gl.glVertex3f(x2 + cam_x, y2 + cam_y, z2 + cam_z) Next I wonder if I can utilize this matrix some how? heres a pic of this: Note the warp speed stars. ALSO.. Note the total LACK of textures.. I NEED to get my unwraping equation done! lol This runs at 40 fps on my old AMD. Much faster w/o the streched stars. Maybe I need to look to the 3D Gurus at other sites but this my fav BB. Not Ready Reading BRAIN. Abort/Retry/Fail? |
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
Oh and if you didn't figure out what the image above is from... here's the the whole model... Yes.. Its a TieFighter from Star Wars. :) Like I said. I didnt create this 3D model, Im just using it as an example. Not Ready Reading BRAIN. Abort/Retry/Fail? |
ML1 Send message Joined: 25 Nov 01 Posts: 20476 Credit: 7,508,002 RAC: 20 |
Take a look at the code used in POV-Ray? Good luck, Martin See new freedom: Mageia Linux Take a look for yourself: Linux Format The Future is what We all make IT (GPLv3) |
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
Thanks Martin.. I have used POV before. Its amazing how well it renders photo-realistic scenes. I'll dig thru the their site and see if I can find any examples of the math im looking for. Maybe one of the add on tools? Thanks again. --Mike Not Ready Reading BRAIN. Abort/Retry/Fail? |
jason_gee Send message Joined: 24 Nov 06 Posts: 7489 Credit: 91,093,184 RAC: 0 |
http://local.wasp.uwa.edu.au/~pbourke/texture_colour/texturemap "Living by the wisdom of computer science doesn't sound so bad after all. And unlike most advice, it's backed up by proofs." -- Algorithms to live by: The computer science of human decisions. |
[AF>france>pas-de-calais]symaski62 Send message Joined: 12 Aug 05 Posts: 258 Credit: 100,548 RAC: 0 |
http://www.celestiamotherlode.net/catalog/fic_starwars.php :D image CELESTIA 3D SETI@Home Informational message -9 result_overflow with a general handicap of 80% and it makes much d' efforts for the community and s' expimer, thank you d' to be understanding. |
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
Thanks Jason for the link.. It IS useful but not exactly what im after. It will help in sorting some of this out. I know that you cant 'un-wrap' an entire sphere as it WILL cause major distorions. You can however do it in sections with very little to no distortion. I was fastinated by the info on pre-distorting the texture. This makes perfect sense to me if your texturing (texturizing?) an entire sphere. I could see where this would be a great approuch to dealing with some other objects as well. What Im after is being able to lay out the faces. Mostly for visual texture alingment. After I find the method, I plan on writing the code to print this 'flat land' mesh. I can use this to import in to a tool such as photoshop to create my own textures over the top of the meshes layer. (hope that makes sense.. lol) Thanks Symaski62 for the link to that site.. Lots of cool stuff there. Im going to download and try to see if I can build the source for that program when I have the time. It MAY be a very VERY cool way to create a star map for Boinc.NET. I haven't done much with this idea as there are only a few of MANY projects that can benifit from the many hours it will take to code this feature. BTW.. I didnt see that version to the TIEFIGHTER at thier site... Interesting. I do know that is the lowend basic TieFighter. It was the first one ever seen in episode 4. Anyone ever play X-Wing Vrs TieFigher? I used to play it online but the 'younger set' kick my hinny bad :) Not Ready Reading BRAIN. Abort/Retry/Fail? |
Fred W Send message Joined: 13 Jun 99 Posts: 2524 Credit: 11,954,210 RAC: 0 |
Don't know if this may help but it occurred to me that your problem is very similar to that faced by creating a projection of the earth for mapping. A bit of googling led me to here. There may be something here that could help with the maths? F. |
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
I want to thanks everyone for the input. I have found what I need.. Mostly from Freds idea on pherical maps. It led me to searching for hours and I came up with this site. Its what I need :) for those that are curious about it... check it out Thanks again.. --Mike Not Ready Reading BRAIN. Abort/Retry/Fail? |
ML1 Send message Joined: 25 Nov 01 Posts: 20476 Credit: 7,508,002 RAC: 20 |
I want to thanks everyone for the input. That's a very good find... I especially liked this diagram for the abstract mind twisting: ...And that's just for the Cartesian coordinates! Beautifully comprehensive! Do we get to see your results? Have fun! Martin See new freedom: Mageia Linux Take a look for yourself: Linux Format The Future is what We all make IT (GPLv3) |
John McLeod VII Send message Joined: 15 Jul 99 Posts: 24806 Credit: 790,712 RAC: 0 |
You actually don't need calculus for this (mostly), you need to study up on solid geometry though. BOINC WIKI |
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
Yes John... straight geo and a bit of trig with some algebra for a nice cocktail of confusion :) Some of the functions are expressed in calculus but these are in regards to integrals. These equations are great for a sphere. Not to bad to figure out. Im now trying to find some ways of un-wraping abstract shapes and haven't actually used the equations at that site for a sphere... lol Check out this section Martin .. 5.9.12 Mercator CS specification It contains the best fit equations for what I want. Im having a little bit of trouble figuring out exactly what some of the 'terms' are.. See the greek letter Lamda?? It looks like a Cap A with out the bar. there is a superscript character that looks like an '*' but its not. I cant find a reference to what this means. does it mean 'not equal'? Its not an inverse.. is it PHi and if so.. HUH?? Where does PHi come to play in this??!! What the heck is it!!?? GRRRrrrrrrr!! I find the equation and I cant READ IT!!! Oh well.. Im still messing with abstracts. Check out MathType.. you can play with it for 30 days. Its nice for writing math out like the equations above. It can't do any actual computing of the terms. You will need something like Mathmatica for that. Thanks again.. --Mike [edit] I think I will take a break and finish the help pages for Boinc.NET.. I got started tonight but got tired.. lol Besides.. if you have ever played a game like tetris for hours on end and then find your self looking at ways to fit cars or buildings together, you will understand that when I look at just about everything now, I start wondering how I would un-wrap the faces.. ;) [/edit] Not Ready Reading BRAIN. Abort/Retry/Fail? |
ML1 Send message Joined: 25 Nov 01 Posts: 20476 Credit: 7,508,002 RAC: 20 |
... 5.9.12 Mercator CS specification Tetris... Wasn't that the greatest act of mental sabotage ever to be foisted onto the computer world? (Then again, Microsoft's solitaire and other things/aspects must rate higher/worse than that!... :-( ) And it's always good to get some mental exercise on real world objects :-) As for your formula: The capitol Lambda-smudge is indeed just Lambda* and signifies a function for longitudinal centring (the Lambda-subscript-c). Hope that helps, Regards, Martin See new freedom: Mageia Linux Take a look for yourself: Linux Format The Future is what We all make IT (GPLv3) |
Mike O Send message Joined: 1 Sep 07 Posts: 428 Credit: 6,670,998 RAC: 0 |
Thanks Martin.. It still dont lool like an * to me ;) I'll post something when I get this working. Thanks all :) --Mike Not Ready Reading BRAIN. Abort/Retry/Fail? |
©2024 University of California
SETI@home and Astropulse are funded by grants from the National Science Foundation, NASA, and donations from SETI@home volunteers. AstroPulse is funded in part by the NSF through grant AST-0307956.