paul.chaney Posted August 13, 2014 Share Posted August 13, 2014 Hi there, To control the weather in a scenery, I'm using the following code. Like this I can control the height of the clouds received by a Cigi packet. Now, I want to control the clouds in depth, slice, density, etc from the ObjectSky class. But I don't see how to get to this derived class to apply their methods. Node clMiddle = engine.world.getNode(id); if (clouds == NULL) { log.message("getNode(clMiddle) failed\n"); } clMiddle.setPosition(dvec3(0.0, 0.0, clBase)); Link to comment
unclebob Posted August 14, 2014 Share Posted August 14, 2014 Hello Paul,Just use node_cast like in this code sample: // make sure that node with id is definitely ObjectSky sky = node_cast(engine.world.getNode(id)); You can also cast manually like this: // make sure that node with id is definitely ObjectSky Node node = engine.world.getNode(id); ObjectSky sky = ObjectSky(node); Here's safe version of cast: Node node = engine.world.getNode(id); if(node != NULL && node.getType() == NODE_OBJECT_SKY) { ObjectSky sky = node_cast(node); } Link to comment
paul.chaney Posted August 14, 2014 Author Share Posted August 14, 2014 Thanks, exactly what I was looking for! Link to comment
unclebob Posted August 14, 2014 Share Posted August 14, 2014 You're welcome, Paul! :) Link to comment
paul.chaney Posted August 14, 2014 Author Share Posted August 14, 2014 Once again, sorry... I can now control all the params of the clouds, as I wished. I also integrated a second cloud layer. And also this one, I can control. But now, the render performance dropped drastically. I changed back the world script file and erased all the controlling commands to the clouds but the render time remains doubled to what I had before. Do I miss a file, where some nodes, meshes, etc. is written? I just doubled the code in the .world file. See below: <node type="ObjectSky" id="1" collider="0" name="baseCloudLayer"> <simulation>1</simulation> <size>24000 24000 800</size> <min_slices>500</min_slices> <max_slices>600</max_slices> <distribute>2</distribute> <humidity>0.96</humidity> <transition>0.5</transition> <extinction>0.7</extinction> <density_image>washington/textures/environment/clouds.png</density_image> <density_velocity>30 30 0</density_velocity> <density_offset>1095.54 1095.54 0</density_offset> <density_layer>3</density_layer> <surface name="sphere" material="sky" property="surface_base"> <material> <blend src="src_alpha" dest="one_minus_src_alpha"/> <options post_scattering="1"/> <state name="inscattering">1</state> </material> </surface> <surface name="volume" material="sky" property="surface_base"> <material> <blend src="src_alpha" dest="one_minus_src_alpha"/> <options post_scattering="1" two_sided="1"/> <state name="surface">1</state> <state name="inscattering">1</state> </material> </surface> <surface name="shadow" material="sky" property="surface_base"> <material> <blend src="zero" dest="src_alpha"/> <options/> <state name="surface">2</state> </material> </surface> <transform>1 0 0 0 0 1 0 0 0 0 1 0 0 0 1615.43994140625 1</transform> </node> Link to comment
silent Posted August 14, 2014 Share Posted August 14, 2014 You can try to delete *.cache and *.cfg files from data directory and try to load your world again. You also can check what cause such performance drop by calling world_analyze and engine_analyze commands from console in debug builds. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
paul.chaney Posted August 14, 2014 Author Share Posted August 14, 2014 Wow, I didn't saw this until now! Thanks! B) Link to comment
Recommended Posts