Forum Archive

Go Back   3D Realms Forums > General Topics > Programming Forum
Blogs FAQ Members List Social Groups Calendar Mark Forums Read

Notices

 
 
Thread Tools
Old 01-12-2005, 05:42 PM   #1
Arvidq
Guest
\'C\" code help to zoom or pan
I'm writing a Windows utility to look at Duke Maps. It's written in 'C' (not C++) and I'm using SetViewPort and SetWindowsExt to zoom and pan the output on the screen. It works OK to a point, but needs some help.

I can click somewhere on the map and it will center on that point, but when I try to zoom in or out, it zooms on the original viewport center, not on the selected point.

I need additional code that will allow me to zoom on a particular point.

I would also like to draw a rectangle around a spot and zoom that to fill the screen.

Any help would be appreciated.
 
Old 01-12-2005, 06:26 PM   #2
DudeMiester

DudeMiester's Avatar
Re: \'C\" code help to zoom or pan
Is this WIN32, OpenGL, Direct3D? What API are you calling?

Also, what's your current algorism/code? Hard to help if I don't know what how you're doing this.
__________________
Forums are the Opiate of the Masses
Higher Game -- "Animal fur is renewable, unlike the oil used to make plastic!"
DudeMiester is offline  
Old 01-13-2005, 11:11 AM   #3
Arvidq
Guest
Re: \'C\" code help to zoom or pan
This is simple Win32 'C' code using Visual Studio 6.0.

I'm using the following code to set the window extents and the viewport extents:

//******************************************
// Draw map on output device
//******************************************
void DrawMap (HDC hdc, HWND hwnd, int Scale)
{
if (bMapfile) // If we have a map file, draw it
{
SetMapMode (hdc, MM_ISOTROPIC);
SetWindowExtEx (hdc, iMaxext, iMaxext, NULL);
SetWindowOrgEx (hdc, 0, 0, NULL);
SetViewportOrgEx (hdc, ixViewport, iyViewport, NULL);
SetViewportExtEx (hdc, Scale, -Scale, NULL);

ShowWalls(hdc, hwnd, map);
}
}

Initially, I draw a square representing the 'field' as seen in BUILD, with a dotted line bisecting it to show the center of the field. This center is set by the Window and Viewport Orgs. If I ZOOM in or out, it ZOOMs based on this center point. If I click any where on the map, it re-centers on the screen using that new point. However, if I ZOOM again, it still uses the original center point, making the area you're looking at wander off the screen as you continue to ZOOM. I want it to use the new point as the center so when you ZOOM, the area you're looking at ZOOMs in and out based on that point. I tried all kinds of values for the 'SET' functions and can't get it to center properly.

Second problem - I have 'right click and drag' set to draw a dotted line box. I would like to be able to draw a box, then zoom that area of the map to fit the screen.

Third problem - (probably fixed if I fix the 1st problem) - if you print the map, it prints the enitre thing, even if you'r looking at a ZOOMed portion. I want to be able to print exactly what you're looking at on the screen.

I had posts on Deja.com (now Google supporteed) in 1999 and also Codeproject.com, Experts Exchange, Google searches and a few more, but all I can find are C++ routines. I need 'C'.

If you can help and need additional info, which might be too long for a post, you can email me at: qvigsan@louisville.stortek.com

Thanks in advance...
 
Old 01-13-2005, 08:21 PM   #4
DudeMiester

DudeMiester's Avatar
Re: \'C\" code help to zoom or pan
Not terribly familier with that part of WIN32, but if I was to hazard a guess I would say switch the two Viewport commands. As for printing it, you'll probably have to crop out the part you're looking at to a seperate bitmap, and print that.
__________________
Forums are the Opiate of the Masses
Higher Game -- "Animal fur is renewable, unlike the oil used to make plastic!"
DudeMiester is offline  
Old 01-14-2005, 01:56 PM   #5
Arvidq
Guest
Re: \'C\" code help to zoom or pan
I'm not sure what you mean by switching the Viewport commands, but I think I may have tried that. I spent a lot of time changing the commands and values, but never got anything to work properly. I think I've read almost everything on the web I could find relating to this, with no success.

I'd really like to see some sample code, if anyone has some that works. Maybe that will show me what I'm doing wrong.

The program (I call it Dukeshow) does work for everything except proper zooming. I sent a copy to the 3D Repository for evaluation. I've been told a few people will look at it for any possible changes. Once that is complete, it will be put into the repository as a freeware utility. It would be nice to have everything working by then.

Thanks for looking at this and maybe you could ask some friends if they know anything about Windows coordinate space functions in 'C'.
 
Old 01-14-2005, 08:39 PM   #6
DudeMiester

DudeMiester's Avatar
Re: \'C\" code help to zoom or pan
I meant switch the order, set the origion before you set the scale, so the viewport scales at the point you want. The way it is now I would expect it to scale at the origion (0, 0) first, then moves off a bit, which would produce the effect you describe.
__________________
Forums are the Opiate of the Masses
Higher Game -- "Animal fur is renewable, unlike the oil used to make plastic!"
DudeMiester is offline  
Old 01-17-2005, 09:45 AM   #7
Arvidq
Guest
Re: \'C\" code help to zoom or pan
I tried to reply this weekend from home, but the Forum said I didn't have permissions to do that. I'm logged in from work now and it says I can. I'll have to contact the web master and find out why...

I tried switching as you said (along with a dozen other tries) and so far, no luck. All this extra testing showed some extra lines of code I could delete because they didn't make a difference (nice to clean up code).

I guess for now I'll just have the utility put on the 3D Repository site (after the reviews are completed). Maybe someday someone who knows more about it than me will try the utility and show me how it's done.

Thanks for your efforts.
 
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:37 PM.

Page generated in 0.12086606 seconds (100.00% PHP - 0% MySQL) with 18 queries

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.

Website is 1987-2014 Apogee Software, Ltd.
Ideas and messages posted here become property of Apogee Software Ltd.