本文整理汇总了C++中Color4函数的典型用法代码示例。如果您正苦于以下问题:C++ Color4函数的具体用法?C++ Color4怎么用?C++ Color4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Color4函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadExr
/*! load an EXR file from disk */
Ref<Image> loadExr(const FileName& filename)
{
Imf::RgbaInputFile file (filename.c_str());
Imath::Box2i dw = file.dataWindow();
ssize_t width = dw.max.x - dw.min.x + 1;
ssize_t height = dw.max.y - dw.min.y + 1;
Imf::Array2D<Imf::Rgba> pixels(height, width);
file.setFrameBuffer (&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
file.readPixels (dw.min.y, dw.max.y);
Ref<Image> img = new Image3f(width,height,filename);
if (file.lineOrder() == Imf::INCREASING_Y) {
for (ssize_t y=0; y<height; y++) {
for (ssize_t x=0; x<width; x++) {
Imf::Rgba c = pixels[y][x];
img->set(x,y,Color4(c.r,c.g,c.b,c.a));
}
}
}
else {
for (ssize_t y=0; y<height; y++) {
for (ssize_t x=0; x<width; x++) {
Imf::Rgba c = pixels[y][x];
img->set(x,height-y-1,Color4(c.r,c.g,c.b,c.a));
}
}
}
return img;
}
示例2: SetUpdateActive
void ShellBall::Refresh(const Vector3& StartPos, const Vector3& JumpVec, bool IsEnemyBall){
SetUpdateActive(true);
SetDrawActive(true);
m_StartPos = StartPos;
m_JumpVec = JumpVec;
m_InStartTime = 0;
m_IsEnemyBall = IsEnemyBall;
//Transform取得
auto Ptr = GetComponent<Transform>();
Ptr->SetScale(m_NowScale);
Ptr->SetPosition(m_StartPos);
//描画コンポーネント
auto PtrDraw = GetComponent<PNTStaticDraw>();
if (m_IsEnemyBall){
PtrDraw->SetDiffuse(Color4(1.0f, 1.0f, 0, 1.0f));
}
else{
PtrDraw->SetDiffuse(Color4(0.0f, 1.0f, 0, 1.0f));
}
//衝突判定を呼び出す
auto PtrCollision = GetComponent<CollisionSphere>();
//衝突は無効にしておく
PtrCollision->SetUpdateActive(false);
//重力を取り出す
auto PtrGravity = GetComponent<Gravity>();
//ジャンプスタート
PtrGravity->StartJump(m_JumpVec);
//今のステートをFiringStateに設定
m_StateMachine->SetCurrentState(FiringState::Instance());
//FiringStateの初期化実行を行う
m_StateMachine->GetCurrentState()->Enter(GetThis<ShellBall>());
}
示例3: glPushMatrix
void SaveGameMenu::Draw2D()
{
camera2D.Clear();
camera2D.Begin();
int a = 0;
for(list<CampaignProgress>::iterator it = highlightedSave; it != savesList.end(); it++)
{
glPushMatrix();
glTranslatef(0, a*150, 0);
saveBackground.Render();
if(highlightedSave == it)
font->Render(((CampaignProgress)*it).currentLevel, Color4(1,0,0,1), Vector2(engine->getScreenWidth()/2-340, 15), 1.0);
else
font->Render(((CampaignProgress)*it).currentLevel, Color4(1,1,1,1), Vector2(engine->getScreenWidth()/2-340, 15), 1.0);
glPopMatrix();
a++;
}
playButton.Render();
backButton.Render();
camera2D.End();
};
示例4: Color4
GMaterial::GMaterial()
{
m_Ambient = Color4(0.1, 0.1, 0.1, 1.0);
m_Diffuse = Color4(0.8, 0.8, 0.8, 1.0);
m_Specular = Color4(0.0, 0.0, 0.0, 1.0);
m_Emission = Color4(0.0, 0.0, 0.0, 1.0);
m_Shininess = 10.f;
}
示例5: Color4
GLight::GLight()
{
m_LightID = GL_LIGHT0;
m_Ambient = Color4( 0.02, 0.02, 0.02, 1.0 );
m_Diffuse = Color4( .8, .8, .8, 1.0 );
m_Specular = Color4( .8, .8, .9, 1.0 );
m_Position = Float4( 100.0, 100.0, 100.0, 1.0 );
}
示例6: Color4
Void LandscapeRegion::OnRegionUpdate( UInt iRegionX, UInt iRegionY )
{
// Update region
m_vOrigin = m_pParentLandscape->GetOrigin();
m_vSize = m_pParentLandscape->GetRegionSize();
m_vOrigin.X += ( m_vSize.X * (Scalar)iRegionX );
m_vOrigin.Y += ( m_vSize.Y * (Scalar)iRegionY );
// Update mesh
//m_arrHeightField = m_pLandscapeMesh->UpdateGeometryBegin( &m_iSampleCountX, &m_iSampleCountY );
UInt iMinX, iMinY, iMaxX, iMaxY;
m_pParentLandscape->GetMinEyeRegion( &iMinX, &iMinY );
m_pParentLandscape->GetMaxEyeRegion( &iMaxX, &iMaxY );
Color4 fColor = Color4( 0.0f, 0.5f, 0.0f, 1.0f );
if ( iRegionX < iMinX || iRegionY < iMinY || iRegionX > iMaxX || iRegionY > iMaxY )
fColor = Color4( 0.5f, 0.0f, 0.0f, 1.0f );
UInt iVertexSize = m_pLandscapeMesh->GetVertexSize();
UInt iVertexCount = m_pLandscapeMesh->GetVertexCount();
UInt iOffset, iSize;
m_pLandscapeMesh->GetIL()->GetFieldRange( &iOffset, &iSize, GPUINPUTFIELD_SEMANTIC_COLOR, 0 );
Byte * arrColors = m_pLandscapeMesh->GetVB()->GetData() + iOffset;
Color4 * pColor;
for( UInt i = 0; i < iVertexCount; ++i ) {
pColor = (Color4*)arrColors;
*pColor = fColor;
arrColors += iVertexSize;
}
for( UInt iY = 0; iY < m_iSampleCountY; ++iY ) {
for( UInt iX = 0; iX < m_iSampleCountX; ++iX ) {
m_arrHeightField[(iY * m_iSampleCountX) + iX] = 0.0f;
}
}
m_fMinHeight = -SHAPE_MARGIN;
m_fMaxHeight = +SHAPE_MARGIN;
m_pLandscapeMesh->UpdateGeometryEnd( m_vOrigin, m_vSize, m_fMinHeight, m_fMaxHeight, NULL );
// Update cost field
for( UInt iY = 0; iY < m_iGridHeight; ++iY ) {
for( UInt iX = 0; iX < m_iGridWidth; ++iX ) {
UInt iIndex = ( (iY * (m_iGridWidth << 1)) + (iX << 1) );
m_arrCostGrid[iIndex] = 1.0f;
m_arrCostGrid[iIndex + 1] = 1.0f;
}
}
// Update path-finding data
_PathFindingGraph_Update();
}
示例7: RedColorMotion
//色変更
void SeekObject::RedColorMotion(){
auto PtrDraw = AddComponent<BasicPNTDraw>();
if (m_IsRed){
PtrDraw->SetDiffuse(Color4(0.7f, 0.7f, 0.7f, 1.0f));
m_IsRed = false;
}
else{
PtrDraw->SetDiffuse(Color4(1.0f, 0, 0, 1.0f));
m_IsRed = true;
}
}
示例8: Color4
//初期化
void NumberSprite::OnCreate(){
auto PtrTransform = AddComponent<Transform>();
PtrTransform->SetPosition(m_StartPos);
PtrTransform->SetScale(1.0f, 1.0f, 1.0f);
PtrTransform->SetRotation(0.0f, 0.0f, 0.0f);
//スプライトをつける
auto PtrSprite = AddComponent<PCTSpriteDraw>(Vector2(128.0f, 128.0f), Color4(1.0f, 1.0f, 1.0f, 1.0f));
PtrSprite->SetTextureResource(L"NUMBER_TX");
//透明処理
SetAlphaActive(true);
//左上原点
PtrSprite->SetSpriteCoordinate(SpriteCoordinate::m_LeftTopZeroPlusDownY);
//スプライトの中のメッシュからバックアップの取得
auto& SpVertexVec = PtrSprite->GetMeshResource()->GetBackupVerteces<VertexPositionColorTexture>();
//各数字ごとにUV値を含む頂点データを配列化しておく
for (size_t i = 0; i < 10; i++){
float from = ((float)i) / 10.0f;
float to = from + (1.0f / 10.0f);
vector<VertexPositionColorTexture> NumVirtex =
{
//左上頂点
VertexPositionColorTexture(
SpVertexVec[0].position,
Color4(1.0f, 1.0f, 1.0f, 1.0f),
Vector2(from, 0)
),
//右上頂点
VertexPositionColorTexture(
SpVertexVec[1].position,
Color4(1.0f, 1.0f, 1.0f, 1.0f),
Vector2(to, 0)
),
//左下頂点
VertexPositionColorTexture(
SpVertexVec[2].position,
Color4(1.0f, 1.0f, 1.0f, 1.0f),
Vector2(from, 1.0f)
),
//右下頂点
VertexPositionColorTexture(
SpVertexVec[3].position,
Color4(1.0f, 1.0f, 1.0f, 1.0f),
Vector2(to, 1.0f)
),
};
m_NumberVertexVec.push_back(NumVirtex);
}
}
示例9: GetStage
//初期化
void ShellBall::Create(){
//Transformだけは追加しなくても取得できる
auto Ptr = GetComponent<Transform>();
Ptr->SetScale(m_NowScale);
Ptr->SetRotation(0, 0, 0.0f);
Ptr->SetPosition(m_StartPos);
//衝突判定をつける
auto PtrCollision = AddComponent<CollisionSphere>();
//衝突は無効にしておく
PtrCollision->SetUpdateActive(false);
//砲弾のグループを得る
auto Group = GetStage()->GetSharedObjectGroup(L"ShellBallGroup");
//砲弾同士は衝突しないようにしておく
PtrCollision->SetExcludeCollisionGroup(Group);
//重力をつける
auto PtrGravity = AddComponent<Gravity>();
//最下地点
PtrGravity->SetBaseY(0.125f);
//ジャンプスタート
PtrGravity->StartJump(m_JumpVec);
//影の作成
auto ShadowPtr = AddComponent<Shadowmap>();
//影の形状
ShadowPtr->SetMeshResource(L"DEFAULT_SPHERE");
//描画コンポーネント
auto PtrDraw = AddComponent<BasicPNTDraw>();
//メッシュの登録
PtrDraw->SetMeshResource(L"DEFAULT_SPHERE");
if (m_IsEnemyBall){
PtrDraw->SetDiffuse(Color4(1.0f, 1.0f, 0, 1.0f));
}
else{
PtrDraw->SetDiffuse(Color4(0.0f, 1.0f, 0, 1.0f));
}
//ステートマシンの構築
m_StateMachine = make_shared< StateMachine<ShellBall> >(GetThis<ShellBall>());
//最初のステートをFiringStateに設定
m_StateMachine->SetCurrentState(FiringState::Instance());
//FiringStateの初期化実行を行う
m_StateMachine->GetCurrentState()->Enter(GetThis<ShellBall>());
}
示例10: Vector2
Rect2D App::drawPopup(const char* title) {
int w = renderDevice->width();
int h = renderDevice->height();
// Drop shadow
renderDevice->pushState();
renderDevice->setBlendFunc(RenderDevice::BLEND_SRC_ALPHA, RenderDevice::BLEND_ONE_MINUS_SRC_ALPHA);
Rect2D rect = Rect2D::xywh(w/2 - 20, h/2 - 20, w/2, h/2);
Draw::rect2D(rect + Vector2(5, 5), renderDevice, Color4(0, 0, 0, 0.15f));
renderDevice->popState();
// White box
Draw::rect2D(rect, renderDevice, Color3::white());
Draw::rect2DBorder(rect, renderDevice, Color3::black());
// The close box
Draw::rect2DBorder(Rect2D::xywh(rect.x1() - 16, rect.y0(), 16, 16), renderDevice, Color3::black());
renderDevice->setColor(Color3::black());
renderDevice->beginPrimitive(PrimitiveType::LINES);
renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 2));
renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 14));
renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 2));
renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 14));
renderDevice->endPrimitive();
float s = w * 0.013;
titleFont->draw2D(renderDevice, title, Vector2(rect.x0() + 4, rect.y0()), s * 1.5, Color3::black(), Color4::clear(), GFont::XALIGN_LEFT, GFont::YALIGN_TOP);
return rect;
}
示例11: Vector3
//爆発の開始
void ShellBall::ExplodeStartMotion(){
//Transform取得
auto Ptr = GetComponent<Transform>();
m_NowScale = Vector3(5.0f, 5.0f, 5.0f);
Ptr->SetScale(m_NowScale);
//描画コンポーネント
auto PtrDraw = GetComponent<PNTStaticDraw>();
//爆発中の色
if (m_IsEnemyBall){
PtrDraw->SetDiffuse(Color4(1.0f, 0.0f, 0, 1.0f));
}
else{
PtrDraw->SetDiffuse(Color4(0.0f, 0.0f, 1.0f, 1.0f));
}
}
示例12:
void
ViewApp::onGraphics (RenderDevice* rd, Array<PosedModelRef> &posed3D, Array<PosedModel2DRef> &posed2D)
{
//das das
rd->setProjectionAndCameraMatrix (defaultCamera);
rd->setAmbientLightColor (Color4 (Color3::white ()));
rd->setColorClearValue (Color3::black ());
rd->clear ();
rd->enableLighting ();
GLight light = GLight::directional (defaultController.pointer ()->position () + defaultController.pointer ()->lookVector ()*2, Color3::white ());
rd->setLight (0, light);
/// dasdas da
for(IndexVarMap::iterator iter = iMap.begin (); iter != iMap.end (); ++iter)
{
G3D::Array<int>& index = iter->second.first;
VAR& var = iter->second.second;
rd->setColor (Color3::red ());
rd->beginIndexedPrimitives ();
rd->setVertexArray (var);
rd->sendIndices (RenderDevice::LINES, index);
rd->endIndexedPrimitives ();
}
rd->disableLighting ();
PosedModel2D::sortAndRender (rd, posed2D);
}
示例13: if
Texture::Encoding::Encoding(const Any& a) {
*this = Encoding();
if (a.type() == Any::STRING) {
format = ImageFormat::fromString(a);
} else if (a.nameBeginsWith("Color4")) {
readMultiplyFirst = a;
}
else if (anyNameIsColor3Variant(a)) {
readMultiplyFirst = Color4(Color3(a), 1.0f);
} else if (a.type() == Any::NUMBER) {
readMultiplyFirst = Color4::one() * float(a.number());
} else {
AnyTableReader r(a);
r.getIfPresent("frame", frame);
r.getIfPresent("readMultiplyFirst", readMultiplyFirst);
r.getIfPresent("readAddSecond", readAddSecond);
String fmt;
if (r.getIfPresent("format", fmt)) {
format = ImageFormat::fromString(fmt);
}
}
}
示例14: transformationProjectionMatrixUniform
template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): transformationProjectionMatrixUniform(0), colorUniform(1), _flags(flags) {
#ifdef MAGNUM_BUILD_STATIC
/* Import resources on static build, if not already */
if(!Utility::Resource::hasGroup("MagnumShaders"))
importShaderResources();
#endif
Utility::Resource rs("MagnumShaders");
#ifndef MAGNUM_TARGET_GLES
const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210});
#else
const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200});
#endif
Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex);
Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment);
vert.addSource(flags & Flag::Textured ? "#define TEXTURED\n" : "")
.addSource(rs.get("generic.glsl"))
.addSource(rs.get(vertexShaderName<dimensions>()));
frag.addSource(flags & Flag::Textured ? "#define TEXTURED\n" : "")
.addSource(rs.get("Flat.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))
#else
if(!Context::current().isVersionSupported(Version::GLES300))
#endif
{
bindAttributeLocation(Position::Location, "position");
if(flags & Flag::Textured) bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates");
}
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
colorUniform = uniformLocation("color");
}
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version))
#endif
{
if(flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureLayer);
}
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
/* Default to fully opaque white so we can see the texture */
if(flags & Flag::Textured) setColor(Color4(1.0f));
#endif
}
示例15: readFloat32
Color4 BinaryInput::readColor4() {
float r = readFloat32();
float g = readFloat32();
float b = readFloat32();
float a = readFloat32();
return Color4(r, g, b, a);
}