Jump to content
Alwarren

Arma Toolbox for Blender - Arma 2/3 exporter script

Recommended Posts

Ah, I guess I should release an update. The proxy handling has completely changed since I ran into Blender limits with vertex groups names...

Send from my tablet, so pardon any autocorrect bollocks

Thanks for the response, Alwarren! I've downgraded to 2.72. I've had some success, but I have another issue when trying to export empty LODs that may or may not be an issue with the Arma Toolbox for Blender:

Issue: Exception when exporting an empty LOD (object with no vertices).

When I import a model in p3d format which contains empty Pilot and/or Geometry LODs, they import as I would expect. That is, the layers contain an object who's origin is 0,0,0, but contains no vertices. However I am unable to export this same configuration. Attempting to export gives the error:

Traceback (most recent call last):
 File "C:\Users\<username>\AppData\Roaming\Blender Foundation\Blender\2.72\script
s\addons\ArmaToolbox\__init__.py", line 813, in execute
   exportMDL(filePtr, self.selectionOnly);
 File "C:\Users\<username>\AppData\Roaming\Blender Foundation\Blender\2.72\script
s\addons\ArmaToolbox\..\ArmaToolbox\MDLexporter.py", line 321, in exportMDL
   export_lod(filePtr, obj, wm, idx)
 File "C:\Users\<username\AppData\Roaming\Blender Foundation\Blender\2.72\script
s\addons\ArmaToolbox\..\ArmaToolbox\MDLexporter.py", line 241, in export_lod
   writeNormals(filePtr, mesh)
 File "C:\Users\<username>\AppData\Roaming\Blender Foundation\Blender\2.72\script
s\addons\ArmaToolbox\..\ArmaToolbox\MDLexporter.py", line 89, in writeNormals
   return v
UnboundLocalError: local variable 'v' referenced before assignment

location: <unknown location>:-1

location: <unknown location>:-1

Looking at the code, it's clear why this happens. The code is attempting to loop through mesh.vertices, of which there are none.

What is the proper method to export an empty LOD?

Is there a known workaround for this issue?

I have not been able to recreate a"Geometry LOD" that matches the original A3_headgear_example.p3d without causing all of the other LODs to "move around" when viewed in-game.

Steps to reproduce:

Option 1 (Using BI Official Examples):

Download the BI Tools Arma 3 sample models: https://community.bistudio.com/wikidata/images/a/a7/A3_Character_Examples_1.1.zip

Unzip the file.

Import \A3_Character_Examples_1.1\A3_headgear_example.p3d into Blender 2.72 or 2.73.

Export as P3D to the directory of your choice.

Check the console for errors.

Option 2 (Using a custom model):

Start a new Blender project using Blender 2.72 or 2.73

If your scene does not contain a default cube, create one (Shift-A -> Mesh -> Cube).

Duplicate the cube onto another layer (Shift-D -> Esc -> M -> Select a layer)

Select the cube on one layer and bring up the properties panel (N).

Enable "Arma Object Properties". Select an LOD Preset of Custom and a custom distance of 1.00.

Change layers and select the cube on the new layer.

Enable "Arma Object Properties". Select an LOD Preset of Custom and a custom distance of 1.00.

Set a new "Named Property" with name = autocenter and value = 0.

Enter edit mode (TAB) and delete all vertices. Leave the origin point at 0,0,0.

Return to object mode (TAB).

Export to the file of your choice.

Check the console for errors.

EDIT: For conciseness. I am nothing if not verbose.

UPDATE:

I've been doing a little tinkering and I may have found a solution...

The original error from the previous post states "local variable 'v' referenced before assignment" in the writeNormals function of MDLexporter.py:

def writeNormals(filePtr, mesh):
   for v in mesh.vertices:
       writeFloat(filePtr, 0)
       writeFloat(filePtr, 1)
       writeFloat(filePtr, 0)

   return v

