
PIECE: stairs 3 steps
PIECE: plate 11x32
For the avatar go up stairs we only need to define the elevation (TheY) for the adequate points. Like you can see in the code:
...
if (e.Key == Key.L && avdead==0 ){
if(TheX==1 && TheZ>=-3 && TheZ<=3)TheY=2.5;
else if(TheX==2 && TheZ>=-3 && TheZ<=3)TheY=3.5;
else if(TheX>=3 && TheZ>=-3 && TheZ<=3)TheY=4.5;
else if(TheX>=3) TheY=4.5;
else TheY=1.5;
transold=trans;
TheXold=TheX;
TheZold=TheZ;
TheX=TheX+1;
trans = new Matrix3D(0.1,0,0,0,0,0.1,0,0,0,0,0.1,0,TheX ,TheY,TheZ,1);
Quaternion qt = new Quaternion(new Vector3D(1, 0, 0),90);
Point3D pt = new Point3D(TheX , TheY,TheZ);
trans.RotateAt(qt,pt);
qt = new Quaternion(new Vector3D(0, 1, 0),-90);
trans.RotateAt(qt,pt);
mtrans= new MatrixTransform3D(trans);
ModelVisual3D mv3D = VP.Children[0] as ModelVisual3D;
Model3DGroup m3Dg = mv3D.Content as Model3DGroup;
m3Dg.Children[4].Transform= mtrans ;
}
if (e.Key == Key.J && avdead==0 ){
if(TheX==3 && TheZ>=-3 && TheZ<=3)TheY=2.5;
else if(TheX==4 && TheZ>=-3 && TheZ<=3)TheY=3.5;
else if(TheX>=5 && TheZ>=-3 && TheZ<=3)TheY=4.5;
else if(TheX>=5) TheY=4.5;
else TheY=1.5;
transold=trans;
TheXold=TheX;
...
We need to create some areas of collision to avoid the avatar to go to some places. We do it using the same old function: Collision
For the demo, create a folder having the name of the .ZIP file and download it - right-clicking the link - and unzip inside the folder :
If you like only to see the application running you don't need to do the above download. Only liberate the firewall and play this web3d application:
![]() |
We are doing our tests at a: Notebook DELL Latitude D600 - Intel Pentium M755 2.0 GHZ - Memory: 512 MB - VideoCard ATI Radeon 9000 32MB DDR 4xAGP - Resolution 1400x1050 - Communication: ADSL 256 kbps (Download: 45 kBps, Upload: 14 kBps)
PREVIOUS LESSON NEXT LESSON T.CONTENTS HOMEPAGE
