本文整理汇总了C++中LuaTable::GetFloat3方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaTable::GetFloat3方法的具体用法?C++ LuaTable::GetFloat3怎么用?C++ LuaTable::GetFloat3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaTable
的用法示例。
在下文中一共展示了LuaTable::GetFloat3方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateModelProperties
// Calculate model radius from the min/max extents
void CAssParser::CalculateModelProperties(S3DModel* model, const LuaTable& modelTable)
{
CalculateModelDimensions(model, model->rootPiece);
model->mins = modelTable.GetFloat3("mins", model->mins);
model->maxs = modelTable.GetFloat3("maxs", model->maxs);
model->radius = modelTable.GetFloat("radius", (model->maxs - model->mins ).Length() * 0.5f);
model->height = modelTable.GetFloat("height", (model->maxs.y - model->mins.y) );
model->relMidPos = modelTable.GetFloat3("midpos", (model->maxs + model->mins) * 0.5f);
}
示例2: ParseCollisionVolume
void SolidObjectDef::ParseCollisionVolume(const LuaTable& table)
{
collisionVolume = new CollisionVolume(
table.GetString("collisionVolumeType", ""),
table.GetFloat3("collisionVolumeScales", ZeroVector),
table.GetFloat3("collisionVolumeOffsets", ZeroVector)
);
// if this unit wants per-piece volumes, make
// its main collision volume deferent and let
// it ignore hits
collisionVolume->SetDefaultToPieceTree(table.GetBool("usePieceCollisionVolumes", false));
collisionVolume->SetDefaultToFootPrint(table.GetBool("useFootPrintCollisionVolume", false));
collisionVolume->SetIgnoreHits(collisionVolume->DefaultToPieceTree());
}
示例3: CalculateModelProperties
// Calculate model radius from the min/max extents
void CAssParser::CalculateModelProperties(S3DModel* model, const LuaTable& modelTable)
{
CalculateModelDimensions(model, model->rootPiece);
// note: overrides default midpos of the SpringRadius piece
model->relMidPos.y = (model->maxs.y + model->mins.y) * 0.5f;
// Simplified dimensions used for rough calculations
model->radius = modelTable.GetFloat("radius", float3::max(float3::fabs(model->maxs), float3::fabs(model->mins)).Length());
model->height = modelTable.GetFloat("height", model->maxs.y);
model->relMidPos = modelTable.GetFloat3("midpos", model->relMidPos);
model->mins = modelTable.GetFloat3("mins", model->mins);
model->maxs = modelTable.GetFloat3("maxs", model->maxs);
model->drawRadius = model->radius;
}
示例4: LoadPieceTransformations
void CAssParser::LoadPieceTransformations(SAssPiece* piece, const LuaTable& pieceMetaTable)
{
//! Process transforms
float3 rotate, scale, offset;
aiVector3D _scale, _offset;
aiQuaternion _rotate;
piece->node->mTransformation.Decompose(_scale,_rotate,_offset);
LOG_S(LOG_SECTION_PIECE,
"(%d:%s) Assimp offset (%f,%f,%f), rotate (%f,%f,%f), scale (%f,%f,%f)",
piece->model->numPieces, piece->name.c_str(),
_offset.x, _offset.y, _offset.z,
_rotate.x, _rotate.y, _rotate.z,
_scale.x, _scale.y, _scale.z
);
offset = pieceMetaTable.GetFloat3("offset", float3(_offset.x, _offset.y, _offset.z));
offset.x = pieceMetaTable.GetFloat("offsetx", offset.x);
offset.y = pieceMetaTable.GetFloat("offsety", offset.y);
offset.z = pieceMetaTable.GetFloat("offsetz", offset.z);
rotate = QuaternionToRadianAngles(_rotate);
rotate = float3(rotate.z, rotate.x, rotate.y); //! swizzle
rotate = pieceMetaTable.GetFloat3("rotate", rotate * RADTODEG);
rotate.x = pieceMetaTable.GetFloat("rotatex", rotate.x);
rotate.y = pieceMetaTable.GetFloat("rotatey", rotate.y);
rotate.z = pieceMetaTable.GetFloat("rotatez", rotate.z);
rotate *= DEGTORAD;
scale = pieceMetaTable.GetFloat3("scale", float3(_scale.x, _scale.z, _scale.y));
scale.x = pieceMetaTable.GetFloat("scalex", scale.x);
scale.y = pieceMetaTable.GetFloat("scaley", scale.y);
scale.z = pieceMetaTable.GetFloat("scalez", scale.z);
LOG_S(LOG_SECTION_PIECE,
"(%d:%s) Relative offset (%f,%f,%f), rotate (%f,%f,%f), scale (%f,%f,%f)",
piece->model->numPieces, piece->name.c_str(),
offset.x, offset.y, offset.z,
rotate.x, rotate.y, rotate.z,
scale.x, scale.y, scale.z
);
piece->offset = offset;
piece->rot = rotate;
piece->scale = scale;
}
示例5: ReadAtmosphere
void CMapInfo::ReadAtmosphere()
{
// MAP\ATMOSPHERE
const LuaTable atmoTable = mapRoot->SubTable("atmosphere");
atmosphere_t& atmo = atmosphere;
atmo.cloudDensity = atmoTable.GetFloat("cloudDensity", 0.5f);
atmo.minWind = atmoTable.GetFloat("minWind", 5.0f);
atmo.maxWind = atmoTable.GetFloat("maxWind", 25.0f);
atmo.fogStart = atmoTable.GetFloat("fogStart", 0.1f);
atmo.fogColor = atmoTable.GetFloat3("fogColor", float3(0.7f, 0.7f, 0.8f));
atmo.skyColor = atmoTable.GetFloat3("skyColor", float3(0.1f, 0.15f, 0.7f));
atmo.sunColor = atmoTable.GetFloat3("sunColor", float3(1.0f, 1.0f, 1.0f));
atmo.cloudColor = atmoTable.GetFloat3("cloudColor", float3(1.0f, 1.0f, 1.0f));
atmo.skyBox = atmoTable.GetString("skyBox", "");
// clamps
atmo.cloudDensity = max(0.0f, atmo.cloudDensity);
atmo.maxWind = max(0.0f, atmo.maxWind);
atmo.minWind = max(0.0f, atmo.minWind);
atmo.minWind = min(atmo.maxWind, atmo.minWind);
}
示例6: ReadLight
void CMapInfo::ReadLight()
{
const LuaTable lightTable = parser->GetRoot().SubTable("lighting");
light.sunStartAngle = lightTable.GetFloat("sunStartAngle", 0.0f);
light.sunOrbitTime = lightTable.GetFloat("sunOrbitTime", 1440.0f);
light.sunDir = lightTable.GetFloat4("sunDir", float4(0.0f, 1.0f, 2.0f, FLT_MAX));
if (light.sunDir.w == FLT_MAX) { // if four params are not specified for sundir, fallback to the old three param format
light.sunDir = lightTable.GetFloat3("sunDir", float3(0.0f, 1.0f, 2.0f));
light.sunDir.w = FLT_MAX;
}
light.sunDir.ANormalize();
light.groundAmbientColor = lightTable.GetFloat3("groundAmbientColor", float3(0.5f, 0.5f, 0.5f));
light.groundSunColor = lightTable.GetFloat3("groundDiffuseColor", float3(0.5f, 0.5f, 0.5f));
light.groundSpecularColor = lightTable.GetFloat3("groundSpecularColor", float3(0.1f, 0.1f, 0.1f));
light.groundShadowDensity = lightTable.GetFloat("groundShadowDensity", 0.8f);
light.unitAmbientColor = lightTable.GetFloat3("unitAmbientColor", float3(0.4f, 0.4f, 0.4f));
light.unitSunColor = lightTable.GetFloat3("unitDiffuseColor", float3(0.7f, 0.7f, 0.7f));
light.unitSpecularColor = lightTable.GetFloat3("unitSpecularColor", light.unitSunColor);
light.unitShadowDensity = lightTable.GetFloat("unitShadowDensity", 0.8f);
}
示例7: ReadLight
void CMapInfo::ReadLight()
{
const LuaTable lightTable = mapRoot->SubTable("lighting");
light.sunDir = lightTable.GetFloat3("sunDir", float3(0.0f, 1.0f, 2.0f));
light.sunDir.Normalize();
light.groundAmbientColor = lightTable.GetFloat3("groundAmbientColor",
float3(0.5f, 0.5f, 0.5f));
light.groundSunColor = lightTable.GetFloat3("groundDiffuseColor",
float3(0.5f, 0.5f, 0.5f));
light.groundSpecularColor = lightTable.GetFloat3("groundSpecularColor",
float3(0.1f, 0.1f, 0.1f));
light.groundShadowDensity = lightTable.GetFloat("groundShadowDensity", 0.8f);
light.unitAmbientColor = lightTable.GetFloat3("unitAmbientColor",
float3(0.4f, 0.4f, 0.4f));
light.unitSunColor = lightTable.GetFloat3("unitDiffuseColor",
float3(0.7f, 0.7f, 0.7f));
light.specularSunColor = lightTable.GetFloat3("unitSpecularColor",
light.unitSunColor);
light.unitShadowDensity = lightTable.GetFloat("unitShadowDensity", 0.8f);
}
示例8: LoadPieceTransformations
void CAssParser::LoadPieceTransformations(
SAssPiece* piece,
const S3DModel* model,
const aiNode* pieceNode,
const LuaTable& pieceTable
) {
aiVector3D aiScaleVec, aiTransVec;
aiQuaternion aiRotateQuat;
// process transforms
pieceNode->mTransformation.Decompose(aiScaleVec, aiRotateQuat, aiTransVec);
// metadata-scaling
piece->scales = pieceTable.GetFloat3("scale", aiVectorToFloat3(aiScaleVec));
piece->scales.x = pieceTable.GetFloat("scalex", piece->scales.x);
piece->scales.y = pieceTable.GetFloat("scaley", piece->scales.y);
piece->scales.z = pieceTable.GetFloat("scalez", piece->scales.z);
if (piece->scales.x != piece->scales.y || piece->scales.y != piece->scales.z) {
// LOG_SL(LOG_SECTION_MODEL, L_WARNING, "Spring doesn't support non-uniform scaling");
piece->scales.y = piece->scales.x;
piece->scales.z = piece->scales.x;
}
// metadata-translation
piece->offset = pieceTable.GetFloat3("offset", aiVectorToFloat3(aiTransVec));
piece->offset.x = pieceTable.GetFloat("offsetx", piece->offset.x);
piece->offset.y = pieceTable.GetFloat("offsety", piece->offset.y);
piece->offset.z = pieceTable.GetFloat("offsetz", piece->offset.z);
// metadata-rotation
// NOTE:
// these rotations are "pre-scripting" but "post-modelling"
// together with the (baked) aiRotateQuad they determine the
// model's pose *before* any animations execute
//
// float3 rotAngles = pieceTable.GetFloat3("rotate", aiQuaternionToRadianAngles(aiRotateQuat) * RADTODEG);
float3 pieceRotAngles = pieceTable.GetFloat3("rotate", ZeroVector);
pieceRotAngles.x = pieceTable.GetFloat("rotatex", pieceRotAngles.x);
pieceRotAngles.y = pieceTable.GetFloat("rotatey", pieceRotAngles.y);
pieceRotAngles.z = pieceTable.GetFloat("rotatez", pieceRotAngles.z);
pieceRotAngles *= DEGTORAD;
LOG_SL(LOG_SECTION_PIECE, L_INFO,
"(%d:%s) Assimp offset (%f,%f,%f), rotate (%f,%f,%f,%f), scale (%f,%f,%f)",
model->numPieces, piece->name.c_str(),
aiTransVec.x, aiTransVec.y, aiTransVec.z,
aiRotateQuat.w, aiRotateQuat.x, aiRotateQuat.y, aiRotateQuat.z,
aiScaleVec.x, aiScaleVec.y, aiScaleVec.z
);
LOG_SL(LOG_SECTION_PIECE, L_INFO,
"(%d:%s) Relative offset (%f,%f,%f), rotate (%f,%f,%f), scale (%f,%f,%f)",
model->numPieces, piece->name.c_str(),
piece->offset.x, piece->offset.y, piece->offset.z,
pieceRotAngles.x, pieceRotAngles.y, pieceRotAngles.z,
piece->scales.x, piece->scales.y, piece->scales.z
);
// NOTE:
// at least collada (.dae) files generated by Blender represent
// a coordinate-system that differs from the "standard" formats
// (3DO, S3O, ...) for which existing tools at least have prior
// knowledge of Spring's expectations --> let the user override
// the ROOT rotational transform and the rotation-axis mapping
// used by animation scripts (but re-modelling/re-exporting is
// always preferred!) even though AssImp should convert models
// to its own system which matches that of Spring
//
// .dae : x=Rgt, y=-Fwd, z= Up, as=(-1, -1, 1), am=AXIS_XZY (if Z_UP)
// .dae : x=Rgt, y=-Fwd, z= Up, as=(-1, -1, 1), am=AXIS_XZY (if Y_UP) [!?]
// .blend: ????
piece->bakedRotMatrix = aiMatrixToMatrix(aiMatrix4x4t<float>(aiRotateQuat.GetMatrix()));
if (piece == model->GetRootPiece()) {
const float3 xaxis = pieceTable.GetFloat3("xaxis", piece->bakedRotMatrix.GetX());
const float3 yaxis = pieceTable.GetFloat3("yaxis", piece->bakedRotMatrix.GetY());
const float3 zaxis = pieceTable.GetFloat3("zaxis", piece->bakedRotMatrix.GetZ());
if (math::fabs(xaxis.SqLength() - yaxis.SqLength()) < 0.01f && math::fabs(yaxis.SqLength() - zaxis.SqLength()) < 0.01f) {
piece->bakedRotMatrix = CMatrix44f(ZeroVector, xaxis, yaxis, zaxis);
}
}
piece->rotAxisSigns = pieceTable.GetFloat3("rotAxisSigns", float3(-OnesVector));
piece->axisMapType = AxisMappingType(pieceTable.GetInt("rotAxisMap", AXIS_MAPPING_XYZ));
// construct 'baked' part of the piece-space matrix
// AssImp order is translate * rotate * scale * v;
// we leave the translation and scale parts out and
// put those in <offset> and <scales> --> transform
// is just R instead of T * R * S
//
// note: for all non-AssImp models this is identity!
//
piece->ComposeRotation(piece->bakedRotMatrix, pieceRotAngles);
piece->SetHasIdentityRotation(piece->bakedRotMatrix.IsIdentity() == 0);
assert(piece->bakedRotMatrix.IsOrthoNormal() == 0);
}
示例9: ReadWater
void CMapInfo::ReadWater()
{
const LuaTable wt = mapRoot->SubTable("water");
water.repeatX = wt.GetFloat("repeatX", 0.0f);
water.repeatY = wt.GetFloat("repeatY", 0.0f);
water.damage = wt.GetFloat("damage", 0.0f) * (16.0f / 30.0f);
water.absorb = wt.GetFloat3("absorb", float3(0.0f, 0.0f, 0.0f));
water.baseColor = wt.GetFloat3("baseColor", float3(0.0f, 0.0f, 0.0f));
water.minColor = wt.GetFloat3("minColor", float3(0.0f, 0.0f, 0.0f));
water.surfaceColor = wt.GetFloat3("surfaceColor", float3(0.75f, 0.8f, 0.85f));
water.surfaceAlpha = wt.GetFloat("surfaceAlpha", 0.55f);
water.planeColor = wt.GetFloat3("planeColor", float3(0.0f, 0.4f, 0.0f));
hasWaterPlane = wt.KeyExists("planeColor");
water.specularColor = wt.GetFloat3("specularColor", light.groundSunColor);
water.specularFactor = wt.GetFloat("specularFactor", 20.0f);
water.fresnelMin = wt.GetFloat("fresnelMin", 0.2f);
water.fresnelMax = wt.GetFloat("fresnelMax", 0.3f);
water.fresnelPower = wt.GetFloat("fresnelPower", 4.0f);
water.texture = wt.GetString("texture", "");
water.foamTexture = wt.GetString("foamTexture", "");
water.normalTexture = wt.GetString("normalTexture", "");
// use 'resources.lua' for missing fields (our the engine defaults)
const LuaTable resGfxMaps = resRoot->SubTable("graphics").SubTable("maps");
if (!water.texture.empty()) {
water.texture = "maps/" + water.texture;
} else {
water.texture = "bitmaps/" + resGfxMaps.GetString("watertex", "ocean.jpg");
}
if (!water.foamTexture.empty()) {
water.foamTexture = "maps/" + water.foamTexture;
} else {
water.foamTexture = "bitmaps/" + resGfxMaps.GetString("waterfoamtex", "foam.jpg");
}
if (!water.normalTexture.empty()) {
water.normalTexture = "maps/" + water.normalTexture;
} else {
water.normalTexture = "bitmaps/" + resGfxMaps.GetString("waternormaltex", "waterbump.png");
}
// water caustic textures
LuaTable caustics = wt.SubTable("caustics");
string causticPrefix = "maps/";
if (!caustics.IsValid()) {
caustics = resRoot->SubTable("graphics").SubTable("caustics");
causticPrefix = "bitmaps/";
}
if (caustics.IsValid()) {
for (int i = 1; true; i++) {
const string texName = caustics.GetString(i, "");
if (texName.empty()) {
break;
}
water.causticTextures.push_back(causticPrefix + texName);
}
} else {
// load the default 32 textures
for (int i = 0; i < 32; i++) {
char defTex[256];
sprintf(defTex, "bitmaps/caustics/caustic%02i.jpg", i);
water.causticTextures.push_back(defTex);
}
}
}
示例10: Load
unsigned int CCustomExplosionGenerator::Load(CExplosionGeneratorHandler* h, const string& tag)
{
unsigned int explosionID = -1U;
if (tag.empty()) {
return explosionID;
}
const std::map<std::string, unsigned int>::const_iterator it = explosionIDs.find(tag);
if (it == explosionIDs.end()) {
CEGData cegData;
const LuaTable* root = h->GetExplosionTableRoot();
const LuaTable& expTable = (root != NULL)? root->SubTable(tag): LuaTable();
if (!expTable.IsValid()) {
// not a fatal error: any calls to ::Explosion will just return early
logOutput.Print("[CCEG::Load] WARNING: table for CEG \"" + tag + "\" invalid (parse errors?)");
return explosionID;
}
vector<string> spawns;
expTable.GetKeys(spawns);
for (vector<string>::iterator si = spawns.begin(); si != spawns.end(); ++si) {
ProjectileSpawnInfo psi;
const string& spawnName = *si;
const LuaTable spawnTable = expTable.SubTable(spawnName);
if (!spawnTable.IsValid() || spawnName == "groundflash") {
continue;
}
const string className = spawnTable.GetString("class", spawnName);
psi.projectileClass = h->projectileClasses.GetClass(className);
psi.flags = GetFlagsFromTable(spawnTable);
psi.count = spawnTable.GetInt("count", 1);
if (psi.projectileClass->binder->flags & creg::CF_Synced) {
psi.flags |= SPW_SYNCED;
}
string code;
map<string, string> props;
map<string, string>::const_iterator propIt;
spawnTable.SubTable("properties").GetMap(props);
for (propIt = props.begin(); propIt != props.end(); ++propIt) {
creg::Class::Member* m = psi.projectileClass->FindMember(propIt->first.c_str());
if (m && (m->flags & creg::CM_Config)) {
ParseExplosionCode(&psi, m->offset, m->type, propIt->second, code);
}
}
code += (char)OP_END;
psi.code.resize(code.size());
copy(code.begin(), code.end(), psi.code.begin());
cegData.projectileSpawn.push_back(psi);
}
const LuaTable gndTable = expTable.SubTable("groundflash");
const int ttl = gndTable.GetInt("ttl", 0);
if (ttl > 0) {
cegData.groundFlash.circleAlpha = gndTable.GetFloat("circleAlpha", 0.0f);
cegData.groundFlash.flashSize = gndTable.GetFloat("flashSize", 0.0f);
cegData.groundFlash.flashAlpha = gndTable.GetFloat("flashAlpha", 0.0f);
cegData.groundFlash.circleGrowth = gndTable.GetFloat("circleGrowth", 0.0f);
cegData.groundFlash.color = gndTable.GetFloat3("color", float3(1.0f, 1.0f, 0.8f));
cegData.groundFlash.flags = SPW_GROUND | GetFlagsFromTable(gndTable);
cegData.groundFlash.ttl = ttl;
}
cegData.useDefaultExplosions = expTable.GetBool("useDefaultExplosions", false);
explosionID = explosionData.size();
explosionData.push_back(cegData);
explosionIDs[tag] = explosionID;
} else {
explosionID = it->second;
}
return explosionID;
}
示例11: content_error
//.........这里部分代码省略.........
speed = fabs(speed);
rSpeed = fabs(rSpeed);
maxAcc = fabs(udTable.GetFloat("acceleration", 0.5f)); // no negative values
maxDec = fabs(udTable.GetFloat("brakeRate", 3.0f * maxAcc)) * (canfly? 0.1f: 1.0f); // no negative values
turnRate = udTable.GetFloat("turnRate", 0.0f);
turnInPlace = udTable.GetBool( "turnInPlace", true);
turnInPlaceDistance = udTable.GetFloat("turnInPlaceDistance", 350.f);
turnInPlaceSpeedLimit = udTable.GetFloat("turnInPlaceSpeedLimit", (speed / GAME_SPEED) * 0.2f);
const bool noAutoFire = udTable.GetBool("noAutoFire", false);
canFireControl = udTable.GetBool("canFireControl", !noAutoFire);
fireState = udTable.GetInt("fireState", canFireControl ? -1 : 2);
fireState = std::min(fireState,2);
moveState = udTable.GetInt("moveState", (canmove && speed>0.0f) ? -1 : 1);
moveState = std::min(moveState,2);
buildRange3D = udTable.GetBool("buildRange3D", false);
buildDistance = udTable.GetFloat("buildDistance", 128.0f);
buildDistance = std::max(128.0f, buildDistance);
buildSpeed = udTable.GetFloat("workerTime", 0.0f);
repairSpeed = udTable.GetFloat("repairSpeed", buildSpeed);
maxRepairSpeed = udTable.GetFloat("maxRepairSpeed", 1e20f);
reclaimSpeed = udTable.GetFloat("reclaimSpeed", buildSpeed);
resurrectSpeed = udTable.GetFloat("resurrectSpeed", buildSpeed);
captureSpeed = udTable.GetFloat("captureSpeed", buildSpeed);
terraformSpeed = udTable.GetFloat("terraformSpeed", buildSpeed);
flankingBonusMode = udTable.GetInt("flankingBonusMode", modInfo.flankingBonusModeDefault);
flankingBonusMax = udTable.GetFloat("flankingBonusMax", 1.9f);
flankingBonusMin = udTable.GetFloat("flankingBonusMin", 0.9);
flankingBonusDir = udTable.GetFloat3("flankingBonusDir", float3(0.0f, 0.0f, 1.0f));
flankingBonusMobilityAdd = udTable.GetFloat("flankingBonusMobilityAdd", 0.01f);
armoredMultiple = udTable.GetFloat("damageModifier", 1.0f);
armorType = damageArrayHandler->GetTypeFromName(name);
radarRadius = udTable.GetInt("radarDistance", 0);
sonarRadius = udTable.GetInt("sonarDistance", 0);
jammerRadius = udTable.GetInt("radarDistanceJam", 0);
sonarJamRadius = udTable.GetInt("sonarDistanceJam", 0);
stealth = udTable.GetBool("stealth", false);
sonarStealth = udTable.GetBool("sonarStealth", false);
targfac = udTable.GetBool("isTargetingUpgrade", false);
isFeature = udTable.GetBool("isFeature", false);
canResurrect = udTable.GetBool("canResurrect", false);
canCapture = udTable.GetBool("canCapture", false);
hideDamage = udTable.GetBool("hideDamage", false);
showPlayerName = udTable.GetBool("showPlayerName", false);
cloakCost = udTable.GetFloat("cloakCost", -1.0f);
cloakCostMoving = udTable.GetFloat("cloakCostMoving", -1.0f);
if (cloakCostMoving < 0) {
cloakCostMoving = cloakCost;
}
canCloak = (cloakCost >= 0);
startCloaked = udTable.GetBool("initCloaked", false);
decloakDistance = udTable.GetFloat("minCloakDistance", 0.0f);
decloakSpherical = udTable.GetBool("decloakSpherical", true);
decloakOnFire = udTable.GetBool("decloakOnFire", true);
cloakTimeout = udTable.GetInt("cloakTimeout", 128);
示例12: LoadPieceTransformations
void CAssParser::LoadPieceTransformations(const S3DModel* model, SAssPiece* piece, const LuaTable& pieceMetaTable)
{
// Process transforms
float3 rotate, offset;
float3 scale(1.0,1.0,1.0);
aiVector3D _scale, _offset;
aiQuaternion _rotate;
piece->node->mTransformation.Decompose(_scale,_rotate,_offset);
const aiMatrix4x4t<float> aiRotMatrix = aiMatrix4x4t<float>(_rotate.GetMatrix());
LOG_S(LOG_SECTION_PIECE,
"(%d:%s) Assimp offset (%f,%f,%f), rotate (%f,%f,%f,%f), scale (%f,%f,%f)",
model->numPieces, piece->name.c_str(),
_offset.x, _offset.y, _offset.z,
_rotate.w, _rotate.x, _rotate.y, _rotate.z,
_scale.x, _scale.y, _scale.z
);
// Scale
scale = pieceMetaTable.GetFloat3("scale", float3(_scale.x, _scale.z, _scale.y));
scale.x = pieceMetaTable.GetFloat("scalex", scale.x);
scale.y = pieceMetaTable.GetFloat("scaley", scale.y);
scale.z = pieceMetaTable.GetFloat("scalez", scale.z);
if (scale.x != scale.y || scale.y != scale.z) {
//LOG_SL(LOG_SECTION_MODEL, L_WARNING, "Spring doesn't support non-uniform scaling");
scale.y = scale.x;
scale.z = scale.x;
}
// Rotate
// Note these rotations are put into the `Spring rotations` and are not baked into the Assimp matrix!
rotate = pieceMetaTable.GetFloat3("rotate", float3(0,0,0));
rotate.x = pieceMetaTable.GetFloat("rotatex", rotate.x);
rotate.y = pieceMetaTable.GetFloat("rotatey", rotate.y);
rotate.z = pieceMetaTable.GetFloat("rotatez", rotate.z);
rotate *= DEGTORAD;
// Translate
offset = pieceMetaTable.GetFloat3("offset", float3(_offset.x, _offset.y, _offset.z));
offset.x = pieceMetaTable.GetFloat("offsetx", offset.x);
offset.y = pieceMetaTable.GetFloat("offsety", offset.y);
offset.z = pieceMetaTable.GetFloat("offsetz", offset.z);
LOG_S(LOG_SECTION_PIECE,
"(%d:%s) Relative offset (%f,%f,%f), rotate (%f,%f,%f), scale (%f,%f,%f)",
model->numPieces, piece->name.c_str(),
offset.x, offset.y, offset.z,
rotate.x, rotate.y, rotate.z,
scale.x, scale.y, scale.z
);
// construct 'baked' part of the modelpiece matrix
// Assimp order is: translate * rotate * scale * v
piece->scaleRotMatrix.LoadIdentity();
piece->scaleRotMatrix.Scale(scale);
piece->scaleRotMatrix *= aiMatrixToMatrix(aiRotMatrix);
// piece->scaleRotMatrix.Translate(offset);
piece->offset = offset;
piece->rot = rotate;
piece->mIsIdentity = (scale.x == 1.0f) && aiRotMatrix.IsIdentity();
}
示例13: ParseWeapon
//.........这里部分代码省略.........
bool defaultSoundTrigger = (wd.type == "BeamLaser" && !wd.beamburst) ||
wd.type == "Melee" || wd.type == "Rifle";
wd.soundTrigger = wdTable.GetBool("soundTrigger", defaultSoundTrigger);
//sunparser->GetDef(wd.highTrajectory, "0", weaponname + "minbarrelangle");
wd.stockpile = wdTable.GetBool("stockpile", false);
wd.stockpileTime = wdTable.GetFloat("stockpileTime", wd.reload);
wd.interceptor = wdTable.GetInt("interceptor", 0);
wd.targetable = wdTable.GetInt("targetable", 0);
wd.manualfire = wdTable.GetBool("commandfire", false);
wd.coverageRange = wdTable.GetFloat("coverage", 0.0f);
// FIXME -- remove the old style ?
LuaTable shTable = wdTable.SubTable("shield");
const float3 shieldBadColor (1.0f, 0.5f, 0.5f);
const float3 shieldGoodColor(0.5f, 0.5f, 1.0f);
if (shTable.IsValid()) {
wd.shieldRepulser = shTable.GetBool("repulser", false);
wd.smartShield = shTable.GetBool("smart", false);
wd.exteriorShield = shTable.GetBool("exterior", false);
wd.visibleShield = shTable.GetBool("visible", false);
wd.visibleShieldRepulse = shTable.GetBool("visibleRepulse", false);
wd.visibleShieldHitFrames = shTable.GetInt("visibleHitFrames", 0);
wd.shieldEnergyUse = shTable.GetFloat("energyUse", 0.0f);
wd.shieldForce = shTable.GetFloat("force", 0.0f);
wd.shieldRadius = shTable.GetFloat("radius", 0.0f);
wd.shieldMaxSpeed = shTable.GetFloat("maxSpeed", 0.0f);
wd.shieldPower = shTable.GetFloat("power", 0.0f);
wd.shieldPowerRegen = shTable.GetFloat("powerRegen", 0.0f);
wd.shieldPowerRegenEnergy = shTable.GetFloat("powerRegenEnergy", 0.0f);
wd.shieldRechargeDelay = (int)(shTable.GetFloat("rechargeDelay", 0) * GAME_SPEED);
wd.shieldStartingPower = shTable.GetFloat("startingPower", 0.0f);
wd.shieldInterceptType = shTable.GetInt("interceptType", 0);
wd.shieldBadColor = shTable.GetFloat3("badColor", shieldBadColor);
wd.shieldGoodColor = shTable.GetFloat3("goodColor", shieldGoodColor);
wd.shieldAlpha = shTable.GetFloat("alpha", 0.2f);
}
else {
wd.shieldRepulser = wdTable.GetBool("shieldRepulser", false);
wd.smartShield = wdTable.GetBool("smartShield", false);
wd.exteriorShield = wdTable.GetBool("exteriorShield", false);
wd.visibleShield = wdTable.GetBool("visibleShield", false);
wd.visibleShieldRepulse = wdTable.GetBool("visibleShieldRepulse", false);
wd.visibleShieldHitFrames = wdTable.GetInt("visibleShieldHitFrames", 0);
wd.shieldEnergyUse = wdTable.GetFloat("shieldEnergyUse", 0.0f);
wd.shieldForce = wdTable.GetFloat("shieldForce", 0.0f);
wd.shieldRadius = wdTable.GetFloat("shieldRadius", 0.0f);
wd.shieldMaxSpeed = wdTable.GetFloat("shieldMaxSpeed", 0.0f);
wd.shieldPower = wdTable.GetFloat("shieldPower", 0.0f);
wd.shieldPowerRegen = wdTable.GetFloat("shieldPowerRegen", 0.0f);
wd.shieldPowerRegenEnergy = wdTable.GetFloat("shieldPowerRegenEnergy", 0.0f);
wd.shieldRechargeDelay = (int)(wdTable.GetFloat("shieldRechargeDelay", 0) * GAME_SPEED);
wd.shieldStartingPower = wdTable.GetFloat("shieldStartingPower", 0.0f);
wd.shieldInterceptType = wdTable.GetInt("shieldInterceptType", 0);
wd.shieldBadColor = wdTable.GetFloat3("shieldBadColor", shieldBadColor);
wd.shieldGoodColor = wdTable.GetFloat3("shieldGoodColor", shieldGoodColor);
wd.shieldAlpha = wdTable.GetFloat("shieldAlpha", 0.2f);
}
int defInterceptType = 0;
if ((wd.type == "Cannon") || (wd.type == "EmgCannon")) {
defInterceptType = 1;
} else if ((wd.type == "LaserCannon") || (wd.type == "BeamLaser")) {
defInterceptType = 2;
} else if ((wd.type == "StarburstLauncher") || (wd.type == "MissileLauncher")) {
示例14: CreateFeatureDef
void CFeatureHandler::CreateFeatureDef(const LuaTable& fdTable, const string& mixedCase)
{
const string name = StringToLower(mixedCase);
if (featureDefs.find(name) != featureDefs.end()) {
return;
}
FeatureDef* fd = new FeatureDef;
fd->myName = name;
fd->filename = fdTable.GetString("filename", "unknown");
fd->description = fdTable.GetString("description", "");
fd->blocking = fdTable.GetBool("blocking", true);
fd->burnable = fdTable.GetBool("flammable", false);
fd->destructable = !fdTable.GetBool("indestructible", false);
fd->reclaimable = fdTable.GetBool("reclaimable", fd->destructable);
fd->autoreclaim = fdTable.GetBool("autoreclaimable", fd->autoreclaim);
fd->resurrectable = fdTable.GetInt("resurrectable", -1);
//this seem to be the closest thing to floating that ta wreckage contains
fd->floating = fdTable.GetBool("nodrawundergray", false);
if (fd->floating && !fd->blocking) {
fd->floating = false;
}
fd->noSelect = fdTable.GetBool("noselect", false);
fd->deathFeature = fdTable.GetString("featureDead", "");
fd->metal = fdTable.GetFloat("metal", 0.0f);
fd->energy = fdTable.GetFloat("energy", 0.0f);
fd->maxHealth = fdTable.GetFloat("damage", 0.0f);
fd->reclaimTime = fdTable.GetFloat("reclaimTime", (fd->metal + fd->energy)*6.f);
fd->smokeTime = fdTable.GetInt("smokeTime", (fd->blocking) ? 300 : 0);
fd->drawType = fdTable.GetInt("drawType", DRAWTYPE_MODEL);
fd->modelname = fdTable.GetString("object", "");
if (!fd->modelname.empty()) {
if (fd->modelname.find(".") == std::string::npos) {
fd->modelname += ".3do";
}
fd->modelname = string("objects3d/") + fd->modelname;
}
// these take precedence over the old sphere tags as well as
// feature->radius (for feature <--> projectile interactions)
fd->collisionVolumeTypeStr = fdTable.GetString("collisionVolumeType", "");
fd->collisionVolumeScales = fdTable.GetFloat3("collisionVolumeScales", ZeroVector);
fd->collisionVolumeOffsets = fdTable.GetFloat3("collisionVolumeOffsets", ZeroVector);
fd->collisionVolumeTest = fdTable.GetInt("collisionVolumeTest", COLVOL_TEST_CONT);
// initialize the (per-featuredef) collision-volume,
// all CFeature instances hold a copy of this object
fd->collisionVolume = new CollisionVolume(
fd->collisionVolumeTypeStr,
fd->collisionVolumeScales,
fd->collisionVolumeOffsets,
fd->collisionVolumeTest
);
fd->upright = fdTable.GetBool("upright", false);
// our resolution is double TA's
fd->xsize = fdTable.GetInt("footprintX", 1) * 2;
fd->zsize = fdTable.GetInt("footprintZ", 1) * 2;
const float defMass = (fd->metal * 0.4f) + (fd->maxHealth * 0.1f);
fd->mass = fdTable.GetFloat("mass", defMass);
fd->mass = max(0.001f, fd->mass);
// custom parameters table
fdTable.SubTable("customParams").GetMap(fd->customParams);
AddFeatureDef(name, fd);
}
示例15: ReadWater
void CMapInfo::ReadWater()
{
const LuaTable wt = mapRoot->SubTable("water");
water.repeatX = wt.GetFloat("repeatX", 0.0f);
water.repeatY = wt.GetFloat("repeatY", 0.0f);
water.damage = wt.GetFloat("damage", 0.0f) * (16.0f / 30.0f);
water.absorb = wt.GetFloat3("absorb", float3(0.0f, 0.0f, 0.0f));
water.baseColor = wt.GetFloat3("baseColor", float3(0.0f, 0.0f, 0.0f));
water.minColor = wt.GetFloat3("minColor", float3(0.0f, 0.0f, 0.0f));
water.ambientFactor = wt.GetFloat("ambientFactor", 1.0f);
water.diffuseFactor = wt.GetFloat("diffuseFactor", 1.0f);
water.specularFactor= wt.GetFloat("specularFactor",1.0f);
water.specularPower = wt.GetFloat("specularPower", 20.0f);
water.planeColor = wt.GetFloat3("planeColor", float3(0.0f, 0.4f, 0.0f));
water.hasWaterPlane = wt.KeyExists("planeColor");
water.surfaceColor = wt.GetFloat3("surfaceColor", float3(0.75f, 0.8f, 0.85f));
water.surfaceAlpha = wt.GetFloat("surfaceAlpha", 0.55f);
water.diffuseColor = wt.GetFloat3("diffuseColor", float3(1.0f, 1.0f, 1.0f));
water.specularColor = wt.GetFloat3("specularColor", light.groundSunColor);
water.fresnelMin = wt.GetFloat("fresnelMin", 0.2f);
water.fresnelMax = wt.GetFloat("fresnelMax", 0.8f);
water.fresnelPower = wt.GetFloat("fresnelPower", 4.0f);
water.reflDistortion = wt.GetFloat("reflectionDistortion", 1.0f);
water.blurBase = wt.GetFloat("blurBase", 2.0f);
water.blurExponent = wt.GetFloat("blurExponent", 1.5f);
water.perlinStartFreq = wt.GetFloat("perlinStartFreq", 8.0f);
water.perlinLacunarity = wt.GetFloat("perlinLacunarity", 3.0f);
water.perlinAmplitude = wt.GetFloat("perlinAmplitude", 0.9f);
water.windSpeed = wt.GetFloat("windSpeed", 1.0f);
water.texture = wt.GetString("texture", "");
water.foamTexture = wt.GetString("foamTexture", "");
water.normalTexture = wt.GetString("normalTexture", "");
water.shoreWaves = wt.GetBool("shoreWaves", true);
water.forceRendering = wt.GetBool("forceRendering", false);
// use 'resources.lua' for missing fields (our the engine defaults)
const LuaTable resGfxMaps = resRoot->SubTable("graphics").SubTable("maps");
if (!water.texture.empty()) {
water.texture = "maps/" + water.texture;
} else {
water.texture = "bitmaps/" + resGfxMaps.GetString("watertex", "ocean.jpg");
}
if (!water.foamTexture.empty()) {
water.foamTexture = "maps/" + water.foamTexture;
} else {
water.foamTexture = "bitmaps/" + resGfxMaps.GetString("waterfoamtex", "foam.jpg");
}
if (!water.normalTexture.empty()) {
water.normalTexture = "maps/" + water.normalTexture;
water.numTiles = std::min(16,std::max(1,wt.GetInt("numTiles",1)));
} else {
water.normalTexture = "bitmaps/" + resGfxMaps.GetString("waternormaltex", "waterbump.png");
if (resGfxMaps.KeyExists("waternormaltex")) {
water.numTiles = std::min(16,std::max(1,resGfxMaps.GetInt("numTiles",1)));
}else{
// default texture is a TileSet of 3x3
// user-defined textures are expected to be 1x1 (no DynWaves possible)
water.numTiles = 3;
}
}
// water caustic textures
LuaTable caustics = wt.SubTable("caustics");
string causticPrefix = "maps/";
if (!caustics.IsValid()) {
caustics = resRoot->SubTable("graphics").SubTable("caustics");
causticPrefix = "bitmaps/";
}
if (caustics.IsValid()) {
for (int i = 1; true; i++) {
const string texName = caustics.GetString(i, "");
if (texName.empty()) {
break;
}
water.causticTextures.push_back(causticPrefix + texName);
}
} else {
// load the default 32 textures
for (int i = 0; i < 32; i++) {
char defTex[256];
sprintf(defTex, "bitmaps/caustics/caustic%02i.jpg", i);
water.causticTextures.push_back(defTex);
}
}
}