Clearly in my example mesh.vertices is an empty list. I looked through the rest of the code and realized that you only call writeNormals one time (also in MDLexporter.py) and you do not use that return value for anything... So I removed it.

This lead to another error in the writeMass function:

perVertMass = totalMass / totalVerts

A division by 0 error... fair enough. I changed it to:

if totalVerts > 0:
   perVertMass = totalMass / totalVerts
else:
   perVertMass = totalMass

This seems to work great. I can import and immediately export the sample model from BI, package up my mod and everything works as expected! Huzzah!

My only question is, do you think I will find any negative impact on most models? My guess is that any model that can suffice without a geometry LOD at all is probably also not very dependent on mass, and this should not cause any unexpected issues. Thoughts?

Edited by tofarley

Share this post


Link to post
Share on other sites

Hi everybody !

I'm desapointed ! I can't do nothing from blender in buldozer !

I made just a box in blender, made a texture very nice in blender....

But when when i try to export it to Object builder =>

- The proportions of the box are not the same !

- i can't see my texture neither in O2, neither in buldozer, in any format (i have my texture in .paa and .tga (not compressed with RLE from GIMP)!!).

Could someone make a little video tuto, to show how you export a simple box model, with a basic texture ?

I tried this one, but i don't have my texture like the author :

Please ! could someone make just a little video with this blender plugin ?? :butbut: :butbut:

P.S : i use blender 2.72 and the last arma toolbox plugin + GIMP

Thanks again ;)

Share this post


Link to post
Share on other sites
- The proportions of the box are not the same !

As has been said before, make sure you apply the scale of the object before exporting. Also, be aware that the zero point for the exported object is the origin of the object, not the origin of Blender's coordinate system.

- i can't see my texture neither in O2, neither in buldozer, in any format (i have my texture in .paa and .tga (not compressed with RLE from GIMP)!!).

Have you assigned a material? You MUST assign a material, the face texture will not work.

Please ! could someone make just a little video with this blender plugin ?? :butbut: :butbut:

If you follow that tutorial video, you should get the same result. The only difference is that you no longer have a button but need to click the checkbox in front of the title.

Can you tell what exactly you did, and what result you are getting?

Share this post


Link to post
Share on other sites

I don't know if we talk about the same thing, but i set the custom distance to "0.00" like in the video , and in display window i have scale : 1.000 !

I have assigned a material, but nothing else ! i didn't set anything in, just added one and that's all !

"The only difference is that you no longer have a button but need to click the checkbox in front of the title." <=> i don't understand what you mean :(

Thanks for your quick answer ;)

I will try again, and again, and again until i success ;)

EDIT : then i retry with just a box i spawned in O2 directly, and applied my texture => it's OK !

Then i retried with my box, and i understood what i missed !! ==> You have to delete the texture path like he said at 4'47s in the video, and re-take it with the folder browser ! ;)

Thanks again ;)

Edited by chal00

Share this post


Link to post
Share on other sites
EDIT : then i retry with just a box i spawned in O2 directly, and applied my texture => it's OK !

I'm not entirely sure I understand. You should pick texture from your P drive, then you don't need to correct anything later.

I guess I really should make a tutorial, it's just that I'm not good at that.

Send from my tablet, so pardon any autocorrect bollocks

Share this post


Link to post
Share on other sites

Assigning a material to your mesh and specifying the path to a base texture works perfectly.

As long as you make sure your project files are present on your work drive.Which the tools set up

as P: .

As an aside,it also works just fine for Cold war assault.Although the path structure is slightly different.

But the point is,it works. :)

Share this post


Link to post
Share on other sites

I'm a new user of blender,wanna ask is this addon works fine on Blender 2.74?

Share this post


Link to post
Share on other sites

Should work, in fact I am using 2.74 myself :)

Send from my tablet, so pardon any autocorrect bollocks

Share this post


Link to post
Share on other sites
Should work, in fact I am using 2.74 myself :)

