Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Defend

Member Since 10 Jun 2004
Offline Last Active Mar 12 2013 02:24 PM

Topics I've Started

Unity: Beginner asking advanced question about interacting with dynamic slopes

18 February 2013 - 09:22 AM

I've only recently started learning how to use Unity and 3D development tools in general, so this question is pretty naive about what can and can't be done. 

 

Basically, can I create an scene with an interactive character running around, where the landscape changes shapes beneath the character's feet and the character 1. stays connected to the land, and more importantly 2. reacts to the gradient beneath his feet as said gradient is changing. 

 

For example, imagine the following takes place over 4 seconds:

 

Attached File  curvingFloor2.jpg   7.8KB   31 downloads

 

In the 2nd step, the character should start being pulled down the slope due to the change in gradient.

In the 3rd step, assuming some magical force is keeping their feet on the inverted ground, they are still being affected by the new gradient but less severely, as the gradient here is more shallow than the 2nd image.

 

Is this hard to do in Unity?

If it isn't too hard, could someone give a quick and general semi-layman's terms description of how?

 

 

Cheers

 

 


DirectX - Where did my window icon go after fullscreen?

23 September 2010 - 08:58 AM

I thought I'd post this here as I don't know if it's really a problem of DirectX code. EDIT - This is a DirectX issue, as it turns out.

Basically my window can toggle between windowed and fullscreen mode fine, saving previous position and state. But one thing I don't know how to bring back is the little window icon up in the top-left. The one that brings up the restore, move, size, etc menu.

I'm not sure where in my code the mistake is, because I'm missing something fundamental it seems. But here are some snippets: EDIT - The following code snippets are fine really. The problem doesn't exist unless DirectX changes the display mode.

Creating the icon:
    WNDCLASS wc;
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
Before changing the display mode for fullscreen mode:
        SetWindowLongPtr(g_parentWindow, GWL_style, WS_POPUP|WS_VISIBLE); 
SetWindowPos(g_parentWindow, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
Before changing the display mode for returning to windowed mode:
        if (g_maximised)
SetWindowLongPtr(g_parentWindow,
GWL_style,
WS_OVERLAPPEDWINDOW
|WS_CLIPCHILDREN
|WS_MAXIMIZE
|WS_VISIBLE);
else
SetWindowLongPtr(g_parentWindow,GWL_style,WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_VISIBLE);

SetWindowPos(g_parentWindow,
HWND_NOTOPMOST,
viewCopy.left,
viewCopy.top,
viewCopy.right - viewCopy.left,
viewCopy.bottom - viewCopy.top + (g_statBarIsOn?statRec.bottom:0),
SWP_FRAMECHANGED);


The results are the same whether the window is maximised or not.

I imagine the solution is simply a necessary call that I'm missing... but I don't know what that is. :S Cheers. :)

[Edited by - ApochPiQ on September 25, 2010 1:04:37 PM]

Win32 - Callbacks and globals - Any advice to avoid too many globals?

14 September 2010 - 09:54 AM

Using a typical parent window with a couple of children, my callback functions need to know things like handles of other windows, backbuffer sizes, positioning structures and what have you.

I find that I'm starting to get too many globals, and the resulting mess that comes from having globals. I need one to save the window position when it goes full screen, and 2 more for the menu and status bar status. And 4 more for the various windows themselves, and one for the renderer. ... Too much. :/ But I don't know how I'm supposed to call any of my functions from the Callback functions otherwise.

Any tips?

String issues and MENUITEMINFO

02 September 2010 - 08:45 PM

VC++2008, Win32, Directx9

I'm trying to build a menu dynamically in run-time, based on available video resolutions.

The MENUITEMINFO struct needs a LPWSTR for its dwTypeData. Not a LPCWSTR, but LPWSTR.

I have a line of strings and ints that I can turn into a wstring without hassle, but from there I'm just not sure.




cout << i << ": " << painterBBSizes[i].cx << "x" << painterBBSizes[i].cy << endl;


