PROJECT 3 D AUTORIUS RYTIS DZIKARAS DARBO UDAVINIAI
PROJECT 3 D AUTORIUS: RYTIS DZIKARAS
DARBO UŽDAVINIAI: • • TEKSTO KODAVIMAS; LAUKŲ IŠDĖSTYMAS; PANAUDOTA OPENGL SDK IR RAJAWALI SDK. TAIP PAT LOGIN SISTEMA.
KLASĖS APRAŠYMAI: public class Cubes { private Float. Buffer vertex. Buffer; private int num. Faces = 6; private float[][] colors = {1. 0 f, 1. 0 f, {1. 0 f, }; { 1. 0 f}, 1. 0 f} private float[] vertices = { -1. 0 f, 1. 0 f, -1. 0 f, 1. 0 f, -1. 0 f, 1. 0 f, -1. 0 f, -1. 0 f, 1. 0 f }; Ir t. t. . .
KLASĖS APRAŠYMAI: public class Cubes 2 { private Float. Buffer vertex. Buffer; private int num. Faces = 6; private float[][] colors = {1. 0 f, 0. 5 f, 0. 0 f, {1. 0 f, 0. 0 f, 1. 0 f, {0. 0 f, 1. 0 f, 0. 0 f, {0. 0 f, 1. 0 f, {1. 0 f, 0. 0 f, }; { 1. 0 f}, 1. 0 f} private float[] vertices = { -1. 0 f, 1. 0 f, -1. 0 f, -1. 0 f, 1. 0 f, -1. 0 f, 1. 0 f, -1. 0 f, 1. 0 f }; . . .
KLASĖS APRAŠYMAI: import import java. nio. Byte. Buffer; java. nio. Byte. Order; java. nio. Float. Buffer; javax. microedition. khronos. opengles. GL 10; android. content. Context; android. graphics. Bitmap. Factory; android. opengl. GLUtils; public class Photo. Cube { private Float. Buffer vertex. Buffer; private Float. Buffer tex. Buffer; private int num. Faces = 6; private int[] image. File. IDs = { R. drawable. vienas, }; private int[] texture. IDs = new int[num. Faces]; private Bitmap[] bitmap = new Bitmap[num. Faces]; private float cube. Half. Size = 1. 2 f; public Photo. Cube(Context context) { Byte. Buffer vbb = Byte. Buffer. allocate. Direct(12 * 4 * num. Faces); vbb. order(Byte. Order. native. Order()); vertex. Buffer = vbb. as. Float. Buffer(); for (int face = 0; face < num. Faces; face++) { bitmap[face] = Bitmap. Factory. decode. Stream( context. get. Resources(). open. Raw. Resource(image. File. IDs[face])); int img. Width = bitmap[face]. get. Width(); int img. Height = bitmap[face]. get. Height(); float face. Width = 2. 0 f; float face. Height = 2. 0 f; if (img. Width > img. Height) { face. Height = face. Height * img. Height / img. Width; } else { face. Width = face. Width * img. Width / img. Height; } float face. Left = -face. Width / 2; float face. Right = -face. Left; float face. Top = face. Height / 2; float face. Bottom = -face. Top; . . .
KLASĖS APRAŠYMAI: public class Triangle { private Float. Buffer vertex. Buffer; private Float. Buffer color. Buffer; private Byte. Buffer index. Buffer; private float[] vertices = { -1. 0 f, 1. 0 f, -1. 0 f, 0. 0 f }; private float[] colors = { 1. 0 f, 1. 0 f, 1. 0 f }; private byte[] indices = { 2, 4, 3, 1, 4, 2, 0, 4, 1, 4, 0, 3 }; public Triangle() { Byte. Buffer vbb = Byte. Buffer. allocate. Direct(vertices. length * 4); vbb. order(Byte. Order. native. Order()); vertex. Buffer = vbb. as. Float. Buffer(); vertex. Buffer. put(vertices); vertex. Buffer. position(0); Byte. Buffer cbb = Byte. Buffer. allocate. Direct(colors. length * 4); cbb. order(Byte. Order. native. Order()); color. Buffer = cbb. as. Float. Buffer(); color. Buffer. put(colors); color. Buffer. position(0); index. Buffer = Byte. Buffer. allocate. Direct(indices. length); index. Buffer. put(indices); index. Buffer. position(0); }. . .
KLASĖS APRAŠYMAI: public class Trianglespalvotas { private Float. Buffer vertex. Buffer; private Float. Buffer color. Buffer; private Byte. Buffer index. Buffer; private float[] vertices = { -1. 0 f, 1. 0 f, -1. 0 f, 0. 0 f }; private float[] colors = { 0. 0 f, 1. 0 f, 0. 0 f, 1. 0 f }; private byte[] indices = { 2, 4, 3, 1, 4, 2, 0, 4, 1, 4, 0, 3 }; public Trianglespalvotas() { Byte. Buffer vbb = Byte. Buffer. allocate. Direct(vertices. length * 4); vbb. order(Byte. Order. native. Order()); vertex. Buffer = vbb. as. Float. Buffer(); vertex. Buffer. put(vertices); vertex. Buffer. position(0); Byte. Buffer cbb = Byte. Buffer. allocate. Direct(colors. length * 4); cbb. order(Byte. Order. native. Order()); color. Buffer = cbb. as. Float. Buffer(); color. Buffer. put(colors); color. Buffer. position(0); index. Buffer = Byte. Buffer. allocate. Direct(indices. length); index. Buffer. put(indices); index. Buffer. position(0); }. . .
KLASĖS APRAŠYMAI: public class Renderer extends Rajawali. Renderer { public Context context; private Directional. Light directional. Light; private Sphere earth. Sphere; public Renderer(Context context) { super(context); this. context = context; set. Frame. Rate(60); } public void init. Scene(){ directional. Light = new Directional. Light(1 f, . 2 f, -1. 0 f); directional. Light. set. Color(1. 0 f, 1. 0 f); directional. Light. set. Power(2); get. Current. Scene(). add. Light(directional. Light); Material material = new Material(); material. enable. Lighting(true); material. set. Diffuse. Method(new Diffuse. Method. Lambert()); material. set. Color(0); Texture earth. Texture = new Texture("Earth", R. drawable. earthtruecolor_nasa_big); try{ material. add. Texture(earth. Texture); } catch (ATexture. Exception error){ Log. d("DEBUG", "TEXTURE ERROR"); } earth. Sphere = new Sphere(1, 24); earth. Sphere. set. Material(material); get. Current. Scene(). add. Child(earth. Sphere); get. Current. Camera(). set. Z(4. 2 f); }. . .
LANGAI: Iš šių langų pereinama į 3 D figūrų langus mygtukų paspaudimo pagalba
KODAVIMO VEIKIMAS: • • PRISIJUNGIAMIA PATENKAME I PAGRINDINĮ LANGĄ KURIAME SPAUDZIAME PASIRINKTĄ MYGTUKĄ • • PASPAUDĘ MYGTUKĄ PATENKAME Į LANGĄ LANGE MATOME 3 D FIGŪRĄ
NAUJOJE VERSIJOJE BUS: • BUS PRIDĖTAS PASIRINKTOS GRAFIKOS VARTOJIMAS FIGŪROMS • • CUSTOM GRAFIKOS KROVIMAS TAIP PAT DUOMENŲ DALIJIMASIS
PROBLEMOS: • NEPAVYKO PADARYTI PERĖJIMO Į ŽEMĖS IR MARSO VAIZDUS • VISADOS ĮKELUS PAVEIKSLIUKUS NEVEIKDAVO R, META ERROR: CANNOT RESOLVE „R“.
DARBO IŠVADOS: • • NORIU PADARYTI DVI GALIMAS KALBAS YRA DAUG KĄ TVARKYTI
- Slides: 14