Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hey guys, I have a nice video here showing how I coded my level of detail (LOD) which is very important for outdoor terrains. (indoor can just hide whole rooms etc) See my other post in the 'Programming' section for more info. https://www.youtube.com/watch?v=AX8XTW1pm2c |
||||
|
Nice work, Robo! Please tell me how you made the fps counter on the screen. |
||||
|
Robo, thank you for having published this video tutorial to explain your very nice LOD project. I think it could also be useful to modify the textures of the targeted object : one having a high resolution if the player is not far from it and other ones having lower resolutions if the player is far enough. |
||||
|
GolOO wrote: Nice work, Robo! Please tell me how you made the fps counter on the screen. Its a behavior you attach to a 2D overlay - I adjusted an existing one to run twice a second: // This Coppercube behavior must be attached to a 2D Overlay2, where it will show the FPS. // Origional : Isaac Sukin /* <behavior jsname="behavior_FPS" description="FPS counter"> </behavior> */ behavior_FPS = function() { this.fps = 60; this.framesThisSecond = 0; this.lastFpsUpdate = 0; }; behavior_FPS.prototype.onAnimate = function(n, timeMs) { if (timeMs > this.lastFpsUpdate + 500) { // update twice every second this.fps = (0.5 * this.framesThisSecond * 2) + 0.5 * this.fps; // compute the new FPS ccbSetSceneNodeProperty(n, "Text", this.fps.toFixed(0)); // reset counter till next update this.lastFpsUpdate = timeMs; this.framesThisSecond = 0; } this.framesThisSecond++; } |
||||
|
wrote: Robo, thank you for having published this video tutorial to explain your very nice LOD project. I think it could also be useful to modify the textures of the targeted object : one having a high resolution if the player is not far from it and other ones having lower resolutions if the player is far enough. cheers, thanks. CopperCube uses mipmaps that adjust texture sizes automatically according to distance so no need for that I don't think but you could specify the maximum texture size the mipmaps will use depending on memory available - I have this in my game menu. |
||||
|
Robo wrote: GolOO wrote: Nice work, Robo! Please tell me how you made the fps counter on the screen. Its a behavior you attach to a 2D overlay - I adjusted an existing one to run twice a second: // This Coppercube behavior must be attached to a 2D Overlay2, where it will show the FPS. // Origional : Isaac Sukin /* <behavior jsname="behavior_FPS" description="FPS counter"> </behavior> */ behavior_FPS = function() { this.fps = 60; this.framesThisSecond = 0; this.lastFpsUpdate = 0; }; behavior_FPS.prototype.onAnimate = function(n, timeMs) { if (timeMs > this.lastFpsUpdate + 500) { // update twice every second this.fps = (0.5 * this.framesThisSecond * 2) + 0.5 * this.fps; // compute the new FPS ccbSetSceneNodeProperty(n, "Text", this.fps.toFixed(0)); // reset counter till next update this.lastFpsUpdate = timeMs; this.framesThisSecond = 0; } this.framesThisSecond++; } Thank you very much, Robo! |
||||
|
Very nice job robo :) But, first of all save your eyes... NEVER use a white background while coding.. NEVER use small fonts, too.... So, try to use notepad++ or something else instead of CC's own script editor. Yes i know it is a damned work to save and reload your code every time when you add a single dot, but it is the only way to save your eyes.... |
||||
|
couldn't agree more. also, js syntax coloring, acting as visual typo detector etc. saves your energy, you can concentrate more and longer. https://notepad-plus-plus.org/downloads/ |
||||
|
wrote: Very nice job robo :) But, first of all save your eyes... NEVER use a white background while coding.. NEVER use small fonts, too.... So, try to use notepad++ or something else instead of CC's own script editor. Yes i know it is a damned work to save and reload your code every time when you add a single dot, but it is the only way to save your eyes.... good advice - thanks. Yes, I do use Notepad++ actually - I shouldn't use white backgrounds true enough.....eat lots carrots for ur eyes :) |
|