Jump to content

[Stopped] please close Post if you want.


Recommended Posts

hi !

In my attempt to try make a realistic 747 gear system, induced by Cpt.Kipard gear , and Orbitus pluggin !!

I know exactly how to make this type off gear now, with the Firespitter plugin !!

I Have a model working well, and it's have the same specification than a 747 gear.

Without charge the wheel are inclined , and on charge everything move accordingly with

the wheel collider .

But to achieve this I need to use the FxlooK stock module !!

this module is too simple , he work only with global reference in KSP , so if he is linked or reference an

object with animation , the module ignore the orientation reference off the parent and keep

the X and Y relative to global orientation, he manage only Z in local orientation.

And it's really a pity ..

And this how a revised module should be :

MODULE

{

name = FXModuleLookAtConstraint

CONSTRAINLOOKFX

{

targetName = Wheel_REAR

rotatorsName = AxleBeam

targetAxisRefName =Parent (with animation) <- to keep the local reference of the parent if parent have animation

}

}

If someone have time to do this sort of pluggin .:blush:....

Because I have to say it's very cool to see the gear in action on ground, but

(caused by the stock module, when the gear raise), it's bad because object

mesh managed by the stock module keep the global orientation during animation.....

With a revised Fxlookatconstraint, the are much more possibility to have a good variety

of realistic gear in KSP ...

In action :

ISzaCgL.gif

steph

Edit : 17h49

And Fxlookatconstraint win the battle , I give up, this f:huh: module is just good for simple suspension car!!

Sometime is possible to avoid the bug movement during main animation but you loose on the other side on other movement !

it's possible to manage torque link I have the solution, but it's break the hierarchy in blender you have object non moving but

moving only in KSP (not very good for modif), and that demand a whole of bunch of FXposition etc ...

Conclusion it's possible to make a gear like (my picture gif) with Firespitter..

but small part don't move well during gear animation !! or demande so much effort for nothing it's just ridicule !

with a good module Fxlookatconstraint, working in parent reference that give a much simplest hierarchy, and you

keep all thing correctly linked with main animation, but for now it's not the case .....

bye !

Edited by stephm
If it's a request bad section so removed request
Link to comment
Share on other sites

hi !

Looking with monodevelop in the code of FxlookAtConstraint :

I 'll try to retrieve the principal function (transform) : LookAt

This is the actual code :

//
// FxLookATII.cs
//------------------------------------------------------------------------------

using UnityEngine;

namespace GameData.Plugins
{
public class FxLookATII : PartModule
{
// Object reference
[KSPField]
public string Source;

[KSPField]
public string ConstrainedObject;

// ------------------------------------
private Transform source;
private Transform target;

//
private bool initialized = false;

public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);

if (HighLogic.LoadedSceneIsFlight)
{
source = this.part.FindModelTransform(Source);
target = this.part.FindModelTransform(ConstrainedObject);

if (source != null && target != null)
{
//Debug.Log("start init");
initialized = true;
}
}
}

public override void OnUpdate()
{
if (initialized)
{
//Debug.Log("OnUpdate working");
// Orient the Z axis source to target in theory
Vector3 up = Vector3.up;
source.LookAt (target.transform, base.transform.up);
}
}
}
}

With debug line I have checked if ksp acces to the plugin it's ok.

No error on this side.

but its nothing appends !

Any idea ?

thk

Edit Looking in UNITY doc :

Description

Rotates the transform so the forward ( ok for that it's the Z axis) vector points at /target/'s current position.

Then it rotates the transform to point its up direction vector in the direction hinted at by the worldUp vector. If you leave out the worldUp parameter, the function will use the world y axis. worldUp is only a hint vector. The up vector of the rotation will only match the worldUp vector if the forward direction is perpendicular to worldUp.

If someone have possibility to translate in French it would be great !!, difficulty to understand underligned text !

I have just try this : source.LookAt(target); -> result no action !!!

steph

Edited by stephm
Link to comment
Share on other sites

hello! bonsoir !

New test, this time I try to learn with the excellent taraniselsu 's tuto on this Github page.

And the result is a bunch of Null reference object, not from this example hopefully :D but in my attempt to adap

my test based on LookAt...

I'm trying to use Config.node, not a good idea at my level I think !!!!!!!!!

Purpose is evident match the stock module node.

this is the code :


using System;
using UnityEngine;

namespace Plugins
{
public class FxLookAtRevI : PartModule
{
// variables
//
private String LoadSource;
private String LoadMovingObject;
private Transform TrSource;
private Transform TrMovingObject;
//
// check if cfg contains node
private bool TestLoad = false;
//
// node FxGroup
[KSPField(isPersistant = true)]
public FxGroup MyFxGroup;
//
public FxLookAtRevI()
{
if (MyFxGroup == null)
MyFxGroup = new FxGroup();
//
Debug.Log("Initialisation MyFxgroup");
}
//
//
public override void OnLoad(ConfigNode node)
{
//
Debug.Log("Essais MyFxGroup.load");
MyFxGroup.Load(node);
//
LoadSource = MyFxGroup.Source;
LoadMovingObject = MyFxGroup.MovingObject;
//
Debug.Log ("Source = " + LoadSource + " MovingObject = " + LoadMovingObject);
//
if (LoadSource != null)
TestLoad = true;
}
//
public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);
if (TestLoad)
{
TrSource = part.FindModelTransform(LoadSource);

TrMovingObject = part.FindModelTransform(LoadMovingObject);
}
}
//
//
public override void OnUpdate()
{
TrMovingObject.LookAt(TrSource);
}
//
// Class Config Node
//
[Serializable]
public class FxGroup : IConfigNode
{
[SerializeField]
public String Source = "Source";
[SerializeField]
public String MovingObject = "MovingObject";

public void Load (ConfigNode node)
{
if (node.HasValue ("Source"))
{
Source = node.GetValue("Source");
}
//
if (node.HasValue ("MovingObject"))
{
MovingObject = node.GetValue("MovingObject");
}
}

public void Save (ConfigNode node)
{
node.AddValue ("Source", Source);
node.AddValue ("MovingObject", MovingObject);
}
}
}
}

