tag:blogger.com,1999:blog-3058873894782091765.post8556102601671008869..comments2019-05-23T03:06:57.427-07:00Comments on Rogach on Scala: How to create your own simple 3D render engine in pure JavaRogachnoreply@blogger.comBlogger62125tag:blogger.com,1999:blog-3058873894782091765.post-79773071125292848362018-11-07T08:23:16.082-08:002018-11-07T08:23:16.082-08:00How do i move the object in z coordinate?How do i move the object in z coordinate?Jancraft888https://www.blogger.com/profile/07467516608535545723noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-14798221989082260122018-10-05T13:06:41.881-07:002018-10-05T13:06:41.881-07:00any tips on import/translators for object import
any tips on import/translators for object import<br />Unknownhttps://www.blogger.com/profile/01701483244014567736noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-62026991732620347052018-05-03T07:15:54.168-07:002018-05-03T07:15:54.168-07:00This comment has been removed by the author.Aidan Lindonhttps://www.blogger.com/profile/14404215670204972479noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-43333119834270642502018-05-03T07:13:37.870-07:002018-05-03T07:13:37.870-07:00A link for complete source code would be great. Al...A link for complete source code would be great. Also, you are not very clear on where to insert the lists and double code and stuff.Aidan Lindonhttps://www.blogger.com/profile/14404215670204972479noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-67422978536790776652018-01-24T15:16:22.983-08:002018-01-24T15:16:22.983-08:00You could simply specify a cylinder instead of a t...You could simply specify a cylinder instead of a tetrahedron. To do this, it would be easier to include a parser for external *.obj or other 3D model format, instead of writing all the vertex locations for cylinder etc. The cylinder object would have to have enough segments for bending. The bend operations would be performed on the model and simply displayed in Rogach's 3D viewer.tedtoohttps://www.blogger.com/profile/15873517914025224363noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-84594491919639247932018-01-24T08:52:24.210-08:002018-01-24T08:52:24.210-08:00Hello Rogach. Can this approach be used to create ...Hello Rogach. Can this approach be used to create simple 3D view for pipe bending machine?<br />What I mean is this: when you bend a pipe you basically have 3 'parts' of bending: straight, curve(or bend) and rotation (of the pipe).<br />For example: to bend a pipe in U shape you need:<br />1. Straight: 500 mm<br />2. Bend: 90 degrees<br />3. straight: 100 mm<br />4. Bend: 90 degrees<br />What I like to have is to draw a 'pipe' which follow this steps and at the end you have a complete U shape bended pipe on the screen. <br />Can you help me with this?Anton Šmerchttps://www.blogger.com/profile/15000133986504634252noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-43592636716996716662018-01-06T13:51:33.028-08:002018-01-06T13:51:33.028-08:00It's at the end of the article:
https://gist....It's at the end of the article:<br /><br />https://gist.github.com/Rogach/f3dfd457d7ddb5fcfd99/4f2aaf20a468867dc195cdc08a02e5705c2cc95c<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-2847941360873334642018-01-06T05:42:39.209-08:002018-01-06T05:42:39.209-08:00Please!Please!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-80405158074855117492018-01-04T19:10:41.278-08:002018-01-04T19:10:41.278-08:00Thanks for very interesting article, I could make ...Thanks for very interesting article, I could make all examples!Unknownhttps://www.blogger.com/profile/02062651788089229451noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-43853191550213560432017-12-20T20:52:03.420-08:002017-12-20T20:52:03.420-08:00Yes, it does fish-eye the image, but technically i...Yes, it does fish-eye the image, but technically it is mathematically correct perspective projection. For it to look like proper perspective projections in computer graphics, all you have to do is divide by the Z value, not the radial distance to the camera. Anonymous...https://www.blogger.com/profile/10464049325150530366noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-81772948875103227122017-09-03T04:51:36.534-07:002017-09-03T04:51:36.534-07:00Any ideas how to adjust the distance from the nomi...Any ideas how to adjust the distance from the nominal camera position whilst adjusting the FoV? What I am trying to do is create a slider which adjusts FoV between 0 and 180 degrees (which is done). The problem is of course as it approaches 180 degrees the cube is a long way from the camera and vice versa as it approaches 0 degrees it is too close to the camera. If there was a way to maintain relative size or proportion during the transform then you could see the cube go from obtuse perspective to acute. A bit like going from a wide-angle lens to a telephoto lens but the object in view remains roughly the same size.<br /><br />here is the section of code I am working with from Rogach:<br /><br /> double fovAngle = Math.toRadians((FoVSlider.getValue())/2);<br /> double fov = (1.0/Math.tan(fovAngle))*180;tedtoohttps://www.blogger.com/profile/15873517914025224363noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-86557722382461835982017-09-01T18:47:37.324-07:002017-09-01T18:47:37.324-07:00Hey artistic otaku I have zipped all the code and ...Hey artistic otaku I have zipped all the code and put here:<br /><br />http://wyeldsoft.com/temp/CubePerspVwr.zip<br /><br />I got as far as trying to nest the controls in a sensible way. I think GroupLayout is the way to go but got distracted doing other things in the mean time...<br /><br />I am trying to build a widget that will let me overlay sketches of cubes so I can measure how accurate humans are at drawing cubes. By adjusting the amount of perspective (FoV) and orientation, size etc of the java-created cube, I can get a reading when compared to the sketch. This for a project I am working on in cog sci. If you have any ideas that would be helpful.tedtoohttps://www.blogger.com/profile/15873517914025224363noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-92203396469630528332017-09-01T03:55:31.420-07:002017-09-01T03:55:31.420-07:00This looks more like fish-eye projection, not pers...This looks more like fish-eye projection, not perspective projection.<br /><br />For example, consider several objects with equal Z coordinate. Under this projection, object close to the center will get one value of R, but for object far away from the center (but still at the same Z) R will be greater (2x, for example). Thus objects away from the center will be smaller (since you divide by R).Rogachhttps://www.blogger.com/profile/03638328639499267397noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-51682901236430227132017-08-31T21:57:31.834-07:002017-08-31T21:57:31.834-07:00Here is some code that is able to convert the orig...Here is some code that is able to convert the original affine screen coordinates to perspective projection coordinates. Don't worry about the extra array lists, those are just for my own organization purposes.<br /><br />double r = Math.pow(objects.get(o).faces.get(i).v.get(ii).zDisplay, 2) + Math.pow(objects.get(o).faces.get(i).v.get(ii).x, 2) + Math.pow(objects.get(o).faces.get(i).v.get(ii).y, 2);<br /> r = Math.sqrt(r);<br /> r = ((r * Math.PI) / (360.0d / FOVslider.getValue()));<br /> r = (r / frame.getHeight());<br /> objects.get(o).faces.get(i).v.get(ii).xDisplay = objects.get(o).faces.get(i).v.get(ii).xDisplay / r;<br /> objects.get(o).faces.get(i).v.get(ii).yDisplay = objects.get(o).faces.get(i).v.get(ii).yDisplay / r;<br /><br />I use xdisplay and ydisplay as separate values for displaying each vertex on the screen so that I can modify them without worrying about accidentally tampering with other variable values.Anonymous...https://www.blogger.com/profile/10464049325150530366noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-42868830397173017802017-08-21T06:32:26.146-07:002017-08-21T06:32:26.146-07:00can u provide the link for complete source code?can u provide the link for complete source code?artistic otakuhttps://www.blogger.com/profile/18109699668094107709noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-12271980760620624662017-07-21T02:05:49.383-07:002017-07-21T02:05:49.383-07:00magic!magic!tedtoohttps://www.blogger.com/profile/15873517914025224363noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-35819941799266939852017-07-21T01:58:31.745-07:002017-07-21T01:58:31.745-07:00You'll probably want to rewrite the GUI to see...You'll probably want to rewrite the GUI to see the effects better - you now need 6 sliders: 3 for camera XYZ position and 3 for camera rotation.Rogachhttps://www.blogger.com/profile/03638328639499267397noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-80311759554356709452017-07-21T01:54:31.454-07:002017-07-21T01:54:31.454-07:00I don't think you can achieve perspective proj...I don't think you can achieve perspective projection using only a matrix - basically, you need to divide X and Y by Z coordinate, and that's not possible to do via matrix multiplication on the vector. For example, OpenGL's perspective projection matrix is only needed for clipping - actual perspective projection happens manually after all the matrices.<br /><br />Here's the working code: https://gist.github.com/Rogach/f3dfd457d7ddb5fcfd99/1a951d7d4e7aff16746984a13c5b15ac0ea0b2ad<br /><br />I took your code, and added the necessary tweaks for it to work with perspective transform. The actual magic happens in lines 132-133 (fov angle to scaling computation) and lines 169-174 (division by Z).Rogachhttps://www.blogger.com/profile/03638328639499267397noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-51539085345318589862017-07-20T21:09:48.737-07:002017-07-20T21:09:48.737-07:00wow - that was surprisingly easy. However, I do no...wow - that was surprisingly easy. However, I do not really have a perspective view (just distorted isometric). Still need to do some maths on the w value (ie scale z or w?). Any ideas? I changed your tetrahedron to a cube. Code is here: http://wyeldsoft.com/temp/DemoViewerPersp.javatedthenoobhttps://www.blogger.com/profile/02756067848130793237noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-89903278340702020162017-07-20T20:40:36.571-07:002017-07-20T20:40:36.571-07:00Ok - I'll give it a go. i am pretty new to thi...Ok - I'll give it a go. i am pretty new to this stuff. What I like about your implementation is that it is almost entirely raw java - you are not using the Java3D API, which already has its own camera class and so on. The way you have done it means you need to understand every aspect to get it to work. If you already have an example with a 4x4 matrix that would be useful...tedthenoobhttps://www.blogger.com/profile/02756067848130793237noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-64479808409739523132017-07-20T12:55:55.763-07:002017-07-20T12:55:55.763-07:00Hi! You probably don't need 4x4 matrix for per...Hi! You probably don't need 4x4 matrix for perspective projection - you can just divide by Z coordinate (but just be careful with negative z values).<br /><br />But camera control will feel weird in that case, since in current implementation camera is strictly situated at (0,0,0) and there is no way to handle translations in 3x3 matrix. Expanding to 4x4 matrix should not be hard - just add W coordinate to Vertex, replace Matrix3 class with Matrix4 (with appropriate changes), add a [0,0,0,1] row and column to heading, roll and pitch transforms, and add a pan transform somewhere.Rogachhttps://www.blogger.com/profile/03638328639499267397noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-54484979159994793922017-07-20T07:36:59.444-07:002017-07-20T07:36:59.444-07:00Hello Rogach - I am really impressed with how simp...Hello Rogach - I am really impressed with how simple this demo is. However, it only shows an affine projection. How difficult would it be to make it a fully 4x4 matrix for perspective projection? I am trying to build a simple cube viewer that I can control the FoV. But not much point unless fully perspective. Can you help?tedthenoobhttps://www.blogger.com/profile/02756067848130793237noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-44609286770863590592017-01-16T02:19:41.644-08:002017-01-16T02:19:41.644-08:00Instead of working in pixel coordinates, you could...Instead of working in pixel coordinates, you could use homogenous coordinates (x and y axis is between -1 and 1). From there, you can use a projection, view and model matrix to control the vertex positions on the screen.Unknownhttps://www.blogger.com/profile/10965877666937969484noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-26455352277646160372016-12-20T02:42:57.675-08:002016-12-20T02:42:57.675-08:00No, never tried going that route.No, never tried going that route.Rogachhttps://www.blogger.com/profile/03638328639499267397noreply@blogger.comtag:blogger.com,1999:blog-3058873894782091765.post-61152479248378086682016-12-19T20:28:40.691-08:002016-12-19T20:28:40.691-08:00Do you know any good sources for learning how to u...Do you know any good sources for learning how to use OpenCL or LWJGL? I am curious to see how fast my modified 3D rendering program would run using the GPU to render the objects.Anonymous...https://www.blogger.com/profile/10464049325150530366noreply@blogger.com