From DoomWiki.org Warning: You are not logged in. Your IP address will be recorded in this page's edit history. Anti-spam check. Do not fill this in! ==Making polygons== Any ideas how to construct the convex polygons that make up level geometry from the level data lumps? I guess the most important info is in SEGS and SSECTORS, but I can't figure out how it works. [[User:Fredrik|Fredrik]] 15:38, 25 Feb 2005 (GMT) :Yeah, this looks kind of tricky. The SSECTORS themselves are lists of SEGs, and each SEG seems to have a starting "distance" along its length but no length or ending distance. : You can probably infer the end point of SEGs by something like (ruby pseudocode): seg_hash = {} # create a list of segs for each linedef foreach seg in segs seg_hash[seg.linedef] = [] if seg_hash[seg.linedef] == nil seg_hash[seg.linedef].push(seg) end # go through each linedef seg_hash.each_key do |linedef| # sort by start point seglist = seg_hash[linedef].sort { |a,b| a.startpoint <=> b.startpoint } # assign endpoints from the start of the next segment in the list # use the full length of the linedef for the last entry for i in 0..seglist.length-1 seglist[i].endpoint = if i >= seglist-1 linedefs[linedef].length else seglist[i+1].startpoint end end end : Then you'll get the complete data you need in order to highlight segments for example. You wont be able to get complete polygons unless you do something cleverer (maybe involving the dividing line data in NODES?) : [[User:Fraggle|Fraggle]] 16:01, 25 Feb 2005 (GMT) [[Image:E1M1 segs.png|thumb|250px|Regular segs and subsectors]] [[Image:E1M1 GL segs.png|thumb|250px|glBSP segs and subsectors]] All of a sudden I came to think of glBSP, which generates convex subsectors. Watch the difference :) I wanted this for more advanced level statistics such as volume, volume per sector, monsters per volume unit etc. [[User:Fredrik|Fredrik]] 18:10, 25 Feb 2005 (GMT) :I finally figured a way to do this (see third image): [[Image:All SS E1M1.png|thumb|250px|Original IWAD subsectors]] :For each subsector, determine a point within it (in map coordinates). I did this by taking the first (or only) seg, finding the normal vector at the midpoint and projecting -1 units (i.e. to the right of the seg). (N.B. The end points of each seg are given by the vertices in the seg structure.) :Create a rectangular polygon enclosing the whole map. :Starting with the root node, slice the polygon using the node's partition line, and keep just the part on the same side as the subsector point determined above. Then, select the subnode corresponding to the side the point is on and repeat slicing and subnoding until you reach the subsector in the node tree (0x8000 bit set in child node). :Now, the polygon covers the subsector but may extend out into the void. To clip, slice the polygon with each seg in the subsector, keeping just the right-hand slice each time. :There is one subsector in E1M1 (subsector number 143) for which this does not seem to work, and one or two subsectors in some of the other maps I checked as well. I'm not sure why this is, but I just ignored these anomolous subsectors. :[[User:Radius|radius]] 14:59, 15 Nov 2005 (UTC) Summary: All contributions to DoomWiki.org are considered to be released under the CC BY-SA 4.0 International (see Doom Wiki:Copyrights for details). By contributing, you agree to be bound by the Terms of Use. Your changes will be visible immediately. Please enter a summary of your changes above. Do not submit copyrighted images or text without permission! This includes text taken from in-game codices or logbooks, or from official instruction manuals, strategy guides, and other such books. This project is not affiliated with id Software, Raven Software, ZeniMax Media, Bethesda SoftWorks, or any other commercial software developer or publisher. Use of trademarked logos and other protected intellectual property is solely for the purpose of analysis and critical commentary on the identified products and associated fan community activity, and does not imply any endorsement by any of these organizations or their employees, past or present. Upload images to the wiki. Don't forget to categorize pages! For testing, please use a sandbox. View this template Cancel | Editing help (opens in new window)