Saturday, October 22, 2011
Graph 3D ( Voxelized 3D Cartesian Co-ordinate system)
Well looks like I am to release my technology. It's a basic 3D Cartesian Co-ordinate system. Uses advanced Fuzzy Logic just to achieve minimal rendering performance. Please note, does not include space leaping which is the final optimization that achieves 8 times performance through-put as a minimum. For an understanding of this system reading on Jim Blinns mathematics a must.
Saturday, October 8, 2011
Writeable Bitmap Alpha Channel
Was able to move the 3D engine to SilverLight and create aspx file ready for the web. So happy I have the alpha channel back thought I would make some tests.
Here is a wall of glass, from single line of code.
Here is a wall of glass, from single line of code.
Adding another wall of glass is simple. The alpha value starts at 255, every time it hits a wall 64 is subtracted from alpha.
This is the glass with less opacity.
Just simply use screen.Pixels[offset] = Alpha << 24 | Red << 16 | Green << 8 | Blue;
A Voxel Engine is just a stack of slices in front of the camera. So as each slice is rendered alpha is decreased by one. It gives this effect.
The next screen shots show a basic 3D World. Moving up and down changes the light effect.
With a little trial and error, I came up with this background. Adding a desert map from Google would give me a World representing Mars for a space adventure.
Sunday, October 2, 2011
Writeable Bitmap on the Web
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Silverlight
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
System.Windows.Threading.DispatcherTimer tmr;
System.Windows.Media.Imaging.WriteableBitmap screen;
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
screen = new System.Windows.Media.Imaging.WriteableBitmap(320, 204);
tmr = new System.Windows.Threading.DispatcherTimer();
tmr.Interval = System.TimeSpan.FromMilliseconds(100);
tmr.Tick += OnTimer;
tmr.Start();
}
void OnTimer(Object Sender, EventArgs args)
{
int px,py;
int offset = 0;
for (py = 0; py < 204; py++)
{
for (px = 0; px < 320; px++)
{
screen.Pixels[offset] = 64 << 24 | 0 << 16 | 0 << 8 | 255;
offset++;
}
}
image1.Source = screen;
}
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
tmr.Stop();
}
//fin.
}
}
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Silverlight
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
System.Windows.Threading.DispatcherTimer tmr;
System.Windows.Media.Imaging.WriteableBitmap screen;
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
screen = new System.Windows.Media.Imaging.WriteableBitmap(320, 204);
tmr = new System.Windows.Threading.DispatcherTimer();
tmr.Interval = System.TimeSpan.FromMilliseconds(100);
tmr.Tick += OnTimer;
tmr.Start();
}
void OnTimer(Object Sender, EventArgs args)
{
int px,py;
int offset = 0;
for (py = 0; py < 204; py++)
{
for (px = 0; px < 320; px++)
{
screen.Pixels[offset] = 64 << 24 | 0 << 16 | 0 << 8 | 255;
offset++;
}
}
image1.Source = screen;
}
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
tmr.Stop();
}
//fin.
}
}
Open Visual Studio and choose new project C# -> SilverLight. Make sure it's SilverLight 4. When the solution is created select the Grid and press Delete key. Then go to Toolbox select Image component place it in the IDE and make sure Stretch is equal to Fill.
The pixel format is Alpha | Red | Green | Blue. I used Blue = 255, and Alpha = 64. This blends the background white color with the image color.
This gives us a Bitmap that can be updated 10 times a second for games and animations. For 50 updates per second set timer interval to 20 instead of 100.
Your first internet application! And it's working on my Browser Google Chrome, fantastic result. I have a book that shows a silverlight app running on Mozilla Firefox as well. Just shows how powerful and well done Visual Studio 2010 Professional really is. The Toolbox is my favorite, allows me to set up projects quickly.
Change :
screen.Pixels[offset] = 64 << 24 | 0 << 16 | 0 << 8 | 255;
to :
screen.Pixels[offset] = py << 24 | 0 << 16 | 0 << 8 | 255;
And get this :
Silverlight Website of note : http://10rem.net/ C64 emulator, synthesizer, what else has to be said?
Subscribe to:
Posts (Atom)