LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2005, 11:19 AM   #1
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Rep: Reputation: 15
D3D Crosshair?


Hi again,

Just wondering is someone could give me some info on how to make a D3D crosshair in a 3D video game. This is not for cheating or anything like that... it is just for practice, in single player.

Thanks Again
 
Old 10-06-2005, 05:09 AM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
In what game? You mean a game from scratch? That could take a while. Maybe a few thousand lines just to create a window, initialize DX, handle inputs and load graphics...

If you just wanna know how it works, the concept of a crosshair is simple though: Simply set the mouse cursor to invisible, load an image with the cross-hair and let that be your "new" mouse cursor. Usually, it's done with a small image, where everything is black (or any other color, actually) but the cursor itself. You then tell DX to ignore the color at position 0,0 of the image, so only the actual cursor is displayed.

If you really want an example, download DX SDK. It comes with a few examples, but I highly doubt somebody would be kind enough to write thousand of lines to show how a cross-hair works

Last edited by Mega Man X; 10-06-2005 at 05:12 AM.
 
Old 10-06-2005, 05:40 AM   #3
Viper-Inc
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0
i think he just wants to replace the game crosshair (the gun crosshair to where you are aiming) with something else.

like a cross +
or a O with a dot in it
or just a dot.

i myself do not know how to do this and will be interested in hearing of how to do it as i have wondered this for quite some time.
 
Old 10-06-2005, 08:43 AM   #4
geeman2.0
Member
 
Registered: Feb 2005
Location: Ontario, Canada
Distribution: Gentoo, Slackware
Posts: 345

Rep: Reputation: 30
If you're trying to mod an existing closed source video game to do this then the solution is likely very complex and highly dependent on which particular game this is.
 
Old 10-06-2005, 09:39 AM   #5
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Viper-Inc
i think he just wants to replace the game crosshair (the gun crosshair to where you are aiming) with something else.

like a cross +
or a O with a dot in it
or just a dot.

i myself do not know how to do this and will be interested in hearing of how to do it as i have wondered this for quite some time.
Yes, that's what I ment... I am not making a game from scratch I would like this for an already made game in single player mode. I would just like to make a customized crosshair that is different to the in game one just an X or T with a little dot in the middle of it would be good. Anyway the game is battlefield2.

Last edited by InvisibleSniper; 10-06-2005 at 09:41 AM.
 
Old 10-07-2005, 12:34 PM   #6
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
I see. So technically speaking, this has really nothing to do with programming . And as geeman2.0, this kind of modification really depends of the game. As an example, Doom 3 core files are packed in .pak files. You can rename those files to .zip (or was it .rar), uncompress them, change whatever you want and repack them. That's pretty much the way every gun mod is done for Doom 3.

I've no experience creating mods. Just a little creating maps for Unreal Engine, so I'm not in a position to help or advice you with Battlefield. I would advice you searching google for tutorials modding Battlefield.

Regards!

Last edited by Mega Man X; 10-07-2005 at 12:37 PM.
 
Old 10-07-2005, 11:59 PM   #7
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Original Poster
Rep: Reputation: 15
What I really wanted to do was use D3D to add a crosshair, I know this is possible but I do not know how to do it. In other words, have my custom made D3D crosshair follow the in game crosshair moving as I move.

Isn't there some D3D functions that can inject code into the game? I basically want to write over the game's original crosshair with my own(different colour, different shape).

Last edited by InvisibleSniper; 10-08-2005 at 12:02 AM.
 
Old 10-08-2005, 01:29 AM   #8
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
D3D is a graphics API. It is not an API to "inject code into games." There are only a few ways off the top of my head that I could think of that what you want would be possible.
  • Download the BF2 mod tools and use those to change the graphics that the game itself loads from. I haven't really done much with these tools myself except to look at them briefly, so I'm not sure how you would do what you want offhand.
  • Create a separate D3D app with a window that would somehow sit on top of all other windows to display the crosshair. This seems pretty ugly and not even guaranteed to work with BF2 running fullscreen.
  • Put a piece of scotch tape in the middle of your monitor and draw your crosshair.

One other problem is that BF2 uses Punkbuster. So... if you try and use this on a server with Punkbuster enabled (and I believe all ranked servers have to enable Punkbuster) and you have modified your game files using the first method, I'm guessing that you would get kicked.
 
Old 10-10-2005, 12:25 AM   #9
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
I don't know about battlefield2, but if it uses the quake3 (or any ID engine), you can:

goto the folder base(q3, q3, something "base") and you'll find a base*.pk* (or *.pak). Rename this to base*.zip. Open it, and look for the crosshair .tga's. They are probably in the Sprites, or Grapics/SFX folder. When you locate them, find the crosshair that is the one you want to change in the game. Make a note of the location of the crosshair (the path + the filename), e.g. sprites/crosshairs/mycross.tga, and then use a program like The GIMP (www.gimp.org) to make your own crosshair. After you're finished with your crosshair, create a new pak file of your own called "mycrosshair.pk* (.pak)) and compress your crosshair.tga file into it with the same path and same name. It will then have replaced the crosshair with your own.

Here, I'll use quake3 as an example:

(1): Goto C:\program files\quake III Arena\baseq3
(2): Rename pak0.pk3 to pak0.zip (you may have to tell windows to show file extensions)
(3): Open pak0.zip with your fav' archiving program (WinZIP, WinRAR, etc...)
(4): In the archiving program, browse to the folder, gfx/2d/
(5): You will now see a few TARGA (.tga) images. The one we will focus on is "crosshaira.tga"
(6): Select and extract "crosshaira.tga", and open it with The GIMP or Photoshop
(7): Edit it to suit your needs
(8): Create a folder called "gfx"
(9): Browse into the newly created folder called "gfx" and create another folder called "2d"
(10): Save your image into this "2d" folder
(11): Create a new archive called "mycross.zip" and compress the "gfx" folder into it
(12): Rename "mycross.zip" to "mycross.pk3" and place it into the "baseq3" folder.
(13): Luanch the game and enjoy your new crosshair!


That is how it is done for Quake3. It will be almost the same thing for any ID engine. If it is some other 3D engine (like Unreal, or Halflife), then you'll have to get their custom archiving tools. But in the end, it is still really just the same thing.

Good luck!

Note: Punkbuster and other cheat detecting programs might see this change as a cheat, and therefor you might be kicked out of servers.

Last edited by The_Nerd; 10-10-2005 at 12:27 AM.
 
Old 10-10-2005, 12:35 AM   #10
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
BF2 doesn't use the Q3 engine. I believe it is an all new engine that Dice developed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
D3D Menu using C++ Viper-Inc Programming 0 10-05-2005 11:22 AM
WineX 4.0 [Cedega] Ragnarok Online "cannot init d3d or bad grf file" TonitoX2 Linux - Games 2 08-08-2004 06:58 PM
quake3 crosshair issue pld Linux - Games 1 02-16-2004 05:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration