Rabu, 05 Desember 2018

Membuat Java Animasi 3D Kubus Transparan menggunakan Netbeans 8.2

Tutorial Membuat Animasi 3D Kubus Transparan
Menggunakan Netbeans 8.2

oleh :
Mokh. Miftakhudin ( 17.MI.0011 )
Caranya :
  1. Pertama, Buka Aplikasi Java Netbeans 8.2 
     
  2. Selanjutnya, buat sebuah Project baru 
  3. Pilih Java => Java Application =>Next 
    \
  4. Rename Project sesuai keinginan kita =>Finish 
  5. Setelah project terbuka, masukkan/tambahkan file JAR pada library project :
  6. Pilih file yang ingin ditambahkan :
  7. Setelah project terbuka, masukkan koding seperti berikut :
  8. Kemudian kita "Run" project, atau tekan "F6" 
  9. Jika berhasil maka hasilnya seperti dibawah ini : 
Full koding : 
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package jobsheet9; import com.sun.j3d.utils.behaviors.mouse.MouseRotate; import com.sun.j3d.utils.geometry.GeometryInfo; import com.sun.j3d.utils.geometry.NormalGenerator; import com.sun.j3d.utils.geometry.Sphere; import com.sun.j3d.utils.geometry.Stripifier; import com.sun.j3d.utils.geometry.Triangulator; import java.awt.BorderLayout; import java.awt.GraphicsConfiguration; import com.sun.j3d.utils.universe.*; import java.awt.Dimension; import java.awt.image.BufferedImage; import javax.media.j3d.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.vecmath.Color3f; import javax.vecmath.Point3d; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; /** * * @author My asus */ public final class Jobsheet9 extends JPanel{ int s = 0, count = 0; public Jobsheet9() { setPreferredSize(new Dimension(500, 500)); setLayout(new BorderLayout()); GraphicsConfiguration gc=SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas3D = new Canvas3D(gc); add("Center", canvas3D); BranchGroup scene = createSceneGraph(); scene.compile(); // SimpleUniverse is a Convenience Utility class SimpleUniverse simpleU = new SimpleUniverse(canvas3D); // This moves the ViewPlatform back a bit so the // objects in the scene can be viewed. simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); } public BranchGroup createSceneGraph() { BranchGroup lineGroup = new BranchGroup(); Appearance app = new Appearance(); QuadArray lsa = new QuadArray(48,QuadArray.COORDINATES|QuadArray.NORMALS); Vector3f [] normals=new Vector3f[24]; for(int i=0;i<24 300="" app.setcoloringattributes="" app.setmaterial="" app.setpolygonattributes="" app.setrenderingattributes="" app="" application="" args="" arguments="" boundingsphere="" ca.setcolor="" ca.setshademodel="" ca="" clrs="new" code="" color3f="" coloringattributes="" command="" cube="6" directionallight="" div="" f1.setschedulingbounds="" f1.settransformgroup="" f1="" f="" false="" fifth="" first="" for="" fourth="" frame.add="" frame.setdefaultcloseoperation="" frame.setsize="" frame.setvisible="" frame="new" here="" i="0;i<24;i++)clrs[i]=new" int="" jframe="" jobsheet9="" jscrollpane="" light1.setcolor="" light1.setdirection="" light1.setinfluencingbounds="" light1="" light2.setcolor="" light2.setdirection="" light2.setinfluencingbounds="" light2="" line="" linegroup.addchild="" linegroup="" logic="" lsa.setcoordinates="" lsa.setnormals="" lsa="" main="" mat.setambientcolor="" mat.setdiffusecolor="" mat.setemissivecolor="" mat.setlightingenable="" mat.setspecularcolor="" mat="" material="" miftakhudin="" mouserotate="" new="" normals="" objrotate.addchild="" objrotate.setcapability="" objrotate="" okh.="" oloringattributes.shade_gouraud="" olygonattributes.cull_none="" olygonattributes.polygon_line="" pa.setcullface="" pa.setpolygonmode="" pa="" param="" point3d="" point3f="" polygonattributes="" pts="" public="" quad="" quads="" ra.setignorevertexcolors="" ra="" rame.exit_on_close="" ransformgroup.allow_transform_write="" renderingattributes="" return="" second="" sh.setappearance="" sh.setgeometry="" sh.setpickable="" sh="" shape3d="" sixth="" sphere="" static="" the="" third="" todo="" transformgroup="" tring="" true="" vector3f="" void="" x="0.5f;pts[23].y=0.5f;pts[23].z=-0.5f;" y="1;normals[21].y=1;normals[22].y=1;normals[23].y=1;" z="1;normals[13].z=1;normals[14].z=1;normals[15].z=1;">

Share this

0 Comment to "Membuat Java Animasi 3D Kubus Transparan menggunakan Netbeans 8.2"

Posting Komentar