Monday, October 12, 2009

WPF 3D Cube with different image on each side

<Grid Name="Gr" Margin="0">
<Viewport3D Margin="0" Name="v3d">
<ModelVisual3D >
<ModelVisual3D.Content>
<Model3DGroup>
<!-- Lights -->
<AmbientLight Color="LightGray" />
<DirectionalLight Color="Black" Direction="1,-2,-3" />
<DirectionalLight Color="White" Direction="-1,2,3" />

<GeometryModel3D >
<GeometryModel3D.Geometry>
<!-- Cube -->
<MeshGeometry3D
TextureCoordinates="
-1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1
-1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1"
Positions="
-1,-1,-1 1,-1,-1 1,-1, 1 -1,-1, 1
-1,-1, 1 1,-1, 1 1, 1, 1 -1, 1, 1
1,-1, 1 1,-1,-1 1, 1,-1 1, 1, 1
1, 1, 1 1, 1,-1 -1, 1,-1 -1, 1, 1
-1,-1, 1 -1, 1, 1 -1, 1,-1 -1,-1,-1
-1,-1,-1 -1, 1,-1 1, 1,-1 1,-1,-1
"
TriangleIndices="
0 1 2 2 3 0
" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup >
<DiffuseMaterial >
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="C:\a1.jpg" Opacity="1"></ImageBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="LightGray" Opacity="0"></SolidColorBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>

</GeometryModel3D>
<GeometryModel3D >
<GeometryModel3D.Geometry>
<!-- Cube -->
<MeshGeometry3D
TextureCoordinates="
-1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1
-1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1"
Positions="
-1,-1,-1 1,-1,-1 1,-1, 1 -1,-1, 1
-1,-1, 1 1,-1, 1 1, 1, 1 -1, 1, 1
1,-1, 1 1,-1,-1 1, 1,-1 1, 1, 1
1, 1, 1 1, 1,-1 -1, 1,-1 -1, 1, 1
-1,-1, 1 -1, 1, 1 -1, 1,-1 -1,-1,-1
-1,-1,-1 -1, 1,-1 1, 1,-1 1,-1,-1
"
TriangleIndices="
4 5 6 6 7 4
" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup >
<DiffuseMaterial >
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="C:\a2.jpg" Opacity="1"></ImageBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="LightGray" Opacity="0"></SolidColorBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>

</GeometryModel3D>

<GeometryModel3D >
<GeometryModel3D.Geometry>
<!-- Cube -->
<MeshGeometry3D
TextureCoordinates="
-1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1
-1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1"
Positions="
-1,-1,-1 1,-1,-1 1,-1, 1 -1,-1, 1
-1,-1, 1 1,-1, 1 1, 1, 1 -1, 1, 1
1,-1, 1 1,-1,-1 1, 1,-1 1, 1, 1
1, 1, 1 1, 1,-1 -1, 1,-1 -1, 1, 1
-1,-1, 1 -1, 1, 1 -1, 1,-1 -1,-1,-1
-1,-1,-1 -1, 1,-1 1, 1,-1 1,-1,-1
"
TriangleIndices="
8 9 10 10 11 8
" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup >
<DiffuseMaterial >
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="C:\a3.jpg" Opacity="1"></ImageBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="LightGray" Opacity="0"></SolidColorBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>

</GeometryModel3D>
<GeometryModel3D >
<GeometryModel3D.Geometry>
<!-- Cube -->
<MeshGeometry3D
TextureCoordinates="
-1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1
-1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1"
Positions="
-1,-1,-1 1,-1,-1 1,-1, 1 -1,-1, 1
-1,-1, 1 1,-1, 1 1, 1, 1 -1, 1, 1
1,-1, 1 1,-1,-1 1, 1,-1 1, 1, 1
1, 1, 1 1, 1,-1 -1, 1,-1 -1, 1, 1
-1,-1, 1 -1, 1, 1 -1, 1,-1 -1,-1,-1
-1,-1,-1 -1, 1,-1 1, 1,-1 1,-1,-1
"
TriangleIndices="
12 13 14 14 15 12
" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup >
<DiffuseMaterial >
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="C:\a4.jpg" Opacity="1"></ImageBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="LightGray" Opacity="0"></SolidColorBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>

