Calculating WorldCraft .MAP file texture coordinates?

Started by
9 comments, last by IntertainmenT Software 23 years, 2 months ago
I have managed to parse a WorldCraft .MAP file and create polygons for every brush. I don''t know how to calculate texture coordinates for every vertex. I am using WorldCraft 3.3 (mapversion = 220), but don''t mind if you have out-dated info... Any formulas, algorithms, or source code showing how to calculate texture coordinates would be greatly appreciated . thanx, stefan
Advertisement
Visit this site: http://halflife.gamedesign.net/resources/mapformat.shtml

It will tell you what those numbers after the texture name mean, and how to apply them. I hope thats what you wanted.
My problem is that I have the polygons created for every brush and I know the texture scale, shift, and rotation for every polygon. But how do I calculate texture coordinates for every vertex in the polygon?

from, stefan
Hi there,
I''ve got the same problem in the level editor I''m currently writing. I''ve got shift, scale, and rotation, but now I need to know the texture coords for the polys. I also know I could use glMatrixMode(GL_TEXTURE); glRotatef..... but this seems somehow inefficient.

Thanks ,
Anonymus

The Worldcraft 3.3 .MAP tells you the U-axis, and the V-axis, and U-shift, and the V-shift, now to calculate the texture coords for vertex A, use the following equations:

// assuming rot_angle = 0, and scale is 1u = (DotProduct(A, U_Axis) + U_shift) / texture_width;v = (DotProduct(A, V_Axis) + V_shift) / texture_height; 



- code
Ok then, this will do.

Thank you,
Anonymus
Just wondering how many people are using Worldcraft for map generation... and how many are actually parsing .map files. Is it a fairly decent approach?

I was thinking of writing my own level editor, but I really don''t want to do that if I don''t have to.

quote:Original post by Sydan

Just wondering how many people are using Worldcraft for map generation... and how many are actually parsing .map files. Is it a fairly decent approach?

I was thinking of writing my own level editor, but I really don''t want to do that if I don''t have to.



I''m parsing the HalfLife .map files created with Worldcraft 3.3, I can also parse the regular Quake3 maps, but I chose the HL format becuase of the ease of generating texture coords straight from the file itself... no fuss, no complicated calcualation needed... the HL .map has everything.



- code
I have been wanting to parse a .map file for a while but i cant figure it out. Could one of you that know how to do this tell me how to take the brushes (which i know are made up of at least 4 planes) and generate the polys and stuff from them? All i need it to know how to do just that, the bsp tree stuff i can do. I have been trying to figure it out from the id software bsp code, but its hardly commented and i cant seem to understand all of what they are doing.

-SirKnight
quote:Original post by SirKnight

I have been wanting to parse a .map file for a while but i cant figure it out. Could one of you that know how to do this tell me how to take the brushes (which i know are made up of at least 4 planes) and generate the polys and stuff from them? All i need it to know how to do just that, the bsp tree stuff i can do. I have been trying to figure it out from the id software bsp code, but its hardly commented and i cant seem to understand all of what they are doing.

-SirKnight


The algorithm is actually quite simple, and rather obvious after you've seen it. Here it is:

For each plane in this brush, do this:

1) Generate a huge polygon from the plane
2) Split this huge polygon with another plane of this brush
3) Save the back half of the split
4) Use the saved back half, repeat step 2, until every other plane in this brushes has served as a splitter.

So in other words, what you're doing here is just clipping this initially huge polygon down to the right size... and this "right size" is defined by the other planes of this brush. And of course, you do this for every brush - and that'll give you a list of polygons that make this level.

And that's it! Very simple, the SplitPolygonWithPlane() function will have to be written anyway, for building the BSP tree.

Hope that helped.

Edited by - somecodeguy on February 10, 2001 11:40:55 PM

- code

This topic is closed to new replies.

Advertisement