Jump to content

Babylon does not import model with its textures if I have bakeCurrentTransformIntoVertices in loop


ian
 Share

Recommended Posts

I have problem with physics and mesh impostor with sphere.

I create some componets in blender. And add each component texture.  I create pathMesh from components. (pathMesh have multi materials and textures because each component has its own material and texture)

If I load babylon with sandbox it load OK (but sandbox doesn't have pathMesh.bakeCurrentTransformIntoVertices(); .

If I have pathMesh.bakeCurrentTransformIntoVertices(); in loop then pathMesh is loaded without textures and physics works OK.

If I remove pathMesh.bakeCurrentTransformIntoVertices(); then pathMesh is loaded correctly with textures, but physics doesn't work as it should.

var pathMesh;

meshTask.onSuccess = function (task) {                       
        for (var i=0; i<task.loadedMeshes.length; i++ ){
            var newMesheI = task.loadedMeshes[i];
            if ( newMesheI.id == "Path" ) {                        
                pathMesh = newMesheI;                                
       
              pathMesh.checkCollisions = true;
              pathMesh.bakeCurrentTransformIntoVertices(); // this line works ok with physics but pathMesh doesn load correcly with textures
               pathMesh.pBody= perplexus.setPhysicsState(BABYLON.PhysicsEngine.MeshImpostor , { mass: 0, friction: 0.4, restitution: 0 });                         
            }

...

I need pathMesh.bakeCurrentTransformIntoVertices();  and correcly inported pathMesh with its textures?

Can anybody help me solve this problem? Any advice? What should I do? Am I missing anything?

Greetings

Link to comment
Share on other sites

I don't know how to upload .babylon file and textures on playgroudn.

Therefore I upload this examples on my server.

This link http://ajna4taiga.no-ip.org:8080/TestBabylonjs/TextureIssueWithBake.html shows example what happens if I use bakeCurrentTransformIntoVertices.
 This example show that textures are not loading OK. But physics works ok. Ball fall on model. Everything work OK except texutres.

This http://ajna4taiga.no-ip.org:8080/TestBabylonjs/TextureIssueWithoutBake.html link show how textures loads OK, But ball is not fall on model it stops on air. Physics/collision here doesn't work OK.
This code is same except it doesn have bakeCurrentTransformIntoVertices.
 
Everything can be viewed if you press F12. The source code is there and texutes and .babylon (model is same for both examples.)
 
I don't know to reproduce the issue with playground.

Greetings
 
Link to comment
Share on other sites

http://playground.babylonjs.com/#19BQOY#1

There it is, guys.  Activate line 19, and the texture changes.  Weird.  *scratch scratch*  :)

@ian - I hosted your .babylon file and three textures... at my free github site.  You should go get one, too.  You can simply drag - drop files onto your github webpage, then "commit" them (hit a button at the website bottom), and then they can be used in the playground... just like I did. 

Have a try, if you wish.  Create a github account, put your 4 files in a folder there, change the .babylon url in the playground demo (to point at your github repository), and then run/save the new playground.  Then you will be ready for future playground tests... forever.  And... free online storage with no CORS hassles!   That's a good good good thing, yes?   I think so.

You can see your 4 files (and other files) at https://github.com/Wingnutt/misc

Link to comment
Share on other sites

I have good and bad news.  Deltakosh, textures are loadaing OK.

Bad news is that rotation model and use cannon mesh impolster on model and sphere mesh impostor on sphere. Physics doesn't work as is should.

I think that there should make some test with physics cannon (mesh impostor and sphere impostor).

Previous version works better then now. 

Link to comment
Share on other sites

Hi ho!

So, a quick word about the mesh impostor - At the moment, the direct position vertex data and indices are taken into account. So if you scaled your mesh (which you have. The scaling value of the mesh is 1, 0.25, 1) it won't work correctly. This is why baking the current transformation works.

I know how to solve this (simply scaling all of the position vertex data * scaling vector), but I actually was trying to avoid this, as this might create different unexpected problems.

Let me check how I can solve this in the nicest way. Until them, baking is better than st(r)eaming.

Link to comment
Share on other sites

  • 2 weeks later...

I do not understand exactly you RaananW. 

You suggest. If we use mesh impostor and mesh sphere impostor together. It will be the best not to scale any of this two mesh? 
I would realy like to know how mesh impostor and sphere impostor works the best together?
What mesh.updatePhysicsBody() realy do and where it do the best if we rotate mesh?
I create new models and sphere imostor sometimes on same position in mesh impostor falls through.
I check model and normals and it looks fine, but may be I do not know something should when modeling mesh for mesh impostor in blender?
I realy don't know if there is problem in my mesh(mesh impostor) model or there are porblems with mesh impostor physics?

If you think there could be problems with physics, on what you should I be careful or (pay attention) when I'm modeling sphere and mesh(for mesh impostor)? 
 

Greetings

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...