Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (563) Games in Android Showcase (151) games submitted by our members Games in WIP (605) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 IndexedTriangleArray.calculateFaceNormals()  (Read 1682 times) 0 Members and 1 Guest are viewing this topic.
Preston

Senior Devvie

Medals: 4

 « Posted 2003-11-14 11:59:59 »

Well, this doesn't seem to work for me when it comes to light. A kind of vectors are being calculated but the light isn't correct...

I think I've read here somewhere that there's still a problem with the calculateFaceNormals() method and indexed triangles? Unfortunately a search doesn't find it...

William mentioned once that the way this method would work in J3d and Xith3d differs, but what dit he mean by this?

How would it be possible to calculate the normals for a IndexedTriangleArray?
Preston

Senior Devvie

Medals: 4

 « Reply #1 - Posted 2003-11-15 05:34:51 »

The Java3d Tutorium chapter 6.5 describes the normal problem, too. It says:
Quote

When a vertex is shared by surfaces of widely varying orientations, having only one normal per vertex can result in problems. (..) If the normal is selected as the actual normal for one surface, it is very wrong for its neighbor. (..) The solution to both problems is to increase the number of vertices in order to increase the number of normals. This, of course, increases memory usage and rendering time.

So do I understand it correctly that bascially it's impossible for a method like calculateFaceNormals for an IndexedTriangleArray do calculate the normals, because surfaces with totally different orientation share the same vertex and hence normal?
Is the problem different with TriangleStripArrays? Because there the shared vertexes are always neighbours?

So this is the "art": with IndexedTriangleArrays you've to find out all vertexes/normals which can't be shared and so you insert new ones?

Being on that topic: I read many times in the Tutorial that usually TriangleStrips are faster than indexed ones. Do you Xith3d users out there use Strips or Indexed arrays?
In case you use strips: do you calculate the strips manually or is there a helper class inside Xith3d? Like in Java3d the GeometryInfo's Stripifier. However I don't find such a thing in Xith3d. :-)
Preston

Senior Devvie

Medals: 4

 « Reply #2 - Posted 2003-11-15 05:54:47 »

With J3d-Tutorium I meant this one from September 2000: http://developer.java.sun.com/developer/onlineTraining/java3d/

Since Xith3d has got a similar architecture to Java3d I find this Tutorium a be good start point for Xith3d newbies, too. Additional to the official Xith3d Tutorium.
Yuri Vl. Gushchin

Senior Devvie

Speak Java!

 « Reply #3 - Posted 2003-11-15 09:00:00 »

Quote
So do I understand it correctly that bascially it's impossible for a method like calculateFaceNormals for an IndexedTriangleArray do calculate the normals, because surfaces with totally different orientation share the same vertex and hence normal?
Is the problem different with TriangleStripArrays? Because there the shared vertexes are always neighbours?

The problems with automatic calculations of face normals may happen in every case where you have vertex shared by multiple (2 or more) triangles, because of this MAY happen that two normals should be associated with the same vectex coordinates. This is true for all indexed geometries, strips and triangle fans.

If you still want to use indexed or stripified geometries in your app [which IS the case, because of often they give you higher performance], you may go simple way and first convert your geom to triangle array, calculate normals and the indexify/stripify geom.

Another case is when you KNOW that surface of your geom is smoothed, i.e. guaranteed to have one normal per vertex. Then you can invent the algorithm that will generate normals on indexed/stripified geom.

Quote
I read many times in the Tutorial that usually TriangleStrips are faster than indexed ones. Do you Xith3d users out there use Strips or Indexed arrays?

Not always and not in every case. This depends primarily on strip lengths, number of strips, etc.

Yuri

Yuri Vl. Gushchin
JProof Group
Yuri Vl. Gushchin

Senior Devvie

Speak Java!

 « Reply #4 - Posted 2003-11-17 14:25:34 »

I think all com.sun.j3d.utils.geometry.* classes should be ported to Xith3D, but major question is WHEN...

Yuri

Yuri Vl. Gushchin
JProof Group
Preston

Senior Devvie

Medals: 4

 « Reply #5 - Posted 2003-11-18 12:25:04 »

Quote
I think all com.sun.j3d.utils.geometry.* classes should be ported to Xith3D, but major question is WHEN...

I see. You, David, Wil and Jens should have more time. :-)  Like most of us, here, I suppose. ;-)

A general thought on the Java3d to Xith3d connection: how's the legal status of porting parts of Java3d to Xith3d?
We talked about this topic recently concerning Vecmath. It looks like there's soon a free/opensource Vecmath which we/Xith3d could use as replacement for SUN's vecmath.
However what about other ports? It depends on what "port" actually means, I suppose. If it's a new implementation of a borrowed design it shouldn't be a problem. Or anybody know more?

It would be strange, if for copyright issues a Xith3d based game would have to include the entire Java3d runtime environment... ;-)
(Or isn't this funny? I'm no lawyer, just a developer)

A second thought: What would happen if SUN revived their Java3d some day (or did they do already) ? Would they have to port some parts back to Java3d, or would they tend to dislike Xith3d as a competitor? :-)
Yuri Vl. Gushchin

Senior Devvie

Speak Java!

 « Reply #6 - Posted 2003-11-18 14:13:48 »

Regarding com.sun.j3d.utils.geometry.*, there is a clear copyright statement in every source file (in fact, very close to BSD license).

Regarding Vecmath, I personally use now Kenji Hiranabe vecmath with minor modifications, and can state that it is 100% compatible with Xith3D [means no Xith3D modifications required to replace Sun VecMath with that one]. See http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1063928279 "third party library copyright issues" for more details.

I don't think Xith3D should be dependent on Java3D at all [even I think right now it is already not dependent, but maybe I missed something].

Yuri

Yuri Vl. Gushchin
JProof Group
abies

Senior Devvie

 « Reply #7 - Posted 2003-12-16 07:37:40 »

I have added simple implementation of normal generator for IndexedTriangleArray, which smooth all normals. It is certainly not perfect for all models, but at least works for simple case. I'll commit a patch to issue list later today.

Preston

Senior Devvie

Medals: 4

 « Reply #8 - Posted 2003-12-16 09:21:00 »

Quote
I have added simple implementation of normal generator for IndexedTriangleArray, which smooth all normals. It is certainly not perfect for all models, but at least works for simple case. I'll commit a patch to issue list later today.

Will this normal generator be added to the official Xith3d source code? That would be nice.

Currently I'm also using such a "always smooth normals" generator (but it's seperate to IndexedTriangleArrays) but still all the >90° surfaces are smoothed, too ... which looks not very good on the typical Lightwave models I use. :)
When this will be added to Xith3d I'll use it thankfully. :-)
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 wxwsk8er (49 views) 2015-03-20 15:39:46 Fairy Tailz (42 views) 2015-03-15 21:52:20 Olo (26 views) 2015-03-13 17:51:59 Olo (29 views) 2015-03-13 17:50:51 Olo (33 views) 2015-03-13 17:50:16 Olo (40 views) 2015-03-13 17:47:07 ClaasJG (29 views) 2015-03-10 11:36:42 ClaasJG (36 views) 2015-03-10 11:33:01 Pippogeek (45 views) 2015-03-05 14:36:23 Pippogeek (37 views) 2015-03-05 13:56:12
 LiquidNitrogen 23x KevinWorkman 23x basil_ 21x BurntPizza 21x Riven 18x theagentd 18x EgonOlsen 17x Roquen 14x princec 12x Slyth2727 9x NegativeZero 9x SHC 9x Varkas 9x Ecumene 8x ClaasJG 7x teletubo 7x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org