anchoring
Anchoring kinda works now
This commit is contained in:
@@ -172,7 +172,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="Advapi32.lib UxTheme.lib Comctl32.lib Comdlg32.lib Shell32.lib Urlmon.lib ole32.lib oleaut32.lib uuid.lib oded.lib OPCODE_D.lib"
|
AdditionalDependencies="Advapi32.lib UxTheme.lib Comctl32.lib Comdlg32.lib Shell32.lib Urlmon.lib ole32.lib oleaut32.lib uuid.lib ode.lib OPCODE.lib"
|
||||||
OutputFile="./Blocks3D-Debug.exe"
|
OutputFile="./Blocks3D-Debug.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ PartInstance::PartInstance(const PartInstance &oinst)
|
|||||||
bottom = oinst.bottom;
|
bottom = oinst.bottom;
|
||||||
shape = oinst.shape;
|
shape = oinst.shape;
|
||||||
changed = true;
|
changed = true;
|
||||||
|
physBody = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartInstance::setSize(Vector3 newSize)
|
void PartInstance::setSize(Vector3 newSize)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ XplicitNgine::XplicitNgine()
|
|||||||
contactgroup = dJointGroupCreate(0);
|
contactgroup = dJointGroupCreate(0);
|
||||||
|
|
||||||
dWorldSetGravity(physWorld, 0, -0.5, 0);
|
dWorldSetGravity(physWorld, 0, -0.5, 0);
|
||||||
dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
//dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
XplicitNgine::~XplicitNgine()
|
XplicitNgine::~XplicitNgine()
|
||||||
@@ -42,16 +42,22 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2)
|
|||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
||||||
if (dGeomGetClass(o1) == dSphereClass || dGeomGetClass(o2) == dSphereClass)
|
|
||||||
contact[i].surface.mu = 20;
|
// Define contact surface properties
|
||||||
else
|
contact[i].surface.mu = 0.5;
|
||||||
contact[i].surface.mu = 0.5;
|
|
||||||
contact[i].surface.slip1 = 0.0;
|
contact[i].surface.slip1 = 0.0;
|
||||||
contact[i].surface.slip2 = 0.0;
|
contact[i].surface.slip2 = 0.0;
|
||||||
contact[i].surface.soft_erp = 0.8;
|
contact[i].surface.soft_erp = 0.8;
|
||||||
contact[i].surface.soft_cfm = 0.01;
|
contact[i].surface.soft_cfm = 0.01;
|
||||||
dJointID c = dJointCreateContact (g_xplicitNgine->physWorld,g_xplicitNgine->contactgroup,contact+i);
|
|
||||||
dJointAttach (c,dGeomGetBody(o1),dGeomGetBody(o2));
|
// Create joints
|
||||||
|
dJointID c = dJointCreateContact(
|
||||||
|
g_xplicitNgine->physWorld,
|
||||||
|
g_xplicitNgine->contactgroup,
|
||||||
|
contact+i
|
||||||
|
);
|
||||||
|
|
||||||
|
dJointAttach (c,b1,b2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,13 +72,14 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
// init body
|
// init body
|
||||||
partInstance->physBody = dBodyCreate(physWorld);
|
partInstance->physBody = dBodyCreate(physWorld);
|
||||||
|
|
||||||
// init geom
|
// Create geom
|
||||||
partInstance->physGeom[0] = dCreateBox(physSpace,
|
partInstance->physGeom[0] = dCreateBox(physSpace,
|
||||||
partInstance->getSize()[0],
|
partInstance->getSize()[0],
|
||||||
partInstance->getSize()[1],
|
partInstance->getSize()[1],
|
||||||
partInstance->getSize()[2]
|
partInstance->getSize()[2]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Debug output
|
||||||
dVector3 result;
|
dVector3 result;
|
||||||
dGeomBoxGetLengths(partInstance->physGeom[0], result);
|
dGeomBoxGetLengths(partInstance->physGeom[0], result);
|
||||||
printf("[XplicitNgine] Part Geom Size: %.1f, %.1f, %.1f\n",
|
printf("[XplicitNgine] Part Geom Size: %.1f, %.1f, %.1f\n",
|
||||||
@@ -81,8 +88,8 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
result[2]
|
result[2]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Create rigid body
|
||||||
printf("[XplicitNgine] Created Geom for PartInstance\n");
|
printf("[XplicitNgine] Created Geom for PartInstance\n");
|
||||||
|
|
||||||
dBodySetPosition(partInstance->physBody,
|
dBodySetPosition(partInstance->physBody,
|
||||||
partInstance->getPosition()[0],
|
partInstance->getPosition()[0],
|
||||||
partInstance->getPosition()[1],
|
partInstance->getPosition()[1],
|
||||||
@@ -91,22 +98,17 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
|
|
||||||
printf("[XplicitNgine] Created Body for PartInstance\n");
|
printf("[XplicitNgine] Created Body for PartInstance\n");
|
||||||
|
|
||||||
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
if(!partInstance->anchored)
|
||||||
|
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// There is 100% a better way of doing this, but for now, anchored parts can be like this?
|
if(partInstance->anchored)
|
||||||
if(partInstance->anchored) {
|
return;
|
||||||
dBodySetPosition(partInstance->physBody,
|
|
||||||
partInstance->getPosition()[0],
|
|
||||||
partInstance->getPosition()[1],
|
|
||||||
partInstance->getPosition()[2]
|
|
||||||
);
|
|
||||||
|
|
||||||
dBodySetLinearVel(partInstance->physBody, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
||||||
|
|
||||||
// I hate matricies
|
// TODO: Rotation code
|
||||||
|
// Probably should be done AFTER we get physics KINDA working!!!
|
||||||
const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]);
|
const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]);
|
||||||
partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2]));
|
partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2]));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user