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

Aktuelle Zeit: Fr Apr 26, 2024 15:46

Foren-Übersicht » Programmierung » OpenGL
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Annäherung der NURBS
BeitragVerfasst: Do Apr 25, 2013 06:47 
Offline
DGL Member

Registriert: Do Mär 21, 2013 14:57
Beiträge: 51
Programmiersprache: C#,C++
Hi Leute,

ich bin zur Verwendung von Nurbs- bzw. Bezierflächen gezwungen. Wenn ich eine Fläche mit dem Querschnitt eines
Viertelkreises mit Hilfe der Nurbs darstellen möchte übergebe ich an die nötige Funktion ein Array von Punkten bzw.
deren Koordinaten. Die Nurb wird dann, aktuell, von A nach C gezeichnet und an B angenähert. Ich möchte jedoch,
dass diese im Kreisbogen durch B verläuft, damit ein perfektes Kreissegment im Querschnitt der Fläche entsteht.
Jetzt habe ich bereits mit Gewichtungen der einzelnen Punkte gearbeitet aber werde aus diesen noch nicht richtig
schlau. Hat jemand ne Ahnung was ich machen muss um einen "perfekten" Viertelkreis zu erhalten, bzw. wie ich den
Punkt C gewichten muss?!

PS: Bitte beachtet, dass ich noch recht neu in der OpenGL Welt bin.





Hier mein Source - Code zur Erzeugung der Punkte für eine NURB:

Code:
  1.  
  2. for (int i = 0; i < this.resolution - 1; i++)
  3.             {
  4.                 dx = ((Math.Abs((float)((this.PartialFrontPlain1[0].X - this.RarePlain2_1[0].X) / this.resolution))) * i);
  5.                 dy = ((Math.Abs((float)((this.PartialFrontPlain1[0].Y - this.RarePlain2_1[0].Y) / this.resolution))) * i);
  6.                 dz = ((Math.Abs((float)((this.PartialFrontPlain1[0].Z - this.RarePlain2_1[0].Z) / this.resolution))) * i);
  7.  
  8.                 this.controlPointsTopNurb1[i, 0, 0] = this.PartialFrontPlain2[0].X - dx;
  9.                 this.controlPointsTopNurb1[i, 0, 1] = this.PartialFrontPlain2[0].Y - dy;
  10.                 this.controlPointsTopNurb1[i, 0, 2] = this.PartialFrontPlain2[0].Z + dz;
  11.                 this.controlPointsTopNurb1[i, 0, 3] = 1;
  12.  
  13.                 this.controlPointsTopNurb1[i, 1, 0] = this.PartialFrontPlain2[0].X - dx - 0.003;
  14.                 this.controlPointsTopNurb1[i, 1, 1] = this.PartialFrontPlain2[0].Y - dy + radius_top_scaled - 0.003;
  15.                 this.controlPointsTopNurb1[i, 1, 2] = this.PartialFrontPlain2[0].Z + dz;
  16.                 this.controlPointsTopNurb1[i, 1, 3] = 1;
  17.  
  18.                 this.controlPointsTopNurb1[i, 2, 0] = this.PartialFrontPlain1[0].X - dx;
  19.                 this.controlPointsTopNurb1[i, 2, 1] = this.PartialFrontPlain1[0].Y - dy;
  20.                 this.controlPointsTopNurb1[i, 2, 2] = this.PartialFrontPlain1[0].Z + dz;
  21.                 this.controlPointsTopNurb1[i, 2, 3] = 1;
  22.             }
  23.  
  24.             this.controlPointsTopNurb1[this.resolution - 1, 0, 0] = this.RarePlain2_3[0].X;
  25.             this.controlPointsTopNurb1[this.resolution - 1, 0, 1] = this.RarePlain2_3[0].Y;
  26.             this.controlPointsTopNurb1[this.resolution - 1, 0, 2] = this.RarePlain2_3[0].Z;
  27.             this.controlPointsTopNurb1[this.resolution - 1, 0, 3] = 1;
  28.  
  29.             this.controlPointsTopNurb1[this.resolution - 1, 1, 0] = this.RarePlain2_3[0].X - 0.003;
  30.             this.controlPointsTopNurb1[this.resolution - 1, 1, 1] = this.RarePlain2_3[0].Y + radius_top_scaled - 0.003;
  31.             this.controlPointsTopNurb1[this.resolution - 1, 1, 2] = this.RarePlain2_3[0].Z;
  32.             this.controlPointsTopNurb1[this.resolution - 1, 1, 3] = 1;
  33.  
  34.             this.controlPointsTopNurb1[this.resolution - 1, 2, 0] = this.RarePlain2_3[1].X;
  35.             this.controlPointsTopNurb1[this.resolution - 1, 2, 1] = this.RarePlain2_3[1].Y + radius_top_scaled;
  36.             this.controlPointsTopNurb1[this.resolution - 1, 2, 2] = this.RarePlain2_3[1].Z;
  37.             this.controlPointsTopNurb1[this.resolution - 1, 2, 3] = 1;
  38.  



