|
|
#1 | |
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
VMF Brush Side U/V axis, translation and scale
I'm winding down on the development of a VMF Exporter for 3ds Max. I've gotten almost everything nailed down. But I've reached a wall with one element: brush side uaxis and vaxis.
What I'm unable to figure out is how to take a face in Max and get the following bit of code for the VMF: Code:
"uaxis" "[1 0 0 0] 0.25" "vaxis" "[0 1 0 0] 0.25" Quote:
Any help would be appreciated. |
|
|
|
|
|
|
#2 |
![]() Join Date: Aug 2011
Reputation: 60
Posts: 1,160
|
ugh... I'm not good at vector/matrix math - I like generic - but this mostly planes on cubes. it's usually alot more about 2D/3D spaces and their matrix representations. especially on slant surfaces.
anyway, this just a wild theoretical explanation as help. Code:
"plane" "(-128 -448 -384) (-128 -64 -384) (128 -64 -384)" "uaxis" "[1 0 0 0] 0.25" "vaxis" "[0 -1 0 0] 0.25" a z-normal axis plane uaxis should be the vector in that direction >> normalize(p2-p1) vaxis should be the vector in that direction >> normalize(p2-p0) the scale and translation values can be obtained from a calculation on generated texcoords you get from max I guess. I hope it helps. it might not work for all on the first try. but I guess it's a tip in the direction you have to search for.
Last edited by episoder: 02-06-2012 at 09:53 PM. |
|
|
|
|
|
#3 |
![]() Join Date: Aug 2008
Reputation: 416
Posts: 908
|
PM'ed
|
|
|
|
|
|
#4 | |
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
Quote:
For some reason the introduction of matrix math and vectors turns my brain to mush. The irony is that I essentially solved a very similar dilemma when working out ways to map displacements. The only real difference is that this is looking for two unit vectors instead of one... and this is dealing with uvw coordinates; my brain didn't want to reuse any of the same kind of thinking because I'm 1) untrained and 2) not naturally mathematically inclined. Again, thank you I was half expecting for this thread to go unanswered for weeks (or forever) but now I can probably get this out tonight or tomorrow.
Last edited by shawnolson: 02-07-2012 at 11:05 AM. Reason: typo |
|
|
|
|
|
|
#5 |
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
Actually... it looks like my excitement was premature. The formula above assumes that the UVW is aligned to the Plane (side of a brush). But that is not always true. In Hammer... it is not so easy to manipulate that... but in Max it is very easy to control the uvw.
Since my goal is to translate exactly what you see in Max world brushes into the game, I cannot use that formula. For example, the X and Y axis of a face might be [1 0 0] and [0 1 0] when the U/V axis might be something different. Unless, of course, I'm simply missing some basic concept (which I don't find hard to believe ).Still, I appreciate the input. Hopefully I can make a breakthrough as the VMF exporter I've got will export entire scenes as brushes/models/entities/displacements/textures and the sky--all in one environment... which has been my goal for several years! Last edited by shawnolson: 02-07-2012 at 10:30 PM. Reason: typo |
|
|
|
|
|
#6 |
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
I am even further behind than I thought in solving this
Not to make duplicate content everywhere, here is the link to the extended description of the expanding dilemma: http://forums.cgsociety.org/showthre...f=98&t=1034253I emailed Valve directly via the SDK address on their contact page. My guess is that it will go unanswered as I sent an email last year that also went unanswered. |
|
|
|
|
|
#7 |
![]() Join Date: Aug 2008
Reputation: 416
Posts: 908
|
hmm. I think this code is what you are after:
Code:
//transforms uaxis and vaxis into per-point texture coordinates for each point on the face float uax = dot(uaxisVector, point) / texturescaleUaxis + textureOffsetUaxis float vax = dot(vaxisVector, point) / texturescaleVaxis + textureOffsetVaxis point.XCoord = uax / texture.Width point.YCoord = vax / texture.Height next point *texturescaleUaxis is Uaxisscale *uaxisVector is Vector(Uaxis[0], Uaxis[1], Uaxis[2]) *textureOffsetUaxis is Uaxis[3];
|
|
|
|
|
|
#8 | ||
![]() Join Date: Aug 2011
Reputation: 60
Posts: 1,160
|
ugh... sorry but...
Quote:
![]() and here's the other one. Quote:
notes on error: reversing some vmfs: the uv axis seems to just mirror the mapping on 2 opposing brush faces. this might be different looking or go wrong with max. also consider the fact that explicit texture mapping brushes are not working as you might want it to be. this' where your textures usually be squary and sheared and nothing else. |
||
|
|
|
|
|
#9 | |
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
Quote:
Sorry if the consequent reply seemed less than gratefull. Far from it, I have been very grateful with all help anyone has given me.And yes, life is for learning. My frustration is simply in my own lack of understanding and intuition regarding any 3D math. With most things I am a very quick learner; this is a situation that my brain isn't wired to solve naturally. With all of the help I've gotten so far, I have gotten "closer" to the answer (I think ... ). My optimisim about solving it in hours/days is less, though... more like weeks at this rate. I will release a version probably tomorrow that is no longer spitting out textures perpendicular to the faces but still not always rotated correctly and not yet scaled/translated correctly. As much as I'd like to have solved this on my own, though, I am not averse to help and solutions. Sometimes being given an answer isn't always a bad thing, just like sometimes it's good to stew in the frustration of trying to figure things out! Being as it is that I've been actively releasing all these tools for everyone freely, a little free help in return isn't too much to ask, aye? I want to use this thing--not spend forever trying to figure out how to make it ![]() Again, thank you all. |
|
|
|
|
|
|
#10 | ||||
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
So I've been struggling on this for weeks now. All along I've known that the problem is that my fundamental trigonometry skills/knowledge are exceptionally poor. Nonetheless, solving this is important to me so I'm keeping at it... and slowly getting a better feeling for the math behind the scenes.
But I'm still not there. I keep coming back to Zombie's code above and the variables are starting to "feel" more meaningful ... but still I cannot figure it out. How to reverse engineer that and use the data I have available is not coming easily. Essentially, I am iterating over each face of a brush... getting three vertexes that I use to define the plane. Quote:
I then get the corresponding texture coordinates: Quote:
Quote:
So far, the best I've done is to use the face verts to create a uaxis and vaxis: Quote:
However, using the texture coordinates is also not correct. In fact, using just the mesh verts to create the u/v axis looks better (even though incorrect). So the dilemma is simply this: how to take V1,V2,V3 and TV1,TV2,TV3 and convert them into the uaxis/vaxis in the VMF. Somehow the mesh verts and uv verts have to be factored in together. Once there, I will factor in any extra offsetting of a face's individual texture (since the textures have have even more offsetting beyond this... but right now I can't even get past the basic UVW stage). Ideas? |
||||
|
|
|
|
|
#11 |
![]() Join Date: Aug 2011
Reputation: 60
Posts: 1,160
|
have you already tried tangent space computation?
like this: uaxis = cross(normal,up); vaxis = cross(normal,uaxis); it may come off distorted or upside down or shifted and the orientation is based on the surface again but it's legit. edit: for the reversing from uvw coords you'd also just calculate the direction of u and v per face and use a few bits of that projection for the translation and scale. that should do best for not the cubic but rotated uv orientation. Last edited by episoder: 02-23-2012 at 09:43 AM. |
|
|
|
|
|
#12 | |
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
Quote:
Maybe it is because the upVector needs to be defined differently? I have simply made it [0,0,1] but the problem is that the normal on up/down faces in this example are parallel with that vector. Last edited by shawnolson: 02-23-2012 at 09:40 AM. Reason: typo |
|
|
|
|
|
|
#13 |
![]() Join Date: Nov 2009
Reputation: 41
Posts: 170
|
Well I need to share the good news. The problem is solved. I'll be loading the updated version of WW tools with proper VMF UVW support in the next week.
I was personally unable to solve it. Luckily a good friend (Andrew Penry) took up the challenge... and he figured out in a week what I couldn't figure out in about two months! I had half-expected the formula to be simple--and that I would yell DOH! when I saw it. But, as it turns out, the logic and formula is a little complex... so I'm not going to explain it here. But I will ask Andrew to write up a little overview of it for adding to the VMF docs on the wiki or on the WW docs site so that anyone interested in this problem can get an explanation. For me, now that it's solved... I'm running onto the next set of WW functions and finishing some levels. |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|