Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Go Back  Xtreme Visual Basic Talk > > > > Moving Sea Bed in VB.Net


Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2005, 02:47 AM
Trevor Newsome Trevor Newsome is offline
Newcomer
 
Join Date: Jan 2005
Posts: 6
Question Moving Sea Bed in VB.Net


Hi everyone,

I am new to DirectX, and have been working with the Dolphin tutorial to animate a ship. I have managed to get my ship on the screen and move it in all the axis. My next task is to move the sea bed in a direction. Could someone please either show me some code or give me some advice how to do this. I have tried looking at previous versions of DirectX for VB6 and unfortunately I am lost, maybe because it is a lot different in VB.Net, and I cannot find any examples on the WEB for VB.Net. I have included my source in a zip file, but have removed the .EXE's.

Thanks for any help in advance.

NOTE to move the ship you need to have CAPS LOCK on. The keys are QAZXOP
Attached Files
File Type: zip Ship.zip (164.0 KB, 41 views)
Reply With Quote
  #2  
Old 01-17-2005, 05:35 PM
sgt_pinky's Avatar
sgt_pinky sgt_pinky is offline
Contributor
 
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 633
Default

Which version of the DirectX SDK do you have? If you don't have the one with the installer called 'dxsdk_dec2004.exe', download that, because it has Managed DirectX documentation, and adds info to MSDN, so you can press F1 on keywords.

Also has a lot more samples.
Reply With Quote
  #3  
Old 01-24-2005, 01:00 AM
Trevor Newsome Trevor Newsome is offline
Newcomer
 
Join Date: Jan 2005
Posts: 6
Default

I am using VB.Net with DirectX9 my friend. I will download the suggested file, but it does seem from the documetation that this is just for the C and C#.
Reply With Quote
  #4  
Old 01-24-2005, 05:51 PM
sgt_pinky's Avatar
sgt_pinky sgt_pinky is offline
Contributor
 
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 633
Default

That's right. The reason that MS haven't done specific VB.NET ones (apart from the HLSL tutorial) is that they would be practically identical in code to the C# ones. It's very simple to translate the C# tutorials into VB.NET (and I never use C#, only VB).
Reply With Quote
  #5  
Old 02-03-2005, 05:14 PM
Trevor Newsome Trevor Newsome is offline
Newcomer
 
Join Date: Jan 2005
Posts: 6
Question Still need a little help

Hi again,

Right I have managed to get my spaceship and my skybox together, but unfortunately, my spaceship is larger than my skybox. So my skybox looks as if its inside my spaceship. How do I get around this please?

Cheers in advance

My source is below:

'********************************************************************* ******

Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Imports Direct3D = Microsoft.DirectX.Direct3D

Namespace TNGrapix

Public Class Screen
Inherits Form

Private device As device = Nothing 'Our rendering device

Private ship As Mesh = Nothing

Private skybox As Mesh = Nothing 'Our mesh object in sysmem
Private meshMaterials() As Direct3D.Material 'Materials for our mesh
Private meshTextures() As Texture 'Texture for our mesh
Private presentParams As New PresentParameters

Function InitialiseGraphics() As Boolean
'Get the current desktop display mode so we can set up a back buffer
'of the same format.
Try
'Set up the structure used to create the D3DDevice. Since we are now
'using more complex geometry, we will crate a device with a zbuffer.
presentParams.Windowed = True
presentParams.SwapEffect = SwapEffect.Discard
presentParams.EnableAutoDepthStencil = True
presentParams.AutoDepthStencilFormat = DepthFormat.D16

'Create the D3dDevice
device = New Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, presentParams)
AddHandler device.DeviceReset, AddressOf Me.OnResetDevice
Me.OnResetDevice(device, Nothing)
Catch ex As DirectXException
Return False
End Try
Return True
End Function

