1 / 21

Grafikprogrammierung mittels Java3D

Grafikprogrammierung mittels Java3D. Transformationen Frank Krack. Geometrische Transformationen. Skalierung. Translation. Rotation. Objekte in Java3D. Objekte werden anhand der Fläche gespeichert Einfache Vorstellung mit Punkten

meg
Télécharger la présentation

Grafikprogrammierung mittels Java3D

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grafikprogrammierungmittels Java3D Transformationen Frank Krack

  2. Geometrische Transformationen Skalierung Translation Rotation

  3. Objekte in Java3D • Objekte werden anhand der Fläche gespeichert • Einfache Vorstellung mit Punkten • alle Punkte eines ObjektsV = {vi | vi = (xi, yi, zi) Є R3, i Є N}

  4. Translation • Verschiebung • Addition aller Punkte mit Translationsvektor tx = 1.0, ty = 1.0, tz = -1.5

  5. Homogene Translation • Translation als Matrizenmultiplikation • homogenen Koordinaten

  6. Skalierung • Dehnung / Stauchung • Multiplikation aller Punktemit Skalierungsvektor x = 0.25, y = 0.5, z = 1.0

  7. Homogene Skalierung • Skalierung als Matrizenmultiplikation • homogenen Koordinaten

  8. Rotation • Drehung um eine Achse • Multiplikation aller Punktemit Rotationsmatrix

  9. Rotation • Rotation um Y-Achse • Rotation um Z-Achse

  10. Homogene Rotation • Rotation als Matrixmultiplikation mit homogenen Koordinaten • z.B. Drehung um Z-Achse

  11. Mathematik in Java • Matrix- und Vektoroperationen sind im javax.vecmath-Package enthalten • Klassen: • Vector3f, Vector3d • Matrix3f, Matrix3d, Matrix4f, Matrix4d • Unterstützung für • Vektoroperationen (z.B. Skalar- und Vektorprodukt) • Matrixoperationen (Transformation von Punkten)

  12. Transform3D • speichert eine Transformation in einer 4x4-Matrix Konstruktor Transform3D t3d_trans = new Transform3D(); Standardkonstruktur initialisiert die Matrix als Einheitsmatrix Transform3D t3d_trans = new Transform3D(float[] matrix); Erzeugt eine Transformationsobjekt und übergibt in einem 16 Elemente großen Array die Transformationsmatrix. Package: javax.media.j3d.Transform3D

  13. Transform3D Funktionen void setTranslation(Vector3d trans) setzt nur die Translationswerte des Vektors trans in die Transformationsmatrix void set(Vector3f trans) Änderung der Matrix in Einheitsmatrix mit Translationswerten trans void setScale(Vector3d scale) void setScale(double scale) Setzt den Wert der Transformation auf eine Skalierung für alle drei Dimensionen unterschiedlich bzw. gleichmäßig

  14. Transform3D Funktionen void rotX(double angle) void rotY(double angle) void rotZ(double angle) Setzt den Wert der Transformation aufeine Rotation um die entsprechendeAchse. Der Winkel angle ist im Bogenmass. Umrechnug: Math.PI / 2.0d = Math.toRadians (90.0d);

  15. zusammengesetzte Transformationen • Folge von Transformationen • Matrizen-Produkt • Vorsicht!!! • Die Matrixmultiplikation ist assoziativ: A*B*C = (A*B)*C = A*(B*C) nicht kommutativ: A*B != B*A Translation * Rotation != Rotation * Translation Rotation1 * Rotation2 != Rotation2 * Rotation1

  16. wichtige Reihenfolge

  17. Zusammengestzte Transformationen • Rotation um Achse im Punkt • Translation zum Ursprung T1 • Rotation Rz( ) • Translation zum Startpunkt T2 R = T2 * Rz( ) * T1

  18. Transform3D Funktionen void set (Vector3f trans, float scale) void set (Vector3d trans, double scale) binden gleichzeitig eine Translation und eine Skalierung in die Matrix ein void setRotation(AxisAngle4d) Rotation um eine beliebige Achse im Raum void mul(Transform3D t3d_t1)this = this * t3d_t1 void mul(Transform3D t3d_t1, Transform3D t3d_t2) führen Multiplikation der Matrizen aus this = t3d_t1 * t3d_t2

  19. TransformGroup • Verzweigung im Szenen-Graphen, die eine Transformation speichert Konstruktor TransformGroup tg = new TransformGroup() Standardkontruktor, der eine Verzweigung mit einer neutralen Transformation (Einheitsmatrix) erzeugt TransformGroup tg = new TransformGroup(Transform3D transform) Erzeugt eine Verzweigung mit einem Transform3D-Objekt Package:javax.media.j3d.TransformGroup

  20. TransformGroup • Funktionen • void setTransform(Transform3D transform) • Setzt die Transformation der TransformGroup • void addChild(Node child) • - Hängt einen Knoten als Kind ein • Kind kann wieder eine TransformGroup sein • nachfolgende Transformation ist relativ zur vorhergehenden

  21. Quellen • Sun Java 3D Tutorialhttp://developer.java.sun.com/developer/onlineTraining/java3d/ • Skript Graphische DatenverarbeitungProf. Dr. Werner Heinzel

More Related