Und hier der Code zum zeichnen bzw. ausgeben der NURB:

Code:
  1.  
  2. GL.Map2(MapTarget.Map2Vertex4, 0.0, 1.0, 4, 3, 0.0, 1.0, 12, this.resolution, ref this.controlPointsTopNurb1[0, 0, 0]);
  3. GL.MapGrid2(this.resolution, 0.0, 1.0, this.resolution, 0.0, 1.0);
  4. GL.EvalMesh2(MeshMode2.Fill, 0, this.resolution, 0, this.resolution);
  5.  


Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.

_________________
_______________________________________
Lets move over mountains and through valleys:
GL.Map2(,,,,,,,,,)
GL.MapGrid2(,,,,,,,,,)
GL.EvalMesh2(,,,,,,,,,)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Annäherung der NURBS
BeitragVerfasst: Fr Apr 26, 2013 10:36 
Offline
DGL Member

Registriert: Do Mär 21, 2013 14:57
Beiträge: 51
Programmiersprache: C#,C++
Ich hab das ganze jetzt mal versucht mit den GluNURBS zu machen, aber da wird nichtmal was ausgegeben und ich
finde irgendwie auch keine stimmitge Beschreibung im Netz die mir hilft sozusagen einen viertel Zylinder zu zeichnen
mit Hilfe dieser.

