Solved

Complex 3D Character?

Posted on 2002-06-22
12
380 Views
Last Modified: 2013-12-26
Hi,

I'm familiar with both OpenGL and DirectX8 as far as setup
and construction of basic 3d geometric shapes, Etc.

What I want to do is Parse a 3D Character File and
construct that character making it possible to move
the character in relation to the Bones.

I know how to parse the file, create vertex arrays,
texture map, etc, I just can't figure out how to
define the character in a way that I can move/pose
it easily.

The 3D Character is defined with the following:

Vertices                     (X-Y-Z,Normal X-Y-Z)
TextureVertices      (U-V)
Bones:         Bound to Vertices
Blendings: Bound to Vertices
Faces:         Bound to Vertices

Of course VB source code would be great, but if someone
could point me to information(preferably free!) dealing
specifically with addressing bone manipulation I'd accept
that as an answer too.

Everything that I've found on the net deales with
character animation through transforms of the world view,
I'm looking for info on manipulating parts of an object
in relation to the rest of the object.

Also, I know squat about C++, so until next semester
(I'm taking C++ then), I need info in VB.  I'll raise the
points if this is extremly complex, It just seems like
I'm missing the forest for the trees here.....





0
Comment
Question by:DXNewbie
12 Comments
 
LVL 2

Expert Comment

by:kamarey
Comment Utility
Take a look at ID3DXSkinMesh.
0
 

Author Comment

by:DXNewbie
Comment Utility
I don't find a reference to ID3DXSkinMesh in the Object browser?
0
 
LVL 2

Expert Comment

by:kamarey
Comment Utility
You can find it in DirectX documentation.
0
 
LVL 1

Expert Comment

by:M.E.Pierce
Comment Utility
That's because it's a C++ interface,
use the VB equiv: D3DXSkinMesh (No I)

Look here for more info about it, should bring you up to speed.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_vb/directx_vb/Graphics/Reference/VB/D3DX/Classes/D3DXSkinMesh/d3dxskinmesh.asp

You may be jumping a little further ahead than you should,
I'd create a simple character, try 2 bones with
2 cubes (sharing a common vertex plane for 1 face)
and add bones and cubes as you get an understanding of the
transforms required to pose it the way you want.

0
 
LVL 1

Expert Comment

by:nomad516
Comment Utility
Use an .3ds file instead, convert it to .x file via the
utility that comes with the DX8 SDK...then use .x files
instead...(just follow the documentation)
0
 

Author Comment

by:DXNewbie
Comment Utility
The point of my question was that I want to be able to take
a 3D character from a 3D game and manipulate it in my program.
I can't very well ask the software company to send me .3DS files
of thier proprietary characters.....
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:DXNewbie
Comment Utility
Comment for M.E.Pierce:

Ok, I see the structure of the mesh object but how do I
initialize the mesh?
I'm not sure about the CreateSkinMesh fuction, specifically
the options and declarations arguments.

My character file has:
19 bones
760 faces
496 vertices

I'm calling:
dim MyChar as D3DXMesh

Set MyChar = objD3DX.CreateSkinMesh(760, 496, 19, *, *, devDG)

I've tried every possible combination in the * fields,

Always exits with an automation error or type mismatch error.

(I've also tried CreateSkinMeshFVF)

Can you clarify the usage of either of these?
0
 
LVL 4

Expert Comment

by:joachimc
Comment Utility
Hi

Take a look at the

Implementing skinned meshes with DirectX8

http://www.gamedev.net/reference/programming/features/skinmesh/

It teaches you everything you need to be able to use a skinned mesh with .x files.

/Joachim
0
 

Author Comment

by:DXNewbie
Comment Utility
I appreciate the inf, but I'm already familiar with matix
math and 3D transforms, I specifically need info on
Constructing a Skinned mesh from scratch in VB using
(preferably)DirectX 8(or 8.1) or (will accept)OpenGL.

Not loading it from a .x file , not the C++ method.

0
 
LVL 2

Accepted Solution

by:
kamarey earned 200 total points
Comment Utility
Use D3DXCreateSkinMeshFVF instead of D3DXCreateSkinMesh.

D3DXCreateSkinMeshFVF(
  760,
  496,
  19,
  OPTIONS,
  FVF,
  pDevice,
  ppSkinMesh
);

In field OPTIONS you can put D3DXMESH_MANAGED or D3DXMESH_SYSTEMMEM and maybe D3DXMESH_DYNAMIC.
In field FVF put your vertex format.

If it doestn't work, write here errors you get.
If you can, post piece of code.

And take a look  here:
http://www.gamedev.net/reference/articles/article1835.asp
0
 

Author Comment

by:DXNewbie
Comment Utility
OK, I think I've got the skin creation down, but how do I
Render the mesh?

Here's my code:

Option Explicit

Dim g_DX As New DirectX8
Dim g_D3D As Direct3D8
Dim g_D3DDevice As Direct3DDevice8
Dim g_D3DX As D3DX8
Dim IsInited As Boolean

Dim BodyMesh As D3DXSkinMesh
Dim HeadMesh As D3DXSkinMesh

Const D3DFVF_NVERTEX = (D3DFVF_VERTEX)

Dim g_VB As Direct3DVertexBuffer8

Dim bVertex() As D3DVERTEX          'Body Vertices
Dim hVertex() As D3DVERTEX          'Head Vertices

Private Sub Form_Load()

Me.Show

Set g_D3D = g_DX.Direct3DCreate()
If g_D3D Is Nothing Then Exit Sub

Dim Mode As D3DDISPLAYMODE
g_D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, Mode

Dim d3dpp As D3DPRESENT_PARAMETERS
d3dpp.Windowed = 1
d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
d3dpp.BackBufferFormat = Mode.Format

Set g_D3DDevice = g_D3D.CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,d3dpp)
If g_D3DDevice Is Nothing Then Exit Sub
Set g_D3DX = New D3DX8

CreateGeometry     'Read Skin Files and fill Vertex Buffers
InitGeometry          'Assign Parameters to SkinMesh

End Sub

Private Sub Timer1_Timer()

g_D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H808080, 1#, 0

' Begin the scene.
g_D3DDevice.BeginScene
If IsInited Then
    ' Rendering of scene objects occur here.
   'NOT USING THESE ANYMORE-ORIGINALLY FOR RENDERING PRIMITIVES
   ' g_D3DDevice.SetStreamSource 0, g_VB, UBound(cVertex)
    'g_D3DDevice.SetVertexShader D3DFVF_NVERTEX
    'g_D3DDevice.DrawPrimitive D3DPT_TRIANGLELIST, 0, 1

End If
' End the scene.
g_D3DDevice.EndScene

g_D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End Sub

Private Sub Form_Unload(Cancel As Integer)

    Set g_D3D = Nothing
    Set g_D3DDevice = Nothing

End Sub

Private Sub InitGeometry()

On Error Goto ErrorHandler

Set BodyMesh = g_D3DX.CreateSkinMeshFVF(760, 496, 19, D3DXMESH_DYNAMIC, D3DFVF_NVERTEX, g_D3DDevice)
Set HeadMesh = g_D3DX.CreateSkinMeshFVF(931, 421, 1, D3DXMESH_DYNAMIC, D3DFVF_NVERTEX, g_D3DDevice)

If BodyMesh Is Nothing or HeadMesh Is Nothing Then Goto ErrorHandler

D3DXMeshVertexBuffer8SetData BodyMesh, 0, UBound(bVertex) * 3, 0,bVertex(0)
D3DXMeshVertexBuffer8SetData HeadMesh, 0, UBound(hVertex) * 3, 0,hVertex(0)

IsInited = True
Exit Sub
ErrorHandler:
MsgBox("Mesh Initialization Error")
IsInited = False
End Sub

I think I've successfully created my meshes, I know I still have to set the bone influences, texture data, etc.
but I'd like to be able to render the mesh before I start
modifying it,
So that I can see what's happening at each step.
0
 

Author Comment

by:DXNewbie
Comment Utility
Thank All of you very much,
But I had to award the points to the person
who helped me the most(and most directly).
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now