newbie to Directx. 
Author Message
 newbie to Directx.

Hi all,

I'm a newbie to Directx 3D ...

I'm trying to build a 3D blocks of rectangular...

where I specify the x and y coordinates... and like to draw 3D block..

and also, can specify camera angel and view the object in all differ
direction.

how am i going to do that ???

any sample code or books please...

thanks



Mon, 04 Oct 2004 13:49:53 GMT  
 newbie to Directx.
Hi,

Well, I included the lib file instead of the tlb one. If you need the type lib (6K) to evaluate the
suggestion, just tell.

Vanderghast, Access MVP



Sun, 03 Oct 2004 22:48:43 GMT  
 newbie to Directx.
thanks alot Michel,

This is very helpfull...

I believe I need the DLL to compile the application.

so, can i please have the dll...

thanks again


Quote:
> Hi,

> If you want to do it more or less blindly,  just confirm the following is

satisfactory and I can
Quote:
> send you the dll file (around 50K) by e-mail.

> OK, assume you have that dll (I included its lib ), the code you will need
to produce, in VB6,
> would look like a Form, Form1, a Module, Module1, and a class, Class1.

> The form Form1 has no control at all and its code is (no need to modify

it, just cut and paste):
Quote:

> ==========
> Option Explicit

> Const MyName As String = "Chap03 - Form1"

> Private Sub Form_Click()
>     ' Make the form invisible, the application will soon close, see Sub
Main()
>     Me.Visible = False
> End Sub

> Private Sub Form_Paint()
>     Helper.Draw
> End Sub

> Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
>     ' Do not close if still visible... just turn it invisible.
>     '   Main( ) will close the form
>     If Me.Visible Then
>         Me.Visible = False
>         Cancel = True
>     End If

> End Sub

> Private Sub Form_Resize()

>     Debug.Assert Not (Helper Is Nothing) ' Have we set the
>         ' startup object as Main( )   or left it as Form1?

>     Helper.Resize
>     Helper.Draw

> End Sub

> Public Property Get InitialCaption() As String
>     InitialCaption = MyName
> End Property

> ==============

> The code in the module contains the subroutine Main( ) that starts the

application ( the "Startup

- Show quoted text -

Quote:
> Object" is specified as Main( ), not at Form1, see Project Properties ...
from the menu):

> =============
> Option Explicit
> Const MyName As String = "Chap03 - Module1"

> Public Helper As vgD3DHelper

> Public Sub Main()

> Dim f As Form1
> Dim x As Class1
> Dim ErrStr As String

>     Set x = New Class1
>     x.PrepareData

>     Set f = New Form1

>     Set Helper = New vgD3DHelper
>     If Not Helper.Initialize(x, f.hWnd, ErrStr) Then
>         MsgBox ErrStr, vbOKOnly, MyName
>         End
>     End If

>     ' Specify what is visible
>     Helper.AngleOpeningDegree = 45
>     Helper.Aspect = 1
>     Helper.NotCloserThan = 0.1
>     Helper.NotFarterThan = 10#

>     ' Display in modal mode
>     f.Show

>     Do While f.Visible
>         Helper.Draw
>         x.StatsOn f ' Display the statistics

>         DoEvents
>     Loop

>     ' Done...
>     Helper.Detach
>     Set Helper = Nothing

>     Set f = Nothing
>     Set x = Nothing

>     End

> End Sub

> ===========

> Again, there is no need to modify it, you can cut and paste it.

> Lastly, the class, it owns the data to be drawn and tell the sequence the

drawing must be done.

- Show quoted text -

Quote:
> Here is a sample of the code (draw a {*filter*} wall, with a foundation line
in black):

> ===========
> Option Explicit
> Const MyName As String = "Chap03 - Class1"

> Implements vgID3DHelper03

> Private Geo As vgVertexSimple
> Private Geo2 As vgVertexSimple

> ' To keep up with the statistics...
> Const ComputeAtNotLessThan__Frames As Long = 30
> Private StepNumber As Variant

> Public Sub PrepareData()

