Still got to fine-tune resizing behaviour a little more, as well as allow arbitrary rotations of props (based on how they are positioned in the level, as well as the rotation of the katamari). The attachment issue mentioned in the video is already fixed. I can now roll the katamari around a level and pick up pretty sizeable props by the end of it, so things are really starting to take shape now
I figured i'd get in the habit of writing out an occasional update whenever a milestone is met. Also, I finally worked out how to fix AddAttachedPropForProp so that all the parameters are use-able with no loss in precision.
Update as of 24/06/2012
Re-attachments on resize are now limited, so that only the last 60 or so props are re-attached (this makes a noticeable performance boost when you get to a large size and there were near 300 attachments!)
Made both my attachment list and my world entity list massively more efficient, giving a noticeable reduction in lag when re-attaching props and adding the collision callbacks.
Came up with a full fix for AddAttachedPropToProp which lets all position and rotation parameters be used correctly (the normal function ignores z position and uses z rotation for both position and rotation. Fix is outlined below).
Props are now rotated when they are attached, based on the rotation of the katamari, this makes the whole thing seem a lot more "ball like".
Props should no longer float when attached to the katamari as a side-effect of glancing collisions with very thin/small props.
Started work on a basic particle system when resizing (this is still very much a WIP as it is way too bright) [Thanks palistov for giving me a place to start with the particle editor too]
You can see a video of the rotation-based attachment here.
This let me attach props at the correct position without any Z-rotation, but there was still a rotation in y by 90 degrees, and rotating the attached prop is not possible. To get around this, I made is a 3-stage attachment method, split over two functions. The first function is designed to offset the 90-degree rotation by creating a base prop on which all attachments should be made:
string AddAttachedPropToBase(string &in asBaseName, string &in asAttachName, string &in asAttachFile, float posX,float posY, float posZ, float angX,float angY,float angZ)
{
//Generate a unique name for this level
AddLocalVarInt("DUMMY_ID",1);
string dummyName1 = "ATTACHMENT_DUMMY_" + GetLocalVarInt("DUMMY_ID");
//Attach the dummy prop, at the attachment position with cumulative 0,0,0 rotation
AddAttachPropToProp(asBaseName,dummyName1,"block_box.ent",posZ-angZ,posY,0,-posX,90,-posX);
//Attach the actual prop with the desired rotation
AddAttachedPropToProp(dummyName1,asAttachName,asAttachFile,0,0,0,angX,angY,angZ);
//Return the name of the dummy prop, so that if RemoveAttachedPropFromProp needs to be used,
//Instead of removing asAttachName, remove the returned dummy name instead to remove the prop.
return dummyName1;
}
This works, as recall the base has a position of (0,0,0) and rotation of (0,-90,0). For the next attached prop this means that "z" position is now "x" position and (-"x") is now "z". Using this knowledge, the dummy prop is added using the same approach as the initial fix with appropriate swapping of z and x components, and the 90 degree offset already corrected for by the base. Notice that posZ has angZ subtracted from it to offset the translation-by-bug which will be applied in the next step. At the end of the second attachment there is now a dummy prop is at position (posX,posY,posZ-angZ) with rotation (0,0,0).
The desired prop is then attached to the dummy prop at relative positon (0,0,angZ), with the desired rotation, giving a prop attached at (posX,posY,posZ) with angle (angX,angY,angZ).
With the tricky explanation out the way - An example, for attaching a barrel to another barrel:
void someFunction()
{
//Come up with some name for the base name - can just append "_base" to the end of each prop name.
string baseName = "barrel01_1_base";
//Create the base (you only need one base per prop)
AddAttachedBaseToProp("barrel01_1", baseName, "block_box.ent");
//Attach the prop to the base at (1,0,0) with rotation (45,45,45)
AddAttachedPropToBase(baseName,"barrel01_attachment","barrel01.ent",1,0,0,45,45,45);
}
(This post was last modified: 06-24-2012, 05:18 PM by Apjjm.)
I feel if I were to open the .hps to this mod, my computer would explode. I can only imagine what is going on in there.
Also, I never knew there was an issue with the AddAttachedPropToProp. May I ask what it was doing wrong? (unless it was what you said in the parenthesis)
(06-25-2012, 04:27 PM)Statyk Wrote: I feel if I were to open the .hps to this mod, my computer would explode. I can only imagine what is going on in there.
Also, I never knew there was an issue with the AddAttachedPropToProp. May I ask what it was doing wrong? (unless it was what you said in the parenthesis)
It's a bug where one parameter is used for two things (probably down to a typo in Amnesia source ). I wrote a topic when i first encountered the issue some time ago: http://www.frictionalgames.com/forum/thread-9358.html
I updated the wiki with the bug and the no-rotation fix the other day.
The hps source (after pre-processing) currently stands at 2872 lines, but 1800 of those lines are an automatically generated lookup table of information about entities.
(This post was last modified: 06-25-2012, 05:00 PM by Apjjm.)