Posted by: | thiago.pastor | |
Data created: | 18 January 2011 |
hi all, How to convert between the ITexmap and IBitmapTex ? i tried the normal way using (IBitmapTex) texmap but get a null pointer the only way it worked was doing IBitmapTex bitmap = map.RefTarget as IBitmapTex; but, i dont know if this is the right way More one thing about this; iam using int axis = map.TheUVGen.Axis; and iam getting the result 0 in the axis (and i should get 1 for my model -- i looked at the texture coords values, and they are in the X and Z components, so i should get 1 there ), in the original API i can compare the result (axis) with those constants below //#define AXIS_UV 0 01 //#define AXIS_VW 1 12 //#define AXIS_WU 2 20
#define AXIS_UV 0 #define AXIS_VW 1 #define AXIS_WU 2
but in Max.net i cant acess those (was it converted to a Enum ? Or i need to look at the original apis for the correct value) -- the defines was converted to .net ? ----- I need to get the normals of a model, and im using
IRVertex vertx = mesh.GetRVert(i); IPoint3 vert = vertx.Rn.Normal;
or mesh.GetNormal(i) but in some cases i am getting a strange IPoint3 vert in some cases doing vert.x throw exception (the property x in not constructed) the way i found to make it work was using a mesh.BuildNormals before all, after that everything works normally. I need to call this function ? did im changing the model ? Is there a better way ? Thanks in advance ? Max.Net is really helping me !!! ;)
| |
18 January 2011
#2623 | |
More one thing, sometimes i need to check some flags values, I need to put the Hexa values by hand in the comparation or is there some Enums or Defines to help. Thanks
| |
19 January 2011
#2628 | |
Hello,
A simple cast, as you have shown, or even something like var bitmapTex = (IBitmapTex)map; should work. BitmapTex derives from Texmap and therefore will upcast from it if you have the correct object. I haven't tried much else of what you described, however, I would look up the values of the defines from Max SDK docs and try to use those. There is a chance that the enums in max.net are wrong (I did most of them by hand). Marsel Khadiyev (Software Developer, EPHERE Inc.) | |
19 January 2011
#2630 | |
other thing. some models has more than one normal per vertex, and i need to access them in the original API, i would use
IRVertex vertx = mesh.GetRVert((int)i0); IPoint3 vert = vertx.Rn.Normal;
IRVertex vertx = mesh.GetRVert((int)i0); IPoint3 vert = vertx.Ern[i].Normal; but in max.net vertx.Ern[i] is NOT an array, i just can access ONE normal. Is this correct ? how can access the others ?
| |
19 January 2011
#2631 | |
I'll need to specify that as being an array for the converter. Will try to do that for next build. Marsel Khadiyev (Software Developer, EPHERE Inc.) | |
1 October 2013
#4617 | |
To get the Vertex Normals you have to work throu all faces and their smoothing groups. i created a exporter with max.net where i used an example from the c++ 3ds exporter to create those vertex normals. here are some code snippets to get you the right track ^^ You will notice that i use Vector3D instead of working with ipoint3 from the wrapper. this as one main reason. mathematical operation are not working correctly with ipoint3. Only Vector3D is creating the correct result. Vector4 is a class that holds 4 float values. public class VNormal // used for generating and holding the vertex normal arrays public List<VNormal> ComputeVertexNormals(IMesh imMesh) // computes the vertex normals public MeshData GenerateMeshStream(EntityNode EntityNodeArg)
}
hope this is helping with handling vertex normals
Mario Röske |