Code:
  1.  
  2.             GL.Color3(Color.Green);
  3.             float dx, dy, dz;
  4.  
  5.             // Scale measures down.
  6.             float radius_top_scaled = this.parameterList[6].Value / scale_factor;
  7.             float radius_bot_scaled = this.parameterList[7].Value / scale_factor;
  8.  
  9.             float[] knots_line = new float[6] { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f };
  10.             float[] knots_depth = new float[32];
  11.             float[, ,] controlPoints = new float[this.resolution, 3, 4];
  12.  
  13.             for (int i = 0; i < this.resolution - 1; i++)
  14.             {
  15.                 dx = ((Math.Abs((float)((this.PartialFrontPlain1[0].X - this.RarePlain2_1[0].X) / this.resolution))) * i);
  16.                 dy = ((Math.Abs((float)((this.PartialFrontPlain1[0].Y - this.RarePlain2_1[0].Y) / this.resolution))) * i);
  17.                 dz = ((Math.Abs((float)((this.PartialFrontPlain1[0].Z - this.RarePlain2_1[0].Z) / this.resolution))) * i);
  18.  
  19.                 controlPoints[i, 0, 0] = (float)this.PartialFrontPlain2[0].X - dx;
  20.                 controlPoints[i, 0, 1] = (float)this.PartialFrontPlain2[0].Y - dy;
  21.                 controlPoints[i, 0, 2] = (float)this.PartialFrontPlain2[0].Z + dz;
  22.                 controlPoints[i, 0, 3] = 1;
  23.  
  24.                 controlPoints[i, 1, 0] = (float)this.PartialFrontPlain2[0].X - dx;
  25.                 controlPoints[i, 1, 1] = (float)this.PartialFrontPlain2[0].Y - dy + radius_top_scaled;
  26.                 controlPoints[i, 1, 2] = (float)this.PartialFrontPlain2[0].Z + dz;
  27.                 controlPoints[i, 1, 3] = (float)(Math.Sqrt(2) / 2);
  28.  
  29.                 controlPoints[i, 2, 0] = (float)this.PartialFrontPlain1[0].X - dx;
  30.                 controlPoints[i, 2, 1] = (float)this.PartialFrontPlain1[0].Y - dy;
  31.                 controlPoints[i, 2, 2] = (float)this.PartialFrontPlain1[0].Z + dz;
  32.                 controlPoints[i, 2, 3] = 1;
  33.             }
  34.  
  35.             controlPoints[this.resolution - 1, 0, 0] = (float)this.RarePlain2_3[0].X;
  36.             controlPoints[this.resolution - 1, 0, 1] = (float)this.RarePlain2_3[0].Y;
  37.             controlPoints[this.resolution - 1, 0, 2] = (float)this.RarePlain2_3[0].Z;
  38.             controlPoints[this.resolution - 1, 0, 3] = 1;
  39.  
  40.             controlPoints[this.resolution - 1, 1, 0] = (float)this.RarePlain2_3[0].X;
  41.             controlPoints[this.resolution - 1, 1, 1] = (float)this.RarePlain2_3[0].Y + radius_top_scaled;
  42.             controlPoints[this.resolution - 1, 1, 2] = (float)this.RarePlain2_3[0].Z;
  43.             controlPoints[this.resolution - 1, 1, 3] = (float)(Math.Sqrt(2) / 2);
  44.  
  45.             controlPoints[this.resolution - 1, 2, 0] = (float)this.RarePlain2_3[1].X;
  46.             controlPoints[this.resolution - 1, 2, 1] = (float)this.RarePlain2_3[1].Y + radius_top_scaled;
  47.             controlPoints[this.resolution - 1, 2, 2] = (float)this.RarePlain2_3[1].Z;
  48.             controlPoints[this.resolution - 1, 2, 3] = 1;
  49.  
  50.             for (int i = 0; i < 16; i++)
  51.             {
  52.                 knots_depth[i] = 0.0f;
  53.             }
  54.             for (int i = 16; i < 32; i++)
  55.             {
  56.                 knots_depth[i] = 1.0f;
  57.             }
  58.  
  59.             IntPtr top_nurb1 = OpenTK.Graphics.Glu.NewNurbsRenderer();
  60.             OpenTK.Graphics.Glu.BeginSurface(top_nurb1);
  61.             OpenTK.Graphics.Glu.NurbsSurface(top_nurb1, 6, ref knots_line[0], 32, ref knots_depth[0], 4, 12, ref controlPoints[0, 0, 0], 2, 1, OpenTK.Graphics.MapTarget.Map2Vertex4);
  62.             OpenTK.Graphics.Glu.EndSurface(top_nurb1);
  63.             OpenTK.Graphics.Glu.DeleteNurbsRenderer(top_nurb1);
  64.  

_________________
_______________________________________
Lets move over mountains and through valleys:
GL.Map2(,,,,,,,,,)
GL.MapGrid2(,,,,,,,,,)
GL.EvalMesh2(,,,,,,,,,)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Annäherung der NURBS
BeitragVerfasst: Fr Mai 03, 2013 10:12 
Offline
DGL Member

Registriert: Do Mär 21, 2013 14:57
Beiträge: 51
Programmiersprache: C#,C++
Das Problem wurde gelöst, danke.

_________________
_______________________________________
Lets move over mountains and through valleys:
GL.Map2(,,,,,,,,,)
GL.MapGrid2(,,,,,,,,,)
GL.EvalMesh2(,,,,,,,,,)


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


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 122 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.093s | 19 Queries | GZIP : On ]