![]() The glutsphere is a utility functionality to create some geometry to play with. (Lots of tutorials on this too, another tip: there is no right or wrong, there are pros and cons with everything, and be prepared to code in support for more than one format, as this will simplify things a lot in the future, if you’re thinking any seriously about this.) Of course, as soon as you start talking loading and saving, you also have to think about what format you’ll be using. And saving because the user will have to preserve all the changes they made with your edit tool. Loading because you’ll have to get real data into your app to work with. Two bits of functionality that you’ll have to think about straightaway are loading and saving the models. The new coordinates of the vetrex will be stored in your mesh scene object in memory. Sometimes, this works well actually.įollowing the picking, you’ll have to modify the vertex, so you’re looking at dragging it to a different location. IF you only pick the front vertex, the user will have to rotate the view slightly, and un-hide the vertices in the back, in order to pick them. This is a ui decision you’ll have to make: you can just pikc the front vertex or give the user the opportunity to choose which vertex she wants, etc. As you suggest, you will come across the situation where you pick a vertex, and there are more vertices hidden behind it (a term describing this is occlusion: the vertices in the back are occluded by the vertex in the front). These entities may be individual vertices, triangles, a whole mesh, etc, depending on how you implement it and what you want to do. Picking will return you a list of entities that are selected. To edit the model, the use case starts from the UI end: thisl will be done with opengl, and you’ll have to implement picking (there are a few tutorials on thins I think). Tip: if you structure your code nicely, the scene graph part and the rendering/ui part of your application will be conveniently separated into different modules, so that you may re-use the scene handling classes in other applications, involving, say, a different rendering library. Having the mesh in play, you can use OpenGL to render it. There are a few options on what your mesh should have, with the most common approach being to store geometric information as a list of vertices and triangles. Your application has to be able to store a mesh (and probably other types as well - but a mesh is generic enough to get you started), which will then be edited. Once you have the vertices or objects selected you know how to carry on. This is very well explained in the book “OpenGL Superbible 4th edition. ![]() One more thing, with the API you don’t have to worry about what vertices or objects are forward or backward because in the “selection buffer” are stored the Z values. ![]() ![]() So if you will use the OpenGL’s API you don’t have to store the vertices in the screen coordinates because it will return to you the vertices or objects (if any) selected by the user. It’s very easy and very fast to implement the selection with these functions. Should I store the vertex data in a kind of a structure that also has its corresponding screen co-ordinates so that I can select any particular vertex? But this way how can I differentiate vertices that fall on top of each other? I don’t think my method is good nor is it even fairly efficient.įortunately the OpenGL’s API has the functions needed to select objects and these functions are Firstly lets just stick to the selection part. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |