00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llvoground.h"
00035 #include "lldrawpoolground.h"
00036
00037 #include "llviewercontrol.h"
00038
00039 #include "llagent.h"
00040 #include "lldrawable.h"
00041 #include "llface.h"
00042 #include "llsky.h"
00043 #include "llviewercamera.h"
00044 #include "llviewerregion.h"
00045 #include "pipeline.h"
00046
00047 LLVOGround::LLVOGround(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
00048 : LLStaticViewerObject(id, pcode, regionp)
00049 {
00050 mbCanSelect = FALSE;
00051 }
00052
00053
00054 LLVOGround::~LLVOGround()
00055 {
00056 }
00057
00058 BOOL LLVOGround::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
00059 {
00060 if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_GROUND)))
00061 {
00062 return TRUE;
00063 }
00064
00065
00066
00067
00068
00069 return TRUE;
00070 }
00071
00072
00073 void LLVOGround::updateTextures(LLAgent &agent)
00074 {
00075 }
00076
00077
00078 LLDrawable *LLVOGround::createDrawable(LLPipeline *pipeline)
00079 {
00080 pipeline->allocDrawable(this);
00081 mDrawable->setLit(FALSE);
00082
00083 mDrawable->setRenderType(LLPipeline::RENDER_TYPE_GROUND);
00084 LLDrawPoolGround *poolp = (LLDrawPoolGround*) gPipeline.getPool(LLDrawPool::POOL_GROUND);
00085
00086 mDrawable->addFace(poolp, NULL);
00087
00088 return mDrawable;
00089 }
00090
00091 BOOL LLVOGround::updateGeometry(LLDrawable *drawable)
00092 {
00093 LLStrider<LLVector3> verticesp;
00094 LLStrider<LLVector3> normalsp;
00095 LLStrider<LLVector2> texCoordsp;
00096 LLStrider<U32> indicesp;
00097 S32 index_offset;
00098 LLFace *face;
00099
00100 LLDrawPoolGround *poolp = (LLDrawPoolGround*) gPipeline.getPool(LLDrawPool::POOL_GROUND);
00101
00102 if (drawable->getNumFaces() < 1)
00103 drawable->addFace(poolp, NULL);
00104 face = drawable->getFace(0);
00105
00106 if (face->mVertexBuffer.isNull())
00107 {
00108 face->setSize(5, 12);
00109 face->mVertexBuffer = new LLVertexBuffer(LLDrawPoolGround::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB);
00110 face->mVertexBuffer->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE);
00111 face->setGeomIndex(0);
00112 face->setIndicesIndex(0);
00113 }
00114
00115 index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp);
00116 if (-1 == index_offset)
00117 {
00118 return TRUE;
00119 }
00120
00122
00123
00124
00125 LLVector3 at_dir = gCamera->getAtAxis();
00126 at_dir.mV[VZ] = 0.f;
00127 if (at_dir.normVec() < 0.01)
00128 {
00129
00130 }
00131 LLVector3 left_dir = gCamera->getLeftAxis();
00132 left_dir.mV[VZ] = 0.f;
00133 left_dir.normVec();
00134
00135
00136 LLColor4 ground_color = gSky.getFogColor();
00137 ground_color.mV[3] = 1.f;
00138 face->setFaceColor(ground_color);
00139
00140 *(verticesp++) = LLVector3(64, 64, 0);
00141 *(verticesp++) = LLVector3(-64, 64, 0);
00142 *(verticesp++) = LLVector3(-64, -64, 0);
00143 *(verticesp++) = LLVector3(64, -64, 0);
00144 *(verticesp++) = LLVector3(0, 0, -1024);
00145
00146
00147
00148 *indicesp++ = index_offset + 0;
00149 *indicesp++ = index_offset + 1;
00150 *indicesp++ = index_offset + 4;
00151
00152 *indicesp++ = index_offset + 1;
00153 *indicesp++ = index_offset + 2;
00154 *indicesp++ = index_offset + 4;
00155
00156 *indicesp++ = index_offset + 2;
00157 *indicesp++ = index_offset + 3;
00158 *indicesp++ = index_offset + 4;
00159
00160 *indicesp++ = index_offset + 3;
00161 *indicesp++ = index_offset + 0;
00162 *indicesp++ = index_offset + 4;
00163
00164 *(texCoordsp++) = LLVector2(0.f, 0.f);
00165 *(texCoordsp++) = LLVector2(1.f, 0.f);
00166 *(texCoordsp++) = LLVector2(1.f, 1.f);
00167 *(texCoordsp++) = LLVector2(0.f, 1.f);
00168 *(texCoordsp++) = LLVector2(0.5f, 0.5f);
00169
00170 LLPipeline::sCompiles++;
00171 return TRUE;
00172 }