void TriangleWidget::paintGL() { RenderWidget::paintGL(); // Setup the modelview matrix m_modelMatrix.setToIdentity(); m_modelMatrix.rotate(45,1,1,0); QVector3D eyePosition( 0.0, 0.0, 5.0 ); QVector3D targetPosition( 0.0, 0.0, 0.0 ); QVector3D upDirection( 0.0, 1.0, 0.0 ); m_viewMatrix.setToIdentity(); m_viewMatrix.lookAt( eyePosition, targetPosition, upDirection ); m_shader->bind(); m_shader->setUniformValue( "modelMatrix", m_modelMatrix ); m_shader->setUniformValue( "viewMatrix", m_viewMatrix ); m_vertexBuffer.bind(); setAttributeObject( "vertex", GL_FLOAT, 0, 4 ); m_indexBuffer.bind(); // Draw stuff glDrawElements( GL_TRIANGLES, // Type of primitive to draw 3, // The number of indices in our index buffer we wish to draw GL_UNSIGNED_INT, // The element type of the index buffer 0 ); // Offset from the start of our index buffer of where to begin m_shader->release(); }
void ColladaNode::handleLookAt(domLookat *lookat) { if(lookat == NULL) return; domNodeRef node = getDOMElementAs<domNode>(); Pnt3f eyePosition(lookat->getValue()[0],lookat->getValue()[1],lookat->getValue()[2]), lookAtPoint(lookat->getValue()[3],lookat->getValue()[4],lookat->getValue()[5]); Vec3f upDirection(lookat->getValue()[7],lookat->getValue()[8],lookat->getValue()[9]); if(getGlobal()->getOptions()->getFlattenNodeXForms()) { LookAtTransformationElementUnrecPtr LookAtElement = LookAtTransformationElement::create(); LookAtElement->setEyePosition(eyePosition); LookAtElement->setLookAtPosition(lookAtPoint); LookAtElement->setUpDirection(upDirection); setName(LookAtElement, lookat->getSid()); appendStackedXForm(LookAtElement, node); } else { TransformUnrecPtr xform = Transform::create(); NodeUnrecPtr xformN = makeNodeFor(xform); Matrix lookAtMatrix; MatrixLookAt(lookAtMatrix,eyePosition, lookAtPoint, upDirection); xform->setMatrix(lookAtMatrix); if(getGlobal()->getOptions()->getCreateNameAttachments() == true && node->getName() != NULL ) { std::string nodeName = node->getName(); if(lookat->getSid() != NULL && getGlobal()->getOptions()->getFlattenNodeXForms() == false) { nodeName.append("." ); nodeName.append(lookat->getSid()); } setName(xformN, nodeName); } appendXForm(xformN); } }
Camera::Camera(float width, float height) { m_ProjectionMatrix = (glm::mat4)glm::perspective(45.0f, (float)width/(float)height, 0.001f, 1000.0f); glm::vec3 eyePosition(0.0f, 0.0f, 0.0f); glm::vec3 lookinAtPosition(0.0f, 0.0f, -1.0f); glm::vec3 right(1.0f, 0.0f, 0.0f); glm::vec3 forward = lookinAtPosition - eyePosition; forward = glm::normalize(forward); glm::vec3 upDirection = glm::cross(right, forward); m_ViewMatrix = (glm::mat4)glm::lookAt(eyePosition, lookinAtPosition, upDirection); }
Camera::Camera(float width, float height) { m_ProjectionMatrix = (glm::mat4)glm::perspective(45.0f, (float)width/(float)height, 0.001f, 1000.0f); oldDeltaY = 0.0; glm::vec3 eyePosition(0.0f, 0.0f, 0.0f); glm::vec3 lookinAtPosition(0.0f, 0.0f, -1.0f); camera_right = glm::vec3(1.0f, 0.0f, 0.0f); camera_forward = lookinAtPosition - eyePosition; camera_forward = glm::normalize(camera_forward); glm::vec3 camera_up = glm::cross(camera_right, camera_forward); m_ViewMatrix = (glm::mat4)glm::lookAt(eyePosition, lookinAtPosition, camera_up); }
void OpenGLCamera::doFocus() { float m[16]; Vector3d up_unit(getUp()[0], getUp()[1], getUp()[2]); Vector3d eyePosition(getEyePosition()[0], getEyePosition()[1], getEyePosition()[2]); Vector3d center(getCenter()[0], getCenter()[1], getCenter()[2]); Vector3d f_unit = center - eyePosition; f_unit.Normalize(); up_unit.Normalize(); Vector3d s = CrossProduct(f_unit, up_unit); Vector3d u = CrossProduct(s, f_unit); m[0] = s[0]; m[1] = u[0]; m[2] = -f_unit[0]; m[3] = 0.f; m[4] = s[1]; m[5] = u[1]; m[6] = -f_unit[1]; m[7] = 0.f; m[8] = s[2]; m[9] = u[2]; m[10] = -f_unit[2]; m[11] = 0.f; m[12] = 0.f; m[13] = 0.f; m[14] = 0.f; m[15] = 1.f; glMultMatrixf(m); glTranslatef(-eyePosition[0], -eyePosition[1], -eyePosition[2]); }
void drawScene() { if (g_reset) { sceneObject.getMtrx().setAllValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); axisTransform = sceneObject.getMtrx(); g_ambientLight = 0xffffff; g_light1.setDefaults(); g_light2.setDefaults(); g_reset = !g_reset; } //initial position of object Matrix4x4 modelMtrx(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -5, 1); //transforming object with all required transformations modelMtrx = sceneObject.getMtrx()*modelMtrx; //creating a camera object Camera cam({ 0, 0, 0, 1 }, (sceneObject.getMshMdl().getCentroid())*modelMtrx, { 0,1,0,1 }); //pointing camera at object if (g_centerCam) { saveCamera.setAllValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); saveCamera*=cam.getViewMtrx(); g_centerCam = false; } modelMtrx *= saveCamera; //creating projection matrix and aplying it cam.setProjectionMatrix(g_fovy, g_near, g_far, (eProjectionType)g_projectionType, 1); //view to screen matrix Matrix4x4 v2sMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, g_Swidth / 2, g_Sheight / 2, 0, 1); Matrix4x4 projectionMtrx(cam.getProjectionMtrx()* v2sMatrix); //creating a mesh model and apllying all the transformations MeshModel model = sceneObject.getMshMdl(); model.transformMshMdl(modelMtrx); if (g_mesh) { model.transformMshMdl(projectionMtrx); model.drawModelEdges(); } else { Vector4 eyePosition(g_Swidth / 2, g_Sheight / 2, 0, 1); g_zBuffer.emptyBuffer(); Shader shader(g_shadingType); model.material.setAll(g_ambient, g_diffuse, g_specular, g_specularExp); shader.draw(model, g_ambientLight, g_light1, g_light2, g_zBuffer, eyePosition, projectionMtrx); g_zBuffer.drawBuffer(); } modelMtrx *= projectionMtrx; //show bounding box if (g_bbox) { BBox box2 = box; box2.transformBox(modelMtrx); box2.drawBox(); } //show normals if (g_normals) { model.drawNormals(g_normals_size); } //show coordinate systems if (g_showCrdSystem) { model.calcCentroid(); sceneObject.drawObjectCrdSystem(axisTransform, model.getCentroid(), g_Swidth / 2, g_Sheight / 2); } }
//--------------------------------------------------------------------------- void Clouds::update (void) { renderClouds = false; scrollU += frameLength * SCROLL_U_FACTOR; scrollV += frameLength * SCROLL_V_FACTOR; if (scrollU > 1.0f) scrollU -= 1.0f; if (scrollV > 1.0f) scrollV -= 1.0f; if (scrollU < -1.0f) scrollU += 1.0f; if (scrollV < -1.0f) scrollV += 1.0f; //--------------------------------------------------------------------- // If projectionAngle is less then some magic number, draw the clouds. // Otherwise, do not do anything! if (eye->active && eye->usePerspective && (eye->getProjectionAngle() < MAX_CLOUDS_ANGLE)) { //renderClouds = true; //------------------------------------------------------- // Create the cloud grid based on camera CENTER position. Stuff::Vector3D centerPosition(eye->getPosition()); //------------------------------------------------------- // Create a topLeft vertex float tLeftX = centerPosition.x + MAX_CLOUDS_SIZE; float tLeftY = centerPosition.y + MAX_CLOUDS_SIZE; //------------------------------------------------------- // Create the grid. long cloudInc = float2long(MAX_CLOUDS_SIZE * 2.0f / gridSize); float uvInc = MAX_UV_REPEAT / float(gridSize); for (long y=0;y<gridSize;y++) { for (long x=0;x<gridSize;x++) { cloudVertices[x + (y*gridSize)].vx = tLeftX - (cloudInc * x); cloudVertices[x + (y*gridSize)].vy = tLeftY - (cloudInc * y); cloudVertices[x + (y*gridSize)].pu = CLOUD_START_U + (uvInc * x); cloudVertices[x + (y*gridSize)].pv = CLOUD_START_V + (uvInc * y); } } //------------------------------------------------------- // Transform Grid long gridTotal = gridSize * gridSize; for (long i=0;i<gridTotal;i++) { //---------------------------------------------------------------------------------------- // Figure out if we are in front of camera or not. Should be faster then actual project! // Should weed out VAST overwhelming majority of vertices! bool onScreen = true; //----------------------------------------------------------------- // Find angle between lookVector of Camera and vector from camPos // to Target. If angle is less then halfFOV, object is visible. //------------------------------------------------------------------- // Then figure out if FarClipped. Should weed out a boatload more! float hazeFactor = 0.0f; Stuff::Point3D Distance; Stuff::Point3D vPosition; Stuff::Point3D eyePosition(eye->getPosition()); vPosition.x = cloudVertices[i].vx;; vPosition.y = cloudVertices[i].vy; vPosition.z = centerPosition.z; Distance.Subtract(eyePosition,vPosition); float eyeDistance = Distance.GetApproximateLength(); if (eyeDistance > Camera::MaxClipDistance) { hazeFactor = 1.0f; //onScreen = false; } else if (eyeDistance > Camera::MinHazeDistance) { hazeFactor = (eyeDistance - Camera::MinHazeDistance) * Camera::DistanceFactor; } else { hazeFactor = 0.0f; } //------------------------------------------------------------ // Calculate the HazeDWORD here if (hazeFactor != 0.0f) { float fogFactor = 1.0 - hazeFactor; DWORD distFog = float2long(fogFactor * 255.0f); cloudVertices[i].fogRGB = (distFog<<24) + (0xffffff); } else { cloudVertices[i].fogRGB = 0xffffffff; } if (onScreen) { Stuff::Vector3D Distance; Stuff::Point3D objPosition; Stuff::Point3D eyePosition(eye->getCameraOrigin()); objPosition.x = -cloudVertices[i].vx; objPosition.y = CLOUD_ALTITUDE; objPosition.z = cloudVertices[i].vy; Distance.Subtract(objPosition,eyePosition); Distance.Normalize(Distance); float cosine = Distance * eye->getLookVector(); if (cosine > eye->cosHalfFOV) onScreen = true; else onScreen = false; } else { hazeFactor = 1.0f; } Stuff::Vector3D vertex3D(cloudVertices[i].vx,cloudVertices[i].vy,(CLOUD_ALTITUDE+eye->getCameraOrigin().y)); Stuff::Vector4D screenPos; bool inView = eye->projectZ(vertex3D,screenPos); cloudVertices[i].px = screenPos.x; cloudVertices[i].py = screenPos.y; cloudVertices[i].pz = screenPos.z; cloudVertices[i].pw = screenPos.w; //------------------------------------------------------------ // Fix clip. Vertices can all be off screen and triangle // still needs to be drawn! cloudVertices[i].clipInfo = onScreen && inView; //------------------------------------------------------------ // Still need to scrollUVs here! cloudVertices[i].pu += scrollU; cloudVertices[i].pv += scrollV; } for (y=0;y<(gridSize-1);y++) { for (long x=0;x<(gridSize-1);x++) { CloudVertexPtr cloudVertex0 = &(cloudVertices[x + (y *gridSize)]); CloudVertexPtr cloudVertex1 = &(cloudVertices[(x+1) + (y *gridSize)]); CloudVertexPtr cloudVertex2 = &(cloudVertices[(x+1) + ((y+1)*gridSize)]); CloudVertexPtr cloudVertex3 = &(cloudVertices[x + ((y+1)*gridSize)]); bool clipCheck = (cloudVertex0->clipInfo || cloudVertex1->clipInfo || cloudVertex2->clipInfo); if (clipCheck && ((cloudVertex0->pz < 1.0f) && (cloudVertex0->pz > 0.0f) && (cloudVertex1->pz < 1.0f) && (cloudVertex1->pz > 0.0f) && (cloudVertex2->pz < 1.0f) && (cloudVertex2->pz > 0.0f))) { mcTextureManager->addTriangle(mcTextureNodeIndex,MC2_DRAWALPHA); } clipCheck = (cloudVertex0->clipInfo || cloudVertex2->clipInfo || cloudVertex3->clipInfo); if (clipCheck && ((cloudVertex0->pz < 1.0f) && (cloudVertex0->pz > 0.0f) && (cloudVertex2->pz < 1.0f) && (cloudVertex2->pz > 0.0f) && (cloudVertex3->pz < 1.0f) && (cloudVertex3->pz > 0.0f))) { mcTextureManager->addTriangle(mcTextureNodeIndex,MC2_DRAWALPHA); } } } } }
//--------------------------------------------------------------------- void CraterManager::render (void) { if (!useNonWeaponEffects) return; //----------------------------------------------------- // Run through all craters in list and render anything // which not clipped or an invalid_crater CraterDataPtr currCrater = craterList; for (long i=0;i<(long)maxCraters;i++,currCrater++) { if (currCrater->craterShapeId != -1) { long handleOffset = 1; float uvAdd = 0.125; if (currCrater->craterShapeId >= MAX_FOOTPRINTS) { handleOffset = 0; uvAdd = 0.50; } bool onScreen1 = eye->projectZ(currCrater->position[0],currCrater->screenPos[0]); bool onScreen2 = eye->projectZ(currCrater->position[1],currCrater->screenPos[1]); bool onScreen3 = eye->projectZ(currCrater->position[2],currCrater->screenPos[2]); bool onScreen4 = eye->projectZ(currCrater->position[3],currCrater->screenPos[3]); //-------------------------------------------------- // First, if we are using perspective, figure out // if object too far from camera. Far Clip Plane. float hazeFactor = 0.0f; if (eye->usePerspective) { Stuff::Point3D Distance; Stuff::Point3D objPosition; Stuff::Point3D eyePosition(eye->getCameraOrigin()); objPosition.x = -currCrater->position[0].x; objPosition.y = currCrater->position[0].z; objPosition.z = currCrater->position[0].y; Distance.Subtract(objPosition,eyePosition); float eyeDistance = Distance.GetApproximateLength(); if (eyeDistance > Camera::MaxClipDistance) { onScreen1 = false; onScreen2 = false; onScreen3 = false; onScreen4 = false; } else if (eyeDistance > Camera::MinHazeDistance) { hazeFactor = (eyeDistance - Camera::MinHazeDistance) * Camera::DistanceFactor; } else { hazeFactor = 0.0f; } } //---------------- // Check clipping if (onScreen1 || onScreen2 || onScreen3 || onScreen4) { DWORD lightRGB = 0xffffffff; DWORD specR = 0, specB = 0, specG = 0; unsigned char lightr = 0xff,lightg = 0xff,lightb = 0xff; lightr = eye->ambientRed; lightg = eye->ambientGreen; lightb = eye->ambientBlue; lightRGB = lightb + (lightr<<16) + (lightg << 8) + (0xff << 24); if (Terrain::terrainTextures2) { if (TerrainQuad::rainLightLevel < 1.0f) { lightr = (float)lightr * TerrainQuad::rainLightLevel; lightb = (float)lightb * TerrainQuad::rainLightLevel; lightg = (float)lightg * TerrainQuad::rainLightLevel; } if (TerrainQuad::lighteningLevel > 0x0) { specR = specG = specB = TerrainQuad::lighteningLevel; } lightRGB = lightb + (lightr<<16) + (lightg << 8) + (0xff << 24); } DWORD fogRGB = (0xff<<24) + (specR<<16) + (specG<<8) + specB; if (useFog) { DWORD fogValue = 0xff; float fogStart = eye->fogStart; float fogFull = eye->fogFull; if (currCrater->position[0].z < fogStart) { float fogFactor = fogStart - currCrater->position[0].z; if (fogFactor < 0.0) fogRGB = (0xff<<24) + (specR<<16) + (specG<<8) + specB; else { fogFactor /= (fogStart - fogFull); if (fogFactor <= 1.0) { fogFactor *= fogFactor; fogFactor = 1.0 - fogFactor; fogFactor *= 256.0; } else { fogFactor = 256.0; } unsigned char fogResult = fogFactor; fogValue = fogFactor; fogRGB = (fogResult << 24) + (specR<<16) + (specG<<8) + specB; } } else { fogRGB = (0xff<<24) + (specR<<16) + (specG<<8) + specB; } if (hazeFactor != 0.0f) { float fogFactor = 1.0 - hazeFactor; DWORD distFog = float2long(fogFactor * 255.0f); if (distFog < fogValue) fogValue = distFog; fogRGB = (fogValue << 24) + (specR << 16) + (specG << 8) + (specB); } } if (drawOldWay) { //------------------------------------ // Replace with Polygon Quad Elements gos_VERTEX gVertex[4]; gVertex[0].x = currCrater->screenPos[0].x; gVertex[0].y = currCrater->screenPos[0].y; gVertex[0].z = currCrater->screenPos[0].z; gVertex[0].rhw = currCrater->screenPos[0].w; gVertex[0].u = craterUVTable[(currCrater->craterShapeId*2)]; gVertex[0].v = craterUVTable[(currCrater->craterShapeId*2)+1]; gVertex[0].argb = lightRGB; gVertex[0].frgb = fogRGB; gVertex[1].x = currCrater->screenPos[1].x; gVertex[1].y = currCrater->screenPos[1].y; gVertex[1].z = currCrater->screenPos[1].z; gVertex[1].rhw = currCrater->screenPos[1].w; gVertex[1].u = gVertex[0].u + uvAdd; gVertex[1].v = gVertex[0].v; gVertex[1].argb = lightRGB; gVertex[1].frgb = fogRGB; gVertex[2].x = currCrater->screenPos[2].x; gVertex[2].y = currCrater->screenPos[2].y; gVertex[2].z = currCrater->screenPos[2].z; gVertex[2].rhw = currCrater->screenPos[2].w; gVertex[2].u = gVertex[1].u; gVertex[2].v = gVertex[0].v + uvAdd; gVertex[2].argb = lightRGB; gVertex[2].frgb = fogRGB; gVertex[3].x = currCrater->screenPos[3].x; gVertex[3].y = currCrater->screenPos[3].y; gVertex[3].z = currCrater->screenPos[3].z; gVertex[3].rhw = currCrater->screenPos[3].w; gVertex[3].u = gVertex[0].u; gVertex[3].v = gVertex[2].v; gVertex[3].argb = lightRGB; gVertex[3].frgb = fogRGB; TexturedPolygonQuadElement element; element.init(gVertex,craterTextureHandles[handleOffset],false,false); //----------------------------------------------------- // FOG time. Set Render state to FOG on! if (useFog) { DWORD fogColor = eye->fogColor; gos_SetRenderState( gos_State_Fog, (int)&fogColor); } else { gos_SetRenderState( gos_State_Fog, 0); } element.draw(); gos_SetRenderState( gos_State_Fog, 0); //ALWAYS SHUT FOG OFF WHEN DONE! } else { //------------------------------------ gos_VERTEX gVertex[3]; gos_VERTEX sVertex[3]; gVertex[0].x = sVertex[0].x = currCrater->screenPos[0].x; gVertex[0].y = sVertex[0].y = currCrater->screenPos[0].y; gVertex[0].z = sVertex[0].z = currCrater->screenPos[0].z; gVertex[0].rhw = sVertex[0].rhw = currCrater->screenPos[0].w; gVertex[0].u = sVertex[0].u = craterUVTable[(currCrater->craterShapeId*2)]; gVertex[0].v = sVertex[0].v = craterUVTable[(currCrater->craterShapeId*2)+1]; gVertex[0].argb = sVertex[0].argb = lightRGB; gVertex[0].frgb = sVertex[0].frgb = fogRGB; gVertex[1].x = currCrater->screenPos[1].x; gVertex[1].y = currCrater->screenPos[1].y; gVertex[1].z = currCrater->screenPos[1].z; gVertex[1].rhw = currCrater->screenPos[1].w; gVertex[1].u = gVertex[0].u + uvAdd; gVertex[1].v = gVertex[0].v; gVertex[1].argb = lightRGB; gVertex[1].frgb = fogRGB; gVertex[2].x = sVertex[1].x = currCrater->screenPos[2].x; gVertex[2].y = sVertex[1].y = currCrater->screenPos[2].y; gVertex[2].z = sVertex[1].z = currCrater->screenPos[2].z; gVertex[2].rhw = sVertex[1].rhw = currCrater->screenPos[2].w; gVertex[2].u = sVertex[1].u = gVertex[1].u; gVertex[2].v = sVertex[1].v = gVertex[0].v + uvAdd; gVertex[2].argb = sVertex[1].argb = lightRGB; gVertex[2].frgb = sVertex[1].frgb = fogRGB; sVertex[2].x = currCrater->screenPos[3].x; sVertex[2].y = currCrater->screenPos[3].y; sVertex[2].z = currCrater->screenPos[3].z; sVertex[2].rhw = currCrater->screenPos[3].w; sVertex[2].u = gVertex[0].u; sVertex[2].v = gVertex[2].v; sVertex[2].argb = lightRGB; sVertex[2].frgb = fogRGB; if (currCrater->craterShapeId > TURKINA_FOOTPRINT) //We are standard crater. { mcTextureManager->addVertices(craterTextureIndices[handleOffset],gVertex,MC2_ISCRATERS | MC2_DRAWALPHA | MC2_ISTERRAIN); mcTextureManager->addVertices(craterTextureIndices[handleOffset],sVertex,MC2_ISCRATERS | MC2_DRAWALPHA | MC2_ISTERRAIN); } else //We are a footprint { mcTextureManager->addVertices(craterTextureIndices[handleOffset],gVertex,MC2_ISCRATERS | MC2_DRAWALPHA); mcTextureManager->addVertices(craterTextureIndices[handleOffset],sVertex,MC2_ISCRATERS | MC2_DRAWALPHA); } } } } } }
Vector3F BaseView::directionToEye() const { Vector3F v = eyePosition() - m_centerOfInterest; v.normalize(); return v; }
float BaseView::perspectivity(int portWidth) const { return m_hfov * 2.f * eyePosition().distanceTo(m_centerOfInterest) / (float)portWidth; }
void PeaksAndValleys::init(int row, int column) { initMesh(row, column); //Create Effect Technique int shaderFlag = D3D10_SHADER_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG ) shaderFlag |= D3D10_SHADER_DEBUG |D3D10_SHADER_SKIP_OPTIMIZATION; #endif ID3D10Device *device = DirectEngine::getInstance()->getDevice(); ID3D10Blob *errorBlob = nullptr; int result = D3DX10CreateEffectFromFile(L"color.fx", nullptr,nullptr, "fx_4_0", shaderFlag, 0, device, nullptr, nullptr, &_effect,&errorBlob,nullptr ); if (result < 0) { if (errorBlob) { MessageBoxA(nullptr, (char*)errorBlob->GetBufferPointer(), nullptr, 0); errorBlob->Release(); } DXTrace(__FILE__, __LINE__, result, L"D3DX10CreateEffectFromFile",true); } _effectTech = _effect->GetTechniqueByName("ColorTech"); _mvpMatrixV = _effect->GetVariableByName("g_MVPMatrix")->AsMatrix(); //Create Layout D3D10_INPUT_ELEMENT_DESC inputDesc[2]; inputDesc[0].SemanticName = "POSITION"; inputDesc[0].SemanticIndex = 0; inputDesc[0].Format = DXGI_FORMAT_R32G32B32_FLOAT; inputDesc[0].InputSlot = 0; inputDesc[0].AlignedByteOffset = 0; inputDesc[0].InputSlotClass = D3D10_INPUT_PER_VERTEX_DATA; inputDesc[0].InstanceDataStepRate = 0; inputDesc[1].SemanticName = "COLOR"; inputDesc[1].SemanticIndex = 0; inputDesc[1].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; inputDesc[1].InputSlot = 0; inputDesc[1].AlignedByteOffset = sizeof(float) * 3; inputDesc[1].InputSlotClass = D3D10_INPUT_PER_VERTEX_DATA; inputDesc[1].InstanceDataStepRate = 0; // D3D10_PASS_DESC passDesc; _effectTech->GetPassByName("P0")->GetDesc(&passDesc); result = device->CreateInputLayout(inputDesc, 2, passDesc.pIAInputSignature,passDesc.IAInputSignatureSize,&_inputLayout); assert(result>=0); //Matrix D3DXMatrixIdentity(&_modelMatrix); D3DXMatrixIdentity(&_projMatrix); D3DXMatrixIdentity(&_viewMatrix); //Create Project Matrix auto &winSize = DirectEngine::getInstance()->getWinSize(); D3DXMatrixPerspectiveFovLH(&_projMatrix,M_PI/4,winSize.width/winSize.height,1.0f,400.0f); D3DXVECTOR3 eyePosition(0,80,-120); D3DXVECTOR3 targetPosition(0,0,0); D3DXVECTOR3 upperVec(0,1,0); D3DXMatrixLookAtLH(&_viewMatrix, &eyePosition, &targetPosition, &upperVec); }