MENUITEMINFO mitemInfo;

std::wstringstream labelStream;
std::wstring label;

labelStream << painterBBSizes[i].cx << " x " << painterBBSizes[i].cy;
label = labelStream.str();

LPTSTR dest = CT2W(label.c_str());

ERRORPOP(label.c_str()); // Outputs correctly.
ERRORPOP(dest); // Outputs gibberish.

mitemInfo.cbSize = sizeof(MENUITEMINFO);
mitemInfo.fMask = MIIM_TYPE|MIIM_ID|MIIM_DATA;
mitemInfo.fType = MFT_STRING;
mitemInfo.fState = NULL;
mitemInfo.wID = ID_END_THEGREATESTID + 1 + i;
mitemInfo.hSubMenu = NULL;
mitemInfo.hbmpChecked = NULL;
mitemInfo.hbmpUnchecked = NULL;
mitemInfo.dwItemData = NULL;
mitemInfo.dwTypeData = dest; // Outputs the same gibberish.
mitemInfo.cch = sizeof(dest);

InsertMenuItem(g_menu, ID_END_THEGREATESTID, false, &mitemInfo);

The result is gibberish.
ERRORPOP() requires a LPCWSTR.



Anyone see the problem? Cheers.

Win32 fullscreen popup menu behaving badly.

02 September 2010 - 04:50 AM

Using C++ in VS2008, I'm at the beginnings of a DirectX program which can so far display a token image and flip between fullscreen and windowed mode with no problems.

It has a menu bar, which goes invisible as expected in fullscreen mode. The ALT key still worked to activate this menu in fullscreen, but it was very clumsy since its items weren't visible until highlighted, and even then it only responded to about 1 in 5 presses of the ALT key.

So I decided to implement a popup menu instead, that responds to the right mouse button. My problem is that this popup menu is also temperamental in fullscreen mode. It also messes with the custom cursor I am using.

The wrong behaviour is defined as follows:

A right click anywhere will active the popup menu, but also deactive the custom cursor and replace it with the system default.

Once the menu is visible, RIGHT-clicking outside of the menu will deactivate it, but this leaves the default cursor on. However, right-clicking again will activate the menu again, and this continues perfectly if not for the missing custom cursor.

Once the menu is visible, LEFT-clicking outside of the menu will deactivate it, and this displays the custom cursor again. Now it gets a bit more messy because now:
3a· If I right-click, it will return to step 1. Menu on + cursor off.
3b· If I left-click a second time (as if I am gaining focus or something), then right-click, will will activate the default cursor but NOT active the menu (as if I half did and half didn't regain focus or something). Menu off + cursor off.
3c· If I move the mouse and then right-click, it will do one of the above. I can't determine why yet. Step 1 or step 3b. Menu on + cursor off, or menu off + cursor off. Frustrating.

The most visible problem is that once step 3b occurs (menu off + cursor off), the user can flip the custom cursor on and off forever. Left click on, right click off. Not only does the menu never appear, but this is simply not what I want a user to be seeing in my program... the cursor changing for no reason.

I imagine the cursor changing is to do with the menu itself taking focus or something like that. I would like that to be avoided if possible, but the real problem is why is the menu activation temperamental in the first place?

My code for the popup menu is:

TrackPopupMenu(GetSubMenu(g_menu,0), TPM_LEFTALIGN|TPM_HORPOSANIMATION,
30, 30, 0, g_parentWindow, NULL);
I don't think it has much to do with this really, but I don't know what else to look at.

One more thing. If I use F4 to active the menu instead, the cursor behaviour is similar but the menu almost never appears at all. However, I can click on the space where the menu should appear, and sometimes the "selected" option appears then vanishes again.

Problem 1: Can I make the menu activate reliably?
Problem 2: Can I stop the cursor from changing?
Problem 3: Why does a key command function even worse?

Thanks for the read. Any ideas?

PARTNERS