Send from my tablet, so pardon any autocorrect bollocks

Just have tested myself for about 1 hour,no issue sofar.I'm a really rookie to modeling and may i ask with this addon load on blender,everything that should do on O2 can now done by smiply using blender?Or is there some thing else I have to do with O2?

Share this post


Link to post
Share on other sites
Just have tested myself for about 1 hour,no issue sofar.I'm a really rookie to modeling and may i ask with this addon load on blender,everything that should do on O2 can now done by smiply using blender?Or is there some thing else I have to do with O2?

As a rule you do not need to do anything with O2. Internally the exporter uses it to run a script on the exported file but that should go on in the background without you noticing it. Make sure though that the past to the O2 folder is correct.

There will be an update soon which should make this easier.

Send from my tablet, so pardon any autocorrect bollocks

Share this post


Link to post
Share on other sites
As a rule you do not need to do anything with O2. Internally the exporter uses it to run a script on the exported file but that should go on in the background without you noticing it. Make sure though that the past to the O2 folder is correct.

There will be an update soon which should make this easier.

Send from my tablet, so pardon any autocorrect bollocks

Thanks for reply!

Share this post


Link to post
Share on other sites

I succeeded in my work with your amazing plugin ;)

Thanks a lot ! Without that i couldn't do nothing in O2 :(

O2 is the worthest 3D programm i never saw !

N.B : i just noticed that when i exported my simple model to O2 , i had some "ghost" face i had never done in blender. It is like O2 had filled randomly some vertices connections !?!...

But i'm not enought expert to tell you if it is my fault or not !!

For example : i had 2 faces with 8 vertices in blender (2x4 vertices in the same plane) , and in O2 i had 3 faces for the same thing !

Edited by chal00

Share this post


Link to post
Share on other sites

I'm not aware of anything that could introduce new faces in O2... Are you absolutely sure the face is there in O2 and not in Blender? Can you try to reimport the model and verify?

Send from my tablet, so pardon any autocorrect bollocks

Share this post


Link to post
Share on other sites

Hey guys,

first thank you for your work on the exporter! Great job, Alwarren :)

I´m quiet a beginner into modeling and I want to know where I´m making a mistake here:

System: Win7 64bit; Blender v2.74

1. I made a simple object >Picture<(253 kb) >File< (497 kb)

2. I ticked the Arma Exporter Things: >Picture< ( 22kb) (for testing I only have the custom LOD, is this maybe the issue? )

I´ve also changed the path to the O2Script in my ObjectBuilder folder and the P drive, but always the same problem

3. Then I exported it and opened it in ObjectBuilder and it looks like this: >Picture< (22kb)

If I only export a cube it looks correctly in OB, but if it´s going a little bit more advanced it dont work

Now the question is, what am I doing false?

And sorry if the solution is very simple and I´m only stupid...

ir0n

(and sry for my English)

Share this post


Link to post
Share on other sites
And sorry if the solution is very simple and I´m only stupid...

The solution is quite simple, but the stupidity is on me. The exporter ignores scale. I should at the very least output a warning message that the scale isn't 1.

To remedy the problem, just make sure you are in object mode, select your object, and press CTRL-A, then select "Rotation & Scale". This will apply the rotation and scale of the object to the geometry. Location is handled differently, the origin of the object will be the zero point of the model. If you want you can also apply location separately.

(and sry for my English)

Nothing wrong with your English :)

Share this post


Link to post
Share on other sites
The solution is quite simple, ...

You are my hero xD

Arma wouldn´t be Arma without people like you :)

Thanks

ir0n

Share this post


Link to post
Share on other sites
I'm not aware of anything that could introduce new faces in O2... Are you absolutely sure the face is there in O2 and not in Blender? Can you try to reimport the model and verify?

Send from my tablet, so pardon any autocorrect bollocks

No i'm not absolutely sure like i said ! I will retry and give you some pics if it's right !

