#### Archived

This topic is now archived and is closed to further replies.

# Im so confused.

This topic is 5864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

All righty I have a tad bit off a problem when trying to scale objects in Direct 3D using Visual Basic 6. Basically im trying to make a map editor for a first person shooter and I want it so I the user can input how large they want the floor block to be. ie (x.z) Ive got a 1x1 Block I made in 3D studio max 2 which renders fine, but when I try and apply a scale to it so that its the size of the map.x and map.z recorded, it just jumps to different co-ordinates and never seems to scale more then 3 times its size.. I know it has something to do with the world matrix but I can''t find a good explanation of what the world matrix actually is/does. I''ve tried searching through the dolphin and billboarding examples but all the extra junk in there makes it impossible to find what im looking for. If my question makes any sense at all please help a newbish programmer.

##### Share on other sites
How are you creating the scaling transformation matrix? In DirectX, that scaling matrix is:

  sx  0  0 0 0 sy  0 0 0  0 sz 0 0  0  0 1

Whereas sx = X-scale, sy = y-scale, and sz = z-scale.
Remember that the mesh you are using will scale outward from the mesh''s origin, so that may be part of the reason it is moving when you scale it (the mesh is off-center).

home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX

##### Share on other sites
I tried using the matrix before and tried using the settransform with the direct3d scale thingo.

Im not sure if I gave enough information here, what I''m wondering is how can I edit the single mesh? It doesnt seem right using a world matrix because im only trying to change the one mesh...

thanx.

##### Share on other sites
You may want to post some code - I''m not too sure what you may be trying to do. The world transformation matrix is pretty much what you''d always use to orient and scale meshes in your project.

##### Share on other sites
Well basically I set the camera up with this-

vEyePt.x = 0
vEyePt.y = 10
vEyePt.z = 0

vFocusPt.x = 0
vFocusPt.y = 1
vFocusPt.z = -1

then im trying to resize the world matrix like so:

Dim matWorld As D3DMATRIX

D3DXMatrixScaling matWorld, Map.x, 1, Map.z
m_D3DDevice.SetTransform D3DTS_WORLD, matWorld

(btw I moved the 1x1 block to 0,0,0 in 3DS which fixed the location problem) and the block scales to what I want. Though it seems to flip all the axis. (my look around keycode has to be reveresed)

Basically what I want to know is, how to edit a mesh individually in VB. Because I want to be able to place tables, chairs, doors..etc, though wouldnt changing the world matrix scale all of these?

1 new question I just thought off. If I had a floor texture would it be possible to tile it over and over on the surface of the floor or can this not be done because the floors surface only has 4 corners/Points? (I''m really knew at this)

##### Share on other sites
I think you''re thinking about the whole Matrix/SetTransform thing slightly wrongly....

In Direct3D (ie: not specific to C++ or VB), for each model/set of vertices that you want to render, you build a transformation matrix for that model, and then render the model. Setting the world transform does transform all the vertices that are rendered after it, but not before it...

So, for each of your chairs,tables, whatever, you would build its transformation matrix, ie: scaling, translation, etc, set the world transform, and then render the model. Then move on to the next model.

With regard to your floor tiling question, it''s a case of altering the texture coordinates for the floor quad. Instead of going from 0.0f - 1.0f, they might go from 0.0f - 10.0f to scale the texture 10 times. Similarly you can half it, or use whatever fraction you want. You need to set the address mode for that texture stage to WRAP in both coordinates (u and v) - I can''t remember the exact names for the flags - look it up in the SDK docs.

##### Share on other sites
quote:

Ive got a 1x1 Block I made in 3D studio max 2 which renders fine, but when I try and apply a scale to it so that its the size of the map.x and map.z recorded, it just jumps to different co-ordinates and never seems to scale more then 3 times its size.. I know it has something to do with the world matrix but I can''t find a good explanation of what the world matrix actually is/does.

I think you''re not completely understanding how the world transformation works. You can set the world transformation as many times as you want during rendering.

Typically, you would loop through each mesh that you want to draw in your scene, set a world transformation matrix, and draw the mesh. So, if you have the ground, a chair, and a door - that means you would set the ground''s world transformation, draw the floor, set the chair''s world transformation, draw the chair, and finally set the door''s world transformation and draw the door.

With that in mind (and to answer your new question), you may want to split the floor up into multiple meshes, each texture mapped exactly how you want it to appear in 3DS Max. Drawing your map, you would set each floor section''s world transformation and render that portion of the ground. Continue on until the whole ground has been drawn.

To directly answer your 2nd question - when you are texture mapping, you commonly deal with textures coordinates ranging from 0 to 1. Going past 1 means to repeat the texture, so for instance, setting a texture coordinate as 2 means to repeat the texture twice across the surface of the polygon (if one coordinate is 0 and the opposite side is 2).

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
frob
12

• 9
• 21
• 13
• 9
• 17
• ### Forum Statistics

• Total Topics
632608
• Total Posts
3007391

×