GOOGLE VR SDK Development VR game, one of the VR player

Source: Internet
Author: User
Tags google vr

Over the past year, the promotion of VR and AR augmented reality technology has been on the increase. In fact, Vr,ar technology has long ago, has not been popular, undeniable price is the biggest barrier to the impact of technology promotion. Google's biggest contribution to VR is to provide cheap Google glasses, according to Google's drawings, using two Magnifier and a pizza box can easily diy their own VR glasses, the same time Google launched the open source of the VR SDK, so that developers can easily build VR games and VR player, Make it easy for companies that are interested in all this to be able to easily lay out the VR industry chain at a low cost. Many VR glasses have dropped to dozens of dollars, and Google has undoubtedly changed our world through cheap and open source.

Studying Google's SDK requires a certain amount of OpenGL knowledge, or it is difficult to understand. The principle of VR is very simple, people can feel the stereoscopic or 3D of the world depends on the eyes of people, people see things are not the same, there is a perspective difference, look at a three-dimensional object, left and right eye can see the middle part of the object, but the left eye can see more than the left side of the eye, The right eye can see a little more than the left eye. The right part, the brain to two glasses to see something analysis processing synthesis to feel the world, some 3D painting can be appropriate for light and color combination to achieve visual deception is also this principle. If you are familiar with OpenGL, it should be easy to know that 3D modeling, camera location, can show the object angle is not the same, especially when using the perspective effect, the human eye is equivalent to the 3D world camera, two cameras see something and a different. In general, if the one-eyed disabled person does not move, the world they see is flat, but they can look at the world from different angles by swinging their heads or moving their bodies, thus synthesizing the three-dimensional world in the brain. So the principle of VR is to take a picture or video decomposition of two, respectively, to provide to the left and right to see, so as to achieve the effect of cheating eyes, and ultimately achieve the effect of virtual reality.

Google VR SDK is very simple to use, generally best to download the latest Google VR SDK,VR SDK includes unity version and Java version, two versions of the same features, one for the Unity platform, one for Android platform, one for game development, One for application development, of course, this is not absolute, there are many applications also use unity development, there are many games using Java development, the choice of feeling can see their own use habits. The Java version includes two packages, one CARDBOARD.JAR for VR vision support, and one Audio.jar for VR sound support.

