View Full Version : Creating a UV map within an LScript

01-12-2010, 02:18 PM
The documentation explains how to modify an existing vertex map, but I cannot seem to figure how to just take all the geometry my script has made and make a UV map that I can set all the values for within the script.

What's the simplest code I would need to do this? Everything I've tried either returns an error or simply does nothing, and info on the internet is mind-bogglingly scarce.

01-13-2010, 02:18 AM
I figured out how to do it, this post from the archives helped:


I'm not sure why this works and what I was doing didn't. The only difference I can see is that this uses a foreach loop, but I guess the loop is passing values the script can actually use where somehow the code I wrote wasn't.

01-13-2010, 03:23 AM
?Are you asking for help or not? We can't even begin to guess what might be wrong with your original code unless we see it.

The type of loop should not make a difference in this case. The foreach-loop is more limiting in application (and could be slower) than a for-loop iterating through an array by indexing. The reason is that the 'p' variable is a copy of an actual value in the 'points' array, rather than a reference to it. So you cannot alter values in the array using foreach, you can only read them.

01-13-2010, 11:30 PM
I've since adapted the example script so I don't have my old code that didn't work. I didn't post my code before because I had already changed it so many times it didn't matter. I just needed to see working code.

It wasn't the foreach loop that made it work, there was just something in the syntax I was missing. In fact, I just tried to rewrite some code to recreate the error I was getting, but now I can't because I know how the code should be written now and I don't remember what I was missing. Like I said, the documentation has example code showing how to modify a preexisting vertex map, so I was just confused about creating a new vmap.

Thanks anyway though

01-14-2010, 01:36 AM
"but now I can't because I know how the code should be written now"

Don't you just hate improving? Before you knew what you were doing you could write anything! Now you can't anymore. j/k