Game Development Community

Gun Zoom Optics

by raa brubb · in Torque 3D Beginner · 03/28/2014 (3:28 pm) · 21 replies

Does anyone have any idea on how the freak to create gun zoom optics? I'm lost and I have no idea how it's gonna get done. Next problem after this is creating a air combat system and vechiles with weapons. This sucks...
Page «Previous 1 2
#1
03/28/2014 (3:49 pm)
?? Right now you have right-click-to-zoom - do you mean something like "the view through a scope?" If that's the case, try making a black mask image the size of your screen and then when you zoom just push it as a GUI element in front of the playGui control.
#2
03/28/2014 (7:52 pm)
OK, great thanks. However, I do have 3 questions:

1. Where/how can I make/find a GUI? What do I need to get one? Would GIMP work?

2. I looked into the zooming and essentially all it's doing is zooming into the image your looking at. It's all pixelized and its not really a scope.

3. Which directory is the zoom script? I'm not quite sure how to add it for a specific weapon.

Thanks so much for your help!
#3
03/30/2014 (8:43 pm)
Bump
#4
03/30/2014 (9:15 pm)
from \game\art\datablocks\weapons\proxmine.cs
datablock ProximityMineData( ProxMine )
{...
   reticle = 'blank';
   zoomReticle = 'blank';
};

fill in the blank (dodges tomatoes)

example from lurker:
datablock ItemData(Lurker)
{...
   reticle = "crossHair";}
see also the \game\scripts\server\weapon.cs
function WeaponImage::onMount(%this, %obj, %slot)
{...
if (%obj.client !$= "" && !%obj.isAiControlled)
         %obj.client.RefreshWeaponHud(%currentAmmo, %this.item.previewImage, %this.item.reticle, %this.item.zoomReticle, %amountInClips);
\game\scripts\client\client.cs
clientCmdRefreshWeaponHUD
pair.
#5
03/31/2014 (6:46 am)
Quote:2.
I looked into the zooming and essentially all it's doing is zooming into the image your looking at. It's all pixelized and its not really a scope.
Actually it is considerably more complicated than that - it's changing several things and using depth-of-field, so the point you're "zooming" on is clear but things around it might be blurred.
Normal:
www.roostertailgames.com/images/screenshot_001-00001.png"Zoom":
www.roostertailgames.com/images/screenshot_001-00002.pngDetail is fine, except some areas in the far background from the "zoomed" point.
Terrain material settings are important - double-check to be sure your detail texture view distance isn't dropping off too soon if your terrain looks "blurry" when you zoom in on it. In these images the detail distance is set to 150.

Quote:
1. Where/how can I make/find a GUI? What do I need to get one? Would GIMP work?
I'm guessing you mean the actual sight/scope overlay image - and sure, beg, borrow, steal, or make your own. Of course GIMP would work - you just need an image that the engine supports and that can support transparency. I recommend using png. Making your own means you don't have to worry about licensing.
#6
03/31/2014 (10:49 am)
Hmm... so I should sketch an idea for a GUI, create it in blender somehow and then what? How basically to I input the picture and receive information such as ammo?
#7
03/31/2014 (1:13 pm)
Read the documentation - look under Gui Editor/Tutorials....

As far as what to modify in your game project, the in-game UI is located in game/art/gui/playGui.gui.
#8
04/01/2014 (11:16 pm)
For the weapons I can probably find some scope views online and finish it up on GIMP 2.8. I have looked at the documentation already and it doesn't quite tell me how to create the scope for a gun. I just need to have a separate GUI file for every gun that tells which scope to use for each gun. As far as I know, I'm lost with these script files because I don't know C#.

Dane it.
#9
04/02/2014 (6:23 am)
It's not C# - it's TorqueScript. Don't be fooled by the .cs extension; Torque used it several years before Microsoft did - it stands for "c script."

No, the GUI tutorials don't tell you how to do exactly what you're trying to do - they tell you how to edit a GUI. Once you know how to edit a GUI you can make any GUI you want. So don't just "look at" the tutorials - do them. Work through them, then branch out on your own a little. Us primates learn this way....

From your posts you seem very enthusiastic - use that enthusiasm, temper it with patience, and you will go far.
#10
04/02/2014 (10:19 am)
Ohhh... I'll try out the GUI tutorials. The biggest problems is I'm not usually on my computer that can run Torque3D. I'm usually on my laptop trying to make models.

It gets me lost, so it is a little stressful.

I did some level design, my game will be and FPS game with the normal air combat, armored vechiles, ground battles, open maps (not open-source), and releastic graphics. Trying to achieve at least that before I move on.
#11
04/02/2014 (10:39 am)
Quote:
with the normal air combat, armored vechiles, ground battles, open maps (not open-source), and releastic graphics.
Oh, is that all? ;)

If your laptop is powerful enough to run a 3D modelling application what's holding you back from running Torque on it? Is it a Mac, or is the video accelerator one of the ones that T3D doesn't like?
#12
04/02/2014 (2:01 pm)
Well, it barely runs Blender which I'm using for models and stuff. I already have about 10 gun models that need to be animated and stuff. I also need to get MakeHuman for characters and find military reference pictures. There is a lot too do.

My laptop is a crappy Intel GMA Integrated Graphics. I tried running Torque3D on it but it was unbearable. It really stops me from game development.

