News Overview SceneEngine Downloads VideoTutorials Main Page SourceForge Get Involved Bookmark and Share
See also :
Previous : SceneEngine Lua

Create BoxObject with Material and Texture

The following Lua script creates a BoxObject with a ShaderMaterial and a BitmapTexture.

This script shows how to create Blocks, how to set block attributes and create block dependencies using the interface, and how to render and save a scene.

-- Open SceneEngine libraries
require("gmt_lua")
require("sceng_lua")
 
-- Create the Bitmap Texture
bitmap_texture = sceng.BitmapTexture( { file_path="maps/flooring.bamboo.rough.jpg" } )
 
-- Create the ShaderMaterial
shader_material = sceng.ShaderMaterial( { diffuse_color=gmt.Color(1,1,0), diffuse_texture=bitmap_texture } )
 
-- Create the BoxObject
box_object = sceng.BoxObject( { width=20.0, length=20.0, height=20.0, name="Cajon", pos=gmt.Point3(10,10,0), material=shader_material } )
box_object:Set( "subdivs_width", 10.0 )
 
-- Get default render parameters
rp = sceng.RenderParameters()
rp.output_file = "box_material_texture..tga"	
 
-- Render the scene
sceng.Render( rp )
 
-- Save the scene
sceng.SaveScene( "box_material_texture.sceng" )

This is the rendered image:

Image:Box_material_texture.png

Note : This script doesn't create lights nor cameras, these are created by default by the renderer, so your rendered result might vary slightly from the image shown above.

Views