Z sorting of 3DS models

Software: Away3D 4.x

jdeluca, Newbie
Posted: 12 July 2012 06:15 PM   Total Posts: 28

So I’ve loaded my 3ds models on the screen and 2 things are driving me a bit crazy.

One: framerate drops considerably when one of the objects appear on the screen.

Two: The objects look all distorted because some surfaces are showing through. Also, if I put an object behind another, the the object in the back shows through.

These were originally OBJ files that were exported from Maya. I converted them to 3DS using blender because I was easily able to load them in Away 3d 4.

The skybox renders good at a high framerate but once the 3d models come into the scene.

What can I do to fix the Z distortion and increase framerate?

Specs: Galaxy Tab 2, Android 4.0.3, Air 3.3, Flex 4.6, Away3d 4
Current build:away3d-away3d-core-fp11-20c9ebd.

Thanks,
Joe

   

jdeluca, Newbie
Posted: 12 July 2012 06:55 PM   Total Posts: 28   [ # 1 ]

Note: The models I am loading are low poly count.

One of them has 552 faces

The other one has 752 faces.

 

   

Richard Olsson, Administrator
Posted: 12 July 2012 09:55 PM   Total Posts: 1192   [ # 2 ]

First of all, where you not able to load OBJ files? The issue you describe is unrelated to the file format. I’m just wondering why you felt you needed to convert the files.

What kind of material do you have on these objects? I’m surprised that the frame rate would drop from just showing these tiny models. Can you upload a screenshot (or photograph) of the sorting issue? Could it be the same one described here? https://github.com/away3d/away3d-core-fp11/issues/255

 

   

Avatar
Baush, Sr. Member
Posted: 13 July 2012 12:04 AM   Total Posts: 135   [ # 3 ]

Make sure to not use alphaBlending=true and instead use the alphaThreshold = 0.5 for example.

This solved the zsorting problem for me.

 

   

jdeluca, Newbie
Posted: 13 July 2012 05:06 PM   Total Posts: 28   [ # 4 ]

I have tried a variety of things including Prefab.
First the models are coming from Maya as obj.

Prefab won’t import any of the models directly. It gets stuck parsing the files. Some of the models do import but say “The scale of the loaded model appears to be very small. Do you want to rescale?”. When I click ok, it locks up and I have to shut down prefab.

So… I brought them into Blender, scaled them the percent that Prefab mentioned, combined all meshes to one, removed all textures, and reasigned one shader with default everything. Then I export 1 as obj and 1 as 3ds.

Hmm. I just got it to load obj and 3DS exported from Blender. The same issue still exists. Sluggish and seeing objecst that are definitely behind other objects.

One issue that exists in all models imported into Prefab which may be the reason.. It alerts “Oops! Issues were found during the parsing of this file: One or more normals buffers were either empty or invalid(1). The normals buffer was rebuilded.” I’m not exactly sure what that means but all the normals are pointing out.

Now if I export the model from Prefab to OBJ(using defaults), it increased file size from 54kb to 668kb and generates this error in debug mode which could also point to the issue. Again, not really sure what this means. not:It was edited to remove my full project path.

ArgumentError: Error #3671: Buffer has zero size.
      at flash.display3D::Context3D/createVertexBuffer()
at away3d.core.base::SubGeometry/getVertexNormalBuffer()[away3d-away3d-core-fp11-20c9ebd\src\away3d\core\base\SubGeometry.as:309]
at away3d.core.base::SubMesh/getVertexNormalBuffer()[away3d-away3d-core-fp11-20c9ebd\src\away3d\core\base\SubMesh.as:174]
at away3d.materials.passes::DefaultScreenPass/render()[away3d-away3d-core-fp11-20c9ebd\src\away3d\materials\passes\DefaultScreenPass.as:568]
at away3d.materials::MaterialBase/renderPass()[away3d-away3d-core-fp11-20c9ebd\src\away3d\materials\MaterialBase.as:364]
at away3d.core.render::DefaultRenderer/drawRenderables()[away3d-away3d-core-fp11-20c9ebd\src\away3d\core\render\DefaultRenderer.as:154]
at away3d.core.render::DefaultRenderer/draw()[away3d-away3d-core-fp11-20c9ebd\src\away3d\core\render\DefaultRenderer.as:102]
at away3d.core.render::RendererBase/executeRender()[away3d-away3d-core-fp11-20c9ebd\src\away3d\core\render\RendererBase.as:276]
at away3d.core.render::DefaultRenderer/executeRender()[away3d-away3d-core-fp11-20c9ebd\src\away3d\core\render\DefaultRenderer.as:62]
at away3d.core.render::RendererBase/render()[away3d-away3d-core-fp11-20c9ebd\src\away3d\core\render\RendererBase.as:240]
at away3d.containers::View3D/render()[away3d-away3d-core-fp11-20c9ebd\src\away3d\containers\View3D.as:603]
at Components::Game/animateBox()[UAVRecon3\src\Components\scripts\SetupAccelerometer.as:80]
at Components::Game/Accelerometer_onUpdate()[UAVRecon3\src\Components\scripts\SetupAccelerometer.as:34]

I’d really like to get this working because we will be able to use it in the near future for interactive 3D projects. Right now this is a proof of concept. I have to create a learning game to be used at a conference next month and may have to take a 2D route to complete it on time but I have till Wednesday to make that decision. Away3D would be much cooler.

I am getting together images. I’ll post something shortly. Thanks for the help.

 

   

jdeluca, Newbie
Posted: 13 July 2012 05:34 PM   Total Posts: 28   [ # 5 ]

I am not using alphaBlending or alphaThreshold. I do not need alpha.

Well…Here is some other insight that may impact what is happening. I have spheres at the same position as the 3D models. I recently found that I might not have to do it this way.

Anyway, I have an ObjectContainer3D that has a sphere in it and a loaded mesh. The sphere and the mesh are at the same position. There are several in the scene. The other have a different y position to offset them from each other.

I am detecting collision between a ray from the camera and the spheres when the user presses a button. I have an array of ObjectContainer3d that I loop through to check collision when the button is pressed.

I may be able to use the models bounding radius instead of a sphere. Holla back if that is the case.

But sphere is rendered without a material so it is not visible but still detecting collisions. Will this cause the issue I am seeing?

I’m getting some images together now.

 

   

jdeluca, Newbie
Posted: 13 July 2012 06:01 PM   Total Posts: 28   [ # 6 ]

As of right now, there are no texture materials. ColorMaterial(0xffffff)

Attached are some pictures of a model (OBJ). It is a UAV that has a real low poly count. The same model is cloned and placed 1000 from the origin and offset in the y by 200.

What you are seeing is the wings of the plane underneath should not be showing on top of the top plane. If that makes sense.

It gets worse with other models. You can see the landing gear from underneath a wing from viewing it from the top.

And of course the performance is slow when the models are on the screen.

Ultimately the camera is fixed position at the origin and the accelerometer controls the rotation of the camera. Right now the planes are flying around the center in a circle by rotating the ObjectContainer3D on update of the accelerometer. The scene is rendering on update of the accelerometer also.

Thanks,
Joe

 

File Attachments
ScreenShots.zip  (File Size: 219KB - Downloads: 180)
   

jdeluca, Newbie
Posted: 13 July 2012 09:23 PM   Total Posts: 28   [ # 7 ]

I figured out the performance issue of why it was slowing down. It was not related to the rendering issue. It was because of the way I was checking if the models were all loaded. I was probably cloning lots of models.

The rendering issues are still there. It is probably something simple that I need to do.

Thanks.

 

   

jdeluca, Newbie
Posted: 13 July 2012 10:19 PM   Total Posts: 28   [ # 8 ]

All of our 3D models that get exported directly from Maya as OBJ are generating this error.

Main Thread (Suspended: ArgumentError: Error #3671: Buffer has zero size.)
flash.display3D::Context3D/createVertexBuffer [no source]
away3d.core.base::SubGeometry/getVertexNormalBuffer
away3d.core.base::SubMesh/getVertexNormalBuffer
away3d.materials.passes::DefaultScreenPass/render
away3d.materials::MaterialBase/renderPass
away3d.core.render::DefaultRenderer/drawRenderables
away3d.core.render::DefaultRenderer/draw
away3d.core.render::RendererBase/executeRender
away3d.core.render::DefaultRenderer/executeRender
away3d.core.render::RendererBase/render
away3d.containers::View3D/render
Components::Game/animateBox
Components::Game/Accelerometer_onUpdate

 

   

Avatar
Matse, Sr. Member
Posted: 14 July 2012 11:53 AM   Total Posts: 149   [ # 9 ]

Not much help, but if you don’t have any transparency then the problem is most probably with normals. The error you report seems to confirm this.

That’s something you should be able to fix using your 3D software, I think there is a tool for this in Away3D too but can’t seem to find it out.

 

   

jdeluca, Newbie
Posted: 14 July 2012 05:18 PM   Total Posts: 28   [ # 10 ]

Yes… The error points to normals and that is the first thing that I thought it might be. Maybe it still is. I’ve tried so many different things at this point.

I had our 3D team show me the normals for the models and they seem to all be pointed out. The really low poly models have no reason that any face would be pointed in because they started as cubes and were just extruded.

I used to do quite a bit of 3d modeling. Many years of Maya experience. Not so much anymore. But I know a quite a bit about it. I pretty much only do programming now.

If I can just figure out the workflow on one of the models, then I can get all of them in.

I have till Wednesday to decide whether away 3d is the solution for this project or if I have to take a different approach. I was thinking I had till Friday but my timeline got extended.

Thanks for the help. I’m open to all ideas if anyone has any other ideas.

Thanks,
Joe

 

   

Avatar
Fabrice Closier, Administrator
Posted: 14 July 2012 08:46 PM   Total Posts: 1265   [ # 11 ]

Make sure your model is triangulated prior export to obj. If the problem persists, please send me your model offline so I can test it.
One of Prefab’s goal is to display whatever it can and help you spot flaws in your loaded data.
I have fixed a few issues in this regard, which will be part of the next update. As this model is causing the app to hang, I would really like to be able to test it.

 

   

jdeluca, Newbie
Posted: 16 July 2012 01:37 PM   Total Posts: 28   [ # 12 ]

Brilliant!!!

lol! I totally didn’t even think of triangulation for some reason. They are definitely all quads. I am going to check now and see if that is the fix.

Thanks.

 

   

Avatar
Fabrice Closier, Administrator
Posted: 16 July 2012 01:54 PM   Total Posts: 1265   [ # 13 ]

Note that It can be something else than the multipolygonal issue with faces in obj. Try find ‘//’. in your obj file if you still get the error. Obj from maya can be exported without uv’s. So make sure uv’s are set before triangulate and export.

 

   

jdeluca, Newbie
Posted: 16 July 2012 02:53 PM   Total Posts: 28   [ # 14 ]

Hmm… Ok. 3 of my models that I was using were already triangulated.

So I tried one of the real low poly models to see if I could get it to render right. I started out with the same model from Maya as obj.

In blender:
I combined all objects.
Removed the materials and assigned a new default material.
Selected the mesh. Selected all faces.
Normals>Recalculate Outside.
Faces>Triangulate Faces
Exported model.

Brought it into Prefab. It says the same errors. I rescaled the model to what Prefab said to rescale it to and exported again.

Brought it into Prefab and get the same error minus the scaling error. It says:

“Oops! Issues were found during the parsing of this file:

One or more normals buffers were either empty or invalid(1).
The normals buffer was rebuilded.”

And if I just go forth and import it into Away 3D I see the model the same as I did before (but with more polys) and I see the landing gear through the wings from a top ortho view.

I’m attaching the a zip with 2 models in it. One is a simple model that was created in Maya and exported as OBJ. This is what I started with. It’s filename is RQ-7_Shadow.obj. The one that I did stuff to in blender and resaved is called testRQ7Shadow.obj.

I really appreciate the help on this. If I can get these models to look right I can go forth and do some actual game programming. I’ve got about 10 models to get rendering correctly and seems they all have the same issue.

I’m sure it is something simple that I haven’t thought of yet.

Thank you Fabrice.

 

File Attachments
testOBJ.zip  (File Size: 194KB - Downloads: 185)
   

jdeluca, Newbie
Posted: 16 July 2012 02:54 PM   Total Posts: 28   [ # 15 ]

ok checking for the uv’s now.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X