by Spike » Sun Jan 08, 2017 3:57 am
brush_create(world.modelindex, brushFace, brushFace.length, CONTENTBIT_SOLID);
(note that brushFace.length == 6, it just looks a little cleaner to avoid magic numbers. however, chances are that you'll need more faces per brush at some point, this argument should of course be the number of valid faces)
plane normals MUST be normalised. no exceptions.
the normal says the direction the plane is facing, the distance says how far along the plane is along that normal from the origin.
That is, the point at (planedist*planenormal) sits on the plane. Alternatively, planedist=dot(pointonplane,planenormal);
(note that dot(x,y) === x*y in qc, but I'm using function notation because x*y is somewhat weird when you have floats in one place and vectors in another)
so if you want an axial cube centered on the origin, use normals of +x, +y, +z, -x, -y, -z (and by +x I mean '1 0 0'), and some distance that says the 'radius' of the box. to then move it by some vector, planedist += dot(translation,planenormal); should be applied to each of the 6 planes (this logic works regardless of any rotation you have applied. note that using makevectors and negating the results for the other 3 planes should be enough to create a rotated cube centered around the origin).
note that the translation thing can be applied to a single plane, which gives you the translation of a single plane / surface. and by translation, I of course mean 'move' (or the vector/displacement for that movement).
the sdir/sbias and tdir/tbias fields are essentially the same as the plane planenormal/planedist, except that they apply to the texture coords instead. the dir vectors do not need to be normalised, which allows for rescaling the texture. they should normally be tangenital to the normal and each other - that is that the 3 normals each face 90 degrees from each other in order to avoid skewing.
by changing the bias values the same way when translating, you will obtain texture lock.
note that out_x = dot(v_forward,in); out_y = -dot(v_right,in); out_z = dot(v_up,in); can be used to rotate a plane normal (first call makevectors with the rotation difference as an argument - note targ-src angle, which is sucky to calculate with eular angles so try to avoid absolute angle values). adjusting the distance is more tricky, effectively you need to translate the rotation pivot to '0 0 0', rotate it, then move it back.
is it a bird? is it a plane? no, its a friggin maths equation. gah.
with the right helper functions, you should find it managable enough.
.