Cardboardactivity is the main class of VRSDK, to enable the development of Windows to support VR, the window needs to derive from this class. Can call Cardboardview as needed, support a variety of calls, the complete code is as follows, but after the completion of the other than to see a button, the other is black winter, because renderer we do not fill the content, is an empty glsurface, Familiar with the Opgengl, you can refine this class, and later add a cube for testing glasses
public class Testactivity extends cardboardactivity{/* @Override protected void onCreate (Bundle savedinstancestate)        {super.oncreate (savedinstancestate);        This.setcontentview (R.layout.activity_main);        Rajawalicardboardview CV = (rajawalicardboardview) Findviewbyid (R.ID.VIEW2);//new Cardboardview (this);        Cv.setrestoreglstateenabled (FALSE);        Cv.setrenderer (RD);        This.setcardboardview (CV); Rajawalicardboardrenderer renderer = new Rajawalicardboardrenderer (this) {@Override protected void I Nitscene () {Getcurrentscene (). AddChild (Createspherewithtexture (New Texture ("Photo", R.drawable.homepage)))                ;                Getcurrentcamera (). SetPosition (Vector3.zero);            Getcurrentcamera (). Setfieldofview (75); } @Override public void Onnewframe (Headtransform headtransform) {super.onnewframe (he            Adtransform); } @Override Protected void OnRender (Long ellapsedrealtime, double deltatime) {Super.onrender (ellapsedrealtime, Deltatime)            ;            } @Override public void Ondraweye (eye eye) {super.ondraweye (eye); } @Override public void Onfinishframe (Viewport Viewport) {super.onfinishframe (Viewpo            RT); } @Override public void onsurfacechanged (int width, int height) {Super.onsurfacechan            Ged (width, height); } @Override public void onsurfacecreated (EGLConfig config) {super.onsurfacecreated (c            Onfig);            } @Override public void Onrenderershutdown () {Super.onrenderershutdown (); } @Override public void onoffsetschanged (float xoffset, float yoffset, float xoffsetstep, float YO ffsetstep, int xpixeloffset, int ypixeloffset) {Super.onoffSetschanged (Xoffset, Yoffset, Xoffsetstep, Yoffsetstep, Xpixeloffset, Ypixeloffset);            } @Override public void Ontouchevent (Motionevent event) {super.ontouchevent (event);        }        };        Cv.setrenderer (renderer);    Cv.setsurfacerenderer (renderer); }*//* @Override protected void onCreate (Bundle savedinstancestate) {requestwindowfeature (Window.featur        E_no_title); GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, Windowmanager.layoutparams .        Flag_fullscreen);        Super.oncreate (savedinstancestate);        LinearLayout ln = new LinearLayout (this);        Ln.setbackgroundcolor (color.red);        Cardboardview Cbview = new Cardboardview (this);        Cbview.setbackgroundcolor (Color.Blue);        Cbview.setvrmodeenabled (TRUE);        Cbview.setalpha (0);        Cbview.setalignmentmarkerenabled (TRUE);  Cbview.setrenderer (New Vrrenderer (this));      Vrrenderer renderer = new Vrrenderer (this);        Cbview.setrenderer (renderer);        Cbview.setpreserveeglcontextonpause (TRUE);        Setcontentview (Cbview);                Cbview.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) {            Oncardboardtrigger ();        }        });    Mhidebuttonsthread.start ();        } @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_main);        Cardboardview Cardboardview = (cardboardview) Findviewbyid (R.ID.VIEW2);        Cardboardview.setrenderer (RD);        Setcardboardview (Cardboardview);        Vibrator = (Vibrator) getsystemservice (Context.vibrator_service);        Imageleft = (ImageView) Findviewbyid (r.id.image_left);        Imageright = (ImageView) Findviewbyid (r.id.image_right);        Progressleft = (ProgressBar) Findviewbyid (r.id.progress_left); Progressright =(ProgressBar) Findviewbyid (r.id.progress_right);        Statusleft = (TextView) Findviewbyid (r.id.status_text_left);        Statusright = (TextView) Findviewbyid (r.id.status_text_right);        Fadeinanim = new Alphaanimation (0.0f, 1.0f);        Fadeinanim.setduration (500);        Setprogress (TRUE);        SetStatus (True, getString (R.string.status_finding_files));        Kick off our tasks to find all MPOs, which'll in turn kick off showing the first one.    New Mpofindtask (). Execute ((Void) null); } */Private Renderer rd = new Renderer () {@Override public void Ondrawframe (Headtransform headtransfo RM, eye eye, eye eye1) {} @Override public void Onfinishframe (Viewport Viewport) {} @ Override public void onsurfacechanged (int i, int. i1) {} @Override public void Onsurfacecreate        D (EGLConfig EGLConfig) {} @Override public void Onrenderershutdown () {}}; @OverRide public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Cardboardview Msurfaceview = new Cardboardview (this);        Addcontentview (Msurfaceview, New Actionbar.layoutparams (ViewGroup.LayoutParams.MATCH_PARENT)); Msurfaceview.setsystemuivisibility (view.system_ui_flag_layout_stable | view.system_ui_flag_layout_hide_navigation | View.system_ui_flag_layout_fullscreen | View.system_ui_flag_hide_navigation//HIDE nav bar | View.system_ui_flag_fullscreen//Hide Status bar |        view.system_ui_flag_immersive);        Msurfaceview.setrenderer (RD);        Msurfaceview.setvrmodeenabled (TRUE);        Msurfaceview.addchildrenforaccessibility ();    Setcardboardview (Msurfaceview); }}


Reference: Http://www.programcreek.com/java-api-examples/index.php?api=com.google.vrtoolkit.cardboard.CardboardView


GOOGLE VR SDK Development VR game, one of the VR player

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.