3D-Editor Coding Issues

Started by
2 comments, last by Dhaos 15 years, 9 months ago
I have been building a simple 3d-editor and have run into several issues I am unable to resolve. ---------------------------------------------------------------------------------- 1)Preventing a vertice or polygon from being selected when it is not in view. ---------------------------------------------------------------------------------- I have no idea how one would go about this. Currently when you attempt to click in the view area, it tests every single object, vertices or polygons depending on the selection mode, within the model and selects the one closest to the viewer as well as any object that share the same X Y Z. I could make a "possible selection list" that would be refilled each time you rotate the camera, but again I am not sure how to test whether or not a given vertice or polygon is currently visible to the viewer. Perhaps something relating to back face testing? ---------------------------------------------------------------------------------- 2)How to hide individual or groups of polygon. ---------------------------------------------------------------------------------- Storing the hidden polygons in a list, shifting them to the end of a given object array when hidden and only drawing the first set (ex: those not hidden) via editing the number of polygons to draw. This method worries me from a performance standpoint. ---------------------------------------------------------------------------------- Is there a built in toggle for either of these? Testing wether or not a polygon or vertice should be drawn, and preventing a polygon or series of polygons from being rendered?
Advertisement
1) Sounds like you could use a variation of the zbuffer idea as an alternative solution for this. Insert the ID number for the visible polygon into the zbuffer when the new z value is greater than that already in the buffer...

2) Doesn't sound that much of a performance hit to me, assuming your arrays are fixed size.

If all I was doing was looping through the list, without any need to index items within the list repeatedly, I'd use a linklist. I'd create a seperate linklist pointing to invisible polygons. I would make the polygons invisible by inverting its surface normal.
http://www.fotofill.co.uk
For the first one, it sounds like you are trying to implement some sort of 3d picking.

One way to do picking would be to redraw the current view, but use a unique color for every object, vertex, or polygon. Then take the coordinates for the location the user clicked on the screen and get the color in the re-colored view. You can then use this color to determine which object they selected. This colored view would never actually be shown to the user, just used to determine what they clicked on.

It sounds like your current method will select an object if it is near the selected point as well - something this alternate method would not do. You might be able to increase the line/point screen draw size to larger than one pixel to help reduce this problem.
scottrick49
@moosedude: I am unsure of how to gain access to the z-buffer information. Is there a function for this or something even more trivial that I am missing?

Also linked lists are out since the final output function for direct x only accepts arrays. Any additional information (the pointer to the next object) skews the rendering. Inverting the surface normal would create an issue if you hide a front polygon then hid a back polygon, you would then see the "hidden" polygons because they aren't truly invisible/removed.

@scottrick49: The color picking method sounds rather nice, however I never did figure out how you figure out the color of a given pixel. Could you elaborate more on how this would be setup?

Also I dont require the user to pick the exact pixel coordinate of the vertice, I have about a 14px square buffer that is also selectable.

This topic is closed to new replies.

Advertisement