Ejemplo n.º 1
0
void * handshakeWithdrone(char *droneIp, uint16_t dronePort, HANDSHAKE_DATA_T *handshakeData) {
	void *handshakeHandler = NULL;
	char *jsonStr = NULL;
	int32_t bytesSent = 0;
    char handshakeResponse[1024 * 1024] = {0};
    int32_t handshakeResLen = 0;
	HANDSHAKE_REQ_T handshakeRequest = { 0 };

    printf("%s:%s:%d\n", __FILE__, __func__, __LINE__ );
	handshakeHandler = initTcpClientSocket(dronePort, droneIp, NULL);
	if (NULL == handshakeHandler) {
		return NULL;
	}

    printf("%s:%s:%d Sending Handshake request\n", __FILE__, __func__, __LINE__ );
	strncpy(handshakeRequest.controller_name, CONTROLLER_NAME, 64);
	strncpy(handshakeRequest.controller_type, CONTROLLER_TYPE, 64);
	handshakeRequest.d2c_port = D2C_PORT;
	handshakeRequest.arstream2_client_stream_port = 5004;
	handshakeRequest.arstream2_client_control_port = 5005;


	jsonStr = convertToJson(&handshakeRequest);
	if (NULL == jsonStr) {
		printf("Json parsing failed \n");
		closeTcpClient(handshakeHandler);
		return NULL;
	}

	bytesSent = sendSyncDataToTcpServer(handshakeHandler, jsonStr, strlen(jsonStr), handshakeResponse, &handshakeResLen);
	if (0 == bytesSent) {
		free(jsonStr);
		closeTcpClient(handshakeHandler);
		return NULL;
	}
    printf("handshake data %s\n", handshakeResponse);
    
    parseJsonToHandshakeData(handshakeResponse, handshakeData);
    free(jsonStr);
	return handshakeHandler;
}
Ejemplo n.º 2
0
web::json::value BabylonMesh::toJson()
{
	auto jobj = BabylonAbstractMesh::toJson();
	jobj[L"id"] = web::json::value::string(_id);
	jobj[L"name"] = web::json::value::string(_id);
	if (_parentId.size() > 0)
		jobj[L"parentId"] = web::json::value::string(_parentId);
	if (_materialId.size() > 0)
		jobj[L"materialId"] = web::json::value::string(_materialId);


	jobj[L"isEnabled"] = web::json::value::boolean(_isEnabled);
	jobj[L"isVisible"] = web::json::value::boolean(_isVisible);
	jobj[L"pickable"] = web::json::value::boolean(_pickable);
	jobj[L"hasVertexAlpha"] = web::json::value::boolean(_hasVertexAlpha);
	jobj[L"checkCollision"] = web::json::value::boolean(_checkCollision);
	jobj[L"receiveShadows"] = web::json::value::boolean(_receiveShadows);
	jobj[L"infiniteDistance"] = web::json::value::boolean(_infiniteDistance);
	jobj[L"billboardMode"] = web::json::value::number(_billboardMode);
	jobj[L"visibility"] = web::json::value::number(_visibility);
	jobj[L"skeletonId"] = web::json::value::number(_skeletonId);

	auto submeshesArray = web::json::value::array();
	for (auto ix = 0u; ix < submeshes().size(); ++ix){
		submeshesArray[ix] = submeshes()[ix].toJson();
	}
	jobj[L"subMeshes"] = submeshesArray;
	jobj[L"showBoundingBox"] = web::json::value::boolean(_showBoundingBox);
	jobj[L"showSubMeshesBoundingBox"] = web::json::value::boolean(_showSubMeshesBoundingBox);
	jobj[L"applyFog"] = web::json::value::boolean(_applyFog);
	jobj[L"alphaIndex"] = web::json::value::number(_alphaIndex);
	if (_positions.size() > 0)
		jobj[L"positions"] = convertToJson(_positions);
	if (_normals.size() > 0)
		jobj[L"normals"] = convertToJson(_normals);
	if (_uvs.size() > 0)
		jobj[L"uvs"] = convertToJson(_uvs);
	if (_uvs2.size() > 0)
		jobj[L"uvs2"] = convertToJson(_uvs2);
	if (_uvs3.size() > 0)
		jobj[L"uvs3"] = convertToJson(_uvs3);
	if (_uvs4.size() > 0)
		jobj[L"uvs4"] = convertToJson(_uvs4);
	if (_uvs5.size() > 0)
		jobj[L"uvs5"] = convertToJson(_uvs5);
	if (_uvs6.size() > 0)
		jobj[L"uvs6"] = convertToJson(_uvs6);
	if (_colors.size() > 0)
		jobj[L"colors"] = convertToJson(_colors);
	if (_indices.size() > 0)
		jobj[L"indices"] = convertToJson(_indices, false);
	if (_boneIndices.size() > 0){
		jobj[L"matricesIndices"] = convertToJson(_boneIndices);
	}
	if (_boneWeights.size() > 0){
		jobj[L"matricesWeights"] = convertToJson(_boneWeights);
	}
	if (animations.size() == 0 && !associatedSkeleton){

		jobj[L"autoAnimate"] = web::json::value::boolean(false);
		jobj[L"autoAnimateLoop"] = web::json::value::boolean(false);
		jobj[L"autoAnimateFrom"] = web::json::value::number(0);
		jobj[L"autoAnimateTo"] = web::json::value::number(0);

	}
	else if (animations.size()>0){

		jobj[L"autoAnimate"] = web::json::value::boolean(animations[0]->autoAnimate);
		jobj[L"autoAnimateLoop"] = web::json::value::boolean(animations[0]->autoAnimateLoop);
		jobj[L"autoAnimateFrom"] = web::json::value::number(animations[0]->autoAnimateFrom);
		jobj[L"autoAnimateTo"] = web::json::value::number(animations[0]->autoAnimateTo);
	}
	
	else{

		jobj[L"autoAnimate"] = web::json::value::boolean(associatedSkeleton->bones[0].animation->autoAnimate);
		jobj[L"autoAnimateLoop"] = web::json::value::boolean(associatedSkeleton->bones[0].animation->autoAnimateLoop);
		jobj[L"autoAnimateFrom"] = web::json::value::number(associatedSkeleton->bones[0].animation->autoAnimateFrom);
		jobj[L"autoAnimateTo"] = web::json::value::number(associatedSkeleton->bones[0].animation->autoAnimateTo);
	}

	auto janimations = web::json::value::array();
	for (const auto& anim : animations){
		janimations[janimations.size()] = anim->toJson();
	}
	jobj[L"animations"] = janimations;
	FbxMatrix identity;
	identity.SetIdentity();
	if (pivotMatrix != identity){
		auto jpivot = web::json::value::array();
		for (auto x = 0; x < 4; ++x){
			for (auto y = 0; y < 4; ++y){
				jpivot[x * 4 + y] = web::json::value::number( pivotMatrix[x][y]);
			}
		}
		jobj[L"pivotMatrix"] = jpivot;
	}

	auto jinstances = web::json::value::array();
	for (auto& instance : _instances) {
		jinstances[jinstances.size()] = instance.toJson();
	}
	jobj[L"instances"] = jinstances;
	return jobj;
}