00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "std3d.h"
00027
00028 #include "3d/computed_string.h"
00029 #include "3d/texture.h"
00030 #include "3d/primitive_block.h"
00031 #include "3d/material.h"
00032
00033 #include "nel/misc/smart_ptr.h"
00034 #include "nel/misc/debug.h"
00035
00036 #include "nel/misc/file.h"
00037
00038 using namespace std;
00039
00040 namespace NL3D {
00041
00042
00043
00044
00045
00046
00047 CVector CComputedString::getHotSpotVector(THotSpot hotspot)
00048 {
00049 CVector hotspotVector(0,0,0);
00050
00051 if(hotspot==MiddleLeft)
00052 hotspotVector = CVector(0,0,-StringHeight/2);
00053
00054 if(hotspot==TopLeft)
00055 hotspotVector = CVector(0,0,-StringHeight);
00056
00057 if(hotspot==MiddleBottom)
00058 hotspotVector = CVector(-StringWidth/2,0,0);
00059
00060 if(hotspot==MiddleMiddle)
00061 hotspotVector = CVector(-StringWidth/2,0,-StringHeight/2);
00062
00063 if(hotspot==MiddleTop)
00064 hotspotVector = CVector(-StringWidth/2,0,-StringHeight);
00065
00066 if(hotspot==BottomRight)
00067 hotspotVector = CVector(-StringWidth,0,0);
00068
00069 if(hotspot==MiddleRight)
00070 hotspotVector = CVector(-StringWidth,0,-StringHeight/2);
00071
00072 if(hotspot==TopRight)
00073 hotspotVector = CVector(-StringWidth,0,-StringHeight);
00074
00075 return hotspotVector;
00076 }
00077
00078
00079
00080
00081
00082 void CComputedString::render2D (IDriver& driver,
00083 float x, float z,
00084 THotSpot hotspot,
00085 float scaleX, float scaleZ,
00086 float rotateY
00087 )
00088 {
00089 if (Vertices.getNumVertices() == 0)
00090 return;
00091
00092 x*=(float)4/3;
00093
00094 driver.setFrustum(0, 4.0f/3.0f, 0, 1, -1, 1, false);
00095
00096
00097 CVector hotspotVector = getHotSpotVector(hotspot);
00098
00099
00100 CMatrix matrix;
00101 matrix.identity();
00102
00103
00104 driver.setupViewMatrix(matrix);
00105
00106
00107
00108 matrix.translate(CVector(x,0,z));
00109 matrix.rotateY(rotateY);
00110 matrix.scale(CVector(scaleX,1,scaleZ));
00111 matrix.translate(hotspotVector);
00112 driver.setupModelMatrix(matrix);
00113
00114 driver.activeVertexBuffer(Vertices);
00115
00116
00117 Material->setZFunc (CMaterial::always);
00118 Material->setZWrite (false);
00119 Material->setColor (Color);
00120 driver.renderQuads (*Material, 0, Vertices.getNumVertices()/4);
00121 }
00122
00123
00124
00125
00126
00127 void CComputedString::render3D (IDriver& driver,CMatrix matrix,THotSpot hotspot)
00128 {
00129 if (Vertices.getNumVertices() == 0)
00130 return;
00131
00132 CVector hotspotVector = getHotSpotVector(hotspot);
00133 matrix.translate(hotspotVector);
00134
00135 driver.setupModelMatrix(matrix);
00136 driver.activeVertexBuffer(Vertices);
00137
00138
00139 Material->setZFunc (CMaterial::lessequal);
00140 Material->setZWrite (true);
00141 Material->setColor (Color);
00142 driver.renderQuads (*Material,0,Vertices.getNumVertices()/4);
00143 }
00144
00145
00146 }