Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Mo Mai 13, 2024 09:06

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Bad Normals
BeitragVerfasst: Mi Mai 04, 2005 16:17 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Im wondering where im goign wrong with the following:

Code:
  1. Procedure BuildNormals(Var Surface : TSurface);
  2. var
  3. t,v,c : integer;
  4. begin
  5.  
  6. for t := 0 to Surface.Header.NumOfTrianges-1 do
  7. Surface.Trianges[t].Normal := Normalize2(CrossProduct(SubtractVector(GetVertWithoutOrigin(Surface,Surface.Trianges[t].V2),GetVertWithoutOrigin(Surface,Surface.Trianges[t].V1)),SubtractVector(GetVertWithoutOrigin(Surface,Surface.Trianges[t].V3),GetVertWithoutOrigin(Surface,Surface.Trianges[t].V2))));
  8.  
  9. for v := 0 to Surface.Header.NumOfVerts-1 do
  10. begin
  11. Surface.Vertexs[v].Normal := SetVector(0,0,0);
  12. for t := 0 to Surface.Header.NumOfTrianges-1 do
  13. If (Surface.Trianges[t].V1 = v) or (Surface.Trianges[t].V2 = v) or (Surface.Trianges[t].V3 = v) then
  14. Surface.Vertexs[v].Normal := AddVector(Surface.Vertexs[v].Normal,Surface.Trianges[t].Normal);
  15.  
  16. Surface.Vertexs[v].Normal := Normalize2(Surface.Vertexs[v].Normal);
  17. end;
  18.  
  19. end;


Below is a pic of 2 models showing the errors.

Both originaly 3ds's with no errors.


Dateianhänge:
badnormals.JPG
badnormals.JPG [ 15.7 KiB | 3233-mal betrachtet ]

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mai 04, 2005 16:56 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 17, 2002 12:07
Beiträge: 976
Wohnort: Tübingen
hmm, I think I found the problem in the first part of our code (veeeery chaotic, you should make it with more system in it). In my opinion, you substract the wrong Vectors, or the right Vectors in the wrong order. Try it in this way (this is some working (!) code I use):
Code:
  1.  
  2. function CalcNormalOfTriangle(Vertex1, Vertex2, Vertex3: Vector3f): Vector3f;
  3.  var VectorA, VectorB, tmp: Vector3f;
  4. begin
  5.  VectorA:= SubstractVectors(Vertex1, Vertex2);
  6.  VectorB:= SubstractVectors(Vertex2, Vertex3);
  7.  tmp:= CalcCrossProduct(VectorA, VectorB);
  8.  tmp:= Normalize(tmp);
  9.  Result:= tmp;
  10. end;

_________________
"Du musst ein Schwein sein in dieser Welt, sangen die Prinzen, das ist so 1.0. Du musst auf YouTube zeigen, dass dir dein Schweinsein gefällt, das ist leuchtendes, echtes Web 2.0."
- Hal Faber

Meine Homepage: http://laboda.delphigl.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mai 04, 2005 18:27 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
It changes nothing doing it 1-2 , 2-3 insted of 2-1, 3-2

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Mai 04, 2005 23:40 
Offline
DGL Member

Registriert: Sa Jan 22, 2005 21:10
Beiträge: 225
Can't see the pics, but I can remember myself getting mad while coding my 3DS loader, cause of this weired normalflags comming along with the faces... They're some sort of flags, 16 bit long, with the first 3 bits telling you whether to invert a normal or not. Never really got them running... Doubt that anyone really got them running, cause I testet my code with those 3DS models floating around the net and - well - they all seem to use these flags differently...


EDIT: Oh, now I CAN see the pics. However, as it sometimes works and sometimes not, I'd bet it's those normalflags...


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.023s | 17 Queries | GZIP : On ]