public void EndLevelLoad() { int c = _guiList.Count; for (int i = 0; i < c; i++) { if (_guiList[i].ReferenceCount == 0) { // common->Printf( "purging %s.\n", guis[i]->GetSourceFile() ); // use this to make sure no materials still reference this gui bool remove = true; for (int j = 0; j < idE.DeclManager.GetDeclCount(DeclType.Material); j++) { idMaterial material = (idMaterial)idE.DeclManager.DeclByIndex(DeclType.Material, j, false); if (material.GlobalInterface == _guiList[i]) { remove = false; break; } } if (remove == true) { _guiList[i].Dispose(); _guiList.RemoveAt(i); i--; c--; } } } }
public idClipModel(idClipModel model) { _id = model.ID; _owner = model.Owner; _enabled = model.Enabled; _entity = model.Entity; _origin = model.Origin; _axis = model.Axis; _bounds = model.Bounds; _absBounds = model.AbsoluteBounds; _material = model.Material; _contents = model.Contents; _collisionModelHandle = model.CollisionModelHandle; _traceModelCache = null; if (model.TraceModelCache != null) { idConsole.Warning("TODO: LoadModel( *GetCachedTraceModel( model->traceModelIndex ) );"); } _renderModelHandle = model.RenderModelHandle; _touchCount = -1; }
public idMaterial RemapShaderBySkin(idMaterial shader) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } if (shader == null) { return(null); } // never remap surfaces that were originally nodraw, like collision hulls. if (shader.IsDrawn == false) { return(shader); } int count = _mappings.Length; for (int i = 0; i < count; i++) { SkinMapping map = _mappings[i]; // null = wildcard match. if ((map.From == null) || (map.From == shader)) { return(map.To); } } // didn't find a match or wildcard, so stay the same. return(shader); }
public void DrawMaterial(float x, float y, float width, float height, idMaterial material, Vector4 color, float scaleX = 1.0f, float scaleY = 1.0f) { idE.RenderSystem.Color = color; float s0, s1, t0, t1; // // handle negative scales as well if (scaleX < 0) { width *= -1; scaleX *= -1; } if (scaleY < 0) { height *= -1; scaleY *= -1; } // if (width < 0) { // flip about vertical width = -width; s0 = 1 * scaleX; s1 = 0; } else { s0 = 0; s1 = 1 * scaleX; } if (height < 0) { // flip about horizontal height = -height; t0 = 1 * scaleY; t1 = 0; } else { t0 = 0; t1 = 1 * scaleY; } if (ClipCoordinates(ref x, ref y, ref width, ref height, ref s0, ref t0, ref s1, ref t1) == true) { return; } AdjustCoordinates(ref x, ref y, ref width, ref height); DrawStretchPicture(x, y, width, height, s0, t0, s1, t1, material); }
public void Init() { _scaleX = 0.0f; _whiteImage = idE.DeclManager.FindMaterial("guis/assets/white.tga"); _whiteImage.Sort = (float)MaterialSort.Gui; SetupFonts(); _matrix = Matrix.Identity; _origin = Vector3.Zero; _enableClipping = true; _mbcs = false; SetSize(idE.VirtualScreenWidth, idE.VirtualScreenHeight); _currentFontFamily = _fontFamilies[0]; /* * TODO*/ _cursorImages[(int)Cursor.Arrow] = idE.DeclManager.FindMaterial("ui/assets/guicursor_arrow.tga"); _cursorImages[(int)Cursor.Hand] = idE.DeclManager.FindMaterial("ui/assets/guicursor_hand.tga"); _cursorImages[(int)Cursor.Arrow].Sort = (float)MaterialSort.Gui; _cursorImages[(int)Cursor.Hand].Sort = (float)MaterialSort.Gui; /*scrollBarImages[SCROLLBAR_HBACK] = declManager->FindMaterial("ui/assets/scrollbarh.tga"); * scrollBarImages[SCROLLBAR_VBACK] = declManager->FindMaterial("ui/assets/scrollbarv.tga"); * scrollBarImages[SCROLLBAR_THUMB] = declManager->FindMaterial("ui/assets/scrollbar_thumb.tga"); * scrollBarImages[SCROLLBAR_RIGHT] = declManager->FindMaterial("ui/assets/scrollbar_right.tga"); * scrollBarImages[SCROLLBAR_LEFT] = declManager->FindMaterial("ui/assets/scrollbar_left.tga"); * scrollBarImages[SCROLLBAR_UP] = declManager->FindMaterial("ui/assets/scrollbar_up.tga"); * scrollBarImages[SCROLLBAR_DOWN] = declManager->FindMaterial("ui/assets/scrollbar_down.tga");*/ /*crollBarImages[SCROLLBAR_HBACK]->SetSort( SS_GUI ); * scrollBarImages[SCROLLBAR_VBACK]->SetSort( SS_GUI ); * scrollBarImages[SCROLLBAR_THUMB]->SetSort( SS_GUI ); * scrollBarImages[SCROLLBAR_RIGHT]->SetSort( SS_GUI ); * scrollBarImages[SCROLLBAR_LEFT]->SetSort( SS_GUI ); * scrollBarImages[SCROLLBAR_UP]->SetSort( SS_GUI ); * scrollBarImages[SCROLLBAR_DOWN]->SetSort( SS_GUI );*/ _cursor = Cursor.Arrow; /*overStrikeMode = true;*/ _initialized = true; }
protected override void PostParse() { base.PostParse(); _value.Set(0.0f); _thumbMaterial = idE.DeclManager.FindMaterial(_thumbMaterialName); _thumbMaterial.Sort = (float)MaterialSort.Gui; _thumbWidth = _thumbMaterial.ImageWidth; _thumbHeight = _thumbMaterial.ImageHeight; this.Flags |= WindowFlags.HoldCapture | WindowFlags.CanFocus; InitCvar(); }
public idPlayerView(idPlayer player) { _player = player; _screenBlobs = new ScreenBlob[idR.MaxScreenBlobs]; _view = new idRenderView(); _doubleVisionMaterial = idR.DeclManager.FindMaterial("_scratch"); _tunnelMaterial = idR.DeclManager.FindMaterial("textures/decals/tunnel"); _armorMaterial = idR.DeclManager.FindMaterial("armorViewEffect"); _berserkMaterial = idR.DeclManager.FindMaterial("textures/decals/berserk"); _irGogglesMaterial = idR.DeclManager.FindMaterial("textures/decals/irblend"); _bloodSprayMaterial = idR.DeclManager.FindMaterial("textures/decals/bloodspray"); _bfgMaterial = idR.DeclManager.FindMaterial("textures/decals/bfgvision"); _lagoMaterial = idR.DeclManager.FindMaterial(idR.LagometerMaterial, false); ClearEffects(); }
private void Init() { _value.Set(0.0f); _low = 0.0f; _high = 100.0f; _stepSize = 1.0f; _thumbMaterial = idE.DeclManager.FindMaterial("_default"); _buddyWindow = null; _cvar = null; _cvarInit = false; _vertical = false; _scrollBar = false; _verticalFlip = false; _liveUpdate.Set(true); }
private void SetupTraceModelStructure() { // setup model CollisionModel model = new CollisionModel(); _models[idE.MaxSubModels] = model; // create node to hold the collision data CollisionModelNode node = new CollisionModelNode(); node.PlaneType = -1; model.Node = node; // allocate vertex and edge arrays //model.Vertices = new CollisionModelVertex[idE.MaxTraceModelVertices]; //model->edges = (cm_edge_t *) Mem_ClearedAlloc( model->maxEdges * sizeof(cm_edge_t) ); // create a material for the trace model polygons _traceModelMaterial = idE.DeclManager.FindMaterial("_tracemodel", false); if (_traceModelMaterial == null) { idConsole.FatalError("_tracemodel material not found"); } // allocate polygons /*for ( i = 0; i < MAX_TRACEMODEL_POLYS; i++ ) { * trmPolygons[i] = AllocPolygonReference( model, MAX_TRACEMODEL_POLYS ); * trmPolygons[i]->p = AllocPolygon( model, MAX_TRACEMODEL_POLYEDGES ); * trmPolygons[i]->p->bounds.Clear(); * trmPolygons[i]->p->plane.Zero(); * trmPolygons[i]->p->checkcount = 0; * trmPolygons[i]->p->contents = -1; // all contents * trmPolygons[i]->p->material = trmMaterial; * trmPolygons[i]->p->numEdges = 0; * } * // allocate brush for position test * trmBrushes[0] = AllocBrushReference( model, 1 ); * trmBrushes[0]->b = AllocBrush( model, MAX_TRACEMODEL_POLYS ); * trmBrushes[0]->b->primitiveNum = 0; * trmBrushes[0]->b->bounds.Clear(); * trmBrushes[0]->b->checkcount = 0; * trmBrushes[0]->b->contents = -1; // all contents * trmBrushes[0]->b->numPlanes = 0;*/ }
public override void Update() { string s = this.Name; if ((_guiDict != null) && (s != string.Empty)) { _data = _guiDict.GetString(s); if (_data == string.Empty) { _material = null; } else { _material = idE.DeclManager.FindMaterial(_data); } } }
private void InitScroller(bool horizontal) { string thumbImage = "guis/assets/scrollbar_thumb.tga"; string barImage = "guis/assets/scrollbarv.tga"; string scrollerName = "_scrollerWinV"; if (horizontal == true) { barImage = "guis/assets/scrollbarh.tga"; scrollerName = "_scrollerWinH"; } idMaterial mat = idE.DeclManager.FindMaterial(barImage); mat.Sort = (float)MaterialSort.Gui; _sizeBias = mat.ImageWidth; idRectangle scrollRect; if (horizontal == true) { _sizeBias = mat.ImageHeight; scrollRect.X = 0; scrollRect.Y = this.ClientRectangle.Height - _sizeBias; scrollRect.Width = this.ClientRectangle.Width; scrollRect.Height = _sizeBias; } else { scrollRect.X = this.ClientRectangle.Width - _sizeBias; scrollRect.Y = 0; scrollRect.Width = _sizeBias; scrollRect.Height = this.ClientRectangle.Height; } _scroller.InitWithDefaults(scrollerName, scrollRect, this.ForeColor, this.MaterialColor, mat.Name, thumbImage, !horizontal, true); InsertChild(_scroller, null); _scroller.Buddy = this; }
public override void Set(string value) { _data = value; if (_guiDict != null) { _guiDict.Set(this.Name, _data); } if (_material != null) { if (_data == string.Empty) { _material = null; } else { _material = idE.DeclManager.FindMaterial(_data); } } }
public void InitWithDefaults(string name, idRectangle rect, Vector4 foreColor, Vector4 materialColor, string background, string thumbMaterial, bool vertical, bool scrollbar) { SetInitialState(name); _rect.Set(rect); _foreColor.Set(foreColor); _materialColor.Set(materialColor); _thumbMaterial = idE.DeclManager.FindMaterial(thumbMaterial); _thumbMaterial.Sort = (float)MaterialSort.Gui; _thumbWidth = _thumbMaterial.ImageWidth; _thumbHeight = _thumbMaterial.ImageHeight; _background = idE.DeclManager.FindMaterial(_backgroundName); _background.Sort = (float)MaterialSort.Gui; _vertical = vertical; _scrollBar = scrollbar; this.Flags |= WindowFlags.HoldCapture; }
private void PaintCharacter(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, idMaterial shader) { float tmpWidth = width * scale; float tmpHeight = height * scale; if (ClipCoordinates(ref x, ref y, ref tmpWidth, ref tmpHeight, ref s, ref t, ref s2, ref t2) == true) { return; } AdjustCoordinates(ref x, ref y, ref tmpWidth, ref tmpHeight); DrawStretchPicture(x, y, tmpWidth, tmpHeight, s, t, s2, t2, shader); }
/// <summary> /// Sets the stage to a default state. /// </summary> public void Default() { _material = idE.DeclManager.FindMaterial("_default"); _totalParticles = 100; _spawnBunching = 1.0f; _particleLife = 1.5f; _timeOffset = 0.0f; _deadTime = 0.0f; _distribution = ParticleDistribution.Rectangle; _distributionParms[0] = 8.0f; _distributionParms[1] = 8.0f; _distributionParms[2] = 8.0f; _distributionParms[3] = 0.0f; _direction = ParticleDirection.Cone; _directionParms[0] = 90.0f; _directionParms[1] = 0.0f; _directionParms[2] = 0.0f; _directionParms[3] = 0.0f; _orientation = ParticleOrientation.View; _orientationParms[0] = 0.0f; _orientationParms[1] = 0.0f; _orientationParms[2] = 0.0f; _orientationParms[3] = 0.0f; _customPath = ParticleCustomPath.Standard; _customPathParms[0] = 0.0f; _customPathParms[1] = 0.0f; _customPathParms[2] = 0.0f; _customPathParms[3] = 0.0f; _customPathParms[4] = 0.0f; _customPathParms[5] = 0.0f; _customPathParms[6] = 0.0f; _customPathParms[7] = 0.0f; _gravity = 1.0f; _worldGravity = false; _offset = Vector3.Zero; _animationFrames = 0; _animationRate = 0.0f; _initialAngle = 0.0f; _speed = new idParticleParameter(150.0f, 150.0f, null); _rotationSpeed = new idParticleParameter(0.0f, 0.0f, null); _size = new idParticleParameter(4.0f, 4.0f, null); _aspect = new idParticleParameter(1.0f, 1.0f, null); _color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f); _fadeColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); _fadeInFraction = 0.1f; _fadeOutFraction = 0.25f; _fadeIndexFraction = 0.0f; _boundsExpansion = 0.0f; _randomDistribution = true; _entityColor = false; _cycleTime = (int)(_particleLife + _deadTime) * 1000; }
public void Parse(idLexer lexer, idJointMatrix[] joints) { lexer.ExpectTokenString("{"); // // parse name // if (lexer.CheckTokenString("name") == true) { lexer.ReadToken(); } // // parse shader // lexer.ExpectTokenString("shader"); idToken token = lexer.ReadToken(); string materialName = token.ToString(); _material = idE.DeclManager.FindMaterial(materialName); // // parse texture coordinates // lexer.ExpectTokenString("numverts"); int count = lexer.ParseInt(); if (count < 0) { lexer.Error("Invalid size: {0}", token.ToString()); } _texCoords = new Vector2[count]; int[] firstWeightForVertex = new int[count]; int[] weightCountForVertex = new int[count]; int maxWeight = 0; int coordCount = _texCoords.Length; _weightCount = 0; for (int i = 0; i < coordCount; i++) { lexer.ExpectTokenString("vert"); lexer.ParseInt(); float[] tmp = lexer.Parse1DMatrix(2); _texCoords[i] = new Vector2(tmp[0], tmp[1]); firstWeightForVertex[i] = lexer.ParseInt(); weightCountForVertex[i] = lexer.ParseInt(); if (weightCountForVertex[i] == 0) { lexer.Error("Vertex without any joint weights."); } _weightCount += weightCountForVertex[i]; if ((weightCountForVertex[i] + firstWeightForVertex[i]) > maxWeight) { maxWeight = weightCountForVertex[i] + firstWeightForVertex[i]; } } // // parse tris // lexer.ExpectTokenString("numtris"); _triangleCount = lexer.ParseInt(); if (_triangleCount < 0) { lexer.Error("Invalid size: {0}", _triangleCount); } int[] tris = new int[_triangleCount * 3]; for (int i = 0; i < _triangleCount; i++) { lexer.ExpectTokenString("tri"); lexer.ParseInt(); tris[i * 3 + 0] = lexer.ParseInt(); tris[i * 3 + 1] = lexer.ParseInt(); tris[i * 3 + 2] = lexer.ParseInt(); } // // parse weights // lexer.ExpectTokenString("numweights"); count = lexer.ParseInt(); if (count < 0) { lexer.Error("Invalid size: {0}", count); } if (maxWeight > count) { lexer.Warning("Vertices reference out of range weights in model ({0} of {1} weights).", maxWeight, count); } VertexWeight[] tempWeights = new VertexWeight[count]; for (int i = 0; i < count; i++) { lexer.ExpectTokenString("weight"); lexer.ParseInt(); int jointIndex = lexer.ParseInt(); if ((jointIndex < 0) || (jointIndex >= joints.Length)) { lexer.Error("Joint index out of range({0}): {1}", joints.Length, jointIndex); } tempWeights[i].JointIndex = jointIndex; tempWeights[i].JointWeight = lexer.ParseFloat(); float[] tmp = lexer.Parse1DMatrix(3); tempWeights[i].Offset = new Vector3(tmp[0], tmp[1], tmp[2]); } // create pre-scaled weights and an index for the vertex/joint lookup _scaledWeights = new Vector4[_weightCount]; _weightIndex = new int[_weightCount * 2]; count = 0; coordCount = _texCoords.Length; for (int i = 0; i < coordCount; i++) { int num = firstWeightForVertex[i]; int weightCount = weightCountForVertex[i]; for (int j = 0; j < weightCount; j++, num++, count++) { Vector3 tmp = tempWeights[num].Offset * tempWeights[num].JointWeight; _scaledWeights[count].X = tmp.X; _scaledWeights[count].Y = tmp.Y; _scaledWeights[count].Z = tmp.Z; _scaledWeights[count].W = tempWeights[num].JointWeight; _weightIndex[count * 2 + 0] = tempWeights[num].JointIndex; } _weightIndex[count * 2 - 1] = 1; } lexer.ExpectTokenString("}"); // update counters idConsole.Warning("TODO: idRenderModel_MD5 update counters"); /*c_numVerts += texCoords.Num(); * c_numWeights += numWeights; * c_numWeightJoints++; * for ( i = 0; i < numWeights; i++ ) { * c_numWeightJoints += weightIndex[i*2+1]; * }*/ // // build the information that will be common to all animations of this mesh: // silhouette edge connectivity and normal / tangent generation information // Vertex[] verts = new Vertex[_texCoords.Length]; int vertCount = verts.Length; for (int i = 0; i < vertCount; i++) { verts[i].TextureCoordinates = _texCoords[i]; } TransformVertices(verts, joints); idConsole.Warning("TODO: idMD5Mesh Deform"); //_deformInfo = idE.RenderSystem.BuildDeformInformation(verts, tris, _material.UseUnsmoothedTangents); }
public idSimpleWindow(idWindow win) { _gui = win.UserInterface; _context = win.DeviceContext; _drawRect = win.DrawRectangle; _clientRect = win.ClientRectangle; _textRect = win.TextRectangle; _origin = win.Origin; _fontFamily = win.FontFamily; _name = win.Name; _materialScaleX = win.MaterialScaleX; _materialScaleY = win.MaterialScaleY; _borderSize = win.BorderSize; _textAlign = win.TextAlign; _textAlignX = win.TextAlignX; _textAlignY = win.TextAlignY; _background = win.Background; _flags = win.Flags; _textShadow = win.TextShadow; _visible.Set(win.IsVisible); _text.Set(win.Text); _rect.Set(win.Rectangle); _backColor.Set(win.BackColor); _materialColor.Set(win.MaterialColor); _foreColor.Set(win.ForeColor); _borderColor.Set(win.BorderColor); _textScale.Set(win.TextScale); _rotate.Set(win.Rotate); _shear.Set(win.Shear); _backgroundName.Set(win.BackgroundName); if (_backgroundName != string.Empty) { _background = idE.DeclManager.FindMaterial(_backgroundName); _background.Sort = (float)MaterialSort.Gui;; _background.ImageClassification = 1; // just for resource tracking } _backgroundName.Material = _background; _parent = win.Parent; _hideCursor.Set(win.HideCursor); if (_parent != null) { if (_text.NeedsUpdate == true) { _parent.AddUpdateVariable(_text); } if (_visible.NeedsUpdate == true) { _parent.AddUpdateVariable(_visible); } if (_rect.NeedsUpdate == true) { _parent.AddUpdateVariable(_rect); } if (_backColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_backColor); } if (_materialColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_materialColor); } if (_foreColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_foreColor); } if (_borderColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_borderColor); } if (_textScale.NeedsUpdate == true) { _parent.AddUpdateVariable(_textScale); } if (_rotate.NeedsUpdate == true) { _parent.AddUpdateVariable(_rotate); } if (_shear.NeedsUpdate == true) { _parent.AddUpdateVariable(_shear); } if (_backgroundName.NeedsUpdate == true) { _parent.AddUpdateVariable(_backgroundName); } } }
public void DrawStretchPicture(Vertex[] vertices, int[] indexes, idMaterial material, bool clip, float minX, float minY, float maxX, float maxY) { if ((vertices == null) || (indexes == null) || (material == null)) { return; } // break the current surface if we are changing to a new material if (material != _surface.Material) { if (_surface.VertexCount > 0) { AdvanceSurface(); } _surface.Material = material; _surface.Material.EnsureNotPurged(); // in case it was a gui item started before a level change } clip = false; // add the verts and indexes to the current surface if (clip == true) { idConsole.WriteLine("idGuiModle.DrawStretchPicture clip"); /*int i, j; * * // FIXME: this is grim stuff, and should be rewritten if we have any significant * // number of guis asking for clipping * * idFixedWinding w; * for ( i = 0; i < indexCount; i += 3 ) { * w.Clear(); * w.AddPoint(idVec5(dverts[dindexes[i]].xyz.x, dverts[dindexes[i]].xyz.y, dverts[dindexes[i]].xyz.z, dverts[dindexes[i]].st.x, dverts[dindexes[i]].st.y)); * w.AddPoint(idVec5(dverts[dindexes[i+1]].xyz.x, dverts[dindexes[i+1]].xyz.y, dverts[dindexes[i+1]].xyz.z, dverts[dindexes[i+1]].st.x, dverts[dindexes[i+1]].st.y)); * w.AddPoint(idVec5(dverts[dindexes[i+2]].xyz.x, dverts[dindexes[i+2]].xyz.y, dverts[dindexes[i+2]].xyz.z, dverts[dindexes[i+2]].st.x, dverts[dindexes[i+2]].st.y)); * * for ( j = 0; j < 3; j++ ) { * if ( w[j].x < min_x || w[j].x > max_x || * w[j].y < min_y || w[j].y > max_y ) { * break; * } * } * if ( j < 3 ) { * idPlane p; * p.Normal().y = p.Normal().z = 0.0f; p.Normal().x = 1.0f; p.SetDist( min_x ); * w.ClipInPlace( p ); * p.Normal().y = p.Normal().z = 0.0f; p.Normal().x = -1.0f; p.SetDist( -max_x ); * w.ClipInPlace( p ); * p.Normal().x = p.Normal().z = 0.0f; p.Normal().y = 1.0f; p.SetDist( min_y ); * w.ClipInPlace( p ); * p.Normal().x = p.Normal().z = 0.0f; p.Normal().y = -1.0f; p.SetDist( -max_y ); * w.ClipInPlace( p ); * } * * int numVerts = verts.Num(); * verts.SetNum( numVerts + w.GetNumPoints(), false ); * for ( j = 0 ; j < w.GetNumPoints() ; j++ ) { * idDrawVert *dv = &verts[numVerts+j]; * * dv->xyz.x = w[j].x; * dv->xyz.y = w[j].y; * dv->xyz.z = w[j].z; * dv->st.x = w[j].s; * dv->st.y = w[j].t; * dv->normal.Set(0, 0, 1); * dv->tangents[0].Set(1, 0, 0); * dv->tangents[1].Set(0, 1, 0); * } * surf->numVerts += w.GetNumPoints(); * * for ( j = 2; j < w.GetNumPoints(); j++ ) { * indexes.Append( numVerts - surf->firstVert ); * indexes.Append( numVerts + j - 1 - surf->firstVert ); * indexes.Append( numVerts + j - surf->firstVert ); * surf->numIndexes += 3; * } * }*/ } else { int currentVertexCount = _vertices.Count; int currentIndexCount = _indexes.Count; int vertexCount = vertices.Length; int indexCount = indexes.Length; _surface.VertexCount += vertexCount; _surface.IndexCount += indexCount; for (int i = 0; i < indexCount; i++) { _indexes.Add(currentVertexCount + indexes[i] - _surface.FirstVertex); } _vertices.AddRange(vertices); } }
public void DrawStretchPicture(float x, float y, float width, float height, float s, float t, float s2, float t2, idMaterial material) { Vertex[] vertices = new Vertex[4]; int[] indexes = new int[6]; if (material == null) { return; } // clip to edges, because the pic may be going into a guiShader // instead of full screen if (x < 0) { s += (s2 - s) * -x / width; width += x; x = 0; } if (y < 0) { t += (t2 - t) * -y / height; height += y; y = 0; } if ((x + width) > 640) { s2 -= (s2 - s) * (x + width - 640) / width; width = 640 - x; } if ((y + height) > 480) { t2 -= (t2 - t) * (y + height - 480) / height; height = 480 - y; } if ((width <= 0) || (height <= 0)) { // completely clipped away return; } indexes[0] = 3; indexes[1] = 0; indexes[2] = 2; indexes[3] = 2; indexes[4] = 0; indexes[5] = 1; vertices[0].Position = new Vector3(x, y, 0); vertices[0].TextureCoordinates = new Vector2(s, t); vertices[0].Normal = new Vector3(0, 0, 1); // TODO: tangents /*vertices[0].tangents[0][0] = 1; * vertices[0].tangents[0][1] = 0; * vertices[0].tangents[0][2] = 0; * vertices[0].tangents[1][0] = 0; * vertices[0].tangents[1][1] = 1; * vertices[0].tangents[1][2] = 0;*/ vertices[1].Position = new Vector3(x + width, y, 0); vertices[1].TextureCoordinates = new Vector2(s2, t); vertices[1].Normal = new Vector3(0, 0, 1); /*vertices[1].tangents[0][0] = 1; * vertices[1].tangents[0][1] = 0; * vertices[1].tangents[0][2] = 0; * vertices[1].tangents[1][0] = 0; * vertices[1].tangents[1][1] = 1; * vertices[1].tangents[1][2] = 0;*/ vertices[2].Position = new Vector3(x + width, y + height, 0); vertices[2].TextureCoordinates = new Vector2(s2, t2); vertices[2].Normal = new Vector3(0, 0, 1); /*vertices[2].tangents[0][0] = 1; * vertices[2].tangents[0][1] = 0; * vertices[2].tangents[0][2] = 0; * vertices[2].tangents[1][0] = 0; * vertices[2].tangents[1][1] = 1; * vertices[2].tangents[1][2] = 0;*/ vertices[3].Position = new Vector3(x, y + height, 0); vertices[3].TextureCoordinates = new Vector2(s, t2); vertices[3].Normal = new Vector3(0, 0, 1); /*vertices[3].tangents[0][0] = 1; * vertices[3].tangents[0][1] = 0; * vertices[3].tangents[0][2] = 0; * vertices[3].tangents[1][0] = 0; * vertices[3].tangents[1][1] = 1; * vertices[3].tangents[1][2] = 0;*/ DrawStretchPicture(vertices, indexes, material, false, 0, 0, 640.0f, 480.0f); }
protected override bool ParseInternalVariable(string name, Text.idScriptParser parser) { string nameLower = name.ToLower(); if (nameLower == "horizontal") { _horizontal = parser.ParseBool(); } else if (nameLower == "listname") { _listName = ParseString(parser); } else if (nameLower == "tabstops") { _tabStopString = ParseString(parser); } else if (nameLower == "tabaligns") { _tabAlignString = ParseString(parser); } else if (nameLower == "multiplesel") { _multipleSelection = parser.ParseBool(); } else if (nameLower == "tabvaligns") { _tabVerticalAlignString = ParseString(parser); } else if (nameLower == "tabtypes") { _tabTypeString = ParseString(parser); } else if (nameLower == "tabiconsizes") { _tabIconSizeString = ParseString(parser); } else if (nameLower == "tabiconvoffset") { _tabIconVerticalOffsetString = ParseString(parser); } else if (nameLower.StartsWith("mtr_") == true) { string materialName = ParseString(parser); idMaterial material = idE.DeclManager.FindMaterial(materialName); material.ImageClassification = 1; // just for resource tracking if ((material != null) && (material.TestMaterialFlag(MaterialFlags.Defaulted) == false)) { material.Sort = (float)MaterialSort.Gui; } _iconMaterials.Add(name, material); } else { return(base.ParseInternalVariable(name, parser)); } return(true); }
public void DrawStretchPicture(float x, float y, float width, float height, float s, float t, float s2, float t2, idMaterial material) { Vertex[] verts = new Vertex[4]; int[] indexes = new int[6]; /*indexes[0] = 0; * indexes[1] = 1; * indexes[2] = 2; * indexes[3] = 0; * indexes[4] = 2; * indexes[5] = 3;*/ indexes[0] = 3; indexes[1] = 0; indexes[2] = 2; indexes[3] = 2; indexes[4] = 0; indexes[5] = 1; verts[0].Position = new Vector3(x, y, 0); verts[0].TextureCoordinates = new Vector2(s, t); verts[0].Normal = new Vector3(0, 0, 1); /*verts[0].Tangents = new Vector3[] { * new Vector3(1, 0, 0), * new Vector3(0, 1, 0) * };*/ verts[1].Position = new Vector3(x + width, y, 0); verts[1].TextureCoordinates = new Vector2(s2, t); verts[1].Normal = new Vector3(0, 0, 1); /*verts[1].Tangents = new Vector3[] { * new Vector3(1, 0, 0), * new Vector3(0, 1, 0) * };*/ verts[2].Position = new Vector3(x + width, y + height, 0); verts[2].TextureCoordinates = new Vector2(s2, t2); verts[2].Normal = new Vector3(0, 0, 1); /*verts[2].Tangents = new Vector3[] { * new Vector3(1, 0, 0), * new Vector3(0, 1, 0) * };*/ verts[3].Position = new Vector3(x, y + height, 0); verts[3].TextureCoordinates = new Vector2(s, t2); verts[3].Normal = new Vector3(0, 0, 1); /*verts[3].Tangents = new Vector3[] { * new Vector3(1, 0, 0), * new Vector3(0, 1, 0) * };*/ bool ident = _matrix != Matrix.Identity; if (ident == true) { idConsole.Warning("TODO: IDENT == true"); /*verts[0].Position -= _origin; * verts[0].Position *= _matrix.Translation; * verts[0].Position += _origin; * verts[1].Position -= _origin; * verts[1].Position *= _matrix.Translation; * verts[1].Position += _origin; * verts[2].Position -= _origin; * verts[2].Position *= _matrix.Translation; * verts[2].Position += _origin; * verts[3].Position -= _origin; * verts[3].Position *= _matrix.Translation; * verts[3].Position += _origin;*/ } idE.RenderSystem.DrawStretchPicture(verts.ToArray(), indexes.ToArray(), material, ident); }
/// <summary> /// Can't be combined with init, because init happens before the renderSystem is initialized. /// </summary> public void LoadGraphics() { _charSetShader = idE.DeclManager.FindMaterial("textures/bigchars"); _whiteShader = idE.DeclManager.FindMaterial("_white"); _consoleShader = idE.DeclManager.FindMaterial("console"); }