123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|550|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> help: calculating entity size

Sat, 24 May 2008, 17:09
mindstorm8191
Hi. For those of you who don't know me, I have been working steadily on a project called Garbage Invaders, a sort of space ship-based RPG. I have created a function to calculate the size of a ship, as a radius, which I need for proper combat operations. The routine works, but only sort of. I get different values as the ship spins around.

I have created an alpha demo of the game, you can download it here: www.dannysgames.com/project/files/garbageinvaders_alpha1.zip. Just unzip all the files into its own folder and run the executable. All you can really do right now is attach the parts to the ship (drag and drop them on the base ship entity). Once you attach and install the thrusters you'll be able to turn around (rotates to mouse) and move with WSAD.

As for the radius problem, you can press 1 at any time, and a white sphere will be drawn under the ship (you can press it again to recalculate). As the ship spins around, you'll notice the sphere changing size. Here is some code that I use to the ship's radius:

I hope all that makes sense. I will appreciate any help I can get with this problem. If you have any questions, please ask. All this radius calculating is needed so that I can do collisions between bullets and ships. I'll have to wait until bullets have cleared the entity that fired them before I can enable collisions on them. So the more accurate this is, the better.

Thanks in advance.

-=-=-
Vesuvius web game
Sun, 25 May 2008, 12:04
Orion Pax
NUTS...why does everyone use windowed mode in 3d? Mindstorm...add a commandline switch to will disable windowed mode for me and I will check it out for ya.
Sun, 25 May 2008, 15:02
mindstorm8191
Oh - dang, sorry about that. I've added a version that supports full screen - just type -f at the command prompt, and you're all set. Just note, though, there's a few stop statements in there, so if the screen jumps back to the desktop, just hold escape while you return to the game, and it'll exit.

Edit: the url for the new version is the same.

-=-=-
Vesuvius web game
Sun, 25 May 2008, 16:08
Orion Pax
Ok I have never messed with banks yet but there is one thing that has my eye.



Wouldnt that just overwrite the old value of size# with each iteration? Wouldnt you need something like size[y]?

And your not adding or subtracting anything with your variable size#. Unless that is being done with the bank commands.

So you have me stumped. I have never used bank commands and dont really understand them yet. Never used peek and poke commands yet either.
Sun, 25 May 2008, 19:43
Orion Pax

Line 1 = # surfaces
Line 2 = # verts
Line 3 = VertexX(Surf,5)
Line 4 = VertexY(Surf,5)
Line 5 = VertexZ(Surf,5)
Line 6 = TfromedX() OF VertexX()
Line 7 = TformedY() OF VertexY()
Line 8 = TformedZ() OF VertexZ()

VertexX,Y,Z does give the LOCAL coordinates. As in the location of the vertex on the mesh. Not GLOBAL space. So placing a pivot at vertex,y,z will not get you its GLOBAL space. If you move your object to 100,100,100 and use vertexx,y,z you will get a number similar to 0,1,0. My sphere there is not resized so it might produce a different number if you resize it.

So in order to get the GLOBAL coordinates you have to use TFORMEDPOINT/TFORMEDX,Y,Z to get it. Just placing a pivot there wont do.



A sphere at its default size is 1x1x1 units. so vert 1 is always located at 0,1,0 or directly NORTH. A sphere resized by 10 is 10x10x10 and its NORTH pole is at 0,10,0. Just tested. If your getting the same number between vertexX,y,Z and entityX,Y,Z(pivot,false) then that us just a coincedense that your vertex is NEAR the center of GLOBAL Space. Move your mesh 10 spaces in any direction and I BET you will get still get the same number as before.
Mon, 26 May 2008, 19:26
mindstorm8191
Orion, about your question. You should note the function max() at the start of that statement. All this does is calculate the distance of the 'current' point, and if its larger than the size#, it replaces. If not, size# will remain the same.

I thought I would let everyone know I figured everything out now. The real trouble was that parts could be rotated, and since local rotations weren't factored into where the parts were located, the results were wrong. I ended up using a pivot parented to the part, at the vertex's location, and then getting the pivots global coords. This time my results didn't vary, but the size was always a bit too small - so I decided to scale it up a bit, which seems to work, for now. Orion, thanks for the help in the mudchat the other day. Using a pivot verses TFormedPoint gives the same values actually, though I'll probably switch to using TFormedPoint later as it'll save on some speed.

I've come down to other issues relating to the project. They're tied up with the thrusters on the ship, but they're keeping me from adding more detail to the game... in some ways. Its hard to explain. My plan is to eventually have all parts be ultimately controlled by the components in them. Each part (for example, a thruster) will have a small set of components it needs in order to operate, each component controlling the parts overall performance. All the components in the game will have different levels, like leveling up in an RPG game. The trouble is, deciding how the components affect thrusters has so far been difficult, because it only has one control value - output power. I want to add a new output that controls how quickly its thrust can shift around, and with this, I can finish the scripting file that decides all the level values for the components.

If all that doesn't make sense, you honestly don't have to worry about it. What I'm in need of is a ship control system that varies its output slowly. Say you're rotating quickly left, and want to begin rotating right. It'll take some time to slow down and go the other direction. That much would be easy, but the ships are always pointing towards a mouse - no direct human input. The hard part will be to have the ships slow down its rotation gradually to get the ship to look at where the mouse is pointing. Another challenge I'm looking at is more related to lateral thrusters. The ship can rotate to face any direction, and key presses will let the user move the ship about. Instead of just an acceleration value, I want to impose a max speed, which the user can adjust to vary between accel and max speed.

So yeah, all this is pretty complicated. If anyone would be interested in helping me with this project, just let me know and I'll be glad to pull them on board, so to speak.

-=-=-
Vesuvius web game
Tue, 27 May 2008, 13:54
Orion Pax
The pivot idea is a temp and lucky fix. As I stated its just luck that placing the pivot at the VertexX,Y,Z of your vertex is giving you the same result. VertexX,Y,Z just gives you its location on the mesh. TformedPoint WILL give you the verts location in space. Eventually you will get another problem that wont yield the results you need because of it. Just better to go ahead and take care of that before its forgotten and your scratching your head wondering what it is.