|
UploadTexturePhp
Upload Texture Example.
The following code show how to upload an image to the simulator : <?php
// Load metaverse client
require_once 'mmetaverse/src/mjs/mmetaverse/client/MMetaverseClient.class.php';
// Try to open client connection
try {
// Grid User Info
$firstname = 'Juan';
$lastname = 'Perez';
$password = '1234';
$server = '192.168.1.2';
$port = 9000;
// Create a client a do login
$client = new MMetaverseClient($server,$port);
$client->login($firstname, $lastname, $password);
// Sleep while the opensim opens the udp server and
// Register the client
sleep(20);
// Try to upload image using capabilities
try {
// Image Information
$name = 'texture02';
$description = 'Texture upload by MMetaverse';
$content = file_get_contents('image01.jp2');
// Get inventory and upload image
$inventory = $client->getInventory();
$response = $inventory->uploadTexture($name, $description, $content);
// Print the new texture uuid
echo 'New Asset :' . $response->getHyphenated();
} catch (Exception $e) {
// Show the error information
echo 'Error : ' . $e->getMessage();
}
// Close the connection with the simulator
$client->logout();
} catch (Exception $e) {
// Show the error information
echo 'Error : ' . $e->getMessage();
}
?>
|
► Sign in to add a comment