And this time looking in log file, the first ( Debug.Log("Initialisation MyFxgroup");) don't appear at all ..

In fact I'm stuck with the same problem (in the past) I'll encounter with script in 3DS, lack of understanding how

retrieve object from scene.........(and I have completely forget all script thing concerning 3ds lol)..

If someone have an idea :wink: (just learning purpose, I'm not here to became the best plugin maker :blush: **)

steph

(** in fact I have not enough knowledge and intelligent to achieve this goal lol)

Edited by stephm
Link to comment
Share on other sites

Now plugin is working, (in log), discovert and learned some tips about load, persistent data etc ..

this is new code :

//------------------------------------------------------------------------------
using System;
using UnityEngine;

namespace Skylon_MainGear.Plugins
{
public class FxLookAtRevI : PartModule
{
// variables
//
private String LoadSource;
private String LoadMovingObject;
private Transform TrSource;
private Transform TrMovingObject;
//
// check if cfg contains node
private bool TestLoad = false;
//
// node FxGroup
[KSPField(isPersistant = true)]
public FxGroup MyFxGroup;
//
public FxLookAtRevI()
{
if (MyFxGroup == null)
MyFxGroup = new FxGroup();
//
Debug.Log("Initialisation MyFxgroup"); // -> ok in log
}
//
//
public override void OnLoad(ConfigNode node)
{
//
Debug.Log("Essais MyFxGroup get data from cfg"); // -> ok in log
//
//LoadSource = LoadSource + MyFxGroup.Source; -> not working
LoadSource = MyFxGroup.Source; // -> not working
LoadMovingObject = MyFxGroup.getMovingObject; // -> not working
//
Debug.Log ("Source = [" + LoadSource + "] : MovingObject = [" + LoadMovingObject + "]");
//
if (LoadSource != "")
{
TestLoad = true;
Debug.Log ("Testload = true");
}
else
{Debug.Log("Tesload = false");} // -> ok in log ok because TestLoad=""
}
//
public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);
if (TestLoad)
{
TrSource = part.FindModelTransform(LoadSource);

TrMovingObject = part.FindModelTransform(LoadMovingObject);
}
}
//
//
public override void OnUpdate()
{
if (TestLoad)
TrMovingObject.LookAt(TrSource);
}
//
// Class Config Node
//
[Serializable]
public class FxGroup : IConfigNode
{

public String Source;
public String MovingObject;

public void Load (ConfigNode node)
{
if (node.HasValue("Source"))
{
Source = node.GetValue("Source");
}
//
if (node.HasValue("MovingObject"))
{
MovingObject = node.GetValue("MovingObject");
}
}

public void Save (ConfigNode node)
{
node.AddValue("Source", Source);
node.AddValue("MovingObject", MovingObject);
}
// just for learning test
public String getMovingObject {
get {
return MovingObject;
}
}
}
}
}

I know now value are not loaded from cfg, and the bool TestLoad prevent error in OnLoad and OnStart (I hope)

Not sure but still some Null reference object in log.

section of log :

[LOG 09:34:08.110] Initialisation MyFxgroup
[LOG 09:34:08.124] Essais MyFxGroup get data from cfg
[LOG 09:34:08.125] Source = [] : MovingObject = []
[LOG 09:34:08.125] Tesload = false

At this state I haven't enough clue to find a path on whatever happens !!!

I think I have an error in the FxGroup Class, I'm looking here

about config.node , and it's seem correct in monodevelop ?

The error in my opinion is around this :

- LoadSource = MyFxGroup.Source;

If someone have an idea ....

EDIT :21/08/14

Stopped, I'm back a little with KSP playing with 0.24.2 and some wonderfull mods I haven't tested yet

Close Post please.

bye

steph

Edited by stephm
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...