Added scaling to the physic of Box and Button. Adjusted the objectData for block.obj perfectly.
This commit is contained in:
parent
bb57eb2263
commit
c57d73317c
@ -369,6 +369,7 @@
|
|||||||
<dampningA>0.7</dampningA>
|
<dampningA>0.7</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
|
<!-- Do not change width height or length, they have to match the .obj -->
|
||||||
<objectData>
|
<objectData>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<texturePath>blockTexture_small.png</texturePath>
|
<texturePath>blockTexture_small.png</texturePath>
|
||||||
@ -377,9 +378,9 @@
|
|||||||
<specularFactor>0.4</specularFactor>
|
<specularFactor>0.4</specularFactor>
|
||||||
<shininess>2.0</shininess>
|
<shininess>2.0</shininess>
|
||||||
<physicType>Box</physicType>
|
<physicType>Box</physicType>
|
||||||
<width>6</width>
|
<width>4</width>
|
||||||
<height>3</height>
|
<height>1.88</height>
|
||||||
<length>3</length>
|
<length>1.99</length>
|
||||||
<dampningL>0.8</dampningL>
|
<dampningL>0.8</dampningL>
|
||||||
<dampningA>0.9</dampningA>
|
<dampningA>0.9</dampningA>
|
||||||
|
|
||||||
@ -409,6 +410,7 @@
|
|||||||
<dampningA>1.0</dampningA>
|
<dampningA>1.0</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
|
<!-- Do not change width height or length, they have to match the .obj -->
|
||||||
<objectData>
|
<objectData>
|
||||||
<modelPath>switch_inner.obj</modelPath>
|
<modelPath>switch_inner.obj</modelPath>
|
||||||
<texturePath>switchTextureInner.png</texturePath>
|
<texturePath>switchTextureInner.png</texturePath>
|
||||||
@ -424,6 +426,7 @@
|
|||||||
<dampningA>1.0</dampningA>
|
<dampningA>1.0</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
|
<!-- Do not change width height or length, they have to match the .obj -->
|
||||||
<objectData>
|
<objectData>
|
||||||
<modelPath>switch_outer.obj</modelPath>
|
<modelPath>switch_outer.obj</modelPath>
|
||||||
<texturePath>switchTextureOuter.png</texturePath>
|
<texturePath>switchTextureOuter.png</texturePath>
|
||||||
@ -439,6 +442,7 @@
|
|||||||
<dampningA>0.5</dampningA>
|
<dampningA>0.5</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
|
<!-- Width height and length are not exact, Wall should be a TriangleMesh but that does not work... -->
|
||||||
<objectData>
|
<objectData>
|
||||||
<modelPath>simpleWall.obj</modelPath>
|
<modelPath>simpleWall.obj</modelPath>
|
||||||
<texturePath>simpleWallTexture.png</texturePath>
|
<texturePath>simpleWallTexture.png</texturePath>
|
||||||
@ -446,10 +450,10 @@
|
|||||||
<diffuseFactor>0.6</diffuseFactor>
|
<diffuseFactor>0.6</diffuseFactor>
|
||||||
<specularFactor>0.4</specularFactor>
|
<specularFactor>0.4</specularFactor>
|
||||||
<shininess>2.0</shininess>
|
<shininess>2.0</shininess>
|
||||||
<physicType>Box</physicType>
|
<physicType>TriangleMesh</physicType>
|
||||||
<width>6</width>
|
<width>1.5</width>
|
||||||
<height>10</height>
|
<height>10</height>
|
||||||
<length>3</length>
|
<length>6</length>
|
||||||
<dampningL>0.555</dampningL>
|
<dampningL>0.555</dampningL>
|
||||||
<dampningA>0.5</dampningA>
|
<dampningA>0.5</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
8
level.cc
8
level.cc
@ -273,15 +273,21 @@ void Level::load() {
|
|||||||
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
||||||
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
||||||
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
|
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
|
||||||
|
width *= objectScale*compScale;
|
||||||
|
height *= objectScale*compScale;
|
||||||
|
length *= objectScale*compScale;
|
||||||
this->physics.addBox(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size(), rotate);
|
this->physics.addBox(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size(), rotate);
|
||||||
}else if (physicType.compare("Button") == 0){
|
}else if (physicType.compare("Button") == 0){
|
||||||
float width, height, length;
|
float width, height, length;
|
||||||
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
||||||
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
||||||
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
|
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
|
||||||
|
width *= objectScale*compScale;
|
||||||
|
height *= objectScale*compScale;
|
||||||
|
length *= objectScale*compScale;
|
||||||
this->physics.addButton(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size(), rotate);
|
this->physics.addButton(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size(), rotate);
|
||||||
}else if (physicType.compare("TriangleMesh") == 0){
|
}else if (physicType.compare("TriangleMesh") == 0){
|
||||||
this->physics.addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, physicObjects.size(), objectScale, rotate);
|
this->physics.addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, physicObjects.size(), objectScale*compScale, rotate);
|
||||||
} else{
|
} else{
|
||||||
printf("XMLError: Not a valid physicType.\n");
|
printf("XMLError: Not a valid physicType.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
Loading…
Reference in New Issue
Block a user