Tutorial on making weapons?

The place to discuss all things Lugaru.
weirdman338
Posts: 7
Joined: Wed Dec 31, 2008 4:47 pm

Tutorial on making weapons?

Post by weirdman338 » Thu Jan 01, 2009 5:12 pm

Is there a tutuorial on making weapons? I would really like to learn. I have a few weapon Ideas.

Everyone has to start our somwere eh?

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Re: Tutorial on making weapons?

Post by rudel_ic » Thu Jan 01, 2009 8:38 pm

This info is related to x2solid, a tool you shouldn't use. Use Brainfart instead, and read this post:
viewtopic.php?p=68751#p68751

--------------------------------------

This is from the top of my head, I haven't made a model for half a year or so.

Assuming you're doing it with Blender:

1. Model your weapon. Handle is at (0,0,0), tip points towards -X (I think, I always forget this one)
2. Convert all faces to triangles
3. Generate a UV map
4. Take a screenshot of the UV map when all faces are selected to later paint the texture on that screenshot (UV map has to have power of two height and width)
[Note: There are other ways to do this, just gave you that one for the sake of simplicity]
5. Save your model
6. Scale your model up to DimX>1000
7. Apply scaling and rotation (!)
8. Invert all normals
9. Export to X
10. Convert with x2solid.java, rename, paint texture, copy over, done
Addendum: Mirror your texture vertically after painting it

