Jump to content

Mesh impostors on 3D object like path?


ian
 Share

Recommended Posts

Hi guys.  Well, I put the path model (from path_pod_kotom1.babylon... into the playground, but it doesn't look-like the original, nor was it positioned or rotated sanely.  But that is a different issue.

http://www.babylonjs-playground.com/#3QZYR#3

Apparently the playground is using preview release 2.3.   It appears that the model is working fine (other than the model being misshapen in the playground), and no more warnings in the console.  yay!

So, yes, we were using the wrong BJS and/or CannonJS version (inside the zip).  MeshImposter is working fine, it seems. 

Plotting copied vertexData from .babylon files into playground vertexData plots... that's not so good.  But that is the first time I ever tried that, so it is likely a Wingnut problem.  :)  Keep us posted, Ian, good luck.  And thanks for your help/info, Raanan.

Link to comment
Share on other sites

Ok, I try everything. I try with this version I attach it (babylon.js and cannon.js).

I download this two file from https://github.com/BabylonJS/Babylon.js/tree/master/dist/preview%20release.

I thing it must be some problem with model path_pod_kotom.babylon. Can anybody test my example to find out what is a problem?
Is it problem with blender (import-export: Babylon.js)?
I attached in previous post (path_pod_kotom.blend), so you can see model in blender. And you can export it for babylon.

Does BABYLON.SceneLoader.ImportMesh work correct? Did I forget anything in code or in blender modeling?

I attach captureDesktop.mp4 and example_code.zip (model in blender file and exported babylon file). .In video console shows that I use Babylon v2.3.0-beta .

RaananW, Can you please take a look this example and this model. Is possible that there is something wrong with model?

greetings

 

captureDesktop.mp4

example_code.zip

Link to comment
Share on other sites

Yes this is what I want to achive. But your model is not like it is in blender (see blender's model file). I'll try to find the problem first only plane, and then with another plain coninued under angle.

It's look OK.
If Iunderstand correctly. I have some problem in model. I made it with blender.

Can anybody tell me what is the problem with .blender file or .babylon file (exported from blender).

 negative scaling  I'll check where is negativ scaling. (I negativ scaling by x or y or z or everyon or combination?

(mash imposter implementation is OK, fine ) I'll allway check in console that it printout "Babylon.js engine (v2.3.0-beta) launched".

 

OK, I'll try to find out problem in model in .blender and exported .babylon file.

  

Link to comment
Share on other sites

Yes model is a problem.

I don't know how it comes to wrong scale-ing. I test with new simple model and mesh impostor works great. 

RaananW your implementation works great.  Great work!

RaananW Is sphere's impostor bounding box Cube or Sphere? (There are some space between ground and sphere) If I see right is it Cube. 

Probably because betther colision calculation?

 

I attach mp4 video. How it works. OK now I'll try some more complex model. So if sphere will fall through then it is problem with model.
I think I can conclude this topic.

 

Thenx for your help.

greetings

example.mp4

Link to comment
Share on other sites

http://www.babylonjs-playground.com/#3QZYR#6

No gap, Ian.  Sphere impostor uses a CannonJS-based boundingSphere, not a BabylonJS-based boundingBox or boundingSphere.

See line 23?  The "body" is returned when you call setPhysicsState on a mesh.  I named the body... playBallBody.

Look at line 24.  Console.log says the .boundingRadius is 1.5... which is the correct radius for a sphere sized 3.  (I used an object inspector on playBallBody... to find the .boundingRadius property.)

I believe the bounding BOX you are seeing in your video... is coming from BabylonJS.  I believe BabylonJS mesh bounding boxes are not used for physics engines like Cannon and Oimo.  I don't think Cannon or Oimo have a "showBoundingBox" or "showBoundingSphere" for their impostors.

http://www.babylonjs-playground.com/#3QZYR#7

(if BJS boundingBox was used for physics, our sphere would be bouncing like a box)

And, I've now lost my forum cursor by trying to do a control-c and control-v in Firefox... so I will end here.

Link to comment
Share on other sites

I made more complex mesh (Path) and (Ball).

I still have a problem, with mesh impostor and this new model. Ball falls through where it should not. And there is a gap between ball and Path mesh.

I attached test project.

I include Path.blender and Path.babylon files.

Can anybody test this and find the problem? Does babylon exporter have any bug?
What is wrong?
You can rotate model (Path) with key 1,2  3,4  5,6.

Please help.

greetings

TestProj.zip

Link to comment
Share on other sites

Ok, found the problem. The MeshImpostor is not taking the mesh's transformation into account.

To fix this, simply call 

perplexus.bakeCurrentTransformIntoVertices();

before setting the physics impostor. This will "reset" the mesh'S transformation, and the path will work. 

I will check how to get it to work, but this is a wonderful solution in the meantime.

Attached - a happy animated gif.

56a143c0a0fd5_UntitledScreencast.gif.c9b

Link to comment
Share on other sites

OK, RaananW. (all code is same as above, when I attach zip file)
I add 

perplexus.bakeCurrentTransformIntoVertices();

before
perplexus.setPhysicsState(BABYLON.PhysicsEngine.MeshImpostor, { mass: 0, restitution: 0 });

 

1.) SCENARIO 1 change code

(scale playball)

playBall.scaling.x = 2;
playBall.scaling.y = 2;
playBall.scaling.z = 2;
(and postion it on)                    
playBall.position.x = 0;
playBall.position.y = 5;

When playBall falls on path itself starts rolling on the left side of path edge, but playBall falls through left side of path before it colides path's left side edge.

PlayBall should coledes path's left side edge and stops there or deducts.

Here are no differences if I add perplexus.bakeCurrentTransformIntoVertices(); or not.

(attached video how it looks like - Scenario 1 starting .)

2.) SCENARIO 2 (this looks pretty ok, somtimes are problems, somtimes fall falls through path)

