Jump to content

  • Log In with Google      Sign In   
  • Create Account

xycsoscyx

Member Since 15 Aug 2005
Offline Last Active Dec 22 2014 06:53 PM

Topics I've Started

Communication between programs

08 December 2008 - 02:47 PM

What is the best way to communicate between two separate programs? My situation is that I have a program running that has my main class (that handles everything). I also have an ActiveX control that can be loaded externally and will send messages (and sometimes get info back) from the main program. Normally, the main program has an embedded browser that creates the ActiveX object, but I wanted to be able to create that from seperate programs as well and still communicate. Previously, I was using Windows messages, I created a helper window in the main program and just sent messages to it. The problem was that in the embeded browser, everything works fine, but when another process tries to call the functions, nothing gets returned back. For instance, if I want a progress value, I pass a pointer (in either w/lParam of SendMessage) to a variable, then set that variable in the main program. As I said, this works if the ActiveX is created by the main program itself (I assume because it's in the same calling space and the same memory), but it doesn't work if another process created the ActiveX control and sent the messages. The other method I tried was a base interface for my main class. I used SetWindowLongPtr and set the user data of the helper window to a pointer of the main class. Inside the ActiveX control, I get that pointer (type casting to my interface) then call the functions directly. Again, this works when called from the embeded browser, but not from another program creating the ActiveX object. Is there any way to make that second method work (since it's simpler than having to send messages around)? As I said, I assume it's because I have a pointer, which is just a value that points to a memory location, but that memory is not the same between the two programs since it's not shared. Can I allocate it in a global memory location or can I call into the first process (the main program) from the secondary one?

Deferred Shading and Depth Reconstruction

31 December 2007 - 09:26 AM

Sadly, it seems like a lot of the threads on this are old, so I opted to open a new topic about it. I'm working on deferred rendering currently, and I wanted to be able to use the trick to get position from the depth value. I had this working using this method:
// Calculate Depth
Project = mul(Position, Transform);
Depth = Project.z / Project.w;
// Calculate Position
Project.xy = mathamagical;
Project.z = Depth;
Position = mul(Project, InvTransform);
The problem is that this creates the extra matrix multiplication each time I want to reconstruct the position (and the mathamgical part for calculating the XY based on the overlay texture coordinates is annoying as well and adds extra code). Instead of this, I opted to use the linear depth method:
// Calculate Depth
ViewSpace = mul(Position, View);
Depth = ViewSpace.z / FarClip
// Calculate Position
Position = ((ViewDir * Depth) + CameraPosition);
This works fine if my camera is not tilted (the rotation is the identity matrix), but if I try to turn, my lighting turns with it. Here's some screenshots: Correct, Wonky. I'm using code that MJP posted in another thread to calculate the corners of my far frustum plane, then passing those in as texture coordinates for my ViewDir value. Anyone have any idea why it's off like this? EDIT: Here's two screens showing the positions from the above images: Correct, Wonky. You can see that the values are literally turning with the camera, but I don't understand why (I assume I have to adjust my frustum corners perhaps?). [Edited by - xycsoscyx on December 31, 2007 3:46:29 PM]

Rotating Billboard Sprites

18 November 2007 - 08:20 PM

I'm working on (once again) implementing a particle system into my engine, but am having difficulty trying to rotate the sprites. Currently, I'm using a GPU method of offsetting the vertex positions. I have an array of particles with a position, color, spin, etc, and a vertex buffer that I render with (updating the vertices each frame with the particles new info). My question is, how do I spin those particles (I'm using just a single value for the spin, so it's basically spining it on the Z axis away from the camera)? Just to note, here's the snippet of my shader where I calculate the output vertex positions.
float fSpin = kVertex.t0.w;
float fSize = kVertex.t0.z;
float3 kXOffSet = float3( gs_kInvCameraMatrix._m00,
                          gs_kInvCameraMatrix._m10,			
                          gs_kInvCameraMatrix._m20);
float3 kYOffSet = float3( gs_kInvCameraMatrix._m01,
                          gs_kInvCameraMatrix._m11,
                          gs_kInvCameraMatrix._m21);

float3 kPosition = kVertex.o;
kPosition += (-kXOffSet * ((kVertex.t0.x - 0.5f) * fSize));
kPosition += ( kYOffSet * ((kVertex.t0.y - 0.5f) * fSize));
Currently, this code works great for rendering camera aligned billboards, I'm just not quite awake enough to try to add a spin to the sprites.

Removing pinned shortcuts from the Start menu

18 October 2007 - 10:51 AM

My title pretty much says it all, how do I remove a pinned shortcut from the Start menu (on XP and Vista)? I know I need to use the IShellBlah classes, IStartMenuPinnedList in particular (which is only available in the Vista Platform SDK), but how do I use it? Unfortunately, I have found little information (from Google or MSDN directly), but here's a snippet:
IShellItem *pkItem = NULL;
HRESULT hRetVal = SHCreateItemFromParsingName(TEXT("Path to the shortcut"), NULL, IID_PPV_ARGS(&pkItem));     
if(SUCCEEDED(hRetVal))
{
    IStartMenuPinnedList *pkList;
    hRetVal = CoCreateInstance(CLSID_StartMenuPin, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pkList));
    if(SUCCEEDED(hRetVal))
    {
	hRetVal = pkList->RemoveFromList(pkItem);
	pkList->Release();
    }

    pkItem->Release();
}
Simple, it creates a pointer to the IShellItem then removes it from the list. The problem is, I don't know the path to the shortcut, so how do I enumerate through the shortcuts in the pinned list? I found the SHCreateShellItemArray function, but this also requires a parent or source path info for creating the array, so how do I create an array for the pinned shortcut list? How was this done before the Vista Platform SDK (I assume uninstallers still removed their items from the list even before the Vista Platform SDK was released)?

Transformation Matrix

20 August 2007 - 07:20 AM

I'm working on a water effect pixel shader, but I'm make it so that it is less refracted depending on the depth of the water (so water at the shore doesn't refract much so that the image lines up with the true render of the scene). The problem is that there are too many instructions on my target platform (GPU ShaderAnalyzer says I'm using 65 instructions, and I have a max of 64 on my target hardware, which is just what I have at work currently)!! It seems like the best place to optimize is when I get the screen space coordinates, since I need to transform my position (first my regular vertex position to get the regular depth, then my perturbed position for reflection and refractions), then convert from -1 to 1, to 0 to 1. This results in a block like this:
float2 GetCoord(float4 kPosition)
{
	float4 kProject = mul(gs_kTransformMatrix, kPosition);
	float2 kScreen = (((kProject.xy * (1.0f / kProject.w)) + 1.0f) / 2.0f);
	kScreen.y = (1.0f - kScreen.y);
	return kScreen;
}
The Y = (1 - Y) is because I need to flip the texture when using it, but otherwise everything should be the standard code for getting the screen space coordinate from a world space point. Now, onto my actual question, is there any way I can put that addition math (((XY * (1 / W)) + 1) / 2), into the matrix itself, or at least put the Y = (1 - Y) into the matrix (hopefully shaving off a couple instructions)?

PARTNERS