Jump to content

  • Log In with Google      Sign In   
  • Create Account

Rendering Systems



Custom Random Image Blocks for your Journal

Posted by , in Web Dev 11 March 2011 - - - - - - · 793 views

I've recently discovered “Custom Content Blocks” on my journal page. For examples, take a look at the blocks on the right of this page, the top three are custom content blocks. Yesterday I added a “Random Album Image” block to the top of my page. It started displaying random images from my Woody3D gallery. Today when I visited my journal it was displaying random images from every member gallery on gamedev.net. Strange, I thought. That's not going to work. So rather than bug the gamedev.net developers with my feedback, I solved the problem myself.

Requirements: Web server with PHP.

On my server I created a directory with the following items:

Posted Image

The "woody3d_screens" folder contains all images I want to display randomly. To make them fit They are all resized to have a width of 160 pixels. All images are jpeg so they work with my random image script.

The .htaccess file is important. It tells the server to treat any file with the extension .jpg as a php file. This is done because gamedev.net image links need to have of an image type file extension to display. So for instance writing <img src=”random_image.php” /> will not work in the custom block.

The
"woody3d_screens" .jpg file is actually a PHP script. It finds all files in the folder of type jpeg and outputs one of them randomly using a custom header with Content-type: image/jpeg.

The PHP file is just a redirect to the gallery page. I use this because linking directly to my gamedev.net gallery in the custom block creates a popup block advertising the gallery (for some weird reason). So I link my randomized image to the redirect script instead.

Here is what is in each file:

.htaccess

Options All -Indexes

#sets jpg to be processed by php
AddType application/x-httpd-php .jpg

woody3d_screens.jpg

<? 	
 	$gallery = "woody3d_screens";
 	
 	////////////////////////////////////////////////////////////////////////

 	// PROGRAM CONTROL

 	$path         				= $gallery . "/";

 	// Obtain list of images from directory 
 	$image_filename_list      	= get_image_filename_array_from_directory($path);

 	// Get random image file name
 	$image_filename   			= get_random_entry_from_array($image_filename_list);

 	// Output header and data of image
 	if(file_exists($path . $image_filename))
 	{
      	$data = file_get_contents($path . $image_filename);
      	header('Content-type: image/jpeg');
      	echo $data;
 	}
 	exit();

 	////////////////////////////////////////////////////////////////////////


 	// LOCAL FUNCTIONS

 	// Get random entry from array
 	function get_random_entry_from_array($ar)
 	{
 		mt_srand((double)microtime() * 1000000);
 		$num = array_rand($ar);
 		return $ar[$num];
 	}

 	// Get array of image file names from a directory
 	function get_image_filename_array_from_directory($path) 
 	{
 		$images = array();
 		if($img_dir = @opendir($path)) 
 		{   while(($img_file = readdir($img_dir)) !== false) 
 			{
 				// Check for gif, jpg, png
 				// if(preg_match("/(\.gif|\.jpg|\.png)$/", $img_file)) 
 				
 				// Just check for jpg 
 				if(preg_match("/(\.jpg)$/", $img_file)) 
 				{  $images[] = $img_file;
 				}
 			}
 			closedir($img_dir);
 		}
 		return $images;
 	}

 	////////////////////////////////////////////////////////////////////////
?>

woody3d_screens.php

<?
 	header("Location: http://www.gamedev.net/gallery/album/106-woody3d-screens/");
 	exit();
?>

I really like that I can add my own side bar content to the journal pages. This is a feature I think everyone should take advantage of. Comments and thoughts are always welcome.



The importance of a good, “Read This”

Posted by , in Web Dev, Woody3D 24 January 2011 - - - - - - · 729 views



In which words are written and you read them.


I have started titling my journal entries now that they matter. Previous entries (now renamed for relevance) were titled Entry 1, Entry 2, … Very Prussian.

So here we are and you've decided you liked this title and clicked on it. Great! Come in. Have a candy. Like something to drink? Good. Okay so here's my January thus far.

New Woody Website

For new readers, I'm developing Woody3D, a procedurally generated tree rendering system. I've spent a lot of time over the last 20 days redrawing and rewriting the Woody website. Behold the finished: http://woody3d.com/features/

It's greatly simplified from its previous incarnation and better displays the content. Also you don't have to go through 'like' 5 layers of security to get to the forums so... yeah it's better.

Speaking of Content

Want to see how Woody3D works? The Evaluation C++ source code and shaders are now available for download. I've really only left out the leaf animation functions. Also the full Tree Model Library with project files and brushes can be downloaded for free. So... that's better too.

The License is Easier Now

It's a no royalties license for most users. If a product that uses Woody grosses over 250K then an additional one time fee is paid. Read more at http://woody3d.com/license/

Using Gamedev.Net's New Features

Wow a photo of me. I'll have to update it when the sun comes back to Michigan. I've created a Woody gallery as well. My next integrational step is to get some friends...

_NEil



Website, License, and Social

Posted by , in Web Dev, Woody3D 05 November 2010 - - - - - - · 379 views

Keeping Busy or Busily Keeping
Seriously? I had no idea busily was a real word [headshake]. I typed it, trying to be funny, and the spell checker didn't get mad. Use busily in a sentence.
So anyway, I've just finished going through the validation process for a code signing certificate in Rendering Systems' name. Now I can release my executables and other binaries with an expensive name tag! Win! I automated the signing process using a batch script. If you're interested, I made an example Windows batch script and posted it at neilkemp.us.
I've also been putting the finishing touches on the Woody3D website. I'll keep working on it through the weekend and with any luck it should be ready for show very soon.
At the moment, I'm in the process of purchasing a good condenser microphone so I can add commentary to videos.

Comments and Requests for Licensing Info
Thanks for all of the encouraging comments here and elsewhere, it is much appreciated. I've worked very hard to get this far and the interest in what I'm doing only makes it that much easier to keep going.
There have been some comments requesting information about licensing. That announcement is coming, I promise, but I'm going to wait until Woody3D is available online before flying that flag. Thanks for your patience.

Get Connected
Just a reminder you can Follow me on Twitter and subscribe to my YouTube channel for the latest updates and videos.

Have a great weekend,
Neil





Twitter

Posted Image

Google GameDev.Net Search Bar

Posted Image

Recent Comments



PARTNERS