In-depth tutorials and other useful posts that may or may not help:
How to get an imported weapon working with the help of Blender (Contains Blender Hotkey Reference)
How to omit crashing models
How to scale and invert for weapon export
How to generate a UV map
How to invoke x2solid from a terminal
Why only Blender produces working X files
Why you have to mirror your texture as the last step
This topic should be helpful in general if you ignore the original post
This topic is where the converter was born (helpful info in there, dig by yourself)
This topic has links you need (Stay away from Brainfart though, it's not what you want)

If you're a Windows dude, do conversion of X files with x2solid like this:

Code: Select all

Windows users:
You can drag 'n drop multiple .X files onto the batch file
DRAG_X_FILES_HERE.bat
if the batch file and .class files are in the same directory.
Ask if you can't figure out some step or have other questions. Good luck!
Last edited by rudel_ic on Sat Jan 24, 2009 6:37 pm, edited 1 time in total.

weirdman338
Posts: 7
Joined: Wed Dec 31, 2008 4:47 pm

Re: Tutorial on making weapons?

Post by weirdman338 » Fri Jan 02, 2009 11:36 pm

Wow tyvm

*bows* Thank you! YOUR A GOD!

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Re: Tutorial on making weapons?

Post by rudel_ic » Sat Jan 03, 2009 8:09 am

Stay away from subdivision though. A way of modeling weapons that worked well for me is extruding cube faces over and over until you approximate the target shape well enough, then translating individual vertices and / or smoothing vertex groups.

Subdivision can really break your weapon model - Lugaru potentially crashes with a subdivided weapon.

There are some specific shapes that just don't work, for example cones should be a problem. At least they were the last time I made something with x2solid.

There are other mystic problems as well; if you have something that breaks, please post about it so that everybody can contribute to solutions.

And please don't give up after your first broken model. This all isn't easy, but it's also not rocket science, you just have to figure some stuff out in the first few sessions.

weirdman338
Posts: 7
Joined: Wed Dec 31, 2008 4:47 pm

Re: Tutorial on making weapons?

Post by weirdman338 » Sat Jan 03, 2009 11:56 am

Thanks for the info.

kpmwrestler
Posts: 6
Joined: Thu Jan 01, 2009 3:45 am

Re: Tutorial on making weapons?

Post by kpmwrestler » Thu Jan 08, 2009 8:30 pm

Hey I followed your tutorial and everything is working great but the character isn't actually holding the weapon. The weapon is facing the correct direction in the game, but it's in the air a small distance away from the character's hand. The handle is on 0, 0, 0 in Blender, so what would the problem be?

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Re: Tutorial on making weapons?

Post by rudel_ic » Thu Jan 08, 2009 9:02 pm

Make sure the center of the object is on (0,0,0) as well.

You have to be in Object mode for the following stuff. If you're in Edit mode, press TAB.

Then select your weapon (right-click on it), then press H to hide it.
Then Left-click on (0,0,0), then press Shift-S and choose "Cursor -> Grid", make sure it's on 0 on all axes by switching perspective (7, 1, 3 on the NUMBLOCK). If it's not on 0 from some perspective, click on (0,0,0) again with the left mouse button, press Shift-S and choose "Cursor -> Grid".

Once you're certain the cursor is on (0,0,0), press ALT-H to unhide your weapon.

Then, with the mouse over the 3D window, provided your weapon is selected, press SPACE, choose "Transform" -> "Center Cursor".

That sets the weapon's center to (0,0,0) because that's where the cursor is.

Please report whether that fixes it.

Edit: Some info:
The representation of an object's center is a pink dot, by the way. You cannot manipulate that representation directly, hence the instructions above.
The cursor thingie is the crosshairs which you place with LMB in Object mode, and if you snap it to grid, you make certain it's not on (0.000132,0,0) or something.
If you wouldn't hide the weapon, left-clicking on its center would result in translating the weapon instead of setting the cursor.

All this is something you have to get used to in Blender. I'm sure there are other ways of accomplishing this, for example using Empties as helpers instead of the cursor or something, but I got used to doing it this way.

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Re: Tutorial on making weapons?

Post by rudel_ic » Thu Jan 08, 2009 9:23 pm

I will be on IRC for an hour or so to help you if you need further assistance:

http://blog.wolfire.com/2008/09/wolfire-irc-channel/

kpmwrestler
Posts: 6
Joined: Thu Jan 01, 2009 3:45 am

Re: Tutorial on making weapons?

Post by kpmwrestler » Thu Jan 08, 2009 11:11 pm

Awesome thanks it works perfectly now. The pink dot wasn't inside the weapon. Now there's only one thing, the weapon kinda sinks into the ground when dropped and it almost completely disappears. What would cause this?

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Re: Tutorial on making weapons?

Post by rudel_ic » Thu Jan 08, 2009 11:22 pm

I don't know. Would you post the weapon? Put the .blend and the .solid into a ZIP and attach that to your post.

kpmwrestler
Posts: 6
Joined: Thu Jan 01, 2009 3:45 am

Re: Tutorial on making weapons?

Post by kpmwrestler » Fri Jan 09, 2009 9:46 am

Alright I'll also include my baseball bat that has the same problem
Attachments
Weapons.zip
(201.48 KiB) Downloaded 127 times

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Re: Tutorial on making weapons?

Post by rudel_ic » Fri Jan 09, 2009 5:33 pm

It looks like you forgot to invert the normals. So you see the backfaces of your weapons (the faces pointing inwards). If you then drop it on the floor, since the backfaces go into the floor and the front faces don't, but are invisible, it looks like your weapon is almost completely in the floor while it actually isn't.

Invert the normals before exporting and it should work.

User avatar
Stromboli
Posts: 95
Joined: Mon Dec 29, 2008 10:11 am

Re: Tutorial on making weapons?

Post by Stromboli » Fri Jan 09, 2009 11:19 pm

Just backing rudel up on the whole subdivision thing, it REALLY screws up your model. As in screws up the whole game because the vertices of the weapon are flying all over the screen. I have no better way to describe it: maybe I'll take a screenshot.

User avatar
Lotus Wolf
Posts: 2218
Joined: Sun Aug 31, 2008 6:03 pm

Re: Tutorial on making weapons?

Post by Lotus Wolf » Fri Jan 09, 2009 11:51 pm

Awe... Damn... I'm sorry Stromboli, i hadn't been aware of the subdivision thing, my [big] bad. :oops:

i've had a problem of my own, but i got past it. i'm not sure what it is, but sometimes [rarely] i end up with a UV map that doesn't stay on the grid, i'm not sure how else to describe it, but to fix, i've just selected a different UV map technique from the menu, here's a screenshot of an off-the-grid map:
Image
dunno why it happens, but i fixed it with "Lightmap UV Pack" instead of "Unwrap (Smart Projection)", needless to say, it didn't work out so well for an object in lugaru, but at least it's functional.

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Re: Tutorial on making weapons?

Post by rudel_ic » Sat Jan 10, 2009 12:52 am

Yeah, I had that problem with UV maps as well occasionally when I was making tests. I'm fairly certain that it's related to the broken X exporter in Blender. Good thing you found a fix; maybe some other UV map generating algorithm fixes that as well and produces better maps?

Haven't touched my code for some time, but the fact that COLLADA models are far more reliable should be an indicator that somewhen, I'll release a Brainfart that can handle models from other modeling suites, won't be susceptible to the now rampant bugs from X export and so forth.

The point I'm at right now is that COLLADA can be imported in principle, but the mapping to my internal format isn't done yet (that's necessary for conversion). The reason for this is that I am coding my own stuff right now. But rest assured that things will get better, easier, more transparent.

Post Reply