public override GameObject Clone() { Geometry res = new Geometry(); res.SetLocalTranslation(this.GetLocalTranslation()); res.SetLocalScale(this.GetLocalScale()); res.SetLocalRotation(this.GetLocalRotation()); res.Mesh = this.mesh; res.shader = this.shader; res.depthShader = this.depthShader; res.normalsShader = this.normalsShader; res.ShaderProperties = this.ShaderProperties; return res; }
public override GameObject Clone() { Geometry res = new Geometry(); res.SetLocalTranslation(this.GetLocalTranslation()); res.SetLocalScale(this.GetLocalScale()); res.SetLocalRotation(this.GetLocalRotation()); res.Mesh = this.mesh; res.shader = this.shader; res.depthShader = this.depthShader; res.normalsShader = this.normalsShader; res.ShaderProperties = this.ShaderProperties; return(res); }
public override GameObject Clone() { Geometry res = new Geometry(); res.SetLocalTranslation(this.GetLocalTranslation()); res.SetLocalScale(this.GetLocalScale()); res.SetLocalRotation(this.GetLocalRotation()); res.Material = this.Material.Clone(); res.Mesh = this.mesh; res.shader = this.shader; res.depthShader = this.depthShader; res.normalsShader = this.normalsShader; res.ShaderProperties = this.ShaderProperties; for (int i = 0; i < controls.Count; i++) { res.AddController(controls[i]); } return res; }
static TreePopulator() { /* tree = (Node)AssetManager.LoadModel(AssetManager.GetAppPath() + "\\models\\tree\\pine\\LoblollyPine.obj"); tree.GetChildGeom(1).Material.SetValue("tree_height", tree.GetLocalBoundingBox().Max.y); tree.GetChildGeom(1).SetShader(typeof(BarkShader)); tree.GetChildGeom(1).DepthShader = ShaderManager.GetShader(typeof(BarkShader), new ShaderProperties() .SetProperty("DEPTH", true) .SetProperty(Material.TEXTURE_DIFFUSE, true)); tree.GetChildGeom(2).Material.SetValue("tree_height", tree.GetLocalBoundingBox().Max.y); tree.GetChildGeom(2).Material.SetValue(Material.MATERIAL_BLENDMODE, 1); tree.GetChildGeom(2).Material.SetValue(Material.MATERIAL_CULLENABLED, false); tree.GetChildGeom(2).Material.SetValue(Material.MATERIAL_ALPHADISCARD, 0.7f); tree.GetChildGeom(2).Material.Bucket = Rendering.RenderManager.Bucket.Transparent; tree.GetChildGeom(2).SetShader(typeof(LeafShader)); tree.GetChildGeom(2).DepthShader = ShaderManager.GetShader(typeof(LeafShader), new ShaderProperties() .SetProperty("DEPTH", true) .SetProperty(Material.TEXTURE_DIFFUSE, true));*/ tree = new Node(); Geometry g = new Geometry(MeshFactory.CreateQuad()); g.SetLocalScale(new Vector3f(15)); g.SetLocalTranslation(new Vector3f(0, 10, 0)); g.Material.SetValue(Material.MATERIAL_CASTSHADOWS, 0); g.Material.SetValue(Material.MATERIAL_BLENDMODE, 1); g.Material.SetValue(Material.TEXTURE_DIFFUSE, AssetManager.LoadTexture(AssetManager.GetAppPath() + "\\models\\tree\\pine\\billboard.png")); g.Material.SetValue(Material.SHININESS, 0.0f); g.Material.SetValue(Material.MATERIAL_ALPHADISCARD, 0.5f); g.Material.Bucket = RenderManager.Bucket.Transparent; g.SetShader(typeof(GrassShader)); g.Material.SetValue("fade_start", 250.0f); g.Material.SetValue("fade_end", 260.0f); tree.AddChild(g); }
/// <summary> /// Calculates the bounding box of the mesh and sets the mesh to [0, 0, 0]. /// </summary> /// <param name="mesh"></param> public static void SetToOrigin(Geometry geom) { Mesh mesh = geom.Mesh; if (mesh.BoundingBox == null) mesh.BoundingBox = mesh.CreateBoundingBox(); Vector3f difference = geom.GetLocalTranslation().Subtract(mesh.BoundingBox.Center); for (int i = 0; i < mesh.indices.Count; i++) { mesh.vertices[mesh.indices[i]].SetPosition(mesh.vertices[mesh.indices[i]].GetPosition().Add(difference)); } mesh.SetVertices(mesh.vertices, mesh.indices); if (geom.GetController(typeof(Scene.Physics.RigidBodyControl)) != null) { Scene.Physics.RigidBodyControl rbc = (Scene.Physics.RigidBodyControl)geom.GetController(typeof(Scene.Physics.RigidBodyControl)); } geom.SetLocalTranslation(mesh.BoundingBox.Center); }