</GeometryModel3D>


<GeometryModel3D >
<GeometryModel3D.Geometry>
<!-- Cube -->
<MeshGeometry3D
TextureCoordinates="
-1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1
-1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1"
Positions="
-1,-1,-1 1,-1,-1 1,-1, 1 -1,-1, 1
-1,-1, 1 1,-1, 1 1, 1, 1 -1, 1, 1
1,-1, 1 1,-1,-1 1, 1,-1 1, 1, 1
1, 1, 1 1, 1,-1 -1, 1,-1 -1, 1, 1
-1,-1, 1 -1, 1, 1 -1, 1,-1 -1,-1,-1
-1,-1,-1 -1, 1,-1 1, 1,-1 1,-1,-1
"
TriangleIndices="
16 17 18 18 19 16
" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup >
<DiffuseMaterial >
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="C:\a5.jpg" Opacity="1"></ImageBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="LightGray" Opacity="0"></SolidColorBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>

</GeometryModel3D>
<GeometryModel3D >
<GeometryModel3D.Geometry>
<!-- Cube -->
<MeshGeometry3D
TextureCoordinates="
-1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1
-1 1 -1 1 1 -1 1 -1 -1 1
-1 1 1 -1 1 -1 -1 1 -1 1 1"
Positions="
-1,-1,-1 1,-1,-1 1,-1, 1 -1,-1, 1
-1,-1, 1 1,-1, 1 1, 1, 1 -1, 1, 1
1,-1, 1 1,-1,-1 1, 1,-1 1, 1, 1
1, 1, 1 1, 1,-1 -1, 1,-1 -1, 1, 1
-1,-1, 1 -1, 1, 1 -1, 1,-1 -1,-1,-1
-1,-1,-1 -1, 1,-1 1, 1,-1 1,-1,-1
"
TriangleIndices="
20 21 22 22 23 20
" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup >
<DiffuseMaterial >
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="C:\a6.jpg" Opacity="1"></ImageBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="LightGray" Opacity="0"></SolidColorBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>

</GeometryModel3D>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>

<Viewport3D.Camera>
<PerspectiveCamera x:Name="camera"
Position = "2, 4, 6"
LookDirection = "-1, -2, -3"
UpDirection = "0, 1, 0"
FieldOfView = "30">
<PerspectiveCamera.Transform>
<Transform3DGroup>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D
Axis="0 1 0"
Angle="{Binding ElementName=hscroll, Path=Value}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="axisanglerotation"
Axis="1 0 0"
Angle="{Binding ElementName=vscroll, Path=Value}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</PerspectiveCamera.Transform>
</PerspectiveCamera>
</Viewport3D.Camera>
</Viewport3D>
<TextBlock x:Name="text1" Text="Hello There" Foreground="White" FontSize="24" FontWeight="Normal" VerticalAlignment="Top" TextAlignment="Left" Visibility="Visible" Height="28.97"></TextBlock>
</Grid>


/*
Just change the image name for your computer.
The trick here is to have a different geometery model for each side, and show what ever you wana show on that side. I just took a cube 3d code from the net, and changed it to work this way. Because i didnt find any where how to show this.
*/
Enjoy IT!

Monday, June 15, 2009

Tables using space in HardDisk for SQL Server

exec (' sp_spaceused ' )

DECLARE C CURSOR FOR
select name from sysobjects where xtype in ('u') order by 1

OPEN C

declare @name VARCHAR(200)
FETCH NEXT FROM C INTO @name

WHILE @@FETCH_STATUS = 0
BEGIN
-- PRINT 'sp_spaceused ''' + @NAME + '''
exec (' sp_spaceused ' + @NAME + '')
FETCH NEXT FROM C INTO @name
END

CLOSE C
DEALLOCATE C

--Enjoy IT!

Reducing SQL Transaction logs size

Run this first

sp_helpfile

This will give you the transaction log file name. Use it in logfilename.

DBCC ShrinkFile (LogFileName,10, TRUNCATEONLY)

Saturday, April 18, 2009

Saturday, April 11, 2009

SOLID Principle

S.O.L.I.D stands for: When expanded the acronyms might seem complicated, but they are pretty simple to grasp. S - Single-responsiblity...