Discussions
Categories
- 385.5K All Categories
- 4.9K Data
- 2.5K Big Data Appliance
- 2.4K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
3d Theory. vcs to scs transformation.
Hi you 3d gurus.
Please give me a tip!
If you have a point with coordinates given in the View Coordinate System, how do you translate it to a point on the screen?
The point is given by x,y,z in the view coordinate system (vcs). (x is horizontal, y is vertical, and z is distance stright forward from your eye.)
To obtain where to render the point at the screen, I could do something like this:
if(vcs.z <= 0)
IHaveAProblem();
Ofcorse, a point with negative (or zero) z- value shold not be shown, however, a polygon might be visible even though one of its vertexes has a negative z- value. Havent found any good solution. So far, I just dont paint the polygon at all if I find a negative or zero z.
I also tried using the distance, and not the z- value as the divisor:
I want something close to the first solution, but that also works on negative and 0 z values.
Anybody knows?
This is my 3d engine:
http://blake.prohosting.com/ragnvald/
Please give me a tip!
If you have a point with coordinates given in the View Coordinate System, how do you translate it to a point on the screen?
The point is given by x,y,z in the view coordinate system (vcs). (x is horizontal, y is vertical, and z is distance stright forward from your eye.)
To obtain where to render the point at the screen, I could do something like this:
iScreenX = (400*vcs.x)/vcs.z; iScreenY = (400*vcs.y)/vcs.z;The problem is that this only works for z values grather than 0.
if(vcs.z <= 0)
IHaveAProblem();
Ofcorse, a point with negative (or zero) z- value shold not be shown, however, a polygon might be visible even though one of its vertexes has a negative z- value. Havent found any good solution. So far, I just dont paint the polygon at all if I find a negative or zero z.
I also tried using the distance, and not the z- value as the divisor:
double dDivisor; dDivisor = Math.sqrt(vcs.x*vcs.x +vcs.y*vcs.y +vcs.z*vcs.z); iScreenX = (400*vcs.x) / dDivisor; iScreenY = (400*vcs.y) / dDivisor;This is ok for all points not beeing positioned in the middle of your eye (givig dDivisor=0), but it gives a fisheye like view of the world, and thats not exactly what I want.
I want something close to the first solution, but that also works on negative and 0 z values.
Anybody knows?
This is my 3d engine:
http://blake.prohosting.com/ragnvald/
";-)
Ragnvald Barth
Software engineer
Comments
-
Well, as jsalonen (and I) said in the other forum, it involves some tricky stuff. You can either use clipping (check where the polygons collide with the viewpoint and 'clip' them, creating new polygons that can be drawn) or Z buffering, which produces the best quality but also needs extra memory, the size of the view screen actually. So z buffering sucks memory a lot. Then the easiest way is that you don't draw polygons that are too near you.
-
The easy solution, (not to draw at all) works fine for the "fligt simulator" with an open landscape. However, if I create a world where I move around in caves, the problem becomes too visible (does it have to be like that?). And cliping isnt that easy eather, bebcause I have not restricted the polygons to triangles...
-
Z buffering.
-
z buffering is not simple.
-
Well, actually it's not that difficult. Of course you need to make some modifications, but if you can handle the speed and memory requirements it gives the best quality.
-
Well. width zBuffering I would have to write my own fillPolygon routine. And I would have to draw on pixel level. And all the modifications that follow... And the speed would be a problem (after all this is an applet). - I am not looking for the correct solution. I am looking for a dirty cheap and ugly solution that makes my problem less visible!
-
Well, if you intend to do any shading you have to write your own fillPolygon routine anyway. Anyhow, I don't know of an easy solution to your problem...
This discussion has been closed.