I'm currently making models like jet fighters, tanks, helicopters, guns. I need those for the game. I did level design of a map I plan on executing soon. What really concerned me was if I was able to create gun zoom optics. I just don't know how to integrate this.

Sorry, I'm still learning.
#13
04/02/2014 (5:04 pm)
I'm amazed it runs T3D at all - it generally doesn't get along with the Intel integrated chipsets....

Basically, the simplest way to create a scope optic effect is to just insert a gui bitmap object in front of the player's face. art/gui/playGui.gui is the file that contains the default HUD - tweak and play with it until you understand how it works. Don't be afraid to experiment - hell, make a new project just to try something out, then use what you learn in your main project.
#14
04/02/2014 (5:41 pm)
@richard it works well on intel iris pro 5200. Our mac programmer can run the scene at a solid 100fps or so.
#15
04/02/2014 (5:54 pm)
I got time to use my computer today and its coming along great. I have to finish the basic level before I bombard meshes on it, but its coming along. I didn't yet mess with the HUD, but do you think playGui.gui has options to add a picture as a HUD when zoomed? And also for a specific weapon? I need to animate these meshes.

However, I do have two questions that are a bit off topic.
1. Can you use Make Human to create a full-fleged "character"? I need it to create soldiers for my game.
2. Do you know where I can find free military clothes images? I need them for the PhysX clothing I will apply to the Make Human models.

Thanks a lot!

EDIT: I just found where it says the weapon HUD, but it doesn't really give info on the zoom...

new GuiBitmapBorderCtrl(WeaponHUD) {
      isContainer = "0";
      Profile = "ChatHudBorderProfile";
      HorizSizing = "right";
      VertSizing = "top";
      position = "78 693";
      Extent = "124 72";
      MinExtent = "8 8";
      canSave = "1";
      Visible = "1";
      tooltipprofile = "GuiToolTipProfile";
      hovertime = "1000";
      canSaveDynamicFields = "0";
#16
04/02/2014 (6:57 pm)
Sorry, hadn't realized you were that unfamiliar with the codebase.

From gamescriptsclientclient.cs :
function clientCmdRefreshWeaponHUD(%amount, %preview, %ret, %zoomRet, %amountInClips)
{
   if (%ret $= "")
      Reticle.setVisible(false);
   else
   {
      Reticle.setVisible(true);
      Reticle.setbitmap("art/gui/weaponHud/"@ detag(%ret));
   }

   if (isObject(ZoomReticle))
   {
      if (%zoomRet $= "")
      {
         ZoomReticle.setBitmap("");
      }
      else
      {
         ZoomReticle.setBitmap("art/gui/weaponHud/"@ detag(%zoomRet));
      }
   }
}

What that means is that you've got a guibitmapCtrl named Reticle, and one named ZoomReticle.

the .setBitmap("art/gui/weaponHud/"@ detag(%zoomRet)) line means you're setting the bitmap of the respective gui elements by concatenating the directory, and a passed variable (in this case a local, denoted by that %). So all you'll need to do, presuming a stock fps example codebase is drop your textures in the

art/gui/weaponHud/

Directory, then referencing them with the appropriate item for your weapon using those reticle and zoomreticle entries. The codebase goes ducking and weaving about a bit in a couple additional spots, but that's the core of what you'll need to know if you're uninterested in altering the behavior.
#17
04/02/2014 (7:52 pm)
So assuming the file was in art/gui/weaponHud/, I would leave it as

ZoomReticle.setBitmap("art/gui/weaponHud/"@ detag(%zoomRet));

How do I set the specific .png file? Like this?

ZoomReticle.setBitmap("art/gui/weaponHud/M416.png"@ detag(%zoomRet));

So what I was also wondering is where do I place the specific weapon in the code?

Again, I'm really sorry for my noobiness. I'm way better in 3D modeling than scripting.
#18
04/02/2014 (8:07 pm)
artdatablocksweaponsyourfile.cs
(don't forget to list it in : artdatablocksdatablockExec.cs)

datablock ItemData(someGunItemName)
{...
   reticle = "someBitmapName";
   zoomReticle = "someOtherBitmapName";
...
   image = someGunImage; //<---the object that gets mounted to a player when you pick it up. Contains model file reference and the like.
...
}
datablock ShapeBaseImageData(someGunImage)
{

   // Projectiles and Ammo.
   item = someGunItemName; //<--- used to reference item info, such as zoom, or what to possibly throw on death
}
@ means concatenate (combine into a string). If you'd used the entry you gave, the result, which you could find by plugging in either:

error("art/gui/weaponHud/M416.png"@ detag(%zoomRet));
or echo("art/gui/weaponHud/M416.png"@ detag(%zoomRet));

would have been art/gui/weaponhud/m416.pngplussomevalueyoupass.
#19
04/03/2014 (1:03 pm)
Hmm... So where do I find these .cs files?

This is probably a stupid question but whats the difference between rectile and zoomRectile. I saw a weapon template in game/art/datablocks/weapons and was wondering if that is what I use.

Also, how do I animate the guns specifically for Torque3D and can I use MakeHuman?

Thanks again!
#20
04/03/2014 (2:38 pm)
In order to clear this up a bit, here are the steps:

1. Animate the weapon, get it game-ready.
2. Create a new script out of a template at art/datablocks/weapons/
3. Go into gamescriptsclientclient.cs and input the HUD settings.

I'm a little confused. Just tell me when to stop asking questions if I'm being annoying...


Thanks!
Page «Previous 1 2