bool GlobalObject::initStandardClasses(JSContext *cx) { JSAtomState &state = cx->runtime->atomState; /* Define a top-level property 'undefined' with the undefined value. */ if (!defineProperty(cx, state.typeAtoms[JSTYPE_VOID], UndefinedValue(), JS_PropertyStub, JS_StrictPropertyStub, JSPROP_PERMANENT | JSPROP_READONLY)) { return false; } if (!initFunctionAndObjectClasses(cx)) return false; /* Initialize the rest of the standard objects and functions. */ return js_InitArrayClass(cx, this) && js_InitBooleanClass(cx, this) && js_InitExceptionClasses(cx, this) && js_InitMathClass(cx, this) && js_InitNumberClass(cx, this) && js_InitJSONClass(cx, this) && js_InitRegExpClass(cx, this) && js_InitStringClass(cx, this) && js_InitTypedArrayClasses(cx, this) && #if JS_HAS_XML_SUPPORT js_InitXMLClasses(cx, this) && #endif #if JS_HAS_GENERATORS js_InitIteratorClasses(cx, this) && #endif js_InitDateClass(cx, this) && js_InitProxyClass(cx, this); }
SkyBoxObject::SkyBoxObject(void) : Object() , mSceneManager(NULL) , mMaterialName("BaseWhite") ,mDistance(5000) ,mDrawFirst(true) ,mOrientation(Ogre::Quaternion::IDENTITY) { if (createPropertyDictionary("SkyBox")) { static MaterialNameCmd materialNameCmd; defineProperty( "material", "the name of material", "Material", &materialNameCmd, PF_PRIMARY); static DistanceCmd distanceCmd; defineProperty( "distance", "the distance of skybox.", "Real", &distanceCmd, 0); static DrawFirstCmd drawFirstCmd; defineProperty( "draw first", "whether the box is drawn before all other geometry in the scene.", "Bool", &drawFirstCmd, 0); static OrientationCmd orientationCmd; defineProperty( "orientation", "Optional parameter to specify the orientation of the box", "Orientation", &orientationCmd, 0); } }
ModelObject::ModelObject(void) : PlacementObject() , mProxy(NULL) , mModel(NULL) , mModelName() , mAnimationLevel(50) , mCastShadows(false) , mSystem(NULL) { if (createPropertyDictionary("Model")) { static ModelNameCmd modelNameCmd; defineProperty( "model name", "The model filename use to create this model.", "ModelName", &modelNameCmd, PF_PRIMARY); addBaseProperty(); static AnimationLevelCmd animationLevelCmd; defineProperty( "animation level", "The animation level of this object.", "Real", &animationLevelCmd, 0); static CastShadowsCmd castShadowsCmd; defineProperty( "cast shadows", "Does this object cast shadows?", "Bool", &castShadowsCmd, 0); } }
LogicModelObject::LogicModelObject() : mLogicModel(NULL), mLogicModelName(""), mProxy(NULL) { if (createPropertyDictionary("LogicModel")) { static LogicModelNameCmd logicModelNameCmd; defineProperty( "logic model name", "The logic model filename use to create this logic model.", "LogicModelName", &logicModelNameCmd, PF_PRIMARY); } }
////////////////////////////////////////////////////////////////////////// // EffectObject class ////////////////////////////////////////////////////////////////////////// EffectObject::EffectObject(void) : PlacementObject(), mEffect(NULL) { if (createPropertyDictionary("Effect")) { static EffectNameCmd effectNameCmd; defineProperty( "effect name", "The effect template name use to create this effect object.", "effect template name", &effectNameCmd, PF_PRIMARY); addBaseProperty(); } }
////////////////////////////////////////////////////////////////////////// // BulletObject class ////////////////////////////////////////////////////////////////////////// BulletObject::BulletObject(void) : PlacementObject(), mBulletSystem(NULL) { if (createPropertyDictionary("BulletObject")) { static BulletSystemNameCmd bulletSystemNameCmd; defineProperty( "BulletSystemName", "The bullet system template name use to create this bullet object.", "bullet template name", &bulletSystemNameCmd, PF_PRIMARY); addBaseProperty(); } }
////////////////////////////////////////////////////////////////////////// // ParticleSystemObject class ////////////////////////////////////////////////////////////////////////// ParticleSystemObject::ParticleSystemObject(void) : PlacementObject(), mParticleSystem(NULL) { if (createPropertyDictionary("ParticleSystem")) { static ParticleSysNameCmd particleSysNameCmd; defineProperty( "particle system name", "The particle system template name use to create this particle system.", "ParticleSystemName", &particleSysNameCmd, PF_PRIMARY); addBaseProperty(); } }
ActorObject::ActorObject(void) : PlacementObject() , mProxy(NULL) , mActor(NULL) , mActorName() , mSystem(NULL) { if (createPropertyDictionary("Actor")) { static ActorNameCmd actorNameCmd; defineProperty( "actor name", "The actor filename use to create this actor.", "ActorName", &actorNameCmd, PF_PRIMARY); addBaseProperty(); } }
bool GlobalObject::initStandardClasses(JSContext *cx) { /* Native objects get their reserved slots from birth. */ JS_ASSERT(numSlots() >= JSSLOT_FREE(getClass())); JSAtomState &state = cx->runtime->atomState; /* Define a top-level property 'undefined' with the undefined value. */ if (!defineProperty(cx, ATOM_TO_JSID(state.typeAtoms[JSTYPE_VOID]), UndefinedValue(), PropertyStub, StrictPropertyStub, JSPROP_PERMANENT | JSPROP_READONLY)) { return false; } if (!js_InitFunctionAndObjectClasses(cx, this)) return false; /* Initialize the rest of the standard objects and functions. */ return js_InitArrayClass(cx, this) && js_InitBooleanClass(cx, this) && js_InitExceptionClasses(cx, this) && js_InitMathClass(cx, this) && js_InitNumberClass(cx, this) && js_InitJSONClass(cx, this) && js_InitRegExpClass(cx, this) && js_InitStringClass(cx, this) && js_InitTypedArrayClasses(cx, this) && #if JS_HAS_XML_SUPPORT js_InitXMLClasses(cx, this) && #endif #if JS_HAS_GENERATORS js_InitIteratorClasses(cx, this) && #endif js_InitDateClass(cx, this) && js_InitProxyClass(cx, this); }
SkyPlaneObject::SkyPlaneObject(void) : Object() , mSceneManager(NULL) ,mMaterialName("BaseWhite") ,mScale(1000) ,mTiling(10) ,mBow(0) ,mXsegments(1) ,mYsegments(1) ,mDrawFirst(true) { if (createPropertyDictionary("SkyPlane")) { static MaterialNameCmd materialNameCmd; defineProperty( "material", "the name of material", "Material", &materialNameCmd, PF_PRIMARY); static DrawFirstCmd drawFirstCmd; defineProperty( "draw first", "whether the box is drawn before all other geometry in the scene.", "Bool", &drawFirstCmd, 0); static BowCmd bowCmd; defineProperty( "bow", "bow of the plane.", "Ogre::Real", &bowCmd, 0); static ScaleCmd scaleCmd; defineProperty( "scale", "scale of the plane.", "Ogre::Real", &scaleCmd, 0); static TilingCmd tilingCmd; defineProperty( "tiling", "How many times to tile the texture(s) across the plane.", "Ogre::Real", &tilingCmd, 0); static PlaneCmd planeCmd; defineProperty( "plane", "the plane.", "Plane", &planeCmd, 0); static XsegmentsCmd xsegmentsCmd; defineProperty( "x segments", "the number of xsegments the plane will have to it", "Integer", &xsegmentsCmd, 0); static YsegmentsCmd ysegmentsCmd; defineProperty( "y segments", "the number of ysegments the plane will have to it", "Integer", &ysegmentsCmd, 0); } }
EnviromentObject::EnviromentObject(void) : Object() , mSceneManager(NULL) , mViewport(NULL) , mFogMode(Ogre::FOG_NONE) , mFogExpDensity(0.001f) , mFogLinearStart(0.0f) , mFogLinearEnd(1.0f) , mAmbientLight(Ogre::ColourValue::Black) , mBackgroundColour(Ogre::ColourValue::Black) , mFogColour(Ogre::ColourValue::White) , mWeatherParticleSystemName("") , mWeatherParticleSystem(NULL) , mWeatherParticleSystemNode(NULL) , mRenderWeather(true) { if (createPropertyDictionary("Enviroment")) { static AmbientLightCmd ambientColourCmd; defineProperty( "ambient", "The ambient light level to be used for the scene.", "ColourRGB", &ambientColourCmd, 0); static BackgroundColourCmd backgroundCmd; defineProperty( "background", "The background colour of the scene.", "ColourRGB", &backgroundCmd, 0); static FogModeCmd fogModeCmd; defineProperty( "fog.mode", "The fog mode", getEnumTypeString("FogMode", gsFogModeConstants), &fogModeCmd, 0); static FogColourCmd fogColourCmd; defineProperty( "fog.colour", "The colour of the fog.", "ColourRGB", &fogColourCmd, 0); static FogExpDensityCmd expDensityCmd; defineProperty( "fog.exp density", "The density of the fog in exp or exp2 mode.", "Real", &expDensityCmd, 0); static FogLinearStartCmd linearStartCmd; defineProperty( "fog.linear start", "Distance in world units at which linear fog starts to encroach.", "Real", &linearStartCmd, 0); static FogLinearEndCmd linearEndCmd; defineProperty( "fog.linear end", "Distance in world units at which linear fog becomes completely opaque.", "Real", &linearEndCmd, 0); static RenderWeatherCmd renderWeatherCmd; defineProperty( "weather.render weather", "if this option is true, the weather particle system will be rendered.", "Bool", &renderWeatherCmd ); static WeatherParticleSystemNameCmd weatherCmd; defineProperty( "weather.particle system name", "The name of the particle system that used for scene weather.", "String", &weatherCmd ); } }
SkyDomeObject::SkyDomeObject(void) : Object() , mSceneManager(NULL) , mMaterialName("BaseWhite") ,mCurvature(10) ,mTiling(8) ,mDistance(4000) ,mDrawFirst(true) ,mOrientation(Ogre::Quaternion::IDENTITY) ,mXsegments(16) ,mYsegments(16) ,mYsegments_keep(-1) { if (createPropertyDictionary("SkyDome")) { static MaterialNameCmd materialNameCmd; defineProperty( "material", "the name of material", "Material", &materialNameCmd, PF_PRIMARY); static DistanceCmd distanceCmd; defineProperty( "distance", "the distance of SkyDome.", "Ogre::Real", &distanceCmd, 0); static DrawFirstCmd drawFirstCmd; defineProperty( "draw first", "whether the box is drawn before all other geometry in the scene.", "Bool", &drawFirstCmd, 0); static OrientationCmd orientationCmd; defineProperty( "orientation", "Optional parameter to specify the orientation of the box.", "Orientation", &orientationCmd, 0); static CurvatureCmd curvatureCmd; defineProperty( "curvature", "The curvature of the dome.", "Ogre::Real", &curvatureCmd, 0); static TilingCmd tilingCmd; defineProperty( "tiling", "How many times to tile the texture(s) across the dome.", "Ogre::Real", &tilingCmd, 0); static XsegmentsCmd xsegmentsCmd; defineProperty( "x segments", "the number of xsegments the dome will have to it", "Integer", &xsegmentsCmd, 0); static YsegmentsCmd ysegmentsCmd; defineProperty( "y segments", "the number of ysegments the dome will have to it", "Integer", &ysegmentsCmd, 0); static Ysegments_keepCmd ysegments_keepCmd; defineProperty( "y segments keep", "the keep of ysegments", "Integer", &ysegments_keepCmd, 0); } }
VEnvironmentObject::VEnvironmentObject() : VSceneObject() , mSceneMgr(VNULL) , mViewport(VNULL) , mWeatherParticleSystemName("") , mAmbientLight(Ogre::ColourValue::Black) , mBackgroundColor(Ogre::ColourValue::Black) , mFogColor(Ogre::ColourValue::White) , mFogMode(Ogre::FOG_NONE) , mFogExpDensity(0.001f) , mFogLinearStart(0.0f) , mFogLinearEnd(1.0f) , mRenderWeather(VFALSE) { typedef VEnvColorRGBMemberCommand<&VEnvironmentObject::mAmbientLight> VAmbientLightCmd; typedef VEnvColorRGBMemberCommand<&VEnvironmentObject::mBackgroundColor> VBackgroundColorCmd; typedef VEnvColorRGBMemberCommand<&VEnvironmentObject::mFogColor> VFogColorCmd; typedef VObjectMemberPropertyCommand<VEnvironmentObject,Ogre::Real,&VEnvironmentObject::mFogExpDensity> VFogExpDensityCmd; typedef VObjectMemberPropertyCommand<VEnvironmentObject,Ogre::Real,&VEnvironmentObject::mFogLinearStart> VFogLinearStartCmd; typedef VObjectMemberPropertyCommand<VEnvironmentObject,Ogre::Real,&VEnvironmentObject::mFogLinearEnd> VFogLinearEndCmd; typedef VObjectMemberPropertyCommand<VEnvironmentObject,VString,&VEnvironmentObject::mWeatherParticleSystemName> VWeatherParticleSystemNameCmd; if (createPropertyDictionary("Environment")) { static VAmbientLightCmd ambientColorCmd; defineProperty( "ambient", "The ambient light level to be used for the scene", "ColorRGB", &ambientColorCmd, 0); static VBackgroundColorCmd backgroundColorCmd; defineProperty( "background", "The background color of the scene", "ColorRGB", &backgroundColorCmd, 0); static VFogModeCmd fogModeCmd; defineProperty( "fog.mode", "The fog mode", getEnumTypeString("FogMode", gsFogModeConstants), &fogModeCmd, 0); static VFogColorCmd fogColorCmd; defineProperty( "fog.colour", "The color of the fog.", "ColorRGB", &fogColorCmd, 0); static VFogExpDensityCmd expDensityCmd; defineProperty( "fog.exp density", "The density of the fog in exp or exp2 mode.", "Real", &expDensityCmd, 0); static VFogLinearStartCmd linearStartCmd; defineProperty( "fog.linear start", "Distance in world units at which linear fog starts to encroach.", "Real", &linearStartCmd, 0); static VFogLinearEndCmd linearEndCmd; defineProperty( "fog.linear end", "Distance in world units at which linear fog becomes completely opaque.", "Real", &linearEndCmd, 0); static VRenderWeatherCmd renderWeatherCmd; defineProperty( "weather.render weather", "if this option is true, the weather particle system will be rendered.", "Bool", &renderWeatherCmd, 0); static VWeatherParticleSystemNameCmd weatherCmd; defineProperty( "weather.particle system name", "The name of the particle system that used for scene weather.", "String", &weatherCmd, 0); } }
////////////////////////////////////////////////////////////////////////// // TerrainLiquidObject class ////////////////////////////////////////////////////////////////////////// TerrainLiquidObject::TerrainLiquidObject(void) : Object() , mSystem() , mTerrainLiquid() , mProjectionMaterial() , mProjectionCamera() , mMaterialName() , mPosition(Ogre::Vector3::ZERO) , mSubdivision(1) , mTexcoordScale(1) , mTexcoordRotate(0.0f) , mDepthTexLayerEnabled(false) , mDepthTexLayerScale(1.0f) , mDepthTexLayerAdjust(0.0f) , mProjectorName() , mProjectorSize(0.0f) , mReflectPlane(NULL) , mRefractPlane(NULL) , mReflectRenderTargetListener(NULL) , mRefractRenderTargetListener(NULL) , mDiffuse(Ogre::ColourValue::White) , mAdjustDepth(0) , mMatSpecular(Ogre::ColourValue::White) , mShininess(64.f) #if ((OGRE_VERSION_MAJOR << 16) | (OGRE_VERSION_MINOR << 8) | OGRE_VERSION_PATCH) >= 0x010100 , mReflectTexture() , mRefractTexture() #else , mReflectRenderTexture(NULL) , mRefractRenderTexture(NULL) #endif { if (createPropertyDictionary("TerrainLiquid")) { static MaterialNameCmd materialNameCmd; defineProperty( "material", "The material name use to rendering this terrain liquid.", "MaterialName", &materialNameCmd, PF_PRIMARY); static PositionCmd positionCmd; defineProperty( "position", "The position of the terrain liquid.", "Position", &positionCmd, 0); static SubdivisionCmd subdivisionCmd; defineProperty( "subdivision", "The subdivision of the terrain liquid grid.", "PositiveInteger", &subdivisionCmd, 0); static TexcoordRotateCmd texcoordRotateCmd; defineProperty( "texture rotate", "The texture uv rotate of the terrain liquid.", "Ogre::Real", &texcoordRotateCmd, 0); static TexcoordScaleCmd texcoordScaleCmd; defineProperty( "texture scale", "The texture uv factor of the terrain liquid.", "Ogre::Real", &texcoordScaleCmd, 0); static DepthTexLayerEnabledCmd depthTexLayerEnabledCmd; defineProperty( "depth texture layer.enable", "Enable depth texture layer of the terrain liquid.", "Bool", &depthTexLayerEnabledCmd, 0); static DepthTexLayerScaleCmd depthTexLayerScaleCmd; defineProperty( "depth texture layer.height scale", "The height scale factor to generate texcoords for depth texture layer.", "Ogre::Real", &depthTexLayerScaleCmd, 0); static DepthTexLayerAdjustCmd depthTexLayerAdjustCmd; defineProperty( "depth texture layer.height adjust", "The height adjust to generate texcoords for depth texture layer.", "Ogre::Real", &depthTexLayerAdjustCmd, 0); static ProjectorNameCmd projectorNameCmd; defineProperty( "projector name", "The object name use to project texture.", "String", &projectorNameCmd, 0); static ProjectorSizeCmd projectorSizeCmd; defineProperty( "projector size", "The size used to scale the projected texture.", "Ogre::Real", &projectorSizeCmd, 0); static DiffuseCmd diffuseCmd; defineProperty( "diffuse", "The diffuse of the terrain liquid.", "ColourRGB", &diffuseCmd, 0); static DepthCmd depthCmd; defineProperty( "adjustDepth", "The adjust depth to set the alpha as 1.", "Ogre::Real", &depthCmd, 0); static MatSpecularCmd matSpecularCmd; defineProperty( "specular", "The specular of the terrain liquid.", "ColourRGB", &matSpecularCmd, 0); static ShininessCmd shininessCmd; defineProperty( "shininess", "The shininess of the terrain liquid.", "Ogre::Real", &shininessCmd, 0); } }
LightObject::LightObject(void) : Object() , mBaseSceneNode(NULL) , mSceneNode(NULL) , mLight(NULL) , mLightType(Ogre::Light::LT_POINT) , mDiffuse(Ogre::ColourValue::White) , mSpecular(Ogre::ColourValue::Black) , mPosition(Ogre::Vector3::ZERO) , mDirection(Ogre::Vector3::UNIT_Z) , mRange(100000.0f) , mAttenuationConstant(1.0f) , mAttenuationLinear(0.0f) , mAttenuationQuadric(0.0f) , mSpotOuterAngle(40.0f) , mSpotInnerAngle(30.0f) , mSpotFalloff(1.0f) , mCastShadows(false) , mStaticLight(false) { if (createPropertyDictionary("Light")) { static LightTypeCmd lightTypeCmd; defineProperty( "type", "The type of light.", getEnumTypeString("LightType", gsLightTypeConstants), &lightTypeCmd, 0); static DiffuseCmd diffuseCmd; defineProperty( "diffuse", "The colour of the diffuse light given off by this light.", "ColourRGB", &diffuseCmd, 0); static SpecularCmd specularCmd; defineProperty( "specular", "The colour of the specular light given off by this light.", "ColourRGB", &specularCmd, 0); static PositionCmd positionCmd; defineProperty( "position", "The position of the light.\n" "Applicable to point lights and spotlights only.", "Position", &positionCmd, 0); static DirectionCmd directionCmd; defineProperty( "direction", "The direction of the light.\n" "Applicable to directional lights and spotlights only.", "Direction", &directionCmd, 0); static RangeCmd rangeCmd; defineProperty( "range", "The absolute upper range of the light.\n" "Applicable to point lights and spotlights only.", "Real", &rangeCmd, 0); static AttenuationConstantCmd attenuationConstantCmd; defineProperty( "attenuation.constant", "The constant factor in the attenuation formula.\n" "Applicable to point lights and spotlights only.", "Real", &attenuationConstantCmd, 0); static AttenuationLinearCmd attenuationLinearCmd; defineProperty( "attenuation.linear", "The linear factor in the attenuation formula.\n" "Applicable to point lights and spotlights only.", "Real", &attenuationLinearCmd, 0); static AttenuationQuadricCmd attenuationQuadricCmd; defineProperty( "attenuation.quadric", "The quadric factor in the attenuation formula.\n" "Applicable to point lights and spotlights only.", "Real", &attenuationQuadricCmd, 0); static SpotOuterAngleCmd spotOuterAngleCmd; defineProperty( "spotlight.outer", "The angle covered by the spotlights outer cone.\n" "Applicable to spotlights only.", "Real", &spotOuterAngleCmd, 0); static SpotInnerAngleCmd spotInnerAngleCmd; defineProperty( "spotlight.inner", "The angle covered by the spotlights inner cone.\n" "Applicable to spotlights only.", "Real", &spotInnerAngleCmd, 0); static SpotFalloffCmd spotFalloffCmd; defineProperty( "spotlight.falloff", "The falloff between the inner and outer cones of the spotlight.\n" "Applicable to spotlights only.", "Real", &spotFalloffCmd, 0); static CastShadowsCmd castShadowsCmd; defineProperty( "cast shadows", "Does this light cast shadows?", "Bool", &castShadowsCmd, 0); static StaticLightCmd staticLightCmd; defineProperty( "static light", "This light is use as static, which will be use for calculate lightmap only.", "Bool", &staticLightCmd, 0); } }