playMaker

Author Topic: Mega-Fiers Get Vertex Position  (Read 6119 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Mega-Fiers Get Vertex Position
« on: April 18, 2012, 02:10:37 AM »
Hi,

 I have been willing to make a full port of the fantastic Mega Fiers to PlayMaker, and lack of time simply prevented anything to happen until Scottyboombotz found a problem getting the vertex position out of a Mega-Fiers gameObject.

 http://hutonggames.com/playmakerforum/index.php?topic=1414.0

 So indeed, custom actions are required, and here is one to start with. This action will do exactly what the standard GetVertexPosition Does but will work with Mega-Fiers, else Mega.Fiers would cease working as you query for the vertex.

[EDIT] Had a word with Chris West, and I have updated the custom action to better use the api.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Mega-Fiers")]
[Tooltip("Gets the position of a vertex in a Mega-Fiers GameObject.")]
public class MegaFiersGetVertexPosition : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(MegaModifiers))]
[Tooltip("The GameObject to check.")]
public FsmOwnerDefault gameObject;

[RequiredField]
[Tooltip("The index of the vertex.")]
public FsmInt vertexIndex;

[Tooltip("Coordinate system to use.")]
public Space space;

[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Store the vertex position in a variable.")]
public FsmVector3 storePosition;

[Tooltip("Repeat every frame. Useful if the mesh is animated.")]
public bool everyFrame;

public override void Reset()
{
gameObject = null;
space = Space.World;
storePosition = null;
everyFrame = false;
}

private MegaModifiers megaModifiers;

public override void OnEnter()
{

var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
megaModifiers = go.GetComponent<MegaModifiers>();

if (megaModifiers == null)
{
LogError("Missing MegaModifiers!");
return;
}


DoGetVertexPosition();

if (!everyFrame)
{
Finish();
}
}

public override void OnUpdate()
{
DoGetVertexPosition();
}

void DoGetVertexPosition()
{


if ( megaModifiers !=null)
{
switch (space)
{
case Space.World:
var position = megaModifiers.sverts[vertexIndex.Value];
storePosition.Value = megaModifiers.gameObject.transform.TransformPoint(position);
break;

case Space.Self:
storePosition.Value = megaModifiers.sverts[vertexIndex.Value];
break;
}
}
}
}
}

If you have any questions, or requests, feel free to post

Bye,

 Jean
« Last Edit: April 19, 2012, 01:36:05 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mega-Fiers Get Vertex Position
« Reply #1 on: April 19, 2012, 01:37:13 AM »
Hi,

 Just a post to mention that I update the custom action, for a better usage of the Mega-Fiers api,

Thanks top Chris West for his tips.

 Bye,

 Jean

iPetProjectDev

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Mega-Fiers Get Vertex Position
« Reply #2 on: May 16, 2012, 09:16:37 PM »
More MegaFiers stuff puh-leeeze. All these systems are putting my 3D app into the dirt for functionality;)

TIA

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mega-Fiers Get Vertex Position
« Reply #3 on: May 17, 2012, 01:09:28 AM »
Hi,

 Mega-fiers is on the target for a real treat, but I have pending projects, and I can only take that much... So I'd like to finish my vectrosity set of actions, release an alpha preview of my guiml system and then I will tackle Mega Fier!

 As always, pm me of course if do need actions now.

 Bye,

 Jen

devotid

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Mega-Fiers Get Vertex Position
« Reply #4 on: July 25, 2012, 02:32:59 PM »
Jeanfabre...... You are as valuable as the internet....when it comes to Playmaker.:)

Thanks so much for all you do.

Kevin
devotid

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Mega-Fiers Get Vertex Position
« Reply #5 on: July 26, 2012, 02:20:19 AM »
is this meant to work with all the Mega-Fiers? I used bend on a fishing rod test and used get vertex position for the tip of the rod & positioned a cube on the tip (so i could see if it worked) the cube moves to the position of the rod tip when bending but the rod no longer bends.  :(

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mega-Fiers Get Vertex Position
« Reply #6 on: July 26, 2012, 04:51:54 AM »
Hi,

 uhm odd, using my actions should not affect the mega fiers at all. Would you be able to share that scene so that I can debug that?

 As far as I can tell, this action works on all mega fiers modifiers yes.

bye,

 Jean