亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? chasctxt.cpp

?? Windows上的MUD客戶端程序
?? CPP
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*----------------------------------------------------------------------------
                        _                              _ _       
        /\             | |                            | (_)      
       /  \   _ __   __| |_ __ ___  _ __ ___   ___  __| |_  __ _ 
      / /\ \ | '_ \ / _` | '__/ _ \| '_ ` _ \ / _ \/ _` | |/ _` |
     / ____ \| | | | (_| | | | (_) | | | | | |  __/ (_| | | (_| |
    /_/    \_\_| |_|\__,_|_|  \___/|_| |_| |_|\___|\__,_|_|\__,_|

    The contents of this file are subject to the Andromedia Public
	License Version 1.0 (the "License"); you may not use this file
	except in compliance with the License. You may obtain a copy of
	the License at http://www.andromedia.com/APL/

    Software distributed under the License is distributed on an
	"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
	implied. See the License for the specific language governing
	rights and limitations under the License.

    The Original Code is Pueblo client code, released November 4, 1998.

    The Initial Developer of the Original Code is Andromedia Incorporated.
	Portions created by Andromedia are Copyright (C) 1998 Andromedia
	Incorporated.  All Rights Reserved.

	Andromedia Incorporated                         415.365.6700
	818 Mission Street - 2nd Floor                  415.365.6701 fax
	San Francisco, CA 94103

    Contributor(s):
	--------------------------------------------------------------------------
	   Chaco team:  Dan Greening, Glenn Crocker, Jim Doubek,
	                Coyote Lussier, Pritham Shetty.

					Wrote and designed original codebase.

------------------------------------------------------------------------------

	Implementation for the ChQvAsciiText class for  Intel 3DR.

----------------------------------------------------------------------------*/

// $Header: /home/cvs/chaco/modules/client/msw/ChGraphx/ChAscTxt.cpp,v 2.19 1996/06/27 03:42:57 jimd Exp $

#include "grheader.h"

#include "CvInstnc.h"
#include <QvInfo.h>
#include <QvState.h>
#include "ChMaze.h"
#include "ChMazDep.h"
#include "CvTrnsfm.h"
#include "CvNormal.h"
#include "CvBound.h"
#include "CvMaterl.h"
#include "CvTextur.h"
#include "ChGrFont.h"

#define USE_TEXTURE_TEXT	1

/*
From the VRML 1.0 Spec
Also see: 
http://vrml.wired.com/vrml.tech/vrml10-3.html

AsciiText

This node represents strings of text characters from the ASCII coded character set. The first
string is rendered with its baseline at (0,0,0). All subsequent strings advance y by -(size *
spacing). See FontStyle for a description of the size field. The justification field determines
the placement of the strings in the x dimension. LEFT (the default) places the left edge of each
string at x=0. CENTER places the center of each string at x=0. RIGHT places the right edge of
each string at x=0. Text is rendered from left to right, top to bottom in the font set by FontStyle.
The width field defines a suggested width constraint for each string. The default is to use the
natural width of each string. Setting any value to 0 indicates the natural width should be used for
that string. 

The text is transformed by the current cumulative transformation and is drawn with the current
material and texture. 

Textures are applied to 3D text as follows. The texture origin is at the origin of the first string, as
determined by the justification. The texture is scaled equally in both S and T dimensions, with
the font height representing 1 unit. S increases to the right. The T origin can occur anywhere
along each character, depending on how that character's outline is defined. 



JUSTIFICATION

     LEFT     Align left edge of text to origin

     CENTER   Align center of text to origin

     RIGHT    Align right edge of text to origin


FILE FORMAT/DEFAULTS

     AsciiText {

          string         ""    # MFString

          spacing        1     # SFFloat

          justification  LEFT  # SFEnum

          width          0     # MFFloat

     }


*/

/* Helper class for cache */

class ChAsciiCharCache
{
	friend class ChQvAsciiTextInstance;

	protected:
		ChPolyPolygonGx3 *m_pPoly;
		unsigned int m_letter;
		float m_xAdvance, m_yAdvance;
 

	public:
		ChAsciiCharCache(ChPolyPolygonGx3 *pPoly, unsigned int letter, float	xAdvance, float yAdvance)
		{
			m_pPoly = pPoly;
			m_letter = letter;
			m_xAdvance = xAdvance;
			m_yAdvance = yAdvance;
		};
		~ChAsciiCharCache()
		{
			delete m_pPoly;
		};
};

ChQvAsciiTextInstance::ChQvAsciiTextInstance() : ChQvShapeInstance(), m_pCache(0)
{
}

ChQvAsciiTextInstance::~ChQvAsciiTextInstance()
{
	if(m_pCache)
	{
		while(!m_pCache->IsEmpty())
		{
			ChAsciiCharCache *pCharCache = m_pCache->RemoveHead();
			delete pCharCache;
		}
		delete m_pCache;
		m_pCache = 0;
	}
}



float ChQvAsciiTextInstance::GetTextWidth(HFONT hFont, int index)
{
	// return specified length if ! 0, else  string length in units
	QvAsciiText *pNode = (QvAsciiText *)m_pNode;
	#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
	// fixed width not implemented yet for 3dr
	if(pNode->width.num > index && pNode->width.values[index] > 0.0) 
	{						     // treat negative like zero
		return pNode->width.values[index];
	}
	else
	#endif
	{
		char *str = (char*)(pNode->string.values[index].getString());
		return GetTextWidth( hFont, str );
	}
}

float ChQvAsciiTextInstance::GetTextWidth(HFONT hFont,  char * text)
{
	HDC hdc = ::GetDC(NULL);
	HFONT oldFont = HFONT(::SelectObject(hdc, hFont));

	SIZE size;
	if ( !GetTextExtentPoint32(hdc, text, strlen(text), &size) )
	{  // function will fail under Win32s, use	 GetTextExtentPoint
	  	GetTextExtentPoint(hdc, text, strlen(text), &size);
	}

	::SelectObject(hdc, oldFont);
	ReleaseDC(NULL, hdc);

	if(0 == size.cy) size.cy = 1;
	return size.cx * GetFontStyle()->size.value / size.cy; // 
}

float ChQvAsciiTextInstance::GetBaselineOffset()
{
	//return the baseline offset from TL corner for the current font
	// Remember that 1.0 * spacing is -total- font height, including all spacing
	QvAsciiText *pNode = (QvAsciiText *)m_pNode;
	return (-.75 * pNode->spacing.value * GetFontStyle()->size.value);	// bogus computation :: TODO - make accurate
}

float ChQvAsciiTextInstance::GetTextHeight()
{
	QvAsciiText *pNode = (QvAsciiText *)m_pNode;
	return pNode->spacing.value * pNode->string.num * GetFontStyle()->size.value;
}

float ChQvAsciiTextInstance::GetFontLODHeight(ChRenderContext *pRC)
{
	float height;

	ChQvBounds charBounds;
	GxVec3f lower, upper, center(0.,0.,0);
	const float MAX_FONT_HEIGHT = 50;
										// arbitrary value - determines best possible appearance
	const float aMatterOfTaste = 2;		// smaller is higher quality

	lower.set(0., 0., 0.);
	upper.set(GetFontStyle()->size.value * .5, GetFontStyle()->size.value, 0.);
	charBounds.SetBounds(lower, upper);
 	charBounds.SetCenter(center);
	charBounds.SetTransform(GetTransform());

	ChRect extent = GetBoundsExtent(pRC, &charBounds);

	int maxExtent = max(extent.bottom - extent.top, extent.right - extent.left);

	height = maxExtent / aMatterOfTaste;	
	float quality = pRC->GetQuality();
	height *= quality;

	height = max(height, 2.0);
	height = min(height, MAX_FONT_HEIGHT);
	return height;
}

bool ChQvAsciiTextInstance::Construct(ChRenderContext *pRC, ChConstructionIterator *pIterator)
{
#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
	{
		ASSERT(m_frame );
		pRC->LockQv();		   // Lock tree so other threads don't kill our data
		if(!pIterator->IsOKToProceed(this))	 // This locks scene if available
		{
			pRC->UnlockQv();		   // Unlock tree 
			return 0;
		}
		if(IsConstructed())
		{
			pRC->UnlockScene();
			pRC->UnlockQv();		   // Unlock tree 
			return 1;
		}
		m_boolConstructed = true;
		
		
 		QvAsciiText *pNode = (QvAsciiText *)GetNode();

		ChNrMesh mesh = m_mesh = pRC->CreateMesh();
		ChNrFrameAddVisual(GetFrame(), mesh);
		D3DRelease(mesh);

		ChNrObjectSetAppData(mesh, (unsigned long)this);
		ChNrMeshSetPerspective(mesh,true);  
		ChNrMeshSetColorSource(mesh,ColorFromFace); 

				// flag to say something got put in here
		bool boolFilled = false;
		HFONT hFont;

		#if defined(USE_TEXTURE_TEXT)
		{
			// Use Textured text
			const int minimumAscent = 20;  // Before applying quality

			ChQvAsciiTextMaterials materialMap( this);
			pRC->AdjustTransparency(materialMap);
			ChMaterial mat = materialMap.GetMat(0);
			ChColor color = mat.GetBase();

			// Create the text dib - monochrome
			int quality = ((ChMazeWnd*)(pRC->GetWnd()))->GetSettings()->GetAsciiTextQuality();
			quality = peg(quality, 0, 2);

			float xEnlargement = 1 << quality, yEnlargement = 1 << quality;		// Blow up to get rid of jaggies
			int minAscent = minimumAscent * 1 << quality;
			float fontSize = GetFontStyle()->size.value;
			int iAscent = yEnlargement * fontSize;
			while(iAscent < minAscent)
			{
				xEnlargement++;	 yEnlargement++;
				iAscent = yEnlargement * fontSize;
			}

			hFont = CreateFont(iAscent);

		  	float xChar = 0, yChar = 0; 	  // current character position

			int fLeft = 0, fRight = 0, fTotalWidth = 0;
			for(int line = 0; line < pNode->string.num; line++)
			{
				float width = GetTextWidth(hFont, line) * xEnlargement;

				float x;
				switch(pNode->justification.value)
				{
					case QvAsciiText::LEFT:
						x = 0.;	
						break;
					case QvAsciiText::RIGHT:
						x = -width;
						break;
					case QvAsciiText::CENTER:
						x = -((width + 1) / 2);
						break;
				}
				fLeft = min(fLeft, x);
				fRight = max(fRight, x + width);
			}
			fTotalWidth = fRight - fLeft;

			int	iBmpWidth = int(fTotalWidth); 
			int	iBmpHeight = GetTextHeight() * yEnlargement;

			int w = 1, h = 1;

			while(w < iBmpWidth) w = w << 1;
			float xFactor =	float(w) / iBmpWidth;
			xEnlargement *= xFactor;
			iBmpWidth = w;

			while(h < iBmpHeight) h = h << 1;
			float yFactor =	float(h) / iBmpHeight;
			yEnlargement *= yFactor;
			iBmpHeight = h;

			fLeft *= xFactor;
			fRight *= xFactor;
			fTotalWidth *= xFactor;		  // Roughly

			float aspect = yFactor > .01 ? xFactor / yFactor : 1;

			DeleteObject(hFont);
			iAscent = yEnlargement * fontSize;
			hFont = CreateFont(iAscent, aspect);

			CDC dc;
			CBitmap bmp;
			bmp.CreateBitmap(iBmpWidth, iBmpHeight, 1, 1, 0);
			dc.CreateCompatibleDC(0);
			CBitmap *pOldBmp = dc.SelectObject(&bmp);
			CFont *pFont = CFont::FromHandle(hFont); 
			CFont *pOldFont = dc.SelectObject(pFont);

			RECT r = {0, 0, iBmpWidth, iBmpHeight};
			CBrush brush;
			brush.CreateStockObject(BLACK_BRUSH);
			dc.FillRect(&r, &brush); 
			dc.SetTextColor( RGB(0xff, 0xff, 0xff));
			dc.SetBkColor( RGB(0x0, 0x0, 0x0));
			dc.SetTextAlign( TA_TOP | TA_LEFT );

			int charWidths[256];
			dc.GetOutputCharWidth( 0, 255, charWidths );

			for(line = 0; line < pNode->string.num; line++)
			{
													// 'string' field is really QvMFString
				string text = pNode->string.values[line].getString();

				int numChars = text.GetLength();

				float width = GetTextWidth(hFont, line) * xEnlargement;
				if(!(pNode->width.num > line && pNode->width.values[line] > 0.0) )
				{
					width  /= aspect;	// very roughly
				}

				GxVec3f p;
				switch(pNode->justification.value)
				{
					case QvAsciiText::LEFT:
						 p.x() = 0.;	
						break;
					case QvAsciiText::RIGHT:
						p.x() = -width;
						break;
					case QvAsciiText::CENTER:
						p.x() = -width / 2;
						break;
				}
				p.y() = /*-GetBaselineOffset()*/ + line * pNode->spacing.value * fontSize;	// chars ought be on baseline 
				p.z() = 0;

				p.x() -= fLeft;
				p.y() *= yEnlargement;
				CSize cs = dc.GetOutputTextExtent( text, text.GetLength() );
				
				int * pWidths = 0;
				int widthWanted;
				if(pNode->width.num > line && pNode->width.values[line] > 0.0)
				{	
					 widthWanted =  int(pNode->width.values[line] * xEnlargement + .5);
				}
				else
				{
					 widthWanted =  iBmpWidth;
				} 
				pWidths = new int[numChars];
				int sum = 0;
				for(int ich = 0; ich < numChars; ich++)
				{
				 	pWidths[ich] = charWidths[text[ich]];
					sum += pWidths[ich];
				}

				float factor = float(widthWanted) / sum;	// how much to expand or contract the string

				if(pNode->width.num > line && pNode->width.values[line] > 0.0 || factor < 1.0)
				{
					int actual = 0;
					sum = 0;
					for(ich = 0; ich < numChars; ich++)
					{
						sum += pWidths[ich];
						int desired = int(factor * sum);
						pWidths[ich] = desired - actual;
						actual += pWidths[ich];
					}
				}
					//int nCharExtra = (float(widthWanted - cs.cx)) / (text.GetLength() - 1) + .5;
					//dc.SetTextCharacterExtra( nCharExtra );
				dc.ExtTextOut(int(p.x()), int(p.y()), 0, 0, text, text.GetLength(), pWidths);
				delete [] pWidths;
			}

			dc.SelectObject(pOldBmp);
			dc.SelectObject(pOldFont);

			//ChColor color(1., 0., 0.);
			#if (defined(CH_USE_RLAB))
			ChTexture *pTxt = new ChTexture(pRC, color, bmp);
			#else
			ChColor chromaKey((~(*(color.GetNative()))) && 0xffffff);
			ChTexture *pTxt = new ChTexture(pRC, color, bmp, &chromaKey);
			#endif
		
			GxVec3f verts[4], normals[2];
			verts[0].set(fLeft / xEnlargement, pNode->spacing.value * fontSize, 0);
			verts[1].set(fRight / xEnlargement, pNode->spacing.value * fontSize, 0);
			verts[2].set(fRight / xEnlargement, pNode->spacing.value * fontSize - GetTextHeight(), 0);
			verts[3].set(fLeft / xEnlargement, pNode->spacing.value * fontSize - GetTextHeight(), 0);

			// we need both front and back
			normals[0].set(0, 0, 1);
			normals[1].set(0, 0, -1);

			ChNrFaceData face_data[4 * 2 * 2 + 2 + 1];
			int ifd = 0;
			ChNrFaceArray facesAdded;
			int numFacesAdded;

			face_data[ifd++]	=	4;
			face_data[ifd++]	=	0;
			face_data[ifd++]	=	0;
			face_data[ifd++]	=	1;
			face_data[ifd++]	=	0;
			face_data[ifd++]	=	2;
			face_data[ifd++]	=	0;
			face_data[ifd++]	=	3;
			face_data[ifd++]	=	0;

			face_data[ifd++]	=	4;
			face_data[ifd++]	=	0;
			face_data[ifd++]	=	1;
			face_data[ifd++]	=	3;
			face_data[ifd++]	=	1;
			face_data[ifd++]	=	2;
			face_data[ifd++]	=	1;
			face_data[ifd++]	=	1;
			face_data[ifd++]	=	1;

			face_data[ifd++]	=	0;

			ChNrMeshAddFaces(	m_mesh, 
							4, 
							(ChNrVector*)verts, 
							2, 
							(ChNrVector*)normals, 
							face_data, 
							&numFacesAdded,
							&facesAdded);
		
			#if defined(CH_USE_D3D)
			numFacesAdded = facesAdded->GetSize();
			#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区四区的| 六月婷婷色综合| 欧美大片一区二区三区| 成人黄色片在线观看| 亚洲成人7777| ...中文天堂在线一区| 91麻豆精品国产91久久久使用方法 | 欧美性猛交xxxx乱大交退制版| 日本vs亚洲vs韩国一区三区| 亚洲裸体在线观看| 久久久久久久久久电影| 欧美日本一区二区三区四区| 成人黄色电影在线| 国内久久婷婷综合| 视频一区欧美精品| 亚洲美女偷拍久久| 国产精品久线在线观看| 精品国产91洋老外米糕| 欧美日本韩国一区二区三区视频| 成人不卡免费av| 国产一二三精品| 奇米777欧美一区二区| 亚洲综合网站在线观看| 中文字幕第一页久久| 精品理论电影在线| 91精品国产高清一区二区三区| 在线看日本不卡| 色婷婷精品久久二区二区蜜臂av| 国产黄人亚洲片| 激情综合色播激情啊| 三级在线观看一区二区| 亚洲国产精品一区二区久久恐怖片| 国产精品久久久久久久久果冻传媒| 久久影院午夜片一区| 欧美成人一区二区| 欧美一区二区视频在线观看| 欧美日韩一本到| 在线观看免费成人| 欧美影院一区二区三区| 在线区一区二视频| 日本二三区不卡| 欧美视频自拍偷拍| 在线观看www91| 欧美亚洲另类激情小说| 在线中文字幕不卡| 欧美日韩国产一二三| 欧美日韩国产免费一区二区| 欧美日本一区二区三区| 欧美一区二区不卡视频| 欧美一区二区播放| 久久综合五月天婷婷伊人| 久久这里只有精品首页| 26uuu成人网一区二区三区| 精品福利视频一区二区三区| 久久亚区不卡日本| 国产亚洲综合在线| 国产精品久久免费看| 亚洲精品免费看| 香蕉久久夜色精品国产使用方法| 天天影视涩香欲综合网| 精彩视频一区二区| 成人午夜又粗又硬又大| 91久久精品国产91性色tv| 欧美性色综合网| 日韩欧美一二三四区| 国产日韩三级在线| 亚洲欧美日韩在线| 全国精品久久少妇| 成人午夜av电影| 欧美午夜精品一区二区三区| 欧美一区二区三区四区在线观看| 久久久久久9999| 亚洲精品视频免费观看| 石原莉奈在线亚洲二区| 国产成人综合网站| 在线日韩av片| 精品理论电影在线观看 | 日本高清不卡视频| 欧美一区二区黄| 亚洲国产精品激情在线观看| 一区二区在线看| 久久精品国产精品青草| www.99精品| 欧美一区午夜精品| 国产精品亲子伦对白| 婷婷激情综合网| 国产成人午夜精品5599| 精品视频1区2区| 国产欧美日韩中文久久| 亚洲国产精品天堂| 懂色av噜噜一区二区三区av| 欧美日韩在线精品一区二区三区激情| 久久久影院官网| 亚欧色一区w666天堂| 国产成人av影院| 欧美日韩国产另类不卡| 国产精品毛片大码女人| 美日韩一区二区| 色哟哟一区二区在线观看| 欧美精品一区二区蜜臀亚洲| 亚洲在线中文字幕| 成人久久久精品乱码一区二区三区 | 欧美日韩视频第一区| 国产午夜精品一区二区三区视频 | 久久亚洲精品小早川怜子| 亚洲一区二区精品久久av| 福利一区在线观看| 日韩三级伦理片妻子的秘密按摩| 综合久久久久久| 国产激情偷乱视频一区二区三区| 9191国产精品| 夜夜嗨av一区二区三区网页| 成人一区二区三区视频 | 欧美日本韩国一区二区三区视频 | 99久久免费国产| 26uuu成人网一区二区三区| 亚洲r级在线视频| 91丨porny丨首页| 久久久777精品电影网影网| 奇米色777欧美一区二区| 欧美另类久久久品| 一区二区三区国产| youjizz久久| 欧美激情一区二区三区蜜桃视频| 久久精品国产亚洲一区二区三区| 欧美性大战久久久久久久| 亚洲精品你懂的| 99热精品一区二区| 国产精品少妇自拍| 丰满少妇在线播放bd日韩电影| 日韩欧美国产综合一区 | 亚洲国产aⅴ天堂久久| 在线精品视频一区二区| 亚洲欧美日韩国产另类专区| 成人福利视频网站| 一色桃子久久精品亚洲| 91丨porny丨国产入口| 亚洲人成精品久久久久| 成人18视频在线播放| 国产精品白丝在线| 91丝袜美腿高跟国产极品老师| 亚洲色图第一区| 色婷婷精品久久二区二区蜜臂av| 亚洲色图色小说| 91久久精品网| 亚洲va欧美va人人爽午夜 | 精品成人在线观看| 国产麻豆精品在线观看| 日本一区二区三级电影在线观看 | 一区二区视频在线| 欧美色爱综合网| 午夜欧美2019年伦理| 欧美一级xxx| 狠狠色综合日日| 国产日韩影视精品| 91美女在线视频| 亚洲与欧洲av电影| 日韩欧美一区电影| 国产乱码精品一区二区三区av | 粉嫩久久99精品久久久久久夜| 国产精品福利一区| 在线观看国产日韩| 日本色综合中文字幕| 2014亚洲片线观看视频免费| 成人网在线播放| 亚洲一区二区综合| 日韩视频一区二区三区在线播放| 国产一区啦啦啦在线观看| 国产精品免费免费| 欧美写真视频网站| 国产一区在线不卡| 亚洲欧美欧美一区二区三区| 8x福利精品第一导航| 国产99久久久国产精品潘金| 亚洲在线成人精品| 久久―日本道色综合久久| 色婷婷国产精品久久包臀| 日韩高清不卡在线| 国产精品色婷婷| 欧美日韩三级视频| 国产盗摄视频一区二区三区| 综合分类小说区另类春色亚洲小说欧美 | 亚洲乱码日产精品bd| 精品日韩在线一区| 在线精品视频免费观看| 国产一区二区久久| 性欧美疯狂xxxxbbbb| 国产亚洲欧美日韩日本| 欧美日韩一本到| 成人黄色综合网站| 久久国产精品72免费观看| 亚洲精品国产精品乱码不99| 欧美大片国产精品| 精品视频一区 二区 三区| 成人h精品动漫一区二区三区| 午夜一区二区三区在线观看| 中文字幕第一区综合| 日韩女优毛片在线| 欧美视频日韩视频在线观看| 成人av资源在线|