Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


VanillaSnake

Member Since 27 Mar 2006
Offline Last Active Aug 04 2015 06:58 PM

Topics I've Started

How to control a wacom pen in software?

03 August 2015 - 02:11 PM

I would like to emulate a wacom pen in software in Windows 10. What I'm looking to do is have a program move the cursor and draw in photoshop, but I would like to use the wacom driver to do that. As in I want to send photoshop a message pen is touching screen at x,y with pressure p and tilt t without actually using the pen, everything should be done in software. I'm not sure how I can do that. I think windows 10 has a pen api and I will probably use that if I have no other choice but I was wondering if I can somehow use the wacom api or something similar. 


Why does this code work? (Drawing in screen space)

27 May 2015 - 07:07 PM

Hey all, I just wanted to run this code by because I don't fully understand it. I wrote this a while ago and never touched this part of my code till now. Here it is.

float aspectRatio = float(softObjPtr->clientRect.left) / float(softObjPtr->clientRect.bottom);
float planeXOrig = -1.0f, planeYOrig = -1.0f;
float planeWidth = 2.0f;
float planeHeight = 2.0f;
 

softObjPtr->pD3D10VertexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v);
 
v[0] = DX10VERTEX(D3DXVECTOR3(planeXOrig, planeYOrig, 0), D3DXVECTOR4(1, 1, 1, 1), D3DXVECTOR2(0.0f, 1.0f));
v[1] = DX10VERTEX(D3DXVECTOR3(planeXOrig + planeWidth, planeYOrig, 0), D3DXVECTOR4(1, 1, 1, 1), D3DXVECTOR2(1.0f, 1.0f));
v[2] = DX10VERTEX(D3DXVECTOR3(planeXOrig + planeWidth, planeYOrig + planeHeight, 0), D3DXVECTOR4(1, 1, 1, 1), D3DXVECTOR2(1.0f, 0.0f));
v[3] = DX10VERTEX(D3DXVECTOR3(planeXOrig, planeYOrig + planeHeight, 0), D3DXVECTOR4(1, 1, 1, 1), D3DXVECTOR2(0.0f, 0.0f));
 
softObjPtr->pD3D10VertexBuffer->Unmap();

Why does my the code work flawlessly if I'm positioning my quad at -1, -1 with a width of 2? I guess I would understand this if I had a camera and it looked directly at the center then -1 to 1 would cover the entire region correclty, however I don't have a camera, or more correctly, I'm not multiplying this by any projection matrix. It goes straight to v. shader which doesn't modify it at all and gets passed into the pixel shader. Also I read that I have to account for the pixel center/cell center and subtract 0.5f from everything, but my textured quad is displayed correctly as it is? Why?


Full Screen Quad with Texture, looks off

29 July 2014 - 03:00 AM

I'm trying to convert my software rasterizer from ddraw to dx10. I like to at some point use the pixel shader to draw some elements while I do other elements on cpu. So I decided to just create a texture, lock it and draw directly on it, then use a quad to display it. It does work, and all my programs that I wrote under ddraw run just fine, most old functions have this declaration function(DWORD* video_mem, int lpitch32) so all I do is replace the locked texture memory into vid ram, and the stride of the texture into lptich32. Easy enough. The problem comes in when I try to do something like a dotted line, for example if I try to plot a pixel every 5 pixels.

 

for (int x = 0, x1 = 0; x < 50;x++, x1+=5)

{


        texture_buffer[x1 + y1*lpitch32] = COLOR_MAGENTA;


}

 

what I get is a line, but some pixels appear to be either merged with others or too far apart. I don't know what's causing it. To give you a run down of my setup, I create a texture the size of my back buffer, which is the same size as my screen. I create a quad with (-1,-1) to (1,1) coords, I leave it in clip-space and don't use any additional transforms in the vertex shader. My pixel shader just samples the texture. The sampler state filter is set to mip-min-mag or something like that. I thought it might be the filtering, but I didn't find an option how to specify no filter.

 

If needed ill post a picture of what I'm getting and just let me know which code you want me to show you.


D3DCreateEffectFromMemory Fails, everything is correct, why?

25 July 2014 - 12:04 AM

Hi, I'm trying to use a simple hlsl file in the rendering, so I compile my .fx with the fxc.exe as directed on msdn, it produces a clean object with no errors. I read it into memory using msdn's method, but for some reason this function still comes back with E_FAIL. Here's some of my code:

 

ifstream is(TEXT("DX10RendererEffect.fxo"), ios::binary);

is.seekg(0, ios_base::end);

streampos pos = is.tellg();

is.seekg(0, ios_base::beg);

char * effectBuffer = new char[pos];

is.read(effectBuffer, pos);

HRESULT hr;

if (FAILED(hr = D3D10CreateEffectFromMemory((void*)effectBuffer, pos, 0, softObjPtr->pD3D10Device, NULL, &softObjPtr->pD3D10Effect))){

return;
}

 

Also, I've created my device using the D3D10DEBUG_DEVICE flag (something like that), but the function doesn't say anything besides E_FAIL, that on msdn says that means the debug layer is not installed.

 

I don't know if this matters but I'm on a fresh in stall of Windows 7 and I just installed Windows 8.1 SDK. It's a hassle because all the D3DX helper functions are removed, so I can't compile from file, and must use a build rule on visual studio to compile my fx files manually. And the D3D sdk is completely merged with Windows SDK, so I can't tell if the debug layer was installed or not, it should have been right? Any suggestions?


[C#] Getting ray from mouse position

16 November 2012 - 02:59 AM

I'm trying to build a small game in Unity and I ran into this problem. I want to use an unlocked cursor in the game meaning that the look at vector of the camera would not exactly point to the cursor. This is the default setting in Unity it's done by not locking the cursor the center of the screen and simply using the offset, instead the camera moves by the distance that the user moved the cursor. This allows me to use a hardware cursor in the game and also I kind of like the feel of it since the game I have in mind involves a lot of 3D picking. So the problem is that when I try to actually shoot a ray from camera through the cursor (converted to 3D position) the shooting vector is off by a lot at certain camera angles and very close to what it's supposed to be at other angles. I'm not sure what's causing it, this is the code I have so far (except from a Unity C# script)
vector3 v = Camera.ScreenPointToRay(mousePos)
ray = v.direction;

I'm not exactly sure how to fix this or even why it's happening. I suspect that the conversion of the 2D cursor to 3D space results in a false Z value in some camera orientation but I don't exactly how to fix it. Any help appreciated

PARTNERS