Changed the switch object, its graphics and physics should work now(untested). Objects without physics also do not need damping values anymore.

This commit is contained in:
Steffen 2015-02-07 19:34:40 +01:00
parent 3e8689aae2
commit b6a9e2f180
2 changed files with 39 additions and 16 deletions

View File

@ -151,6 +151,17 @@
<modelPath>switch_outer.obj</modelPath>
<xOffset>0.0</xOffset>
<yOffset>-1</yOffset>
<zOffset>0.0</zOffset>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<scale>1.0</scale>
<mass>1.0</mass>
</object>
<object>
<modelPath>switch_outerBox</modelPath>
<xOffset>0.0</xOffset>
<yOffset>-1</yOffset>
<zOffset>1.105</zOffset>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
@ -159,7 +170,7 @@
<mass>0.0</mass>
</object>
<object>
<modelPath>switch_outer.obj</modelPath>
<modelPath>switch_outerBox</modelPath>
<xOffset>0.0</xOffset>
<yOffset>-1</yOffset>
<zOffset>-1.105</zOffset>
@ -170,7 +181,7 @@
<mass>0.0</mass>
</object>
<object>
<modelPath>switch_outer.obj</modelPath>
<modelPath>switch_outerBox</modelPath>
<xOffset>1.105</xOffset>
<yOffset>-1</yOffset>
<zOffset>0.0</zOffset>
@ -181,7 +192,7 @@
<mass>0.0</mass>
</object>
<object>
<modelPath>switch_outer.obj</modelPath>
<modelPath>switch_outerBox</modelPath>
<xOffset>-1.105</xOffset>
<yOffset>-1</yOffset>
<zOffset>0.0</zOffset>
@ -192,7 +203,7 @@
<mass>0.0</mass>
</object>
<object>
<modelPath>switch_outer.obj</modelPath>
<modelPath>switch_outerBox</modelPath>
<xOffset>0.0</xOffset>
<yOffset>-2.105</yOffset>
<zOffset>0.0</zOffset>
@ -525,18 +536,24 @@
<!-- Do not change width height or length, they have to match the .obj -->
<objectData>
<modelPath>switch_outer.obj</modelPath>
<texturePath>switchTextureOuter.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
<modelPath>switch_outerBox</modelPath>
<physicType>Box</physicType>
<width>2.54</width>
<height>2.54</height>
<length>0.33</length>
<dampningL>0.555</dampningL>
<dampningA>0.5</dampningA>
<renderable>false</renderable>
</objectData>
<objectData>
<modelPath>switch_outer.obj</modelPath>
<texturePath>switchTextureOuter.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
<physicType>None</physicType>
<renderable>true</renderable>
</objectData>

View File

@ -192,17 +192,18 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
XMLElement* constraint = thisComposition->FirstChildElement("positionConstraint");
bool rotate = (constraint == NULL);
float dampningL, dampningA;
if (physicType.compare("Player") == 0){
float radius, dampningL, dampningA;
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
if (physicType.compare("Player") == 0){
float radius;
errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&radius));
radius *= objectScale*compScale;
level->addPhysicsObject(object);
level->getPhysics()->addPlayer(friction, radius, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize());
}else if (physicType.compare("Box") == 0){
float width, height, length;
float width, height, length, dampningL, dampningA;
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
@ -212,7 +213,9 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
level->addPhysicsObject(object);
level->getPhysics()->addBox(width, height, length, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), rotate);
}else if (physicType.compare("Button") == 0){
float width, height, length;
float width, height, length, dampningL, dampningA;
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
@ -222,6 +225,9 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
level->addPhysicsObject(object);
level->getPhysics()->addButton(width, height, length, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), rotate);
}else if (physicType.compare("TriangleMesh") == 0){
float dampningL, dampningA;
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
level->addPhysicsObject(object);
level->getPhysics()->addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), objectScale*compScale, rotate);
}else if (physicType.compare("None") == 0){