public override void Run(RenderControl render) { // add a plane var mMaterial1 = MeshPhongMaterial.Create("phong.texture"); mMaterial1.SetFaceSide(EnumFaceSide.DoubleSide); var texture = ImageTexture2D.Create(GetResourcePath("textures/bricks2.jpg")); mMaterial1.SetColorMap(texture); var plane = GeometryBuilder.CreatePlane(500, 500); var planeNode = new PrimitiveSceneNode(plane, mMaterial1); planeNode.SetTransform(Matrix4.makeTranslation(new Vector3(0, 0, -2.5f))); planeNode.SetPickable(false); render.ShowSceneNode(planeNode); mDevice = new PrimitiveSceneNode(GeometryBuilder.CreateSphere(5), null); render.ShowSceneNode(mDevice); mCome = new RigidAnimation(); mCome.Add(new MoveAnimationClip(mDevice, mWorkingPosition, 0, 5)); mGo = new RigidAnimation(); mGo.Add(new MoveAnimationClip(mDevice, new Vector3(-200, -200, 0), 0, 5)); }
public override void Run(RenderControl render) { // Create material var mMaterial1 = MeshPhongMaterial.Create("phong.texture"); mMaterial1.SetFaceSide(EnumFaceSide.DoubleSide); var texture = ImageTexture2D.Create(GetResourcePath("textures/bricks2.jpg")); mMaterial1.SetColorMap(texture); var plane = GeometryBuilder.CreatePlane(500, 500); var planeNode = new PrimitiveSceneNode(plane, mMaterial1); planeNode.SetTransform(Matrix4.makeTranslation(new Vector3(0, 0, -100))); render.ShowSceneNode(planeNode); var box = GeometryBuilder.CreateBox(100, 100, 200); var boxNode = new PrimitiveSceneNode(box, mMaterial1); render.ShowSceneNode(boxNode); var sphere = GeometryBuilder.CreateSphere(50, 32, 32); var sphereNode = new PrimitiveSceneNode(sphere, mMaterial1); sphereNode.SetTransform(Matrix4.makeTranslation(new Vector3(0, 0, 150))); render.ShowSceneNode(sphereNode); }
public override bool Execute(UICommandContext ctx) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Image Files(*.jpg;*.png)|*.jpg;*.png"; if (dlg.ShowDialog() == DialogResult.OK) { var bkg = new ImageBackground(ImageTexture2D.Create(dlg.FileName)); ctx.RenderView.GetViewer().SetBackground(bkg); } return(true); }
private void backgroundImageToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Image files (*.png;*.jpg)|*.png;*.jpg"; if (dlg.ShowDialog() != DialogResult.OK) { return; } var texture = ImageTexture2D.Create(dlg.FileName); var background = new ImageBackground(texture); mRenderView.GetViewer().SetBackground(background); }
public override void Run(RenderControl render) { // prepare points data const int COUNT = 300; var buffer = new Float32Buffer(0); buffer.Reserve(COUNT * 3); var colors = new Float32Buffer(0); Random random = new Random(); for (int i = 0; i < COUNT; i++) { float x = 2000 * (float)random.NextDouble() - 1000; float y = 2000 * (float)random.NextDouble() - 1000; float z = 2000 * (float)random.NextDouble() - 1000; buffer.Append(x, y, z); colors.Append((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble()); } var primitive = GeometryBuilder.CreatePoints(new Float32Array(buffer), new Float32Array(colors)); // prepare point material var material = PointsMaterial.Create("points-material"); material.SetSizeAttenuation(false); material.SetPointSize(15.0f); material.SetColorMap(ImageTexture2D.Create(GetResourcePath("textures/snowflake7_alpha.png"))); material.SetTransparent(true); // enable vertex color material.GetTemplate().SetVertexColors(true); // add to scene var node = new PrimitiveSceneNode(primitive, material); node.SetPickable(false); render.ShowSceneNode(node); }
public override void Run(RenderControl render) { mMaterial1 = MeshPhongMaterial.Create("phong.texture"); mMaterial1.SetColor(new Vector3(1, 0, 1)); var texture = ImageTexture2D.Create(GetResourcePath("textures/bricks2.jpg")); texture.SetRepeat(new Vector2(2.0f, 2.0f)); texture.UpdateTransform(); mMaterial1.SetColorMap(texture); var shape = ShapeBuilder.MakeBox(GP.XOY(), 4, 4, 8); mNode = BrepSceneNode.Create(shape, mMaterial1, null); mMaterial2 = MeshPhongMaterial.Create("phong.texture"); var texture2 = ImageTexture2D.Create(GetResourcePath("textures/water.png")); mMaterial2.SetColorMap(texture2); render.ShowSceneNode(mNode); }