Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 9 Vote(s) - 4.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Work in progress Katamari: The dark descent (Update 16/11)
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#45
RE: Katamari: The dark descent (Update 24/06)

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.

Fixing AddAttachedPropToProp once and for all:
Spoiler below!

This is the function in question from the wiki:
AddAttachedPropToProp(string& asPropName, string& asAttachName, string& asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);
The problem with it: afPosZ is not used for Z position! Rather afRotZ is used for both Z position and ZX rotation.

The initial solution to this problem was to create a new function:
void AttachProp(string& asPropName, string& asAttachName, string& asAttachFile, float afPosX, float afPosY, float afPosZ)
{
  AddAttachedPropToProp(asPropName, asAttachName, asAttachFile, afPosX, afPosY, 0, afPosZ, 90, afPosZ);
}
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:
void AddAttachedBaseToProp(string propName, string baseName, string baseFile)
{
   AddAttachedPropToProp(propName,baseName,baseFile,0,0,0,0,-90.0f,0);
}
The second function then assumes you are attaching props to this base:
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.)
06-24-2012, 05:01 PM
Find


Messages In This Thread
RE: [WIP] Katamari: The dark descent - by Mosnye - 07-31-2011, 01:04 AM
RE: [WIP] Katamari: The dark descent - by Kyle - 07-31-2011, 01:32 AM
RE: [WIP] Katamari: The dark descent - by Apjjm - 07-31-2011, 01:35 AM
RE: Katamari: The dark descent - by skypeskype - 07-31-2011, 05:56 PM
RE: Katamari: The dark descent - by MrCookieh - 07-31-2011, 06:17 PM
RE: Katamari: The dark descent - by Kyle - 07-31-2011, 07:18 PM
RE: Katamari: The dark descent - by DamnNoHtml - 07-31-2011, 08:35 PM
RE: Katamari: The dark descent - by Cryaotic - 07-31-2011, 08:38 PM
RE: Katamari: The dark descent - by skypeskype - 08-01-2011, 10:27 AM
RE: Katamari: The dark descent - by Your Computer - 07-31-2011, 10:33 PM
RE: Katamari: The dark descent - by Apjjm - 08-01-2011, 01:12 AM
RE: Katamari: The dark descent - by bobbo - 08-01-2011, 01:35 PM
RE: Katamari: The dark descent - by Your Computer - 08-02-2011, 12:58 PM
RE: Katamari: The dark descent - by DamnNoHtml - 08-01-2011, 01:31 AM
RE: Katamari: The dark descent - by Tanshaydar - 08-01-2011, 02:20 AM
RE: Katamari: The dark descent - by Frost - 08-01-2011, 12:59 PM
RE: Katamari: The dark descent - by Mosnye - 08-02-2011, 08:09 AM
RE: Katamari: The dark descent - by Tenno - 08-02-2011, 08:11 AM
RE: Katamari: The dark descent - by Apjjm - 08-02-2011, 05:05 PM
RE: Katamari: The dark descent - by Your Computer - 08-02-2011, 06:24 PM
RE: Katamari: The dark descent - by darkadders - 04-10-2012, 02:26 PM
RE: Katamari: The dark descent - by Furix - 08-22-2011, 08:58 AM
RE: Katamari: The dark descent - by skypeskype - 08-23-2011, 03:39 PM
RE: Katamari: The dark descent - by Mosnye - 08-24-2011, 12:50 AM
RE: Katamari: The dark descent - by Henriksen - 08-30-2011, 05:09 PM
RE: Katamari: The dark descent - by Jinxi - 11-25-2011, 11:48 PM
RE: Katamari: The dark descent - by Homicide13 - 04-09-2012, 05:47 AM
RE: Katamari: The dark descent - by Apjjm - 04-09-2012, 01:06 PM
RE: Katamari: The dark descent - by Homicide13 - 04-09-2012, 11:12 PM
RE: Katamari: The dark descent - by Adrianis - 04-09-2012, 11:12 PM
RE: Katamari: The dark descent - by Apjjm - 06-09-2012, 06:01 PM
RE: Katamari: The dark descent - by Statyk - 06-10-2012, 12:07 AM
RE: Katamari: The dark descent - by Apjjm - 06-10-2012, 02:26 AM
RE: Katamari: The dark descent - by Statyk - 06-10-2012, 03:03 AM
RE: Katamari: The dark descent - by Apjjm - 06-10-2012, 03:40 AM
RE: Katamari: The dark descent - by Science - 06-10-2012, 06:04 AM
RE: Katamari: The dark descent - by Statyk - 06-10-2012, 07:02 AM
RE: Katamari: The dark descent - by Adny - 06-10-2012, 11:48 AM
RE: Katamari: The dark descent (Update 24/06) - by Apjjm - 06-24-2012, 05:01 PM



Users browsing this thread: 1 Guest(s)