Environment mapping with DirectX8.1?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  02 February 2004
Environment mapping with DirectX8.1?

I have a mesh loaded up like so

PHP Code:
 Public Sub Create350ZMesh()
    
    
Dim xfName As String
    Dim nMaterials 
As Long
    Dim mtrlBuffer 
As D3DXBuffer
    Dim meshMat 
As D3DMATERIAL8
    Dim i 
As Long
    
    GameDebugger
.WriteLine "Loading 350Z into memory"
    
    
UpdateProgressbar "Loading 350Z Mesh"0
    
    OnLoadStep 
0
    
    With Car350Z
        
        
'load the body mesh to .body
        xfName = App.Path & "\Models\350Z.x"
        Set .Body = d3dx.LoadMeshFromX(xfName, D3DXMESH_MANAGED, d3dDevice, Nothing, mtrlBuffer, nMaterials)
        OnLoadStep = OnLoadStep + 1
        UpdateProgressbar "Loading 350Z Mesh", OnLoadStep
        
        '
apply any textures the body requires
        ReDim 
.BodyTexture(nMaterials)
        
ReDim .BodyTextureName(nMaterials)
        
ReDim .BodyMaterial(nMaterials)
        .
Bodymaterials nMaterials
        
For 0 To nMaterials 1
            OnLoadStep 
OnLoadStep 1
            UpdateProgressbar 
"Loading 350Z Mesh"OnLoadStep
            d3dx
.BufferGetMaterial mtrlBufferimeshMat
            meshMat
.Ambient meshMat.diffuse
            
.BodyMaterial(i) = meshMat
            xfName 
d3dx.BufferGetTextureName(mtrlBufferi)
            .
BodyTextureName(i) = xfName
            d3dDevice
.SetTextureStageState 0D3DTSS_COLOROPD3DTOP_SELECTARG1
            
If Len(xfName) > 0 Then
                Set 
.BodyTexture(i) = d3dx.CreateTextureFromFile(d3dDeviceApp.Path "\Models\" & xfName)
            End If
        Next i
    
    GameDebugger.WriteLine "
Loaded 350Z into memory finished without error"
    
End Sub 


The mesh is of the type

PHP Code:
 Private Type ModelMesh
    Body 
As D3DXMesh
    BackTires 
As D3DXMesh
    FrontPassengerTire 
As D3DXMesh
    FrontDriverTire 
As D3DXMesh
    BodyTexture
() As Direct3DTexture8
    BodyReflection 
As Direct3DTexture8
    TireBump 
As Direct3DTexture8
    BackTiresTexture
() As Direct3DTexture8
    FrontDriverTireTexture
() As Direct3DTexture8
    FrontPassengerTexture
() As Direct3DTexture8
    BodyTextureName
() As String
    BackTiresTextureName
() As String
    FrontDriverTireTextureName
() As String
    FrontPassengerTextureName
() As String
    BodyMaterial
() As D3DMATERIAL8
    BackTiresMaterial
() As D3DMATERIAL8
    FrontDriverMaterial
() As D3DMATERIAL8
    FrontPassengerMaterial
() As D3DMATERIAL8
    Bodymaterials 
As Long
    BackTiresmaterials 
As Long
    FrontDrivermaterials 
As Long
    FrontPassengermaterials 
As Long
    UnitMeshName 
As String
End Type 


Its rendered in the render loop by

PHP Code:
 With Car350Z
            
'draw the body
            D3DXMatrixIdentity matTemp
            D3DXMatrixRotationY matTemp, .Rotation
            D3DXMatrixTranslation matTrans, .X, .Y, .z
            D3DXMatrixMultiply matTemp, matTemp, matTrans
            d3dDevice.SetTransform D3DTS_WORLD, matTemp
            For i = 0 To .Bodymaterials - 1
                d3dDevice.SetMaterial .BodyMaterial(i)
                d3dDevice.SetTexture 0, .BodyTexture(i)
                .Body.DrawSubset i
            Next i
     End With 


I've been looking around at the MSDN archive but its so elusive. Any ideas? I'm hoping I can load a environment map and apply it to the model much like a regular texture map. Is that possible?
__________________
"Game developers are like simple chemicals. (No, not because they're cheap and smelly.) In the right combination, they can make miracles. Screw up the mix, and you can blow up a city." - How to Screw Up a Perfectly Good Game Company in Ten Easy Steps, www.gamedev.net
 
  03 March 2004
Maybe U will find the "sphere mapping" useful. There's a sample in the Dx SDK named "SphereMap Sample"
 
  03 March 2004
Wow this is even better then I was expecting. Except I was only able to dig up a .net version of the dx sdk. I guess its time to bone up on it so I can translate it to plain old vb. Thanks for the helping hand.
__________________
"Game developers are like simple chemicals. (No, not because they're cheap and smelly.) In the right combination, they can make miracles. Screw up the mix, and you can blow up a city." - How to Screw Up a Perfectly Good Game Company in Ten Easy Steps, www.gamedev.net
 
  01 January 2006
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:18 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.