playBall.position.x = 0;
playBall.position.y = 30;
playBall.position.z = -20;

It looks fine.
Because I rotate Path, somtimes Ball falls throught path.

I can rotate path with key  5 or key 6 

---------------------------------------------------------------------------------

I would like to put example on babylonjs-playground. But I don't know it it is possible to add .babylon file on babylonjs-playground.com???

Is it possible to upload .babylon file to www.babalyonjs-playground.com server and load it from it (http://www.babylonjs-playground.com/scenes")

like  for my example ( Import Meshes - example load skull.babylon )

    BABYLON.SceneLoader.ImportMesh("", "scenes/", "skull.babylon", scene, function (newMeshes)

    BABYLON.SceneLoader.ImportMesh("", "scenes/", "Path.babylon", scene, function (newMeshes) 

I don't have permission to upload my model in directory "http://www.babylonjs-playground.com/scenes/"

Kazam_screencast_00000.mp4

Link to comment
Share on other sites

Oh, look at that sphere drop... I will try checking what's wrong with it. The spheres i added worked wonderfully.

Have you tried adding a sphere using Babylon's internal functions? (Or as a geometry in the .babylon file). I doubt there will be any change, but worth a try. Does it happen in any other position? I tried the big slide at the back.

 

Adding an external .babylon file will only be possible if you allow CORS on the remote server.

You could also follow Wingnut's demo here - http://www.babylonjs-playground.com/#3QZYR#7 , he just pasted the vertex-data of both normals and positions, which is a wonderful idea.

 

Link to comment
Share on other sites

RaananW, 
I made new model, just first part (which have problem where ball fall through). 
I have to know you. It's all OK. Mash impostor works OK. I'll make model gradually and test it gradually.
(i think that there should be some problem in .babylon file which was exported or I did some mistake in blender when I create model.)
Once later I'll show you video how it works OK.

I think your mesh impostor work OK. And there are some problems with blender when I modeled model or are there some problem with .babylon exporter.
Maybe it would be good to find problem in file .blender or exported .babylon file. I think that I posted .blender and .babylon file inside zip file before.

greetings

Link to comment
Share on other sites

  • 4 weeks later...

Hi RaananW

Here is some example with your implementation of mesh impostor and sphere impotor.

I have to implement rotation around center of sphere. Now is just around center of path. 

http://ajna4taiga.no-ip.org:8080/BabylonBall/PerplexusProdV1/Main.html

greetins

Link to comment
Share on other sites

RaananW,

My frinds will help me solve rotation around ball. So that perplexus path will rotate around current ball position. He is trying to make it with parent child aproach.


Can you give me any advice or can you give me some code (advice) (with comemnt's how to rotate around ball).
I don't understend well getWorldMatrix how to use it to rotate perplexus(mesho) or should I use pivot intstead..

I have to play with fallow camera also. And try to make mobile variante.

Where is demo section hosted? I can add it to see people this.

How to post to demo section?

I'll be very happy I anybody can help me with code rotation around ball center. Or better rotation depended on camera normalization vector. (I have also problem to solve calculation with DeviceOrientationEvent).
If anybody can help or advice how to code this, I'll add code to make it better to work on mobile:

I like babylon and your mesh impostor works wonderful.

greetings

Link to comment
Share on other sites

Hi ian,

 

we'll be happy to help, but I don't really get the question :)

Try creating a very simple playground and show me what you tried doing. That'll probably get us all started.

 

About the demo section - it is another section of this forum. When you are done, publish your awesome game there. This will also be a wonderful Submission to the monthly challenge, that ends in a few days

Link to comment
Share on other sites

OK, I will prepare playground when I'll have time to prepare it.

I'll try to find demo section on forum. Can you give me direct link(s) for demo and "publishing link". Should I publish after I finish rotation perplexus(mesh) arround current ball?
Now thera are only rotation around X,Y an Z around center of perplexus(mesh). and A and D around worldMatrix of arc camera (W and D key rotate perplexus around arc camera how it looks at perplexus mesh.

There are 2 variante to rotate perplexus.

1. is already around X,Y,Z of center of perplexus(mesh) (key 1,2 3,4 5,6

2. I'll try to solve rotation of perplexus around current center position of ball (maybe keys 1,2 3,4, 5,6

3. variant rotation perplexus mesh around current camera target view with only A and D key for left right rotation and W and S key up and down rotation. Now you can see W and D key for left right rotation of perplexus 

Depending on the camera's view . With our friend we see some problem with key W and S (which doesn perplexus rotate up and down. W S doesn't work ok A and D work OK.

this section of code is not working well

// CODE FOR KEY 119=W AND KEY 115=S DOESN'T WORK !!!
case 119 : // W -> Rotate forward
    var cameraMatrix = mainCamera.getWorldMatrix();
    var finalAxis = (BABYLON.Vector3.TransformCoordinates(BABYLON.Axis.Y, cameraMatrix));
    perplexusRef.perplexus.rotate(finalAxis, (Math.PI / +512) * -1 * rotationSpeed, BABYLON.Space.WORLD);
    perplexusRef.perplexus.updatePhysicsBodyPosition();
    perplexusRef.rotationSpeed = rotationSpeed + 0.1;
    break;
case 115 : // S -> Rotate backward
    var cameraMatrix = mainCamera.getWorldMatrix();
    var finalAxis = (BABYLON.Vector3.TransformCoordinates(BABYLON.Axis.Y, cameraMatrix));
    perplexusRef.perplexus.rotate(finalAxis, (Math.PI / +512) * rotationSpeed, BABYLON.Space.WORLD);
    perplexusRef.perplexus.updatePhysicsBodyPosition();
    perplexusRef.rotationSpeed = rotationSpeed + 0.1;
    break;

// THIS SECTION WORK OK
case 100 : // D -> Rotate right
    var cameraMatrix = mainCamera.getWorldMatrix();
	var finalAxis = (BABYLON.Vector3.TransformCoordinates(BABYLON.Axis.X, cameraMatrix));
	perplexusRef.perplexus.rotate(finalAxis, (Math.PI / +512) * rotationSpeed, BABYLON.Space.WORLD);
	perplexusRef.perplexus.updatePhysicsBodyPosition();
	perplexusRef.rotationSpeed = rotationSpeed + 0.1;		
	break;
case 97 : // A -> Rotate left
  	var cameraMatrix = mainCamera.getWorldMatrix();
  	var finalAxis = (BABYLON.Vector3.TransformCoordinates(BABYLON.Axis.X, cameraMatrix));
  	perplexusRef.perplexus.rotate(finalAxis, (Math.PI / +512) * -1 * rotationSpeed, BABYLON.Space.WORLD);
  	perplexusRef.perplexus.updatePhysicsBodyPosition();
   	perplexusRef.rotationSpeed = rotationSpeed + 0.1;		
    break;

I'll have to edit complete javascript code to be better than it is now.

Link to comment
Share on other sites

Hi all!

I think Ian is talking about the demos on the BJS web site.  Is that correct, Ian?

I think Raanan is talking about the "Demos and Projects" section of the forum (a great place to get feedback about your various demo versions).

For linking demos on the web site (maybe in third party section)...

1.  Make sure your demo is really good, in all ways.  This includes testing on many browsers and getting many opinions (maybe gotten via the Demos and Projects forum)
2.  Publish/host your demo in a place/way that YOU can control future versions of the demo (+ which version of BabylonJS it uses). 
3.  It is best if you publish/host at a place where the URL to demo does NOT change.  Try to minimize future workload for BabylonJS web-masters.
4.  Provide a nice 400px by 250px still-image (jpg?) of the demo, publish that, too.  The web-masters will probably copy it to a screenshots folder for the BJS site.
5.  Provide a short title for the demo (such as 'Perplexus Demo'), and a "by" credit (such as 'by Ian' or 'by Ian Industries').
6.  Pay the BabylonJS web-master large amounts of money, so he/she can go on undeserved vacations and purchase expensive toys.  (just kidding about this, of course)

Recap:  Nice well-tested demo, you host/publish to firm URL, provide correct-size still pic, devise short title text, devise short credits text, then give all to web-master.

I highly-suggest that you take your time and test well.  Possibly avoid numeric keypad controls for your demo.  *shrug*  I hope I haven't said something incorrect.  :)

Now, rotating a meshImposter around a moving sphereImposter pivot-point, with rotation direction based-upon current camera angle?  I have no idea how to do that.  That thought scares me.  :)  Sorry.  Please create a very basic testing scene in the playground... for maximum assistance. 

A good start might be Stvsynrj's and Nockawa's "High-Roller" demo.  It doesn't work REAL well (sphere sinking/sticking issues, maybe caused-by meshImposter and actual mesh... not staying in 'sync').  It is still pretty good, though.  It looks like a nice playground to test (and struggle-with) your issues, and maybe others can help.  Be well.

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...