Archived

This topic is now archived and is closed to further replies.

IntertainmenT Software

Calculating WorldCraft .MAP file texture coordinates?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites

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 1

u = (DotProduct(A, U_Axis) + U_shift) / texture_width;
v = (DotProduct(A, V_Axis) + V_shift) / texture_height;


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok then, this will do.

Thank you,
Anonymus

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Oh wow, that is pretty simple, i didnt know thats how it was done. Thanks, that helped alot. Hopefully by the end of next week ill have a simple map file view running, dont know about the texture mapping part though. I have never been good at getting texture mapping working like i want it.

-SirKnight

Share this post


Link to post
Share on other sites