i3d plugin for Blender 3.6
i3d plugin for Blender 3.6
Hey guys,
as the title says I made a i3d plugin for Blender version 3.6. The plugin is based on blenders .3ds plugin. Sadly the plugin is not so far that we can get rid of 3ds max 3. At the moment it can only be used as "bridge" to convert models for Hidden and Dangerous Deluxe. (3ds format supports only 12 characters filenames for textures and has a buggy blender plugin)
The importer is more or less untouched compared to the 3ds plugin.
The exporter has following things supported at the moment:
- meshes with correct pivots and positions
- materials incl. long filenames
- UV maps
Not supported yet:
- Dummies
- Animations
- Bones
- NURBS
- Properties
The direct import from blender to hidden and dangerous is also not possible at the moment. HDD can't read the mesh geometry while 3ds max 3 somehow can. I need to fix that in the future.
To install just put the folder in %blender root dir%\3.6\scripts\addons and enable the plugin in preferences.
Have fun!
as the title says I made a i3d plugin for Blender version 3.6. The plugin is based on blenders .3ds plugin. Sadly the plugin is not so far that we can get rid of 3ds max 3. At the moment it can only be used as "bridge" to convert models for Hidden and Dangerous Deluxe. (3ds format supports only 12 characters filenames for textures and has a buggy blender plugin)
The importer is more or less untouched compared to the 3ds plugin.
The exporter has following things supported at the moment:
- meshes with correct pivots and positions
- materials incl. long filenames
- UV maps
Not supported yet:
- Dummies
- Animations
- Bones
- NURBS
- Properties
The direct import from blender to hidden and dangerous is also not possible at the moment. HDD can't read the mesh geometry while 3ds max 3 somehow can. I need to fix that in the future.
To install just put the folder in %blender root dir%\3.6\scripts\addons and enable the plugin in preferences.
Have fun!
Last edited by NilsZ on Wed Aug 30, 2023 9:23 am, edited 1 time in total.
Re: i3d plugin for Blender 3.6
A little preview of the alps1 map from HD2 imported to HDD using 4ds tools for blender and i3d plugin.
-
- Private
- Posts: 14
- Joined: Thu Jun 29, 2023 1:52 am
Re: i3d plugin for Blender 3.6
I couldn't seem to preserve the UVMap when I loaded an i3d file from HD1 into Blender :/. We're you able to?
Re: i3d plugin for Blender 3.6
yes indeed it needs a fix. At the moment only exporting to i3d preserves UV maps.battlefeel1942 wrote: ↑Fri Feb 16, 2024 2:58 amI couldn't seem to preserve the UVMap when I loaded an i3d file from HD1 into Blender :/. We're you able to?
-
- Private
- Posts: 14
- Joined: Thu Jun 29, 2023 1:52 am
Re: i3d plugin for Blender 3.6
Do you know much about the i3d format?
I have been investigating this for a few days but am not getting very far. It looks like the typical UV chunk (MAPPINGCOORS 0x4140) is either missing or moved. Its quite strange.
I also discovered an unknown chunk 0x4200. The UV and other data might be here, im still looking into that.
I have been investigating this for a few days but am not getting very far. It looks like the typical UV chunk (MAPPINGCOORS 0x4140) is either missing or moved. Its quite strange.
I also discovered an unknown chunk 0x4200. The UV and other data might be here, im still looking into that.
-
- Private
- Posts: 14
- Joined: Thu Jun 29, 2023 1:52 am
Re: i3d plugin for Blender 3.6
I need to do more testing but it looks like the Mapping Coordinates are storred at the beginning of the unknown chunk mentioned in the previous post.
It seems to conform to the 0x4140 standard at least
https://paulbourke.net/dataformats/3ds/
Mapping coordinates.
First 2 bytes: number of vertices.
Then, for each vertex 2 floats that give the mapping coordinates.
That is, if a point is at the center of the map it will have 0.5 0.5
as mapping coordinates.
There is other data in the chunk, I don't yet know what it relates to.
It seems to conform to the 0x4140 standard at least
https://paulbourke.net/dataformats/3ds/
Mapping coordinates.
First 2 bytes: number of vertices.
Then, for each vertex 2 floats that give the mapping coordinates.
That is, if a point is at the center of the map it will have 0.5 0.5
as mapping coordinates.
There is other data in the chunk, I don't yet know what it relates to.
Re: i3d plugin for Blender 3.6
yes, i3d doesnt use that chunk for UV choords. It has its own chunk. The main difference is that UV choords are stored in a certain order with ID, x position, y position. The 3ds stores them for each face and in a different order.
Beside that i3d supports also bones and nurbs. But it didnt work on that yet.
I attached the sources of i3d plugin, so you can compare it with 3DS.
Beside that i3d supports also bones and nurbs. But it didnt work on that yet.
I attached the sources of i3d plugin, so you can compare it with 3DS.
Re: i3d plugin for Blender 3.6
Also keyframes were disabled in blenders 3ds plugin. They had a little byte length issue, that caused 3ds max to crash. I fixed that but i wrote no algorithm to store keyframes. At the moment the keyframe chunk is only used for position of the objects.
blenders i3d plugin tried to put the position into objects 3d matrix, that wasn't working. after one export-import cycle all positions were messed up.
blenders i3d plugin tried to put the position into objects 3d matrix, that wasn't working. after one export-import cycle all positions were messed up.
-
- Private
- Posts: 14
- Joined: Thu Jun 29, 2023 1:52 am
Re: i3d plugin for Blender 3.6
Ok I found the address 0x4200 contains equivalents for both 0x4140 (TEX_VERTS) and 0x4120 (FACE_ARRAY) as well as a few bytes at the end, I don't know what these are yet.
So reading 0x4200
TEX_VERTS is at the beginning followed by a variant of FACE_ARRAY
Note, FACE_ARRAY is stored twice, at the usual .3ds of 0x4120 and again (a longer array and with slightly different values and no flags) inside 0x4200.
I feel like the FACE_ARRAY inside 0x4200 may be more relevant,but I don't know for sure. I need to keep digging into it.
Is there anything in the Max Plugins about this?
So reading 0x4200
TEX_VERTS is at the beginning followed by a variant of FACE_ARRAY
Note, FACE_ARRAY is stored twice, at the usual .3ds of 0x4120 and again (a longer array and with slightly different values and no flags) inside 0x4200.
I feel like the FACE_ARRAY inside 0x4200 may be more relevant,but I don't know for sure. I need to keep digging into it.
Is there anything in the Max Plugins about this?
-
- Private
- Posts: 14
- Joined: Thu Jun 29, 2023 1:52 am
Re: i3d plugin for Blender 3.6
Ugh, I'm at dead end.
I'm starting to think that the vertx data (points) and face data that exists at 0x4110 (POINT_ARRAY) and 0x4120 (FACE_ARRAY) may be for a collision mesh. which is why UV data was never included for it.
That would mean the vertex data we need to successfully import an i3d into blender exists somewhere else in the file
@NilsZ - When you load an .i3d in 3D Studio MAx, are there two models? One simplified (collision mesh) and one more detailed? The second model (if it exists) could be the same with more vertex/faces.
I'm just guessing now
I'm starting to think that the vertx data (points) and face data that exists at 0x4110 (POINT_ARRAY) and 0x4120 (FACE_ARRAY) may be for a collision mesh. which is why UV data was never included for it.
That would mean the vertex data we need to successfully import an i3d into blender exists somewhere else in the file
@NilsZ - When you load an .i3d in 3D Studio MAx, are there two models? One simplified (collision mesh) and one more detailed? The second model (if it exists) could be the same with more vertex/faces.
I'm just guessing now
Re: i3d plugin for Blender 3.6
No, we dont use collision mesh in HDD.battlefeel1942 wrote: ↑Wed Feb 21, 2024 10:01 pmUgh, I'm at dead end.
I'm starting to think that the vertx data (points) and face data that exists at 0x4110 (POINT_ARRAY) and 0x4120 (FACE_ARRAY) may be for a collision mesh. which is why UV data was never included for it.
That would mean the vertex data we need to successfully import an i3d into blender exists somewhere else in the file
@NilsZ - When you load an .i3d in 3D Studio MAx, are there two models? One simplified (collision mesh) and one more detailed? The second model (if it exists) could be the same with more vertex/faces.
I'm just guessing now
Have a look at the code for better understanding:
Here from exporter, we create a chunk called FACE_MAP_CHANNEL Hex value is 0x4200
Code: Select all
//export mapping channels
for(int i=1; i<mesh.getNumMaps(); i++){
if(!mesh.mapSupport(i))
continue;
struct S_hlp{
ObjectEntry *oe;
int num;
} hlp = {oe, i};
if(!DumpMeshChunk(FACE_MAP_CHANNEL, &hlp, dc))
return false;
}
The task is to implement this into blenders i3d importer plugin.
Code: Select all
case FACE_MAP_CHANNEL:
{
struct S_hlp{
ObjectEntry *oe;
int num;
} *hlp = (S_hlp*)data;
Mesh &mesh = hlp->oe->tri->mesh;
const UVVert *uvverts = mesh.mapVerts(hlp->num);
int num_uv_verts = mesh.getNumMapVerts(hlp->num);
const TVFace *uvfaces = mesh.mapFaces(hlp->num);
int num_faces = mesh.numFaces;
int i;
//save map channel index
dc.ck->Write(&hlp->num, sizeof(int));
//save map vertices
dc.ck->Write(&num_uv_verts, sizeof(word));
for(i=0; i<num_uv_verts; i++){
dc.ck->Write(&uvverts[i].x, sizeof(float));
dc.ck->Write(&uvverts[i].y, sizeof(float));
}
//save map faces
dc.ck->Write(&num_faces, sizeof(word));
for(i=0; i<num_faces; i++){
for(int j=0; j<3; j++){
dc.ck->Write(&uvfaces[i].t[j], sizeof(word));
}
}
}
break;
- Attachments
-
- Common.7z
- (3.46 KiB) Downloaded 459 times
-
- Private
- Posts: 14
- Joined: Thu Jun 29, 2023 1:52 am
Re: i3d plugin for Blender 3.6
I can successfully read 4200.
The problem I am having is, the number of UVs doesn’t match the number of Vertices
For example, door.i3d has 8 vertices and 24 UV coordinates.
domek.i3d has 23 vertices and 46 UV coordinates.
box3.i3d has 8 vertices and 24 UV coordinates.
I don't know enough about 3d modeling to say if the number of vertices match the UV’s 1:1 but that would be my guess.
I will have a look through your importer/exporter
The problem I am having is, the number of UVs doesn’t match the number of Vertices
For example, door.i3d has 8 vertices and 24 UV coordinates.
domek.i3d has 23 vertices and 46 UV coordinates.
box3.i3d has 8 vertices and 24 UV coordinates.
I don't know enough about 3d modeling to say if the number of vertices match the UV’s 1:1 but that would be my guess.
I will have a look through your importer/exporter
Re: i3d plugin for Blender 3.6
the UV and vertices cant be 1:1. Each face (triangular of course) has usually 3 UV coords.
-
- Private
- Posts: 14
- Joined: Thu Jun 29, 2023 1:52 am
Re: i3d plugin for Blender 3.6
WIth what I have learned so far, I have imported an i3d into Blender. I dont have a working importer yet because to import just door.i3d required a hack for the vertex count. The same technique wont work for all assets. This manipulation was just a lucky guess.
The hack is, I needed to take the vertex array from 0x4110 and multiply it by 3 before blender loads it in eg. contextMesh_vertls = contextMesh_vertls * 3
So for example, in door.i3d.
Vertices at 4110
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
Need to become (before it will load correctly)
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
So now there is 24 Vertices and 24UV, which loads correctly, and gives me this
The hack is, I needed to take the vertex array from 0x4110 and multiply it by 3 before blender loads it in eg. contextMesh_vertls = contextMesh_vertls * 3
So for example, in door.i3d.
Vertices at 4110
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
Need to become (before it will load correctly)
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
Vertex: X=-0.5000002384185791, Y=-0.04999801144003868, Z=0.0
Vertex: X=0.51291823387146, Y=-0.049997761845588684, Z=0.0
Vertex: X=-0.49999991059303284, Y=0.05000046268105507, Z=0.0
Vertex: X=0.51291823387146, Y=0.050000712275505066, Z=0.0
Vertex: X=-0.5000002384185791, Y=-0.04990645870566368, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=-0.049906209111213684, Z=3.0032970905303955
Vertex: X=-0.49999991059303284, Y=0.050095830112695694, Z=3.0032970905303955
Vertex: X=0.51291823387146, Y=0.05009607970714569, Z=3.0032970905303955
So now there is 24 Vertices and 24UV, which loads correctly, and gives me this
Re: i3d plugin for Blender 3.6
Did you just edit the door.i3d file before importing or did you edit the importer? If you edited the file, what program did you use?
btw. for which purpose do you need model from Hidden and Dangerous? They are all low quality, thats why i always worked only on exporting files to i3d.
btw. for which purpose do you need model from Hidden and Dangerous? They are all low quality, thats why i always worked only on exporting files to i3d.
Who is online
Users browsing this forum: No registered users and 26 guests