neoRiley Posted January 28, 2014 Share Posted January 28, 2014 I need to parent an object so that I can rotate the child to the proper angle and then move the parent. Right now, I'm creating a new sphere object and assigning a transparency of 0 for the material. If I simply try to create a new Mesh() object without adding geometry/material, the engine/renderer kicks back an error. What' the proper method for doing this? Thanks for your help Quote Link to comment Share on other sites More sharing options...
Merfoo Posted January 28, 2014 Share Posted January 28, 2014 You can just set the .isVisible property to false if you dont want to render it. Meaning you would't have to give the mesh a material.mesh.isVisible = false; Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 28, 2014 Share Posted January 28, 2014 If by creating an empty mesh, you mean "create a mesh without geometry (vertices)", I'm not sure it's possible and you may be interested by the following discussion: http://www.html5gamedevs.com/topic/2796-discussion-about-nodes-meshes-instances/ Your problem seems to be "how to rotate a mesh to the proper angle and then move it" and "parenting it to an empty mesh" could be a solution. You can try to set a pivot matrix. http://jsfiddle.net/gwenaelhagenmuller/24mBJ/1/ Quote Link to comment Share on other sites More sharing options...
neoRiley Posted January 29, 2014 Author Share Posted January 29, 2014 You can just set the .isVisible property to false if you dont want to render it. Meaning you would't have to give the mesh a material.mesh.isVisible = false; That worked perfectly, thanks Merfoo I had looked at that initially, and I should have just tried it, but my assumption was that if you set the parent visibility to false, then the children would also be invisible. Maybe setEnabled() would give you that result? Not to create a sub topic, but I wonder what "visiblity:number" deals with Quote Link to comment Share on other sites More sharing options...
neoRiley Posted January 29, 2014 Author Share Posted January 29, 2014 If by creating an empty mesh, you mean "create a mesh without geometry (vertices)", I'm not sure it's possible and you may be interested by the following discussion: http://www.html5gamedevs.com/topic/2796-discussion-about-nodes-meshes-instances/ Your problem seems to be "how to rotate a mesh to the proper angle and then move it" and "parenting it to an empty mesh" could be a solution. You can try to set a pivot matrix. http://jsfiddle.net/gwenaelhagenmuller/24mBJ/1/ Thanks for all your help Gwenael - the pivot matrix would make sense, but in a scene with multiple items that have to rotate relative to a common pivot/parent, what would be the best approach? If I used a pivot matrix approach, i would have to rotate all objects that were "parented" or using the same matrix. If I just use a parent mesh and add those objects to the parent, all I have to do is rotated/translate the parent. Behind the scenes, I realize the engine is traversing the child nodes and essentially doing the work for me, but from a code standpoint, it's much easier to read and understand for everyone involved I would think maybe I'm missing a feature that makes this not true? Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 29, 2014 Share Posted January 29, 2014 For sure it's easier to have a parent if you have multiple meshes that have to rotate relative to a common pivot/parent, nevertheless you can add a class to handle this differently.Here's a start for this class (BABYLON.CommonPivot) http://jsfiddle.net/gwenaelhagenmuller/2fA92/ Quote Link to comment Share on other sites More sharing options...
neoRiley Posted January 29, 2014 Author Share Posted January 29, 2014 For sure it's easier to have a parent if you have multiple meshes that have to rotate relative to a common pivot/parent, nevertheless you can add a class to handle this differently.Here's a start for this class (BABYLON.CommonPivot) http://jsfiddle.net/gwenaelhagenmuller/2fA92/ I really like that - especially if it's more streamline than having an empty mesh as a parent/pivot. I would love to see this concept flushed out. How would this concept work if you wanted the commonPivot parented? It'd be nice too of you could just pass the mesh and have it store the matrix of the child node based on where it's current matrix. Quote Link to comment Share on other sites More sharing options...
neoRiley Posted January 29, 2014 Author Share Posted January 29, 2014 You know though, in saying that out loud, I think it would make more sense to streamline BABYLON.Mesh or BABYLON.Node to act like this new pivot since all the things I listed above are already supported. Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 29, 2014 Share Posted January 29, 2014 That's pretty much what I suggest in the discussion I refer to in my first answer. Transform node would be nodes that can be parent of meshes, cameras, lights and other transform nodes. Actually only this kind of nodes (transform) should be used for parenting. Meshes wouldn't store transforms info, they would only store geometry. Once I have time I will work on it Quote Link to comment Share on other sites More sharing options...
neoRiley Posted January 31, 2014 Author Share Posted January 31, 2014 Yep, now we're full circle Thanks Gwenael! I appreciate your time and help - John Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 31, 2014 Share Posted January 31, 2014 Beware here, I would like to keep babylon.js easy to use and if for creating a mesh you need to create a node and call setGeometry this will be too much for beginner. I do not want to reproduce 3js model (excellent though but I prefer keeping things simple) gwenael 1 Quote Link to comment Share on other sites More sharing options...
neoRiley Posted January 31, 2014 Author Share Posted January 31, 2014 I couldn't agree with you more Deltakosh - In other engines ranging from PV3D, to Unity3D to Three.js, the paradigm has been to create a new Object3D/GameObject for parenting/pivot changes/rotating local vs world etc. I think that using a new Mesh object and making that work would be the easiest entry point for people coming in, especially if they have experience with other 3D API's. Using setPivotMatrix, though I understand the concept and can appreciate it, is very high level in that it assumes the user knows how to deal with matrix values by hand - and most of us don't, that's why we lean on a 3D api. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 1, 2014 Share Posted February 1, 2014 I'm really opened to all kind of change but we just have to keep in mind: SIMPLICITY:) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Feldspar Posted February 6, 2014 Share Posted February 6, 2014 Having transformation-typed nodes would indeed be much cleaner than parenting with non-visible meshes. But I think you can also leave transformation info within the Mesh Node. I feel like it would be simpler if every Node in the scene tree had a transformation Matrix, then you just have to recursively multiply them to find the world matrix, regardless of the type of the parent. Anyway, looking forward to the pull request ! gwenael 1 Quote Link to comment Share on other sites More sharing options...
gwenael Posted February 18, 2014 Share Posted February 18, 2014 I'm back on BabylonJS unfortunately not for long for the moment. I'll keep in mind SIMPLICITY for all stuff I could do for BabylonJS since I think it's a good approach. I'll try to always have for a function a default mode and an expert mode (more parameters or override of a default value...) Feldspar 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.