≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Adding multiple CubeSceneNodes [Cubes] to Canvas?
Posted by:
(you are not logged in)
Enter the missing letter in: "I?ternational"
(you are not logged in)
Text:
[quote][b]sagh0900[/b] wrote: [code] <script type="text/javascript"> function CopperlichtStart() { // Create 3D Engine var engine = new CL3D.CopperLicht('glcanvas', true, 60, true); if (!engine.initRenderer()) return; // this browser doesn't support WebGL // Create a 3D scene and add it to the 3D engine scene = new CL3D.Scene(); engine.addScene(scene); // Set the scene background color scene.setBackgroundColor(CL3D.createColor(1, 0, 0, 0)); //Force the 3d engine to update the scene every frame scene.setRedrawMode(CL3D.Scene.REDRAW_EVERY_FRAME); // Create a box and add it to the scene graph var boxnode1 = new CL3D.CubeSceneNode(); var boxnode2 = new CL3D.CubeSceneNode(); scene.getRootSceneNode().addChild(boxnode1); scene.getRootSceneNode().addChild(boxnode2); // Add image to the sides of Cube boxnode1.getMaterial(0).Tex1 = engine.getTextureManager().getTexture("resources/crate.gif", true); boxnode2.getMaterial(1).Tex1 = engine.getTextureManager().getTexture("resources/crate.gif", true); // Assign box a rotation boxnode1.addAnimator(new CL3D.AnimatorRotation(new CL3D.Vect3d(0.0, 0.15, -0.15))); boxnode2.addAnimator(new CL3D.AnimatorRotation(new CL3D.Vect3d(0.0, 0.15, -0.15))); //Create a camera and add it to the scene graph var cam = new CL3D.CameraSceneNode(); // Position cam.Pos.X = 0; cam.Pos.Y = 0; cam.Pos.Z = 20; // Width-to-height ratio or Aspect Ratio var canvas = document.getElementById("glcanvas"); var AR = canvas.width / canvas.height; cam.setAspectRatio(AR); // Field of View cam.setFov(45); scene.getRootSceneNode().addChild(cam); scene.setActiveCamera(cam); // Creating the shader program which gives the cube its surface. var vshaderScript = document.getElementById("vshader"); var fshaderScript = document.getElementById("fshader"); var newMaterialType = engine.getRenderer().createMaterialType(vshaderScript.text, fshaderScript.text); if (newMaterialType != -1) boxnode1.getMaterial(0).Type = newMaterialType; boxnode2.getMaterial(1).Type = newMaterialType; else //Exact error message from shader code is written on the website of Copper Licht alert('Unable to create shaders'); } </script> </head> [/code] I tried to add one more cube to the scene to compare the fps with single cube on canvas. But the above snippet isn't working. I want to add as many as cubes to the scene may be using like a " for loop " algorithm. How Could I do that? Moreover, I want to print the FPS to external file like notepad or Excel in Local Repository. please someone help me doing so. Moreover, The size of Cube using cube scene node is pretty big on the canvas, if I ad more cubes to the scene, will cube size reduces automatically so that to maintain of Field Of View? To represent the CONE, do Copperlicht, have any predefined models like CubeSceneNode for cube? Sorry, I put lot of questions, but answers to these can clear my whole doubts on this framework.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact