void Humanoid::InstantiateAtom() { //a single cuboid girder to cover this cell Ogre::SceneManager& sceneManager = GetSceneManager(); m_pAtomEntity = sceneManager.createEntity("human_" + num2string(m_AtomID), "ninja.mesh"); m_pAtomEntitySceneNode->attachObject(m_pAtomEntity); m_pAtomEntitySceneNode->scale(0.004f, 0.004f, 0.004f); m_pAtomEntitySceneNode->setPosition(0, -0.4f, 0); //create physics collider btVector3 halfExtents = btVector3(0.15f, 0.4f, 0.1f); m_pCollisionShape = new btBoxShape(halfExtents); btDefaultMotionState* startMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), OGRE2BT(m_pAtomEntitySceneNode->_getDerivedPosition()))); btScalar mass = 100.f; btVector3 fallInertia(0,0,0); m_pCollisionShape->calculateLocalInertia(mass,fallInertia); btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass, startMotionState, m_pCollisionShape, fallInertia); m_pRigidBody = new btRigidBody(rigidBodyCI); m_pRigidBody->setUserPointer(this); m_pRigidBody->setAngularFactor(0); InitCollisionShapeDebugDraw(Ogre::ColourValue::Green); //todo: is this working? //m_pRigidBody->setCollisionFlags(m_pRigidBody->CF_NO_CONTACT_RESPONSE); //add new rigid body to world btDiscreteDynamicsWorld& dynamicsWorld = GetDynamicsWorld(); dynamicsWorld.addRigidBody(m_pRigidBody, COLLISION_MOB, COLLISION_STRUCTURE|COLLISION_OBJ|COLLISION_MOB); Mob::InstantiateAtom(); }
Mat take_pic ( const camera& cam, const float& global_t ) { int frame_idx = global_t; float center_x = int (cam.center_x) + 0.5; float center_y = int (cam.center_y) + 0.5; int L = (center_x + 0.5) - cam.width * cam.zoom / 2; int U = (center_y + 0.5) - cam.height * cam.zoom / 2; Mat frame = imread ( destination + num2string ( frame_idx ) + ".jpg", CV_LOAD_IMAGE_COLOR); Mat sub_img_temp1 = frame( Rect (L, U, cam.width * cam.zoom, cam.height * cam.zoom)).clone(); IplImage* sub_img_temp2 = new IplImage(sub_img_temp1); Image* sub_img = new Image(sub_img_temp2); float v = log(cam.zoom) / 1.33886; GaussianFilter gss(9, 9, v); ImageWarpper wp; Image *down = wp.downSamplePSF( sub_img, 1/cam.zoom, &gss, 0, 0); //down->SaveImage ("zoom_2_diff4.jpg"); Mat down_mat( down->getIplImg(), 1); return down_mat; }
END_TEST START_TEST(tc_num2string) { char buf[20]; fail_if(num2string(-1,NULL,1) != -1); fail_if(num2string(1,NULL,1) != -1); fail_if(num2string(1,buf,1) != -1); fail_if(num2string(1,buf,3) != 2); fail_if(num2string(11,buf,3) != 3); fail_if(num2string(112,buf,4) != 4); }
static GOOD_OR_BAD LINK_PowerByte(const BYTE data, BYTE * resp, const UINT delay, const struct parsedname *pn) { struct connection_in * in = pn->selected_connection ; ASCII buf[3] = "pxx"; BYTE respond[2+in->CRLF_size] ; num2string(&buf[1], data); RETURN_BAD_IF_BAD(LINK_write(LINK_string(buf), 3, in) ) ; // delay UT_delay(delay); // flush the buffers RETURN_BAD_IF_BAD(LINK_write(LINK_string("\r"), 1, in) ) ; RETURN_BAD_IF_BAD( LINK_readback_data( LINK_string(respond), 2, in) ) ; resp[0] = string2num((const ASCII *) respond); return gbGOOD ; }
void simulation_init () { VideoCapture inputVideo( destination + source ); if (! inputVideo.isOpened() ) { cout << "Can't open Video : " << source << endl; return ; } Mat frame; int num_frame = 0; string temp_save_dir; for (num_frame=0; num_frame>-1; num_frame++) { inputVideo >> frame; if ( frame.empty() ) break; temp_save_dir = destination + num2string(num_frame) + ".jpg"; imwrite ( temp_save_dir, frame); } }
void UnderlayPlating::InstantiateStructure(bool a_IsBuildPoint) { //an overlay plate is essentially an "outer cover" for the tile in one of the six cardinal directions //system is currently setup to handle any combination of the six, but it probably shouldn't be m_IsBuildPoint = a_IsBuildPoint; Ogre::SceneManager& sceneManager = GetSceneManager(); //std::cout << "instantiating UnderlayPlating with direction " << m_Direction << std::endl; m_AtomFlags = RCD_CAN_DESTROY; //create entity m_pAtomEntity = sceneManager.createEntity("UnderlayPlating_" + num2string(m_AtomID), "cell_underlay.mesh"); m_pAtomEntitySceneNode->attachObject(m_pAtomEntity); StopFlashingColour(); //set up the directional offsets Ogre::Vector3 offsetPos(0, 0, 0); Ogre::Vector3 lookatPos(0, 0, 0); btVector3 halfExtents(0.5f, 0.5f, 0.5f); //std::cout << " new overlay plating" << std::endl; if(m_Direction & NORTH) { offsetPos.z += 0.395f; lookatPos.z += 1; halfExtents.setZ(0.005f); //std::cout << "NORTH " << (isPhysical ? "plating" : "trigger") << std::endl; } if(m_Direction & SOUTH) { offsetPos.z -= 0.395f; lookatPos.z -= 1; halfExtents.setZ(0.005f); //std::cout << "SOUTH " << (isPhysical ? "plating" : "trigger") << std::endl; } if(m_Direction & EAST) { offsetPos.x += 0.395f; lookatPos.x += 1; halfExtents.setX(0.005f); //std::cout << "EAST " << (isPhysical ? "plating" : "trigger") << std::endl; } if(m_Direction & WEST) { offsetPos.x -= 0.395f; lookatPos.x -= 1; halfExtents.setX(0.005f); //std::cout << "WEST " << (isPhysical ? "plating" : "trigger") << std::endl; } if(m_Direction & UP) { offsetPos.y += 0.395f; lookatPos.y += 1; halfExtents.setY(0.005f); //std::cout << "UP " << (isPhysical ? "plating" : "trigger") << std::endl; } if(m_Direction & DOWN) { offsetPos.y -= 0.395f; lookatPos.y -= 1; halfExtents.setY(0.005f); //std::cout << "DOWN " << (isPhysical ? "plating" : "trigger") << std::endl; } m_pAtomEntitySceneNode->setPosition(offsetPos); m_pAtomEntitySceneNode->lookAt(lookatPos, Ogre::Node::TS_LOCAL); m_pAtomEntitySceneNode->yaw(Ogre::Degree(90)); //create physics body and initialise to starting position m_pCollisionShape = new btBoxShape(halfExtents); btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), OGRE2BT(m_pAtomEntitySceneNode->_getDerivedPosition()))); btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0, groundMotionState, m_pCollisionShape, btVector3(0,0,0)); m_pRigidBody = new btRigidBody(groundRigidBodyCI); m_pRigidBody->setUserPointer(this); //add new rigid body to world btDiscreteDynamicsWorld& dynamicsWorld = GetDynamicsWorld(); if(m_IsBuildPoint) { SetEntityVisible(false); m_pAtomEntity->setMaterialName("cell_highlight_material"); dynamicsWorld.addRigidBody(m_pRigidBody, COLLISION_BUILDPOINT, RAYCAST_BUILD); //todo: is this working? //m_pRigidBody->setCollisionFlags(m_pRigidBody->CF_NO_CONTACT_RESPONSE); } else { dynamicsWorld.addRigidBody(m_pRigidBody, COLLISION_STRUCTURE, RAYCAST_BUILD|COLLISION_OBJ|COLLISION_MOB); } InitCollisionShapeDebugDraw(Ogre::ColourValue::Red); }