I'm still confused about this. My dragging is working except that it's rather a challenge to drag at close zoom because the movement is going to fast.
My camera is a perspective :
[source lang="csharp"] private void SetWorldAndCam() { // Set Constant Buffer cbPerObjectBufferDesc = new BufferDescription(); cbPerObjectBufferDesc.SizeInBytes = Marshal.SizeOf(typeof(cbPerObject)); cbPerObjectBufferDesc.Usage = ResourceUsage.Default; cbPerObjectBufferDesc.BindFlags = BindFlags.ConstantBuffer; cbPerObjectBufferDesc.CpuAccessFlags = CpuAccessFlags.None; cbPerObjectBufferDesc.OptionFlags = ResourceOptionFlags.None; cbPerObjectBufferDesc.StructureByteStride = Marshal.SizeOf(typeof(cbPerObject)); // Set Camera camPos = 0.42; camPosition = new Vector3(0.0f, 0.0f, -100.0f); camTarget = new Vector3(0.0f, 0.0f, 0.0f); camUp = new Vector3(0.0f, 1.0f, 0.0f); camView = Matrix.LookAtLH(camPosition, camTarget, camUp); camProj = Matrix.PerspectiveFovLH(0.4f * 3.14f, (float)ptd.Width / ptd.Height, 0.00001f, float.MaxValue); World = Matrix.Identity * 10000; WVP = World * camView * camProj; cbPerObj.WVP = Matrix.Transpose(WVP); DataStream cbData = new DataStream(Marshal.SizeOf(typeof(cbPerObject)), true, true); cbData.Write(cbPerObj); cbData.Position = 0; cbPerObjectBuffer = new Buffer(device, cbData,cbPerObjectBufferDesc); context.VertexShader.SetConstantBuffer(cbPerObjectBuffer, 0); }[/source]
and here is wher I do my dragging :
[source lang="csharp"] public void UpdateScene(float x , float y, float z) { float currentX; float currentY; float currentIH = ptd.Height; float currentIW = ptd.Width; currentX = x ; currentY = y ; Ray mr = PanelToWordSpace(); Console.WriteLine(mr.Position); #region Zoom if (z != 0) { if (z > 0 && camPos > 0.09 ) { camPos = camPos - 0.07; } else { if (z < 0 && camPos < 0.98) { camPos = camPos + 0.07; } } Console.WriteLine(camPos); } #endregion camView = camView * Matrix.Translation(currentX,-currentY,0.00f); camProj = Matrix.PerspectiveFovLH((float)camPos * 3.14f, (float)ptd.Width/ ptd.Height, 0.00001f, float.MaxValue); WVP = World * camView * camProj ; cbPerObj.WVP = Matrix.Transpose(WVP); DataStream cbData = new DataStream(Marshal.SizeOf(typeof(cbPerObject)), true, true); cbData.Write(cbPerObj); cbData.Position = 0; cbPerObjectBuffer = new Buffer(device, cbData, cbPerObjectBufferDesc); context.VertexShader.SetConstantBuffer(cbPerObjectBuffer, 0); }[/source]
The main problem I have is having the mouse cursor stick to the place I am dragging and give the drag a proper speed. Any help would be appreciated.
- Viewing Profile: Posts: Hyrules
Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics
Community Stats
- Group Members
- Active Posts 10
- Profile Views 428
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
114
Neutral
User Tools
Contacts
Hyrules hasn't added any contacts yet.
Latest Visitors
Posts I've Made
In Topic: Draging a map in directx
28 July 2012 - 01:26 PM
In Topic: Keeping the aspect ratio when resizing control
27 July 2012 - 04:22 PM
correction... still have a aspect ratio problem...
In Topic: Draging a map in directx
25 July 2012 - 06:44 PM
well without knowing it you answered another of my questions i didnt want an perpective projection but an orthgraphic one. you help is much appreciated.
In Topic: Draging a map in directx
25 July 2012 - 06:19 PM
duh stupid me i answered my own question... it's Perspective : camProj = Matrix.PerspectiveFovLH(0.4f * 3.14f, (float)ptd.Height / ptd.Width, 0.00001f, 1000.0f);
In Topic: Draging a map in directx
25 July 2012 - 06:05 PM
Here is the camera and world setup i'm not sure if it's othorgraphic... thanks for your help.
[source lang="csharp"] private void SetWorldAndCam() { // Set Constant Buffer cbPerObjectBufferDesc = new BufferDescription(); cbPerObjectBufferDesc.SizeInBytes = Marshal.SizeOf(typeof(cbPerObject)); cbPerObjectBufferDesc.Usage = ResourceUsage.Default; cbPerObjectBufferDesc.BindFlags = BindFlags.ConstantBuffer; cbPerObjectBufferDesc.CpuAccessFlags = CpuAccessFlags.None; cbPerObjectBufferDesc.OptionFlags = ResourceOptionFlags.None; cbPerObjectBufferDesc.StructureByteStride = Marshal.SizeOf(typeof(cbPerObject)); // Set Camera camPosition = new Vector3(0.0f, 0.0f, -1.0f); camTarget = new Vector3(0.0f, 0.0f, 0.0f); camUp = new Vector3(0.0f, 1.0f, 0.0f); camView = Matrix.LookAtLH(camPosition, camTarget, camUp); camProj = Matrix.PerspectiveFovLH(0.4f * 3.14f, (float)ptd.Height / ptd.Width, 0.00001f, 1000.0f); World = Matrix.Identity; WVP = World * camView * camProj; cbPerObj.WVP = Matrix.Transpose(WVP); DataStream cbData = new DataStream(Marshal.SizeOf(typeof(cbPerObject)), true, true); cbData.Write(cbPerObj); cbData.Position = 0; cbPerObjectBuffer = new Buffer(device, cbData,cbPerObjectBufferDesc); context.VertexShader.SetConstantBuffer(cbPerObjectBuffer, 0); }[/source]
[source lang="csharp"] private void SetWorldAndCam() { // Set Constant Buffer cbPerObjectBufferDesc = new BufferDescription(); cbPerObjectBufferDesc.SizeInBytes = Marshal.SizeOf(typeof(cbPerObject)); cbPerObjectBufferDesc.Usage = ResourceUsage.Default; cbPerObjectBufferDesc.BindFlags = BindFlags.ConstantBuffer; cbPerObjectBufferDesc.CpuAccessFlags = CpuAccessFlags.None; cbPerObjectBufferDesc.OptionFlags = ResourceOptionFlags.None; cbPerObjectBufferDesc.StructureByteStride = Marshal.SizeOf(typeof(cbPerObject)); // Set Camera camPosition = new Vector3(0.0f, 0.0f, -1.0f); camTarget = new Vector3(0.0f, 0.0f, 0.0f); camUp = new Vector3(0.0f, 1.0f, 0.0f); camView = Matrix.LookAtLH(camPosition, camTarget, camUp); camProj = Matrix.PerspectiveFovLH(0.4f * 3.14f, (float)ptd.Height / ptd.Width, 0.00001f, 1000.0f); World = Matrix.Identity; WVP = World * camView * camProj; cbPerObj.WVP = Matrix.Transpose(WVP); DataStream cbData = new DataStream(Marshal.SizeOf(typeof(cbPerObject)), true, true); cbData.Write(cbPerObj); cbData.Position = 0; cbPerObjectBuffer = new Buffer(device, cbData,cbPerObjectBufferDesc); context.VertexShader.SetConstantBuffer(cbPerObjectBuffer, 0); }[/source]
- Home
- » Viewing Profile: Posts: Hyrules

Find content