Public Sub OnResetDevice(ByVal sender As Object, ByVal e As EventArgs)
Dim materials As ExtendedMaterial() = Nothing
'Set the directory up two to load the right data (since the default
'build(Location Is bin \ Debug Or bin \ release)
Directory.SetCurrentDirectory((Application.StartupPath + "\..\"))
Dim dev As Device = CType(sender, Device)
'Turn on the zbuffer
dev.RenderState.ZBufferEnable = True

'Turn on ambient lighting
dev.RenderState.Ambient = System.Drawing.Color.White

'Load the mesh from the specified file
ship = Mesh.FromFile("F2015.X", MeshFlags.SystemMemory, device, materials)
skybox = Mesh.FromFile("skybox2.X", MeshFlags.SystemMemory, device, materials)


If meshTextures Is Nothing Then
' We need to extract the material properties and texture names
meshTextures = New Texture(materials.Length) {}
meshMaterials = New Direct3D.Material(materials.Length) {}
Dim i As Integer
For i = 0 To materials.Length - 1
meshMaterials(i) = materials(i).Material3D
' Set the ambient color for the material (D3DX does not do this)
meshMaterials(i).Ambient = meshMaterials(i).Diffuse

' Create the texture
meshTextures(i) = TextureLoader.FromFile(dev, materials(i).TextureFilename)
Next i
End If

End Sub

Private Sub Render()
If device Is Nothing Then
Return
End If

'clear the backbuffer to a blue colour
' This is the stencil. Im not using a stencil.
' |
device.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, System.Drawing.Color.Blue, 1.0F, 0)
' | | |
'This is flags for what we will be clearing. We | This is the value that the
'want to clear the screen to the color |
'mentioned in the next parameter so we specify Target |
'We also want to clear the depth. buffer so our next |
'render call goes OK. We specify ZBuffer to clear |
'the depth buffer |
' The colour that you want the
' Screen cleared to


'This function should be called before you want to draw anything on the screen.
'This tells directx that you are going to start drawing stuff
device.BeginScene()

'Setup the world, view, and projection matrices
SetupMatrices()

'Meshes are divided into subsets, one for each material. Render them in a loop
Dim i As Integer
For i = 0 To meshMaterials.Length - 1
'set the material and texture for this subset
device.Material = meshMaterials(i)
device.SetTexture(0, meshTextures(i))
'Draw the mesh subset
skybox.DrawSubset(i)
ship.DrawSubset(i)
Next i

'This tells d3d that you're done drawing
device.EndScene()

'This function flips the backbuffer with the front buffer. Think of it like this.
'There is someone in front of you, and you are drawing something on a paper. This
'paper is facing you and so is the drawing. When you are done with the drawing you
'flip the paper over to show the person in front of you what you drew.
'Present() acts the same as you flipping over the paper to show your friend.
device.Present()
End Sub

Sub SetupMatrices()

' For our world matrix, we will just leave it as the identity
device.Transform.World = Matrix.RotationY((Environment.TickCount / 1000.0F))

'Set up our view matrix. A view matrix can be defined given an eye point,
'a point to lookat, and a direction for which way is up. Here, we set the
'eye five units back aling the z-axis and up three units, look at the
'origin, and define "UP" to be in the y-direction.
device.Transform.View = Matrix.LookAtLH(New Vector3(0.0F, 0.0F, 20.0F), New Vector3(0.0F, 0.0F, 0.0F), New Vector3(0.0F, 1.0F, 0.0F))

'For the projection matrix, we set up a perspective transform (which
'transforms geometry from 3D view space to 2D viewport space, with
'a perspective divide making objects smaller in the distance). To build
'a perspective transform, we need the field of view (1/4 pi is common),
'the aspect ratio, and the near and far clipping planes (which define at
'what distance geometry should be no longer be rendered).
device.Transform.Projection = Matrix.PerspectiveFovLH(CSng(Math.PI / 4), 1.0F, 1.0F, 100.0F)




End Sub

Private Sub InitializeComponent()
'
'Screen
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Screen"

End Sub

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Me.Render() 'Render on painting
End Sub

Public Sub New()
'Set the initial size of our form
Me.ClientSize = New System.Drawing.Size(400, 300)
'And it's caption
Me.Text = "SpaceView"
End Sub

Shared Sub Main()
Dim frm As New TNGrapix.Screen

If Not frm.InitialiseGraphics() Then 'Initialise Direct3D
MessageBox.Show("could not initialise Direct3D.")
Return
End If
frm.Show()

While frm.Created
frm.Render()
Application.DoEvents()
End While
End Sub

Private Sub Screen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class

End Namespace

'***********************************************************
Reply With Quote
  #6  
Old 02-03-2005, 11:10 PM
sgt_pinky's Avatar
sgt_pinky sgt_pinky is offline
Contributor
 
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 633
Default

Mesh objects contain the geometric scale that you drew them in. The best would be to go back into 3DS Max or whatever you drew the skybox in, and scale it!

The usual trick with skyboxes is for the skybox to be just inside your far Z plane, so that it doesnt get clipped in the perspective transform stage, and it is always drawn at the camera's x,y,z location, so it moves with the camera.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
 
Moving Sea Bed in VB.Net
Moving Sea Bed in VB.Net
 
-->