I don't remember if i did something in O2 before i see those ghost faces !

I'll tell you that tomorrow ;)

Share this post


Link to post
Share on other sites

Hellou.

I want to point out that this tool is purrfect.

Been looking into 3d models from blender to Arma 3 and came across a slightly frustrating problem for which google seems to not find answers.

So i export the model , all "cubes" have arma properties ticked and just in case i set weight 0 because someone had problems with custom weight objects not saving (also tried with weight 1).

After object is exported , it ends up around 9kb (it was 0 for a while but thats because my directory was wrong) and object builder sees only 1 cube , even tho the model is more complex.

What could be the problem ?

Edited by Creepymoto

Share this post


Link to post
Share on other sites
Hellou.So i export the model , all "cubes" have arma properties ticked and just in case i set weight 0 because someone had problems with custom weight objects not saving (also tried with weight 1).

I have to say that I have had no problems exporting weighted objects, I've done a couple of units in the meantime and they all work fine, but then, I do have a newer, as of yet unreleased version of the plugin (which I really should release one of these days).

What could be the problem ?

In that picture you linked you have at least two objects with 1.00 as LOD. You should put them all together in the same mesh, the exporter doesn't merge them. For clarification, each LOD has to be one single MESH object, and all rotations/scales have to be applied before exporting.

Does that solve your problem?

Share this post


Link to post
Share on other sites
I have to say that I have had no problems exporting weighted objects, I've done a couple of units in the meantime and they all work fine, but then, I do have a newer, as of yet unreleased version of the plugin (which I really should release one of these days).

In that picture you linked you have at least two objects with 1.00 as LOD. You should put them all together in the same mesh, the exporter doesn't merge them. For clarification, each LOD has to be one single MESH object, and all rotations/scales have to be applied before exporting.

Does that solve your problem?

Hehe, silly me.

Yes it solved the problem. Thanks for the help.

On a side note , i might have done something wrong and i am back to the drawing board. also addon didnt recognize the p3d inside the pbo.

How it looks :

9F2OyV9.png

How it is supposed to look:

G8hotfx.png

Share this post


Link to post
Share on other sites
On a side note , i might have done something wrong and i am back to the drawing board. also addon didnt recognize the p3d inside the pbo.

Have you applied the sclae (CTRL-A)?

What do you mean with "addon didn't recognize the p3d"?

Share this post


Link to post
Share on other sites
Have you applied the sclae (CTRL-A)?

What do you mean with "addon didn't recognize the p3d"?

Thought i applied it , just to make sure did it again and it worked. Somewhat smaller , have to adjust the scale i guess.

X6WDj44.png

When i load the object in Virtual Reality editor as an addon object , and then go into the mission it says "Could not open veetorn.p3d" - That being the name of the saved p3d trough blender and then made into an addon.

Disclaimer , i am just getting started . Year ago i tried to look into custom objects in arma 3 , every single tool crashed. Now it i am actually getting somewhere.

Share this post


Link to post
Share on other sites
Thought i applied it , just to make sure did it again and it worked. Somewhat smaller , have to adjust the scale i guess.

If you switch Blender to Metric or Imperial units they will end up the same size in Arma.

When i load the object in Virtual Reality editor as an addon object , and then go into the mission it says "Could not open veetorn.p3d" - That being the name of the saved p3d trough blender and then made into an addon.

If you reference the model, make sure you specify its full path, i.e. model = "\MyAddon\object.p3d".

Share this post


Link to post
Share on other sites
If you switch Blender to Metric or Imperial units they will end up the same size in Arma.

If you reference the model, make sure you specify its full path, i.e. model = "\MyAddon\object.p3d".

That was metric , scale was 1.

Yeahh, i might have a wrong link there to the p3d.

Thanks for the help, yet again.

Edit , apparently had trouble saving the scale properly. Everything is fine. Crisis averted.

Edited by Creepymoto

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×