Use of nicamera

Source: Internet
Author: User

1. Create camera.
1) obtained through ninew nicamera
2) read the NIF file and find the appropriate camera Node
2. Create Nirect <Float> object, set the camera viewlesize (assuming the object is nirect <float> kretviewpost)
1) full screen kretviewpost = nirect <float> (0.0f, 1.0f, 1.0f, 0.0f );
2) specific size
Suppose the current window size is 800*600. We want to display the content of camera in the range of 200*100 and the relative coordinate is (Cx = 300, Cy = 100, the size of the view is as follows:
Calculate the ratio of the View: ratioleft = Cx/800, ratiobuton = 1.0-(CY + 100)/600; ratioright = (cx + 200)/800, ratiotop = 1.0-cy/600;
Kretviewpost = nirect <float> (ratioleft ratioright, ratiotop, ratiobuton );
3. Create a nifrustum object and set the percentage of camera cross section bodies
Nifrustum (float fleft, float fright, float ftop, float fbottom, float fnear, float ffar, bool bortho = false)
The value of fleft/fright/ftop/fbuttom depends on the center and display mode of the display area.
1) display mode:
A) orthogonal mode (bortho = true)
If the display area is 200*100, fleft =-(200/2), fright = 200/2, ftop = 100/2, fbuttom =-100/2;
B) non-orthogonal mode (bortho = false)
No matter how large the display area is, the fleft/fbuttom values are between [-0.5, 0.0), and the values of fright/ftop are between (0.0, 0.5]. For example: (-0.4, 0.4, 0.46,-0.46)
The difference between orthogonal and non-orthogonal is that when the non-orthogonal mode is used, the image size of camera is affected by the distance from the focused object (the zoom-in function can be achieved ), the orthogonal mode does not.
2) display Ratio
In orthogonal mode, adjustaspectratio is called, while in non-orthogonal mode, the ratio of fleft (fright) to fbuttom (ftop) is set.
3) Crop distance (for example, fnear = 1.0f, ffar = 1000.0f)
4. Set viewport and frustum respectively through nicamera: setviewport (const nirect <float> &) and camera: setviewfrustum (const nirustum &).

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.