vdheeraj Posted April 22, 2017 Share Posted April 22, 2017 Hi, Have render a bike model as show. Few details regarding the model: Exported model from blender. All parts are under a parent mesh. I want to swap the existing fuel tank with a new fuel tank. Loading new mesh(fuel tank) using AssetsManager. meshTask.onSuccess = function (task) { //Get current tank //Hide current tank //Get current tank position using getAbsolutePosition() //Set position to new tank //Set new tank's parent //Show new tank } Few details regarding new tank model: Exported model from blender. Has no parent. But new tank is not in correct position. I can update the position manually(hard code) and get the following result.(Don't want to do this) Need to swap current mesh with new mesh and retain the position. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 24, 2017 Share Posted April 24, 2017 On 4/22/2017 at 6:43 AM, vdheeraj said: //Set position to new tank //Set new tank's parent Hi @vdheeraj, welcome to the forum. Nice model/scene... pretty. You did a well-explained post, too, thx. Could you try a test for me? Try reversing the order of those two lines. Set tank's parent first, then set position gotten from previous tank. Setting parent AFTER setting position... might accidentally over-ride your position setting. Report results, please. Perhaps this will work. I hope so, but if not, we'll try more ideas... if I can think of some. Quote Link to comment Share on other sites More sharing options...
Convergence Posted April 24, 2017 Share Posted April 24, 2017 Maybe try: //Get current tank //Hide current tank // compute world matrix on current tank //Get current tank position using getAbsolutePosition() // set new tanks parent // set new tanks position using setAbsolutPosition() Quote Link to comment Share on other sites More sharing options...
vdheeraj Posted April 24, 2017 Author Share Posted April 24, 2017 Hi @Wingnut and @Convergence thanks for the suggestions, but didn't resolve the issue. However @Wingnut, while trying to resolve this, came across this post. I'm doing something similar as mention in the post. So instead of having 2 files (original bike and modified tank), combined both and layered them in blender and exported.(All meshes have single parent) Load all the meshes upfront and toggle isVisible and setEnabled to show and hide mesh. Was able to achieve this. Thanks @Wingnut, To quote you "you're just the coolest" . And @Convergence, appreciate your help. Wingnut 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.