2004-06-11 00:24:03 +02:00
|
|
|
// JSInterface_Entity.h
|
|
|
|
//
|
|
|
|
//
|
2004-12-05 22:56:09 +01:00
|
|
|
// A JavaScript class representing a Pyrogenesis CVector3D object.
|
2004-06-11 00:24:03 +02:00
|
|
|
//
|
|
|
|
// Usage: Used when manipulating objects of class 'Vector3D' in JavaScript.
|
|
|
|
//
|
|
|
|
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
|
|
|
|
|
|
|
#include "scripting/ScriptingHost.h"
|
|
|
|
#include "Vector3D.h"
|
|
|
|
|
|
|
|
#ifndef JSI_VECTOR3_INCLUDED
|
|
|
|
#define JSI_VECTOR3_INCLUDED
|
|
|
|
|
|
|
|
namespace JSI_Vector3D
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
component_x,
|
|
|
|
component_y,
|
|
|
|
component_z
|
|
|
|
};
|
2005-03-29 00:13:47 +02:00
|
|
|
static CVector3D* GetVector( JSContext* cx, JSObject* obj );
|
2004-06-11 00:24:03 +02:00
|
|
|
JSBool toString( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
2005-03-29 00:13:47 +02:00
|
|
|
JSBool add( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool subtract( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool negate( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool scale( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool divide( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool dot( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool cross( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool length( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
JSBool normalize( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
struct Vector3D_Info
|
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
IPropertyOwner* owner;
|
|
|
|
void ( IPropertyOwner::*updateFn )();
|
|
|
|
void ( IPropertyOwner::*freshenFn )();
|
2004-06-11 00:24:03 +02:00
|
|
|
CVector3D* vector;
|
|
|
|
Vector3D_Info();
|
|
|
|
Vector3D_Info( float x, float y, float z );
|
2004-08-03 01:14:54 +02:00
|
|
|
Vector3D_Info( const CVector3D& copy );
|
2004-10-07 21:23:35 +02:00
|
|
|
Vector3D_Info( CVector3D* attach, IPropertyOwner* _owner );
|
|
|
|
Vector3D_Info( CVector3D* attach, IPropertyOwner* _owner, void (IPropertyOwner::*_updateFn)() );
|
|
|
|
Vector3D_Info( CVector3D* attach, IPropertyOwner* _owner, void (IPropertyOwner::*_updateFn)(), void (IPropertyOwner::*_freshenFn)() );
|
2004-06-11 00:24:03 +02:00
|
|
|
~Vector3D_Info();
|
|
|
|
};
|
|
|
|
extern JSClass JSI_class;
|
|
|
|
extern JSPropertySpec JSI_props[];
|
|
|
|
extern JSFunctionSpec JSI_methods[];
|
2005-03-29 00:13:47 +02:00
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
JSBool getProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp );
|
|
|
|
JSBool setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp );
|
|
|
|
void finalize( JSContext* cx, JSObject* obj );
|
|
|
|
JSBool construct( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
void init();
|
2004-06-22 15:22:46 +02:00
|
|
|
}
|
2004-06-11 00:24:03 +02:00
|
|
|
|
2004-06-18 20:49:12 +02:00
|
|
|
#endif
|
|
|
|
|