grire974

Members
  • Content Count

    23
  • Joined

  • Last visited

About grire974

  • Rank
    Member

Recent Profile Visitors

730 profile views
  1. Final update - I think I had my definition of Quaternion wrong; in fact I was actually looking for axis of rotation and angle of rotation; which is also expressed as 4 numbers and used in things like OpenGL's glRotate function and other libraries such as Open Scene Graph (OSG). The Quaternion class has functions for creating Quaternions from axis+angle; but nothing (as far as I could tell) for creating axis + angle from a quaternion (or from a matrix, or from standard rotation angles). Found some useful math pages though to help do this; The easiest one to follow is based off of a Quaternion; so if you don't have a Quaternion already - use @RaananW's code above & then convert the Java code listed at the bottom of this page - to convert that Quaternion to axis + angle; worked like a charm for me: http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/
  2. Thank you both! I think @RaananW suggestion will work nicely; great to have some background on it though @dbawel
  3. This might be due to a lack of general understanding - however I would like to know if there is a way (within bablyonjs) to convert a rotation (e.g. rotation.x = a, rotation.y = b, rotation.z = c) to a quaternion (axis of rotation, and an angle for rotation around that axis; e.g. x,y,z,w). According to the babylonjs docs; they seem to be exclusive of each other; e.g. if you set the AbstractMesh.rotate property (quaternion) then the .rotation property is automatically set to the Zero vector & vice versa. Basic rotation around each of the three axes (e.g. .rotation) is easier for most people (e.g. users of my code) to understand (compared to quaternions) but some other software that I'm trying to integrate with works better with quaternions. Rotation matrix seems to have the same problem (e.g. setting the .rotation property doesn't affect it). I converted some C++ code from cocos2dx into JS to convert a rotation matrix to a quaternion: http://www.babylonjs-playground.com/#1H0QGF#2 However this also doesn't give me a the desired result (because BJS is returning an identity matrix I think). Any Thoughts?
  4. Many thanks Delta - as always! Seems I was missing the fact that I had to computeWorldMatrix for my parent node and the child meshes as well. For those interested; heres the final PG in all of its tangental glory: http://www.babylonjs-playground.com/#27IOZS#2
  5. Ah right - well that makes sense. I've updated my PG to use minimumWorld; however its still showing the pre-rotation values for me. Any ideas as to what I might be doing wrong? Here's my updated PG: http://www.babylonjs-playground.com/#27IOZS#1
  6. It is correctly positioned now... However I'm positioning the height of the model based off of the min and max Z values returned from the boundingInfo. My intuition was expecting to use the Y values - but eventually guessed that I had to use the Z values as the model had been rotated 90 degrees around the x axis. The final question I guess is - should boundingInfo automatically represent all translations such as position and rotation (haven't tested for positional changes yet) made to a given mesh; or is it the developer's responsibility to keep track of their changes and apply further calculations to boundingInfo in order to get updated values. Obviously I'd prefer the former - but thought I'd raise the question none the less...
  7. Thanks for the pointer.. In trying to demonstrate my problem - I think I figured it out; I was rotating my mesh 90 degrees around the x axis in order to bring it into line; boundingInfo seems to reflect the mesh's original bounds - rather than those after it has been rotated. This is the playground I created: http://www.babylonjs-playground.com/#27IOZS The goal here is to dynamically load a mesh/babylon file (e.g. potentially any mesh from an unknown source); and then position said mesh such that it is tangental to the ground mesh. I ran the for loop again after the rotation was made to see if that would update the boundingInfo - however it doesn't seem to. Perhaps not a bug - still a little confusing I found; spent quite a lot of time scratching my head on this one.
  8. Hi - Thanks for the reply (sorry to post in the bugs forum if this doesn't appear to be a bug). Still having the same issue; I'd create a sandbox to illustrate this - however I don't see a way to add your own .babylon files to the sandbox..? Any other thoughts? Thanks.
  9. I think I've come across a bug with how SceneLoader handles positioning. Not sure yet whether this is BJS 2.4, or the FBXExporter code that is being used to generate a .babylon file from the FBX that I exported from Blender. When I load this file: https://drive.google.com/open?id=0BzfS-gwTfPBtMFp1bzg5N1BLOWM using BABYLON.SceneLoader.load() I can't get the correct BoundingInfo for the lower equalizer bars (38_EQBars001); it provides the same bounding info as the upper equalizer bars (37_EQBars002). e.g. for (i = 0; i < myScene.meshes.length; i++){ myScene.meshes[i].refreshBoundingInfo(); console.log("found mesh with min: id = "+myScene.meshes[i].id+", "+myScene.meshes[i].getBoundingInfo().minimum.y+", and max"+myScene.meshes[i].getBoundingInfo().maximum.y); } returns the same min and max Y values for both equalizer meshes; even though they display correctly (e.g. not the same positions). If you analyze the JSON of the .babylon file; you'll notice the position values for both meshes are almost identical. What is different is the rotation quaternion for both meshes - which makes sense because to create the 2nd set of equalizer bars, I cloned the first set and then rotated them into position; Thus my theory at this stage is that either the FBXConverter or BJS 2.4 aren't taking this into consideration. I also read this forum: However, using setTimeout in conjunction with refreshBoundingInfo() doesn't seem to have any positive effect. The downside of this all is that I can't tangentially position this model next to anything else as I don't have correct bounding info. Any help would be much appreciated.
  10. Was just wondering if there are any plans (or if anyone knows of a port) to extend support to native iOS / Android via common C++ code? E.g. something that has a compatible API & is compatible with the .babylon file type & FBXConverter etc..?
  11. Haha - yeh for sure; have only been working with this SDK for a few months & am enjoying it thoroughly. Its a good point you raise about diffuse colour possible shining through a transparent region of a texture image; might not be one size fits all (as I'm hoping it to be). Although it does seem to work for opaque image types (e.g. even jpegs). Will post back if I have any revelations.
  12. Wow - thanks wingnut; lots of great stuff to consider there. I didn't notice material.ambientTexture or diffuseTexture in the API docs (in fact I'm not sure they're there at all - is that api intended to be private/internal?). I'd used hemispheric in the past before however it creates reflection effects & wasn't exactly what I was looking for; however I'd glimpsed at the ground color stuff before & had forgotten about that. Stupidly - I just assumed that my code above would only work for solid color models (e.g. ones without image textures); however actually in testing it - it works for both situations in the way that I hoped it would. Thanks again.
  13. Hi All, Just to follow up with my final outcome; I did get something kinda working. The tangental plane idea is a good one; however as noted - its a leaky collider (esp if you want small snow flake sized physics particles); I ended up getting something working more reliable by setting overlapping tangental spheres - which wasn't leaky at all. Outer cube colliders also work; but its the whole square peg round hole thing; just make sure the edges of your cubes are overlapping. The main problem for me in the end was performance; my mac pro tower started to chug with more than 100 snow flakes; which even then looked sparse. Here's a quick and dirty example of it working though (sorry code is not clean whatsoever): http://proofing.tbadigital.com/xmas2015/model.html In the end - the thoughtfulness of the solution was lost on my colleagues who just wanted more snow; so this is what we finished with (#copout) (and no - I didn't write the poem if that's what you're wondering : http://xmas.tbadigital.com/ Thanks for all of your help!
  14. Hi All, I would like to replicate what I've seen referred to in some other engines as ambient light; definition of which being - a light that evenly distributes across the whole scene; e.g. doesn't cast shadows, and no parts of the scene look darker / lighter than any other part. My main reason for this is that some of my 3D content will need to have light maps baked into the texture images (for other non-babylon related reasons) & I don't want the default babylon lighting to affect this light mapping. I noticed this topic asked a similar question: However the answer they got didn't seem to satisfy my requirements. So far - the closest solution I've come up with is: for (i = 0; i < newScene.lights.length; i++){ newScene.lights.setEnabled(false); } for (i = 0; i < newScene.materials.length; i++){ newScene.materials.emissiveColor = newScene.materials.diffuseColor; } However this assumes that all my materials are solid colour; which they won't all be; some of them will have image textures. Any advice would be greatly appreciated? Perhaps a shader effect might be of help? Thanks!
  15. WOW! I think this is the most response I've ever had from a post on any discussion forum EVER (tried to like everyone's posts - but apparently I'm being too positive). Thanks all - @iiceman Interesting you say that; my end goal is to actually build a snow globe for my company's christmas mail out this year; thought I'd start with something simple and then move into a solid particle system; but I probably should have mentioned my end goal rather than comparing it to the trouble board game. @RaananW - I'll give you the solved vote as this gives me a lot to consider + answers my initial question; even though it doesn't look like it can power a snow globe (which stupidly I didn't mention). Will keep playing with this and post back if I come up with any enhancements. Thanks again! @Vousk-prod ; lol