Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I didn't found any function in the documentation for adding a bounding box to another or how to calculate the bounding box that contains the mesh buffers maybe you can point me on this please? and another thing.In the tutorial 3 if we add: var CheckSceneNode = engine.getScene().getAllSceneNodesOfType('mesh'); for (var j = 0; j < CheckSceneNode.length; j++) { if (CheckSceneNode) { alert ("OK"); } } It's not working which it means that it doesn't get the created mesh. Why? Thanks for your quick support. |
||||
|
If you have one bounding box, you can add another one into it by calling yourbox.addInternalPointByVector(box.MaxEdge); yourbox.addInternalPointByVector(box.MinEdge); bagg wrote: if (CheckSceneNode) { alert ("OK"); } Maybe it would be correct with this?
|
||||
|
Ok i'll have a look at the bounding boxes. But with my other problem i changed the code with this var CheckSceneNode = engine.getScene().getAllSceneNodesOfType('mesh'); alert (CheckSceneNode.length); And the CheckSceneNode.length is zero |
||||
|
Ah, you are starting with tutorial 3, now I understand. This will return nothing because the scene node you are creating in there is not a mesh scene node. It's an own one. Do it in the second tutorial for example, there you should get 3. |
||||
|
So if someone creates a custom scene node then he can't get the mesh? |
||||
|
I think you've misunderstood something here. Of course you can get the mesh. If you wrote your own scene node, you already have the mesh. The getAllSceneNodesOfType function just goes through the scene and collects all scene nodes of a specific type. It works just like the document.getElementByTagName() thing. If you created your own HTML tag with an own name (e.g. 'mytag') and your own properties, you won't retrieve it either by calling document.getElementByTagName('div'), |
||||
|
I am sorry but isn't the created custom scene node type a "mesh" type? |
||||
|
No, it's your own type. You derived it directly from the SceneNode type, the base class: ySceneNode.prototype = new SceneNode(); // derive from SceneNode Derive it from the MeshScene node and it is a 'mesh' scene node type. |
||||
|
Ah i see.So in order to get it with engine.getScene().getAllSceneNodesOfType('mesh'); i must change the MySceneNode.prototype = new SceneNode(); to MySceneNode.prototype = new MeshSceneNode(); right? must i do any other changes to the rest of the code? MySceneNode.prototype.OnRegisterSceneNode = function(scene) { scene.registerNodeForRendering(this, Scene.RENDER_MODE_DEFAULT); SceneNode.prototype.OnRegisterSceneNode.call(this, scene); // call base class } MySceneNode.prototype.render = function(renderer) { renderer.setWorld(this.getAbsoluteTransformation()); renderer.drawMesh(this.MyMesh); } |
||||
|
Should probably work like that, yes. |
|