hi
i eventually started to lern maxscript .. a model file import/export script for a very old microprose fligtsimulator
sooo .. i mainly have trouble to understand the way maxscript calls "things"
in this case a vertex
what i want to do:
x = 10
y = 0
z = 35
u = 0.4
v = 0.4
w = 0
thisIndex = polyOp.createVert myEditPolyObject [x ,y , z ]
and now i want to give this newly created vertex the texture coordinates [u, v, w]
i iknow i can move the textur points with eg. <void>moveX <float>p
but how do i aplly this movement to the vertex thisIndex ?
it would help me a lot if i understand the idear behind that method
thx
Replies
So I think the correct procedure for this would be to first create all the verts using the method you showed (polyOp.createVert) and obviously you will have to hook up the faces once you have created the vertices.
Then once all the verts and faces exist, you can use the Unwrap UVW methods to get each geometric vertex index, find the corresponding UV index, and set it to the required value.
Something which might be more difficult is dealing with seams, since you may have one geometric vertex which has 2 (or more!) UV indices. It depends how you're constructing the model, I mean you could just create one geometric vertex for every single UV and then only weld the geometric verts in the very final stage after the UVs are constructed.
Either way it sounds like a "fun" exercise, I am pretty sure that Max's method of accessing/comparing UV and geometric vertex data is quite annoying to use.
I don't have much experience constructing UVs from scratch though - I wrote a maxscript LWO file importer and it correctly imported all the meshes, but I stopped before I got to the UV reconstruction part
edit: you might get some better / more useful replies to this over on www.tech-artists.org
The only level that UV and poly or mesh data share are "faces" whoose ID's are equal. So you could say that face #1 is equal to texture face #1 and all other faces.
What is different though and very important to understand:
Texture Vertex coordinates are way different from mesh Vertex coordinates - because as you might now any set of UV-faces can have a compelte different composition known as shell as a composition in the poly model itself.
So again: face id's are equal but vertex coordinates (and also amount) vary and are different.
Maybe give of a brief overview of what you really want to archive in the big loop - not how to solve this smal step. Because maybe there is a better way to do it.
what i have is
an array with the vertex data
one block looks like this
[x, y, z]
an array with the face data
one block looks like this
(the length of it depending on the amount of vertices the poly shares)
[vertexID1, u1, v1, vertexID2, u2, v2, ...]
what i do atm is
( to create first all vertice and then create the polys does not realy work, bc it can be that i have 2 polys which share the same vertice and max would bring the "illegal face" error and its easier to accomplish the other way around)
EDIT: one thought.. if i have to access the vertices for a lot of things AFTER i´v created the whole mesh it might be better to try this approach again.. bc i don´t see a way to keep the right vertex id´s otherwise
any idear how i can prevent the problem of max not creating faces "over" existing faces? something relatively easy to develop?
here is a code snippet that will read out your texture vertex points if you have a UVWunweap modifiert attached:
here is what you might propably want instead:
http://renderhjs.net/bbs/polycount/colorcatch/xml_tools_18.ms
its a smal script collection I wrote for this game project:
http://boards.polycount.net/showthread.php?p=806838
in particular these code lines might be interesting for you- the script constructs a mesh out of a binary stream and assigns the UV faces directly into the Mesh object- which is a bit tricky at some parts (the order was important or so):
here is the load function that generates the Mesh:
so these lines: are the one to look out for
hope that helps somewhat
found out that i dont need to create my mesh as edit poly.. and to make it even better: it seems a lot more complicate then doing it as edit mesh...
thx hendrik .. this is enough new information to keep going for the next hours..
with the esporter still to go i have some generel maxscript question
what i know what is possible is something like this line to create dynamic vars
execute("b" + i as string + " = 10");
but is there a way to do it more like the flash-actionscript way ?
eval("b" + i) = 10;
but about maxscript- I haven't evaluated dymanic stuff yet, there is format which is pretty powerfull and it would be then written as: whereas each % sign gets replaced by the followed parameters (any number you want). But so far I only traced with it, maybe read up the format related entries in the maxscript help
it doesn´t seem i can catch it within a maxscript line
thx so far
but lets ask the question a bit different
what i want to do:
create dynamically <n> objects with _for 1 to <n>_ and give them the vars myobject_<n>
so i can later access them again dynamical with a _for_
this i what I do all the time in other scripting languages - creating shortcuts to array contents. Not only makes it easier to work with arrays but it also speeds up the code execution since the maxscript does not need to create a 'lookup' each time since the variable 'b' is already cached.
is that perhaps what you have in mind?
buut script for import and export is in the last phase of testing and optimising
this was an ugly crash course of maxscript -.-
i´ll post it as soon as i think it´s worth of v.1.0
i´m curious if there´s still someone modding EAW..
lowpoly wwII plane ownage!!!!!
wohoo :poly142:
i´m wondering how i can link the following information:
face nr #F has 3 vertices [v1, v2, v3]
texture face nr #TF has 3 textur vertices [tv1, tv2, tv3]
as you have mentioned #F == #TF
buuut .. which tv represents which v (or the other way around)?
i know the id´s don´t match.. but somehow i have to be able to tell which tv is based on which v (even if there could be more tv based on one v)
I thought there must be a better way than this, but I haven't found one yet
so am i right if i say i cant use polyOp if i´m working with an Editable_Mesh
annnnd if soo.. what´s the trick there
it seems i can only access with eg.
meshop.getMapFace <Mesh mesh> <Integer mapChannel> <Integer index>
to get a point3 [tvert1, tvert2, tvert3]
and
getFace <mesh> <face_index_integer>
to get a point3 [vert1, vert2, vert3]
buuuuuuuuuuut the question is.. is tvert1 always corresponding to vert1? even if the uv´s are mirrored?
.. i don´t know.. but i´ll try
so i still have to figure out how to get the vertex-clockvise-order for edit_mesh_polys right and the import/export script is somehow doing what its designed for