I was asked about making sculpties in Blender. Well the fact of the matter is that it's a little bit of a pain to set up if you're doing it from scratch. So what I've done is I've taken care of the initial steps and saved the file, and that is available to everyone here: http://bitcracked.com/sl/sculpty.html Just download the file, unzip and open it.
I have it set up with the default cylinder. If you want more vertices just push A (hotkey to select all), go to edit mode, click editing (looks like a sqaure with dots at the corners) and click subdivide.
To export your sculpty map, follow these steps.
1. Move your mouse right over the line between the top and bottom window and choose "split area"
2. Click the little box at the bottom left of the new window you just created and select "UV/image editor"
3. Click on Image > new, and set the dimensions for 256x256. Then, push F10 to go to the render menu, and click the "bake" tab. In the right column, click "Textures", and then click the large "Bake" button. You will see your colored sculpt map appear in the right window.
4. Once the image has been baked, click on image again, choose Save As, and select where you want to save your image. At the bottom of the save screen make sure you select to save your image as a Targa file.
I know there are plugins and junk to make sculpties in blender, but if you don't feel like using those or they're giving you trouble, this can be an easier way to make them without plugins. Just make sure you don't save over your sculptstart.blend file :)
Also, I know that SL will trim down your image to be 128x128 (and 32x33 verts) when you use it as a sculpt map but I always like to start high res and then let it be trimmed down as needed.
skip to main |
skip to sidebar
Pages
LSL help: any question is fair game!
Wednesday, May 26, 2010
Dave's Giant Database Insertion Tutorial
So, I've had a request to explain inserting data into an external database from SL. This is a pretty lengthy subject but to shorten it up for this post I'm going to assume a few things, such as:
That being said, let's get started. The first thing you will need is to set up your database and know what you are going to store. For this example let's say you want to insert the name of an avatar into a database whenever the object is touched, and keep a running tab of how many times they have touched it.
Assume you have a database called "SL" with a table called "stats". Stats has two columns, "name" and "number". Name will be the name of the avatar (for this example it would need to be set as unique). Number will represent the number of times the prim was clicked.
Now what we are going to do is set up our PHP script. What will happen is that every time the prim is clicked, it will send a request to this PHP script, which will then update the database. Here is an example of what the PHP script should look like for this example.
<?php
$db = mysql_connect("localhost", "db_username", "your_password") or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.')</script></html>");
mysql_select_db("SL",$db);
$name = $_GET['name']; //$_GET takes variables that are passed from the url (see the LSL example)
$usertable = "stats";
$update = "INSERT INTO $usertable SET name = '$name', number = 1 ON DUPLICATE KEY UPDATE number = number + 1";
$result = mysql_query($update);
?>
And now for the LSL script that will send the request to the PHP page:
- You have a web server and a place that this database/web script can go.
- You have a database and don't need help setting one up
- You have at least very basic knowledge of PHP and writing MySQL requests.
That being said, let's get started. The first thing you will need is to set up your database and know what you are going to store. For this example let's say you want to insert the name of an avatar into a database whenever the object is touched, and keep a running tab of how many times they have touched it.
Assume you have a database called "SL" with a table called "stats". Stats has two columns, "name" and "number". Name will be the name of the avatar (for this example it would need to be set as unique). Number will represent the number of times the prim was clicked.
Now what we are going to do is set up our PHP script. What will happen is that every time the prim is clicked, it will send a request to this PHP script, which will then update the database. Here is an example of what the PHP script should look like for this example.
<?php
$db = mysql_connect("localhost", "db_username", "your_password") or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.')</script></html>");
mysql_select_db("SL",$db);
$name = $_GET['name']; //$_GET takes variables that are passed from the url (see the LSL example)
$usertable = "stats";
$update = "INSERT INTO $usertable SET name = '$name', number = 1 ON DUPLICATE KEY UPDATE number = number + 1";
$result = mysql_query($update);
?>
And now for the LSL script that will send the request to the PHP page:
string owner_name;key owner_name_query;default
{state_entry()
{
}
touch_start(integer total_number)
{
owner_name_query = llRequestAgentData(llGetOwner(), DATA_NAME);
}
dataserver(key queryid, string data){
if (owner_name_query == queryid){owner_name = data;llHTTPRequest("http://www.yoursite.com/yourphppage.php?name=" + owner_name, [], "");
}
}}
Let's take a look at the URL in the llHTTPRequest function. http://www.yoursite.com/yourphppage.php?name=" + owner_name. Remember the $_GET['name'] part of the PHP script? Well this is where that variable is taking data from. ?name= denotes a variable that can be passed to PHP using a URL. If you want to pass more variables, you can string them along with ampersands like this: ?name=Joe_Shmo&id=123456&status=living
Well I hope that is enough to get you started loading things into databases. Next time we can talk about how to get data back out of the database.
Well I hope that is enough to get you started loading things into databases. Next time we can talk about how to get data back out of the database.
Labels:
dataserver,
llGetOwner,
llHTTPRequest,
llRequestAgentData,
PHP
Sunday, May 23, 2010
Beacon
So Patti wanted a beacon for a radio tower she was making, and I came up with this script. It's a pretty simple script but there's a nifty trick in here I felt like I just *had* to blog about. Here is the beacon script.
The neat trick is using llSetLinkPrimitiveParamsFast instead of llSetPrimitiveParams. Check out the video to see why :) The one using llSetLinkPrimitiveParamsFast is on the left. Nice and smooth :)
Oh! The one thing to look out for: you have to be careful changing the speed, do some math and make sure it won't try setting the glow under 0 or over 1. Otherwise you get a super annoying script error D:
float delay = 0.01;
float k = 0;
integer toggle = 0;
default
{
state_entry()
{
llSetTimerEvent(delay);
}
timer(){
if(toggle == 0){
llSetLinkPrimitiveParamsFast(LINK_SET, [25, ALL_SIDES, k]);
k += 0.03; //changing this will change how fast the blink is
if (k >= .5){
toggle = 1;
}
}
if(toggle == 1){
llSetLinkPrimitiveParamsFast(LINK_SET, [25, ALL_SIDES, k]);
k -= 0.03;
if (k <= 0.04){ toggle = 0; } } } }
The neat trick is using llSetLinkPrimitiveParamsFast instead of llSetPrimitiveParams. Check out the video to see why :) The one using llSetLinkPrimitiveParamsFast is on the left. Nice and smooth :)
Oh! The one thing to look out for: you have to be careful changing the speed, do some math and make sure it won't try setting the glow under 0 or over 1. Otherwise you get a super annoying script error D:
Labels:
llSetLinkPrimitiveParamsfast,
llSetTimerEvent,
timer
Instructions
If you have a question you would like to see answered here, feel free to ask it in the comment section of any post, or email it to:
nucularsecrets@gmail.com
Any question is fair game, so don't be shy!
nucularsecrets@gmail.com
Any question is fair game, so don't be shy!
Featured
- OpenSim (1)
- Outline (1)
- Sculpties in Blender (1)
Followers
Contributors
Friends
Index
- changed (2)
- click and drag (1)
- dataserver (2)
- link_message (1)
- llAllowInventoryDrop (1)
- llAvatarOnSitTarget (1)
- llDetectedKey (2)
- llDetectedName (1)
- llDetectedTouchPos (1)
- llDetectedTouchUV (1)
- llGetOwner (2)
- llGetScriptName (1)
- llHTTPRequest (1)
- llListen (1)
- llParticleSystem (1)
- llRegionSay (1)
- llRemoveInventory (1)
- llRequestAgentData (2)
- llResetScript (1)
- llSay (3)
- llSetLinkPrimitiveParamsfast (2)
- llSetObjectName (1)
- llSetPos (1)
- llSetTimerEvent (1)
- llSitTarget (1)
- particles (1)
- PHP (1)
- timer (1)
- touch (1)
Blog Archive
-
►
2011
(1)
- ► Feb 27 - Mar 6 (1)
-
▼
2010
(18)
- ► Nov 21 - Nov 28 (1)
- ► Sep 19 - Sep 26 (1)
- ► Aug 15 - Aug 22 (1)
- ► Aug 8 - Aug 15 (1)
- ► Aug 1 - Aug 8 (1)
- ► Jul 25 - Aug 1 (1)
- ► Jul 4 - Jul 11 (1)
- ► Jun 13 - Jun 20 (1)
- ▼ May 23 - May 30 (3)
- ► May 16 - May 23 (5)
- ► May 2 - May 9 (2)
Copyright 2010 Nucular Secrets . Powered by Blogger
Blogger Templates created by Deluxe Templates Wordpress by thebookish