Vec3 min (100000, 100000, 100000);
Vec3 max(-100000, -100000, -100000);
for (int i = 0; i < RIGIDTESTCOUNT; i++)//
{
//MeshPtr mesh = Mesh::create();
//Primitives::createBox(vec3(4.0,4.0,4.0))->getMesh(mesh);
//m_boundMeshs[i] = ObjectMeshStatic::create(mesh);
//m_boundMeshs[i]->setMaterial("mesh_base", "*");
NodeReferencePtr noderef = NodeReference::create("data/nodes/DYBZC1.node");
NodePtr node;
ObjectPtr obj;
m_boundMeshs[i] = ObjectMeshStatic::cast(noderef->detachReference());
m_boundMeshs[i]->release();
m_boundMeshs[i]->setCastShadow(0, 0);
m_boundMeshs[i]->setCastWorldShadow(0, 0);
vec3 boxSize = m_boundMeshs[i]->getBoundBox().getMax() - m_boundMeshs[i]->getBoundBox().getMin();
//Primitives::createBox(boxSize)->getMesh(mesh);
//m_boundMeshs[i] = ObjectMeshStatic::create(mesh);
//m_boundMeshs[i]->setWorldTransform(node->getWorldTransform());
//BoundBox box = m_boundMeshs[i]->getBoundBox();
ShapeBoxPtr shape = ShapeBox::create(boxSize);//创建自定义形状
BodyRigidPtr rigid = BodyRigid::create();
rigid->addShape(shape->getShape(), mat4(translate(Vec3(0, 0, -boxSize.z / 2))*m_boundMeshs[i]->getWorldTransform()));//初始化rigidbody
m_boundMeshs[i]->setBody(rigid->getBody());//给mesh设置rigidbody
//m_boundMeshs[i]->addChild(node);
//node->setPosition(node->getPosition() - Vec3(0,0,boxSize.z/2));
//m_boundMeshs[i]->setMaterial("mesh_base_0", "*");
Vec3 outpos;
vec3 dir;
float randx = Game::get()->getRandomFloat(-1, 1)*0.005;
float randy = Game::get()->getRandomFloat(-1, 1)*0.005;
GlobalPivot::get()->getIntersectionByGeoPos(Vec3(31.2162919999999993+ randx, 121.3660770000000042 +randy, 10), outpos, dir);
//Log::message("%d:%f,%f,%f\n",i, outpos.x, outpos.y, outpos.z);
//node->setWorldPosition(outpos );//+ Vec3(0, 0, boxSize.z / 2)
m_boundMeshs[i]->setWorldPosition(outpos + Vec3(0, 0, boxSize.z/2));
//m_boundMeshs[0]->setCollider(0);
if (outpos.x < min.x) min.x = outpos.x;
if (outpos.y < min.y) min.y = outpos.y;
if (outpos.z < min.z) min.z = outpos.z;
if (outpos.x > max.x) max.x = outpos.x;
if (outpos.y > max.y) max.y = outpos.y;
if (outpos.z > max.z) max.z = outpos.z;
}