algorithm - How should I specify rectangles in a 3D scene? -


when rendering 3d rectangles (i.e. rectangles in 3d space), of course, specified list of vertexes 2 triangles. however, representation contains lot of extraneous information gets tiresome code multiple times. i'd create "rectangle" object allow me specify texture, size, position, , orientation in space , export list of vertexes (and indexes), i'm not sure of best way it. should specify position of lower left corner (pre-rotation), or center of rectangle? how should specify orientation, vector containing rotation angles? such simple , standard requirement i'm sure people have thought before, can't find on site or elsewhere on subject. plan use these objects lot, primary goal (apart performance) ease of use rather internal representation. wouldn't hard me code first thing can think of, don't want miss , make unnecessarily difficult.

so, how should represent rectangle object? opinions welcome, sources helpful.

edit: if helps, believe i'd using rectangles on faces of cubes, though not as entire faces of cubes.

it simplest store homogeneous matrix transforms standard, axis-aligned square desired location, along separate matrix determines how map texture onto it.

for location matrix, can store 4x3 matrix doesn't affect w-coordinate. bit redundant: uses 12 values general rectangle needs 8, on other hand, easier convert form usable rendering.

alternately, can store point location (edge or center depending on whatever convenient), , 2 direction vectors, describing direction , length of each edge; relying on rectangle generator make sure edge vectors orthogonal. take 9 values, best can do.

for texture mapping, can store 3x2 matrix defines affine mapping of (u,v) coordinates onto coordinates defined edges of rectangle. can choose zero-based (0,1)x(0,1) mapping, or symmetric (-1,1)x(-1,1) mapping, based on whatever convenient application. in case, require 6 values.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -