Just trying to convert some Java code into Objective-C.
Here is a snippet of the code for the constructor of a class called 'bone' written in Java.
public class Bone {
public static double RADS_TO_DEGS =
Quaternion.RADS_TO_DEGS;
public static double DEGS_TO_RADS =
Quaternion.DEGS_TO_RADS;
public static int LUPA_4CC =
FourCCUtil.fourCCInt("LUPA");
public static int RUPA_4CC =
FourCCUtil.fourCCInt("RUPA");
public static int LLRA_4CC =
FourCCUtil.fourCCInt("LLRA");
public static int RLRA_4CC =
FourCCUtil.fourCCInt("RLRA");
protected float length;
protected Bone parent;
protected Bone[] childBones;
protected int fourCCName;
protected int parentFourCCName;
protected float[] translation;
Here is my attempt at rewriting this code in objective-c:
bone.h
@interface Bone : NSObject{
@property static double RADS_TO_DEGS;
@property static double DEGS_TO_RADS;
@property static int LUPA_4CC;
@property static int RUPA_4CC;
@property static int LLRA_4CC;
@property static int RLRA_4CC;
@protected {
@property float length;
@property Bone parent;
@property Bone[] childBones ;
@property int fourCCName;
@property int parentFourCCName;
@property float[] translation;
bone.m
@implementation VA_Bone
-(id)init{
self=[super init];
if(self){
VA_4ccUtil *FCC = [[VA_4ccUtil alloc] init];
VA_Bone *Bone = [[VA_Bone alloc] init];
VA_TRTransform *TRTform = [[VA_TRTransform alloc] init];
VA_TRUtil *TRUtil = [[VA_TRUtil alloc] init];
VA_Quaternion *Quat = [[VA_Quaternion alloc] init]];
[Bone setDEGS_TO_RADS: [Quat DEGS_TO_RADS]];
[Bone setRADS_TO_DEGS: [Quat RADS_TO_DEGS]];
[Bone setLUPA_4CC: [TRUtil fourCCInt:"LUPA"]];
[Bone setRUPA_4CC: [TRUtil fourCCInt:"RUPA"]];
[Bone setLLRA_4CC: [TRUtil fourCCInt:"LLRA"]];
[Bone setRLRA_4CC: [TRUtil fourCCInt:"RLRA"]];
[self setParent:NULL];
[self setFourCCName:0];
[self setParentFourCCName:0];
[self setTranslation:NULL];
[self setLength:0];
}
return self;
}
My questions are:
1) Have I declared the static methods correctly?
2) Is it possible to assign class types or is it better to use an array such as NSMutableArray instead of Bone[]?
I am still trying to get my head around how to construct a class in objective-c since I am currently converting some Java code into objective c.
Kind Regards, Sam