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 RenderControlContent() { m_control = new RenderControl(); this.Text = "RenderControl"; m_control.Dock = DockStyle.Fill; this.Controls.Add(m_control); }
public bool InitGameWindow(RDisplayMode displayMode, RWindowStyle windowStyle, string title = "Reactor") { try { RGame.GameWindow.Title = title; GameWindowRenderControl control = new GameWindowRenderControl(); control.GameWindow = RGame.GameWindow; control.GameWindow.ClientSize = new System.Drawing.Size(displayMode.Width, displayMode.Height); if (windowStyle == RWindowStyle.Borderless) { control.GameWindow.WindowBorder = WindowBorder.Hidden; } control.GameWindow.X = 0; control.GameWindow.Y = 0; control.Context = (GraphicsContext)control.GameWindow.Context; _renderControl = control; RLog.Info(GetGLInfo()); REngine.CheckGLError(); RLog.Info("Game Window Renderer Initialized."); //PrintExtensions(); REngine.CheckGLError(); RShader.InitShaders(); REngine.CheckGLError(); Screen.Init(); REngine.CheckGLError(); return(true); } catch (Exception e) { RLog.Error(e); return(false); } }
/// <summary> /// /// </summary> private bool StartD3D() { if (!loaded || EffectsManager == null || RenderTechniquesManager == null) { if (EffectsManager == null) { EffectsManager = defaultEffectsManager = new DefaultEffectsManager(new DefaultRenderTechniquesManager()); } //RenderTechniquesManager = DefaultRenderTechniquesManagerObj.Value; //EffectsManager = DefaultEffectsManagerObj.Value; return(false); // StardD3D() is called from DP changed handler } this.IsHitTestVisible = false; surfaceD3D = new RenderControl(); Child = surfaceD3D; device = EffectsManager.Device; deferredRenderer = new DeferredRenderer(); renderRenderable.DeferredRenderer = deferredRenderer; CreateAndBindTargets(); SetDefaultRenderTargets(); //Source = surfaceD3D; InvalidateRender(); return(true); }
public static void RunAnimation(RenderControl render, float timer) { if (mCurrentDemo != null) { mCurrentDemo.Animation(render, timer); } }
public override void Run(RenderControl render) { TopoShapeList auxCurves = new TopoShapeList(); for (int ii = 0; ii < 4; ++ii) { char name = (char)((int)('A') + ii); string fileName = String.Format("data/complex/{0}.sldcrv", name); var curve = CreateSpline(GetResourcePath(fileName)); if (curve != null) { render.ShowShape(curve, ColorTable.Hex(0xFF0000)); auxCurves.Add(curve); } } for (int ii = 0; ii < 12; ++ii) { string fileName = String.Format("data/complex/{0}.sldcrv", ii); var curve = CreateSpline(GetResourcePath(fileName)); if (curve != null) { render.ShowShape(curve, ColorTable.Hex(0xFF00FF)); auxCurves.Add(curve); } } }
public override void Run(RenderControl renderer) { var shape = ShapeBuilder.MakeSphere(new GPnt(), 1); var bufferShape = new BufferShape(shape, null, null, 0.1); bufferShape.Build(); float distance = 3.0f; int halfCount = 5; var scene = renderer.GetScene(); for (int ii = -halfCount; ii < halfCount; ++ii) { for (int jj = -halfCount; jj < halfCount; ++jj) { for (int kk = -halfCount; kk < halfCount; ++kk) { var node = new BrepSceneNode(bufferShape); node.SetTransform(Matrix4.makeTranslation(ii * distance, jj * distance, kk * distance)); scene.AddNode(node); } } } renderer.ZoomAll(); Matrix4 m1 = new Matrix4(1); Matrix4 m2 = new Matrix4(1); Matrix4 x = m1 * m2; }
public override void Run(RenderControl render) { var material = MeshStandardMaterial.Create("workpiece"); material.SetColor(new Vector3(0.9f)); material.SetFaceSide(EnumFaceSide.DoubleSide); var shape = ShapeBuilder.MakeCylinder(GP.YOZ(), 5, 50, 0); mWorkpiece = BrepSceneNode.Create(shape, material, null); render.ShowSceneNode(mWorkpiece); var coord = new GAx2(new GPnt(0, 0, 5), GP.DZ()); var toolShape = ShapeBuilder.MakeCone(coord, 0, 2, 5, 0); var toolNode = render.ShowShape(toolShape, ColorTable.Blue); render.ShowSceneNode(mMotionTrail); // Initialize Animation mAnimation = new RigidAnimation(); var rotation = Matrix4.makeRotationAxis(new Vector3(1, 0, 0), (float)Math.PI); var trf = Matrix4.makeTranslation(-50, 0, 0) * rotation; mAnimation.Add(new MatrixAnimationClip(mWorkpiece, mWorkpiece.GetTransform(), trf, 0, 10)); mAnimation.Add(new MatrixAnimationClip(toolNode, toolNode.GetTransform(), trf, 10, 15)); mAnimation.Add(new RotateAnimationClip(toolNode, Vector3.UNIT_Z, (float)Math.PI * 4, 16, 20)); }
/// <summary> /// 開いて初期化 /// </summary> /// <param name="filePath">PMXファイルのパス</param> /// <param name="textureFolder">テクスチャのフォルダ</param> /// <param name="panel">レンダーパネル</param> /// <returns>MMDModelのインスタンス</returns> public static PMXModel OpenLoad(string filePath, string textureFolder, RenderControl panel) { PMXModel model = FromFile(filePath, textureFolder); model.Load(panel.RenderContext); return(model); }
public override void Run(RenderControl render) { RedMaterial = MeshPhongMaterial.Create("phong.color"); RedMaterial.SetColor(Vector3.Red); GrayMaterial = MeshPhongMaterial.Create("phong.color"); GrayMaterial.SetColor(Vector3.LightGray); GrayMaterial.SetTransparent(true); GrayMaterial.SetOpacity(0.5f); var tube = ShapeBuilder.MakeTube(new GPnt(0, 0, 5), GP.DZ(), 10, 2, 50); TubeNode = BrepSceneNode.Create(tube, RedMaterial, null); var cylinder = ShapeBuilder.MakeCylinder(GP.XOY(), 10, 60, 0); CylinderNode = BrepSceneNode.Create(cylinder, GrayMaterial, null); render.ShowSceneNode(TubeNode); render.ShowSceneNode(CylinderNode); var cone = ShapeBuilder.MakeCone(GP.YOZ(), 5, 0, 10, 0); var bs = new BufferShape(cone, RedMaterial, null, 0.1); bs.Build(); ConeNode1 = new BrepSceneNode(bs); ConeNode2 = new BrepSceneNode(bs); render.ShowSceneNode(ConeNode1); render.ShowSceneNode(ConeNode2); }
public override void Run(RenderControl render) { // 1. Make face with a hole. var c1 = SketchBuilder.MakeCircle(GP.Origin(), 30, GP.DZ()); var c2 = SketchBuilder.MakeCircle(GP.Origin(), 100, GP.DZ()); var face = SketchBuilder.MakePlanarFace(c2); var face2 = SketchBuilder.MakePlanarFace(c1); var shape = BooleanTool.Cut(face, face2); //render.ShowShape(shape, ColorTable.Blue); var faces = shape.GetChildren(EnumTopoShapeType.Topo_FACE); // 2. Hatch the face. foreach (var item in faces) { HatchHatcher hh = new HatchHatcher(item); hh.Build(); var material = BasicMaterial.Create("line"); material.SetColor(new Vector3(0.5f, 0.5f, 1.0f)); var node = hh.Create(material); // 3. Show the hatching lines. render.ShowSceneNode(node); } }
public override void Animation(RenderControl render, float time) { mTheta += 0.5f; mRobot.SetVariable(1, mTheta * 2); mRobot.SetVariable(2, mTheta * 3); mRobot.SetVariable(4, mTheta * 6); mRobot.SetVariable(6, mTheta * 2); mRobot.SetVariable(7, mTheta * 6); mRobot.SetVariable(8, mTheta * 6); if (mD > 30 || mD < 10) { mSign *= -1; } mD += mSign * 0.2f; mRobot.UpdateFrames(); Vector3 pt = new Vector3(0); pt = pt * mRobot.GetFinalTransform(); mMotionTrail.SetPosition(mCount, pt); ++mCount; render.RequestDraw(EnumUpdateFlags.Scene); }
public RenderContainer(SwapChainDescription swapChainDescription, RenderControl control) { try { _swapChainDescription = swapChainDescription; using (Factory1 factory = new Factory1()) using (Adapter adapter = factory.GetAdapter(0)) { Device11 = new Dx11ChainedDevice(adapter, _swapChainDescription); Device10 = new Dx10Device(adapter); } GraphicsDevice = new GenericGraphicsDevice(Device11.Device); SpriteBatch = new SpriteBatch(GraphicsDevice); Reset(control.Width, control.Height); control.Resize += OnRenderControlResize; } catch { Dispose(); throw; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LayoutForm_Load(object sender, EventArgs e) { RenderControl.MakeCurrent(); Display.Init(); Batch = new SpriteBatch(); }
public void Initialize(RenderControl window, GxContext context) { mGlobalBuffer = new ConstantBuffer(context); mGlobalParamsBuffer = new ConstantBuffer(context); mGlobalParamsBufferStore = new GlobalParamsBuffer { mapAmbient = new Vector4(0.5f, 0.5f, 0.5f, 1.0f), mapDiffuse = new Vector4(0.25f, 0.5f, 1.0f, 1.0f), fogColor = new Vector4(0.25f, 0.5f, 1.0f, 1.0f), fogParams = new Vector4(500.0f, 900.0f, mMainCamera.FarClip, 0.0f), brushParameters = new Vector4(45.0f, 55.0f, 0.0f, 0.0f), mousePosition = new Vector4(float.MaxValue), eyePosition = Vector4.Zero, brushSettings = new Vector4(0, 1, 0, 0) }; mGlobalParamsBuffer.UpdateData(mGlobalParamsBufferStore); mGlobalBufferStore = new GlobalBuffer { eyePosition = Vector4.Zero, matProj = Matrix.Identity, matView = Matrix.Identity }; mGlobalBuffer.UpdateData(mGlobalBufferStore); Dispatcher = new GraphicsDispatcher(); MapChunkRender.Initialize(context); MapAreaLowRender.Initialize(context); WmoGroupRender.Initialize(context); M2BatchRenderer.Initialize(context); M2ModelRenderer.Initialize(context); StaticAnimationThread.Instance.Initialize(); WmoManager.Initialize(); M2Manager.Initialize(); GraphicsContext = context; SetActiveCamera(mMainCamera); TextureManager.Instance.Initialize(context); MapManager.Initialize(); mMainCamera.ViewChanged += ViewChanged; mMainCamera.ProjectionChanged += ProjectionChanged; ViewChanged(mMainCamera, mMainCamera.View); ProjectionChanged(mMainCamera, mMainCamera.Projection); CamControl = new CameraControl(window); CamControl.PositionChanged += MapManager.UpdatePosition; if (!LeftHandedCamera) { CamControl.InvertY = true; } }
/// <summary> /// 開いて初期化 /// </summary> /// <param name="filePath">PMXファイルのパス</param> /// <param name="loader">テクスチャなどのパスの解決インターフェース</param> /// <param name="panel">レンダリングコンテキスト</param> /// <returns>MMDModel.</returns> public static PMXModel OpenLoad(string filePath, ISubresourceLoader loader, RenderControl panel) { PMXModel model = FromFile(filePath, loader); model.Load(panel.RenderContext); return(model); }
public override void Run(RenderControl render) { Sphere sp = new Sphere(Vector3.Zero, 10); var widget = AxisWidget.Create(0.05f, 0.4f); for (int ii = -5; ii < 5; ++ii) { for (int jj = -5; jj < 5; ++jj) { Ray ray = new Ray(new Vector3(ii, jj, 20), new Vector3(0, 0, -1)); var rst = ray.intersects(sp); if (!rst.first) { continue; } var pt = ray.getPoint(rst.second); var n = pt.normalized(); var trf = Matrix4.makeTranslation(pt) * Matrix4.makeRotation(Vector3.UNIT_Z, n); var instance = widget.Clone(); instance.SetTransform(trf); render.ShowSceneNode(instance); } } }
/// <summary> /// Make the GameWindow rendering context current /// </summary> public void MakeCurrent() { if (RenderControl != null) { RenderControl.MakeCurrent(); } }
public override void Run(RenderControl renderer) { var ellipse = SketchBuilder.MakeEllipse(GP.Origin(), 10, 5, GP.DX(), GP.DZ()); renderer.ShowShape(ellipse, Vector3.Blue); ParametricCurve pc = new ParametricCurve(ellipse); var paramsList = pc.SplitByUniformLength(1, 0.01); uint itemCount = (uint)paramsList.Count; var points = new ParticleSceneNode(itemCount, Vector3.Green, 5.0f); var lines = new SegmentsSceneNode(itemCount, Vector3.Red, 2); Random random = new Random(); for (int ii = 0; ii < paramsList.Count; ++ii) { var value = pc.D1(paramsList[ii]); var pos = value.GetPoint(); var dir = value.GetVectors()[0]; var end = new GPnt(pos.XYZ().Added(dir.XYZ())); lines.SetPositions((uint)ii, Vector3.From(pos), Vector3.From(end)); lines.SetColors((uint)ii, Vector3.Red, Vector3.From(random.NextDouble(), random.NextDouble(), random.NextDouble())); points.SetPosition((uint)ii, Vector3.From(pos)); } renderer.ShowSceneNode(points); renderer.ShowSceneNode(lines); }
/// <summary> /// Swap the render buffers /// </summary> public void SwapBuffers() { if (RenderControl != null) { RenderControl.SwapBuffers(); } }
public override void Run(RenderControl render) { var arc = SketchBuilder.MakeArcOfCircle(new GCirc(GP.XOY(), 10), 0, Math.PI); var points = new GPntList { new GPnt(0, 0, 0), new GPnt(2, 5, 0), new GPnt(15, 15, 0) }; var line = SketchBuilder.MakeBSpline(points); var extrema = new ExtremaCurveCurve(); extrema.Initialize(arc, line); int count = extrema.GetPointCount(); for (int ii = 0; ii < count; ++ii) { var point = extrema.GetPoint1(ii); var node = new PrimitiveSceneNode(GeometryBuilder.AtomSphere(), EnumPrimitiveType.TRIANGLES, null); node.SetTransform(Matrix4.makeTranslation(Vector3.From(point))); render.ShowSceneNode(node); } render.ShowShape(arc, Vector3.Red); render.ShowShape(line, Vector3.Green); }
public override void Run(RenderControl render) { var paramCurve = Sketch2dBuilder.MakeLine(new GPnt2d(0, 0), new GPnt2d(Math.PI * 20, 20)); // curve one cone { var cone = ShapeBuilder.MakeCone(GP.XOY(), 1, 10, 20, 0); var coneFace = cone.FindChild(EnumTopoShapeType.Topo_FACE, 0); var curveOnConeSurface = SketchBuilder.MakeCurveOnSurface(paramCurve, coneFace); var material = LineDashedMaterial.Create("my.dashed.material"); material.SetColor(ColorTable.Hex(0x0FFAA)); var node = BrepSceneNode.Create(curveOnConeSurface, null, material); node.ComputeLineDistances(); // Enable dashed line style. render.ShowSceneNode(node); } // curve one cylinder { var cylinder = ShapeBuilder.MakeCylinder(GP.XOY(), 2, 20, 0); var cylinderFace = cylinder.FindChild(EnumTopoShapeType.Topo_FACE, 0); var curveOnCylinderSurface = SketchBuilder.MakeCurveOnSurface(paramCurve, cylinderFace); var node2 = BrepSceneNode.Create(curveOnCylinderSurface, null, null); render.ShowSceneNode(node2); } }
public override void Run(RenderControl render) { var sketch = SketchBuilder.MakeEllipse(GP.Origin(), 5, 3, GP.DX(), GP.DZ()); // 1. Sweep { GPntList points = new GPntList { GP.Origin(), new GPnt(20, 10, 30), new GPnt(50, 50, 50), }; var path = SketchBuilder.MakeBSpline(points); render.ShowShape(path, Vector3.Green); var feature = FeatureTool.Sweep(sketch, path, EnumGeomFillTrihedron.ConstantNormal); render.ShowShape(feature, Vector3.Blue); } // 2. Revol { var feature = FeatureTool.Revol(sketch, new GAx1(new GPnt(-20, 0, 0), GP.DY()), 90); render.ShowShape(feature, Vector3.Green); } // 3. Loft { var baseWire = SketchBuilder.MakeRectangle(new GAx2(new GPnt(50, -50, 0), GP.DZ()), 20, 20, 5, false); var topWire = SketchBuilder.MakeCircle(new GPnt(60, -40, 40), 5, GP.DZ()); var loft = FeatureTool.Loft(baseWire, topWire, true); render.ShowShape(loft, Vector3.Red); } }
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) { var geometry = FontManager.Instance().CreateMesh("AnyCAD!"); var node = new PrimitiveSceneNode(geometry, null); render.ShowSceneNode(node); }
public void Create(RenderControl render) { // 随便构造些点 float offset = 10.0f; for (int ii = 0; ii < 10; ++ii) { for (int jj = 0; jj < ii; ++jj) { mPoints.Add(new Vector3(jj * offset, 100, ii * offset)); } } mMotionTrail = new ParticleSceneNode((uint)mPoints.Count, ColorTable.Green, 3.0f); mCurrentIdx = 0; render.ShowSceneNode(mMotionTrail); var lineMaterial = BasicMaterial.Create("myline"); lineMaterial.SetColor(ColorTable.Hex(0xFF0000)); var line = GeometryBuilder.CreateLine(Vector3.Zero, new Vector3(1, 0, 0)); mLineNode = new PrimitiveSceneNode(line, lineMaterial); mLineNode.SetTransform(MakeTransform(mStart, mPoints[0])); mLineNode.RequstUpdate(); render.ShowSceneNode(mLineNode); }
public UIDockContainer(string Name, string Text, string XMLFolder, string TSIFolder) { this.Name = Name; this.Text = Text; this.XMLFolder = XMLFolder; this.TSIFolder = TSIFolder; // // renderPanel // renderControl = new RenderControl(); renderControl.Location = new System.Drawing.Point(3, 3); renderControl.Dock = DockStyle.Fill; renderControl.Name = "renderControl"; renderControl.Size = new System.Drawing.Size(657, 423); renderControl.TabIndex = 0; renderControl.MouseMove += new MouseEventHandler(MouseMove); codePanelDockContainer = new DevComponents.DotNetBar.PanelDockContainer(); // // codePanelDockContainer // codePanelDockContainer.Controls.Add(renderControl); codePanelDockContainer.Location = new System.Drawing.Point(3, 28); codePanelDockContainer.Dock = DockStyle.Fill; codePanelDockContainer.Name = "codePanelDockContainer1"; codePanelDockContainer.Size = new System.Drawing.Size(663, 427); codePanelDockContainer.Style.Alignment = System.Drawing.StringAlignment.Center; codePanelDockContainer.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground; codePanelDockContainer.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2; codePanelDockContainer.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder; codePanelDockContainer.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText; codePanelDockContainer.Style.GradientAngle = 90; codePanelDockContainer.TabIndex = 0; }
public bool Play(RenderControl render, float time) { if (mCurrentIdx >= mPoints.Count) { mLineNode.SetVisible(false); return(false); } mTime += time; if (mTime < 100) //距离上次更新不到100ms,就返回 { return(true); } mTime = 0; Vector3 target = mPoints[mCurrentIdx]; mLineNode.SetTransform(MakeTransform(mStart, target)); mLineNode.RequstUpdate(); mMotionTrail.SetPosition((uint)mCurrentIdx, target); mMotionTrail.RequstUpdate(); render.RequestDraw(EnumUpdateFlags.Scene); ++mCurrentIdx; return(true); }
public override void Run(RenderControl renderer) { string fileName = GetResourcePath("Holes.stp"); var shape = StepIO.Open(fileName); if (shape == null) { return; } renderer.ShowShape(shape, Vector3.LightGray); var bbox = shape.GetBBox(); var shape2 = ShapeBuilder.MakeBox(new GAx2(bbox.CornerMax(), GP.DZ()), 100, 100, 10); renderer.ShowShape(shape2, Vector3.LightGray); ExtremaShapeShape ess = new ExtremaShapeShape(); if (!ess.Initialize(shape, shape2, 0.001)) { return; } var pt1 = ess.GetPointOnShape1(0); var pt2 = ess.GetPointOnShape2(0); var line = SketchBuilder.MakeLine(pt1, pt2); renderer.ShowShape(line, Vector3.Red); }
public override void Run(RenderControl render) { if (!ReadData()) { return; } var material = MeshPhongMaterial.Create("cae-material"); material.GetTemplate().SetVertexColors(true); material.SetFaceSide(EnumFaceSide.DoubleSide); var position = BufferAttribute.Create(EnumAttributeSemantic.Position, EnumAttributeComponents.Three, mPositions); var color = BufferAttribute.Create(EnumAttributeSemantic.Color, EnumAttributeComponents.Three, mColors); BufferGeometry geometry = new BufferGeometry(); geometry.AddAttribute(position); geometry.AddAttribute(color); NormalCalculator.ComputeVertexNormals(geometry); var node = new PrimitiveSceneNode(geometry, EnumPrimitiveType.TRIANGLES, material); node.SetPickable(false); PaletteWidget pw = new PaletteWidget(); pw.Update(mColorTable); render.ShowSceneNode(pw); render.ShowSceneNode(node); }