Nehe OpenGL Tutorial with OpenSceneGraph-32nd lesson

Source: Internet
Author: User
Brief Introduction

The Nehe course of this lesson mainly wants us to introduce the method of pickup (Selection) in OpenGL to exchange with the objects in the scene. In OSG, there is no way to encapsulate the pickup in OpenGL, but it is a more efficient way to perform the intersection with the model in the scene, The reason for processing this OSG can be referred to in OSG in this maillist:new to OSG, some questions (selection buffer, parametric curves) implementation

In the Nehe course of the key to achieve in this lesson in the selection function, it implements the selection in OpenGL way, in our OSG to select the intersection of the code is relatively simple:

Implementation of several Osgutil offers: This lesson uses the Osgutil::linesegmentintersector to detect the intersection between a specified segment and a scene shape

		Case (Osgga::guieventadapter::P ush): {int choose = 0;

				Osg::node *node;
				Osgutil::linesegmentintersector::intersections intersections; if (Viewer->computeintersections (ea,intersections)) {osgutil::linesegmentintersector::intersection intersect
					Ion = *intersections.begin ();
					Osg::nodepath &nodepath = Intersection.nodepath; node = (nodepath.size () >= 1)?

					Nodepath[nodepath.size () -1]:0;
					const char *name = Node->getname (). C_STR ();
				Choose = Atoi (name);							} if (!object[choose].hit)//If the object hasn ' t already Been hit {object[choose].hit=true;											Mark the Object as being Hit score+=1;											Increase Score kills+=1;
					Increase level kills if (kills>level*5)//New level yet?											{miss=0;										Misses Reset back to Zero kills=0;										Reset level kills Level+=1; Increase level if (level>30)// Higher Than 30?									level=30;
					Set level to (Are A God?)	 }
				}
			}

Other parts of the code involve a large number of callback updates and location calculations that are cumbersome, but they are covered in previous courses, and the reader can refer to the contents of the Nehe course.



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.