Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

118 lines (96 sloc) 3.268 kB
//
// SSAbstractObject.m
// GLKit_TD3D
//
// Copyright (c) 2011 71Squared
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "SSAbstractObject.h"
#import "AssetManager.h"
#import "btBulletCollisionCommon.h"
#pragma mark - Private Interface
@interface SSAbstractObject ()
@end
#pragma mark - Public Implementation
@implementation SSAbstractObject
@synthesize gameSceneController;
@synthesize assetManager;
@synthesize shader;
@synthesize state;
@synthesize position;
@synthesize direction;
@synthesize speed;
@synthesize modelMatrix;
@synthesize model;
@synthesize collisionObject;
@synthesize shield;
- (id)initWithScene:(SSGameSceneController *)aGameScene {
self = [super init];
if (self) {
}
return self;
}
- (void)updateWithDelta:(GLfloat)aDelta {
// Implemented in inheriting class
}
- (void)render {
// Implemented in inheriting class
}
- (void)collidedWithObject:(SSAbstractObject*)aObject
{
// Implement in inheriting class
}
- (void)collidedWithCollisionGroup:(short)aCollisionGroup
{
// Implement in inheriting class
}
- (void)setPosition:(GLKVector3)aPosition
{
position = aPosition;
// If there is a collision object for this model then we need to set the position to match that of the model
if (collisionObject) {
collisionObject->getWorldTransform().setOrigin(btVector3(position.x, position.y, position.z));
}
}
- (void)createCollisionObject
{
// Create a new collision object
collisionObject = new btCollisionObject();
// In case it's important to get information from the objects instance, assigning a reference to self
// allows the instance involved within a collision to be queried
collisionObject->setUserPointer((__bridge void*)self);
}
- (void)addToCollisionWorld:(btCollisionWorld*)aCollisionWorld
{
if (collisionObject && !inCollisionWorld)
{
aCollisionWorld->addCollisionObject(collisionObject, collisionGroup, collisionMask);
inCollisionWorld = YES;
}
}
- (void)removeFromCollisionWorld:(btCollisionWorld*)aCollisionWorld
{
if (collisionObject && inCollisionWorld)
{
aCollisionWorld->removeCollisionObject(collisionObject);
inCollisionWorld = NO;
}
}
@end
Jump to Line
Something went wrong with that request. Please try again.