Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Interface between Direct3D's ID3DXMesh and DBpro's Mesh

Author
Message
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 16th Jun 2003 17:53
Hmmm.... I really need some help from those experts that written a lot of TPC DLLs.

FYI, ID3DXMesh is the way Direct3D represent meshes. There are several methods in this object (or COM interface to be precise) which allow programmer to get the vertices and indices list.

I need to written some TPC in a DLL to load a .X file and manipulate in some way which DBpro couldn't do. After that, I would want to return the manipulated mesh back to DBpro.

My question is, how could I return the ID3DXMesh representation in my DLL to DBpro so that I could load it using MAKE MESH FROM MEMBLOCK. I don't think it is not as easy as just returning the ID3DXMesh memory pointer to DBpro.

RobK, IanM, and Kevil, I desperately need your expertise on DLL now. Thanks a bunch! :s
Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jun 2003 18:13
Can you give us more detail? What are you trying to achieve?
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 16th Jun 2003 18:22
Ok, to be more specific, I need to do the followings:

1. I need to change the mesh FVF format so that it will include a three dimensional texture coordinate (default is 2-D), which can't be done using DBpro's CONVER OBJECT FVF cause it lack of the D3DFVF_TEXCOORDSIZE3 flag.

2. I need to compute the normal vector of each vertex in the mesh using the D3DXComputeNormals() function in the DXSDK.

3. I need to compute the tangent of each vertex in the mesh using the D3DXComputeTangent() function in DXSDK.

My real reason of loading a .X file in DLL is because DBpro is unable to do the above manipulation on a mesh. So, I had no choice but to code them in DLL using DXSDK, and pass the mesh back to DBpro.

Correct me anything if I am wrong.

Thanks!

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jun 2003 19:01
I freely admit that some of this goes over my head

1) My *assumption* here would be that if DBPro could handle 3D textures, you should be able to get this working already without an external DLL (assuming you can load the texture in the first place).

From MSDN : D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
Where D3DFVF_TEXTUREFORMAT3 is equal to 1
So D3DFVF_TEXCOORDSIZE3(0) would be 65536 (0x1000), D3DFVF_TEXCOORDSIZE3(1) would be 262144 (0x4000) etc

As these value appear to be unused in the CONVERT OBJECT FVF list, they won't clash with the listed values - try them.

2) and 3) require the mesh in a specific format, and I don't see a way of easily getting them in that format (DLL or not).

There is a function inside the Basic3D library that *may* give you access directly to meshes called 'GetMeshData', but the function prototype doesn't give anything away. Luckily, neither of the commands you want to call need access to the DirectX device, so that could make things a little easier.

If I were you, I'd probably email Lee or Mike to ask for assistance.

There are apparently some vertex access/manipulation commands coming along in the next patch (or the one following) as well - they may very well help you do some of what you want to do.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 16th Jun 2003 20:44
Bullseye... The Tangent was replace from DirectX 8.0 in DirectX 9.0 with Specular, so...

Set Vertex Stream [shader],[pos],6,0
will become your tangent for that model index

Within the Epic battle of the fates the Shadow and the Angel will meet. With it will harbinger the very fight of good vs evil!
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 17th Jun 2003 00:28
DBPro seems to use DX in-built code where possible, so even if a value is not listed for a function, such as CONVERT OBJECT FVF, it may work. How much of that function is DBS' code and how much is DX functions, I don't know.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_103.zip
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 17th Jun 2003 07:40
Raven, are you sure? Meaning that I just need to specify
Set Vertex Stream [shader],[pos],6,0

and the tangent vector will be calculated automatically in my vertex shader?

So what FVF format should I use for my mesh?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 17th Jun 2003 08:01
oh no you also have to declare it within the shader
decl_TANGENT v[pos]

but yeah that's basically all you need... here's an example



should work, but not tested so i'm not gonna guarentee - and i really can't think of anything that'd use the tangent right now, otherwise i'd make an example shader.

But you have to take the value from within the Vertex Shader & Export to the Pixel Shader if you want it - however it should all be done automatically.
I'm trying to figure out though why DBS has Vertex Shader Help on Vertex Shader dxv9.0 when dbp is dxv8.1 hmmm :-s

Within the Epic battle of the fates the Shadow and the Angel will meet. With it will harbinger the very fight of good vs evil!
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 17th Jun 2003 11:45
Ooops... I can see that the syntax
decl_TANGENT v[pos]

requires DirectX 9.0 Pixel Shader. Hmmm... I need to work on this now. I can't possibly wait until the release of Patch 5. Looks like I am screwed.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 17th Jun 2003 13:51
What was the pixel shader supposed to do?

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_103.zip
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 17th Jun 2003 16:38
I need my 3D model to look shiny on certain part. Therefore, I can't use the DBpro's diffuse lighting. What I need is a specular lighting (or is better known as Phong lighting), which will make the object look shiny. I had found some pixel shader routine to calculate specular lighting, but it requires the tangent vector of each vertices in the mesh. Which is the problem that I encountered now, as stated above.

To better illustrate diffuse lighting (DBpro lighting) and specular lighting (the lighting that I want), I had pasted two screenshot below.

I would really grateful if anyone can help me with that. I had been research on this for nearly one month.

top: diffuse lighting
bottom: specular lighting





Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 17th Jun 2003 16:40
Ooops... correction....

The TOP one is SPECULAR LIGHTING
The BELOW one is DIFFUSE LIGHTING

Thanks!

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 17th Jun 2003 19:12
oh oki thats all you want, specular bump mapping?
i'll see about getting on with that around midday

Within the Epic battle of the fates the Shadow and the Angel will meet. With it will harbinger the very fight of good vs evil!
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 18th Jun 2003 07:16
thanks a lot Raven! You are my life saver (if you can come out with something.) x-d

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 20th Jun 2003 04:36
Any luck, Raven?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 20th Jun 2003 06:33
sorry not even had a chance to open up dbp in like 2days, i am getting to it ... i'll message you directly asa i'm done oki
probably doesn't help that only the examples in dbp seem to want to work right now (even if i code them identically which seems a little weird to me :S)

I pride myself that i don't kill...
well not without a good reason

Login to post a reply

Server time is: 2026-07-11 14:56:17
Your offset time is: 2026-07-11 14:56:17