>     ' Initialize our data
>     Set Geo = New vgVertexSimple
>         '   The wall, will be a strip of triangles
>         Geo.AddVertex 0#, 0#, 0#, D3DColorMake(0.6, 0.6, 0.6, 1#)
>         Geo.AddVertex 0#, 0.5, 0#, D3DColorMake(0.8, 0.8, 0.8, 1#)
>         Geo.AddVertex 0.15, 0#, 0#, D3DColorMake(0.5, 0.5, 0.5, 1#)
>         Geo.AddVertex 0.15, 0.5, 0#, D3DColorMake(0.8, 0.8, 0.8, 1#)
>         Geo.AddVertex 0.3, 0#, 0#, D3DColorMake(0.5, 0.7, 0.5, 1#)
>         Geo.AddVertex 0.3, 0.5, 0#, D3DColorMake(0.85, 0.85, 0.85, 1#)
>         Geo.AddVertex 0.45, 0#, 0#, D3DColorMake(0.6, 0.6, 0.6, 1#)
>         Geo.AddVertex 0.45, 0.5, 0#, D3DColorMake(0.8, 0.8, 0.8, 1#)
>         Geo.AddVertex 0.45, 0#, -0.15, D3DColorMake(0.4, 0.4, 0.4, 1#)
>         Geo.AddVertex 0.45, 0.5, -0.15, D3DColorMake(0.65, 0.75, 0.85, 1#)
>         Geo.AddVertex 0.3, 0#, -0.15, D3DColorMake(0.5, 0.5, 0.5, 1#)
>         Geo.AddVertex 0.3, 0.5, -0.15, D3DColorMake(0.65, 0.75, 0.7, 1#)
>         Geo.AddVertex 0.15, 0#, -0.15, D3DColorMake(0.45, 0.45, 0.55, 1#)
>         Geo.AddVertex 0.15, 0.5, -0.15, D3DColorMake(0.65, 0.75, 0.8, 1#)
>         Geo.AddVertex 0#, 0#, -0.15, D3DColorMake(0.35, 0.45, 0.45, 1#)
>         Geo.AddVertex 0#, 0.5, -0.15, D3DColorMake(0.65, 0.75, 0.8, 1#)
>         Geo.AddVertex 0#, 0#, 0#, D3DColorMake(0.6, 0.6, 0.6, 1#)
>         Geo.AddVertex 0#, 0.5, 0#, D3DColorMake(0.8, 0.8, 0.8, 1#)

>         '   the base of the wall, will be a strip of lines
>     Set Geo2 = New vgVertexSimple
>         Geo2.AddVertex 0#, 0#, 0#, &HFF000000
>         Geo2.AddVertex 0.45, 0#, 0#, &HFF000000
>         Geo2.AddVertex 0.45, 0#, -0.15, &HFF000000
>         Geo2.AddVertex 0#, 0#, -0.15, &HFF000000
>         Geo2.AddVertex 0#, 0#, 0#, &HFF000000

> End Sub

> Private Sub vgID3DHelper03_Render(Device As DxVBLibA.Direct3DDevice8, _
>                     ByVal TimeIs As Variant, _
>                     ByVal FrameNumber As Variant)

> Dim xc As Single
> Dim yc As Single
> Dim zc As Single

>     '   Remember the step number, for stats report
>     StepNumber = FrameNumber

>     ' Coordinates of the observer,
>     '   change them each new frame...
>     xc = 2 * Sin(FrameNumber * 0.00873)
>             ' 0.00873 implies about 720 frames for a complete turn around
>             ' 0.00873 radian is about half a degree.

>     yc = 3
>     zc = 2 * Cos(FrameNumber * 0.00873)

>     ' Specify the new coordinates
>     Helper.ObserverAtXYZ xc, yc, zc

>     '   Draw (the objects)
>     Device.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE
>     Geo.DrawPrimitiveUPAll Device, D3DPT_TRIANGLESTRIP
>     Geo2.DrawPrimitiveUPAll Device, D3DPT_LINESTRIP

> End Sub

> Friend Function StatsOn(f As Form1)

>         ' Display only at each ComputeAtNotLessThan__Frames
>         ' (to be signifiant).

>         If 0 = StepNumber Mod ComputeAtNotLessThan__Frames Then
>             f.Caption = f.InitialCaption() & ":  " & _
>                     Helper.FramesPerSecond() & " frames/sec; z: " & _
>                     IIf(D3DZB_FALSE =

Helper.Device.GetRenderState(D3DRS_ZENABLE), "False", "True")
Quote:
>         End If

> End Function

> ===============

> Here, you have  to make modifications to suit your cases. Note I have TWO

geometric objects, Geo
Quote:
> and Geo2. You can define more, in the declaration sections, or even define

an array of them, if you
Quote:
> want.

> Next, PrepareData( ) really create the objects and fill their geometry.
AddVertex takes 3
> coordinates (X, Y, Z) and a color. I used D3DColorMake( r, g, b, a)

taking r, g, b and a (alpha)
Quote:
> values from the range 0.0 to 1.0.  I use a right-hand system of

coordinates (the dll is intended
Quote:
> for engineers, and they mainly use right hand coordinates).

> The vgID3DHelper03_Render may be used to say where is the observer (here,
the observer turns
> restlessly around the origin). You also specify what to draw out of the

"geometry" you already
Quote:
> defined in PrepareData (ie. here, we want a TriangleStrip out of Geo and a

LineStrip out of Geo2,
Quote:
> in this example) and the sequence in which the drawing occur.

> Leave StatsOn( ) as it is (or comment all its  body code). It just display

stats (frames per sec
Quote:
> and if you still have a z-buffer active or not) on the caption of the form
Form1.

> So, you can judge of the complexity of your work in order to use DirectX8

with VB6. It is also your
Quote:
> job to understand 3D system of coordinates, what is a sinus and a cosinus,

what is a TriangleList,
Quote:
> a TriangleStrip and a TriangleFan, as example, but the coding is simple:

define the geometric
Quote:
> elements, and tell the sequence in which you draw them. There is no

lights, no normal, no material,
Quote:
> no texture, just the most basic stuff, but it works. So, if you think that

may help you, just tell,
Quote:
> and I' ll e-mail you the dll (with its code), about 70-80K. It is

completly free, I just expect you
Quote:
> give me some feed-back on how easy/hard, and where it is hard, to use.

> Sure, there is also the drawback that you end using the DLL rather than

DirectX "itself", but since
Quote:
> I supply the code of the dll, you are free to explore its inner working

and gradually change the
Quote:
> code with your own, as you become more proficient with DirectX.

> Be sure you use 16 bits, or 32 bits color-depth for the desktop, not 24

bits. Since we draw in a
Quote:
> window (on a from), we must use the same color-depth than the desktop and

D8X does not support 24
Quote:
> bits !

> Hoping it may help,
> Vanderghast, Access MVP




- Show quoted text -

Quote:
> > Hi all,

> > I'm a newbie to Directx 3D ...

> > I'm trying to build a 3D blocks of rectangular...

> > where I specify the x and y coordinates... and like to draw 3D block..

> > and also, can specify camera angel and view the object in all differ
> > direction.

> > how am i going to do that ???

> > any sample code or books please...

> > thanks



Mon, 04 Oct 2004 07:38:24 GMT  
 newbie to Directx.
Hi,

Send. Should be in you e-mail.

Vanderghast, Access MVP.

Quote:

> thanks alot Michel,

> This is very helpfull...

> I believe I need the DLL to compile the application.

> so, can i please have the dll...

> thanks again



Mon, 04 Oct 2004 18:33:39 GMT  
 newbie to Directx.
thanks alot...

cheers,


Quote:
> Hi,

> Send. Should be in you e-mail.

> Vanderghast, Access MVP.




Quote:
> > thanks alot Michel,

> > This is very helpfull...

> > I believe I need the DLL to compile the application.

> > so, can i please have the dll...

> > thanks again



Tue, 05 Oct 2004 08:08:50 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. plz help newbie --directx

2. DirectX Newbie....

3. Can a Form or 2nd DirectX app be show over top of DirectX App

4. I only downloaded th DirectX SDK which didn't contain documents on DirectX Media

5. ***NEWBIE ALERT***NEWBIE ALERT***NEWBIE ALERT***

6. DirectX 9.0A end-user runtime and Managed DirectX.

7. compatibility problem between directx 8 applications and directx 9...

8. <newbie>HELP!</newbie>

9. Wav sound too delayed ?directx faster

10. VB.Net and DirectX 9: creating an event

11. DirectX 9 DirectMusic

12. DirectX 9 help... positioning objects

 

 
Powered by phpBB® Forum Software