mirror of
https://github.com/thes3m/XNI
synced 2024-12-26 13:26:06 +01:00
Lerp added to vectors.
git-svn-id: http://xni.googlecode.com/svn/XNI@115 ac433895-eea3-a490-d80a-17149a75e588
This commit is contained in:
parent
e60555acd2
commit
a5e7c0f9ff
@ -85,6 +85,9 @@ static NSArray *drawOrderSort;
|
||||
|
||||
// Get the game host.
|
||||
gameHost = (GameHost*)[UIApplication sharedApplication];
|
||||
|
||||
// Initialize game window.
|
||||
[self.window initialize];
|
||||
}
|
||||
|
||||
return self;
|
||||
@ -115,9 +118,6 @@ static NSArray *drawOrderSort;
|
||||
// METHODS
|
||||
|
||||
- (void) run {
|
||||
// Initialize game window.
|
||||
[self.window initialize];
|
||||
|
||||
// Create the graphics device so we can finish initialization.
|
||||
graphicsDeviceManager = [services getServiceOfType:[Protocols graphicsDeviceManager]];
|
||||
graphicsDeviceService = [services getServiceOfType:[Protocols graphicsDeviceService]];
|
||||
|
@ -34,6 +34,7 @@
|
||||
+ (Vector4*) subtract:(Vector4*)value1 by:(Vector4*)value2;
|
||||
+ (Vector4*) multiply:(Vector4*)value by:(float)scalar;
|
||||
+ (Vector4*) transform:(Vector4*)value with:(Matrix*)matrix;
|
||||
+ (Vector4*) lerp:(Vector4*)value1 to:(Vector4*)value2 by:(float)amount;
|
||||
|
||||
- (float) length;
|
||||
- (float) lengthSquared;
|
||||
|
@ -98,6 +98,12 @@
|
||||
return [Vector4 vectorWithStruct:&resultData];
|
||||
}
|
||||
|
||||
+ (Vector4 *)lerp:(Vector4 *)value1 to:(Vector4 *)value2 by:(float)amount {
|
||||
Vector4Struct resultData;
|
||||
Vector4Lerp(value1.data, value2.data, amount, &resultData);
|
||||
return [Vector4 vectorWithStruct:&resultData];
|
||||
}
|
||||
|
||||
- (float) length {
|
||||
return Vector4Length(self.data);
|
||||
}
|
||||
|
@ -39,6 +39,8 @@
|
||||
+ (Vector2*) transform:(Vector2*)value with:(Matrix*)matrix;
|
||||
+ (Vector2*) transformNormal:(Vector2*)value with:(Matrix*)matrix;
|
||||
|
||||
+ (Vector2*) lerp:(Vector2*)value1 to:(Vector2*)value2 by:(float)amount;
|
||||
|
||||
- (float) length;
|
||||
- (float) lengthSquared;
|
||||
|
||||
|
@ -102,6 +102,13 @@
|
||||
return [Vector2 vectorWithStruct:&resultData];
|
||||
}
|
||||
|
||||
+ (Vector2*) lerp:(Vector2*)value1 to:(Vector2*)value2 by:(float)amount {
|
||||
Vector2Struct resultData;
|
||||
Vector2Lerp(value1.data, value2.data, amount, &resultData);
|
||||
return [Vector2 vectorWithStruct:&resultData];
|
||||
}
|
||||
|
||||
|
||||
- (float) length {
|
||||
return Vector2Length(self.data);
|
||||
}
|
||||
|
@ -68,4 +68,12 @@ static inline void Vector2TransformNormal(Vector2Struct *value, MatrixStruct *ma
|
||||
Vector2Set(result,
|
||||
(value->x * matrix->m11) + (value->y * matrix->m21),
|
||||
(value->x * matrix->m12) + (value->y * matrix->m22));
|
||||
}
|
||||
|
||||
static inline void Vector2Lerp(Vector2Struct *value1, Vector2Struct *value2, float amount, Vector2Struct *result) {
|
||||
if (amount <= 0) *result = *value1;
|
||||
if (amount >= 1) *result = *value2;
|
||||
Vector2Set(result,
|
||||
value1->x + (value2->x - value1->x) * amount,
|
||||
value1->y + (value2->y - value1->y) * amount);
|
||||
}
|
@ -41,6 +41,8 @@
|
||||
+ (Vector3*) transform:(Vector3*)value with:(Matrix*)matrix;
|
||||
+ (Vector3*) transformNormal:(Vector3*)value with:(Matrix*)matrix;
|
||||
|
||||
+ (Vector3*) lerp:(Vector3*)value1 to:(Vector3*)value2 by:(float)amount;
|
||||
|
||||
- (float) length;
|
||||
- (float) lengthSquared;
|
||||
|
||||
|
@ -111,6 +111,12 @@
|
||||
return [Vector3 vectorWithStruct:&resultData];
|
||||
}
|
||||
|
||||
+ (Vector3 *)lerp:(Vector3 *)value1 to:(Vector3 *)value2 by:(float)amount {
|
||||
Vector3Struct resultData;
|
||||
Vector3Lerp(value1.data, value2.data, amount, &resultData);
|
||||
return [Vector3 vectorWithStruct:&resultData];
|
||||
}
|
||||
|
||||
- (float) length {
|
||||
return Vector3Length(self.data);
|
||||
}
|
||||
|
@ -86,4 +86,13 @@ static inline void Vector3TransformNormal(Vector3Struct *value, MatrixStruct *ma
|
||||
(value->x * matrix->m11) + (value->y * matrix->m21) + (value->z * matrix->m31),
|
||||
(value->x * matrix->m12) + (value->y * matrix->m22) + (value->z * matrix->m32),
|
||||
(value->x * matrix->m13) + (value->y * matrix->m23) + (value->z * matrix->m33));
|
||||
}
|
||||
|
||||
static inline void Vector3Lerp(Vector3Struct *value1, Vector3Struct *value2, float amount, Vector3Struct *result) {
|
||||
if (amount <= 0) *result = *value1;
|
||||
if (amount >= 1) *result = *value2;
|
||||
Vector3Set(result,
|
||||
value1->x + (value2->x - value1->x) * amount,
|
||||
value1->y + (value2->y - value1->y) * amount,
|
||||
value1->z + (value2->z - value1->z) * amount);
|
||||
}
|
@ -90,3 +90,13 @@ static inline void Vector4Transform(Vector4Struct *value, MatrixStruct *matrix,
|
||||
(value->x * matrix->m13) + (value->y * matrix->m23) + (value->z * matrix->m33) + (value->w * matrix->m43),
|
||||
(value->x * matrix->m14) + (value->y * matrix->m24) + (value->z * matrix->m34) + (value->w * matrix->m44));
|
||||
}
|
||||
|
||||
static inline void Vector4Lerp(Vector4Struct *value1, Vector4Struct *value2, float amount, Vector4Struct *result) {
|
||||
if (amount <= 0) *result = *value1;
|
||||
if (amount >= 1) *result = *value2;
|
||||
Vector4Set(result,
|
||||
value1->x + (value2->x - value1->x) * amount,
|
||||
value1->y + (value2->y - value1->y) * amount,
|
||||
value1->z + (value2->z - value1->z) * amount,
|
||||
value1->w + (value2->w - value1->w) * amount);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user