/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="xScale"></param> /// <param name="yScale"></param> /// <param name="color"></param> /// <param name="texcoordIndexU"></param> /// <param name="texcoordsIndexV"></param> public void CreateBillboard(Vector3 position, float xScale, float yScale, ColorEx color, short texcoordIndexU, short texcoordsIndexV) { if (mRenderMethod == BillboardMethod.Accelerated) { StaticBillboard bb = new StaticBillboard(); bb.Position = position; bb.XScale = xScale; bb.YScale = yScale; bb.TextCoordIndexU = texcoordIndexU; bb.TextCoordIndexV = texcoordsIndexV; uint packedColor = (uint)Root.Singleton.RenderSystem.ConvertColor(color); bb.Color = packedColor; mBillboardBuffer.Add(bb); } else { Billboard bb = mFallbackSet.CreateBillboard(position); bb.SetDimensions(xScale, yScale); bb.TexcoordRect = new RectangleF( texcoordIndexU * mUFactor, texcoordsIndexV * mVFactor, (texcoordIndexU + 1) * mUFactor, (texcoordsIndexV + 1) * mVFactor); bb.Color = color; } }
public void createScene() { Mogre.Vector3 vectLightPos = new Mogre.Vector3(75, 75, 75); m_pSceneMgr.CreateLight("Light").Position = vectLightPos;//(75, 75, 75); DotSceneLoader pDotSceneLoader = new DotSceneLoader(); pDotSceneLoader.ParseDotScene("CubeScene.xml", "General", m_pSceneMgr, m_pSceneMgr.RootSceneNode); pDotSceneLoader = null; m_pSceneMgr.GetEntity("Cube01").QueryFlags = 1 << 1; m_pSceneMgr.GetEntity("Cube02").QueryFlags = 1 << 1; //(CUBE_MASK); m_pSceneMgr.GetEntity("Cube03").QueryFlags = 1 << 1; //(CUBE_MASK); m_pOgreHeadEntity = m_pSceneMgr.CreateEntity("Cube", "ogrehead.mesh"); m_pOgreHeadEntity.QueryFlags = 1 << 0; m_pOgreHeadNode = m_pSceneMgr.RootSceneNode.CreateChildSceneNode("CubeNode"); m_pOgreHeadNode.AttachObject(m_pOgreHeadEntity); Mogre.Vector3 vectOgreHeadNodePos = new Mogre.Vector3(0, 0, -25); m_pOgreHeadNode.Position = vectOgreHeadNodePos;// (Vector3(0, 0, -25)); m_pOgreHeadMat = m_pOgreHeadEntity.GetSubEntity(1).GetMaterial(); m_pOgreHeadMatHigh = m_pOgreHeadMat.Clone("OgreHeadMatHigh"); ColourValue cvAmbinet = new Mogre.ColourValue(1, 0, 0); m_pOgreHeadMatHigh.GetTechnique(0).GetPass(0).Ambient = cvAmbinet; ColourValue cvDiffuse = new Mogre.ColourValue(1, 0, 0, 0); m_pOgreHeadMatHigh.GetTechnique(0).GetPass(0).Diffuse = cvDiffuse; physxScene.Simulate(0); }
/// <summary> /// /// </summary> /// <param name="ent"></param> /// <param name="position"></param> /// <param name="rotation"></param> /// <param name="scale"></param> /// <param name="color"></param> public override void AddEntity(Entity entity, Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color) { SceneNode node = mRootNode.CreateChildSceneNode(); node.Position = position; mNodeList.Add(node); Entity ent = entity.Clone(GetUniqueID()); ent.CastShadows = false; ent.RenderQueueGroup = entity.RenderQueueGroup; node.AttachObject(ent); }
/// <summary> /// /// </summary> /// <param name="ent"></param> /// <param name="position"></param> /// <param name="rotation"></param> /// <param name="scale"></param> /// <param name="color"></param> public override void AddEntity(Entity ent, Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color) { mBatch.AddEntity(ent, position, rotation, scale, color); }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="xScale"></param> /// <param name="yScale"></param> /// <param name="color"></param> /// <param name="texcoordIndexU"></param> public void CreateBillboard(Vector3 position, float xScale, float yScale, ColorEx color, short texcoordIndexU) { CreateBillboard(position, xScale, yScale, color, texcoordIndexU, 0); }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="xScale"></param> /// <param name="yScale"></param> /// <param name="color"></param> public void CreateBillboard(Vector3 position, float xScale, float yScale, ColorEx color) { CreateBillboard(position, xScale, yScale, color, 0, 0); }
/// <summary> /// /// </summary> /// <param name="ent"></param> /// <param name="position"></param> /// <param name="rotation"></param> protected void AddEntity(Entity ent, Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color) { mGeomPage.AddEntity(ent, position, rotation, scale, color); mGeomPage.AddEntityToBoundingBox(ent, position, rotation, scale); }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="rotation"></param> /// <param name="scale"></param> /// <param name="color"></param> public void AddBillboard(Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color) { Vector3 zVector = rotation * Vector3.UnitZ; float degrees = (float)new Degree((Real)MogreLibMath.Utility.ATan2(zVector.x, zVector.z)); if (degrees < 0) { degrees += 360; } int n = (int)(ImpostorTexture.ImpostorYawAngles * (degrees / 360.0f) + 0.5f); short texCoordIndx = (short)((ImpostorTexture.ImpostorYawAngles - n) % ImpostorTexture.ImpostorYawAngles); mBBSet.CreateBillboard(position + (rotation * mEntityBBCenter) * scale, mTex.mEntityDiameter * 0.5f * (scale.x + scale.z), mTex.mEntityDiameter * scale.y, color, texCoordIndx); }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="rotation"></param> /// <param name="scale"></param> /// <param name="color"></param> public void AddBillboard(Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color) { Vector3 zVector = rotation * Vector3.UnitZ; float degrees = (float)new Degree((Real)MogreLibMath.Utility.ATan2(zVector.x, zVector.z)); if (degrees < 0) degrees += 360; int n = (int)(ImpostorTexture.ImpostorYawAngles * (degrees / 360.0f) + 0.5f); short texCoordIndx = (short)((ImpostorTexture.ImpostorYawAngles - n) % ImpostorTexture.ImpostorYawAngles); mBBSet.CreateBillboard(position + (rotation * mEntityBBCenter) * scale, mTex.mEntityDiameter * 0.5f * (scale.x + scale.z), mTex.mEntityDiameter * scale.y, color, texCoordIndx); }
/// <summary> /// /// </summary> /// <param name="ent"></param> /// <param name="position"></param> /// <param name="rotation"></param> /// <param name="scale"></param> /// <param name="color"></param> public override void AddEntity(Entity ent, Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color) { //Get the impostor batch that this impostor will be added to ImpostorBatch iBatch = ImpostorBatch.GetBatch(this, ent); //Then add the impostor to the batch iBatch.AddBillboard(position, rotation, scale, color); //Add the Y position to the center.y value (to be averaged later) mCenter.y += position.y + ent.BoundingBox.Center.y * scale.y; ++mAveCounter; }
public override void ProcessParameters(Mogre.NameValuePairList parameters) { Mogre.NameValuePairList.Iterator ni; if ((ni = parameters.Find("Name")) != parameters.End()) this.name = ni.Value; if ((ni = parameters.Find("Dimensions")) != parameters.End()) this.dimensions = MogreX.StringConverter.ParseVector4(ni.Value); if ((ni = parameters.Find("Skies")) != parameters.End()) this.skies = Mogre.StringConverter.ParseBool(ni.Value); if ((ni = parameters.Find("Shadows")) != parameters.End()) this.shadows = Mogre.StringConverter.ParseBool(ni.Value); if ((ni = parameters.Find("Overlays")) != parameters.End()) this.overlays = Mogre.StringConverter.ParseBool(ni.Value); if ((ni = parameters.Find("CamPosition")) != parameters.End()) this.camPosition = Mogre.StringConverter.ParseVector3(ni.Value); if ((ni = parameters.Find("CamOrientation")) != parameters.End()) this.camOrientation = Mogre.StringConverter.ParseQuaternion(ni.Value); if ((ni = parameters.Find("CamClipDistance")) != parameters.End()) this.camClipDistance = MogreX.StringConverter.ParseVector2(ni.Value); if ((ni = parameters.Find("CamPolyMode")) != parameters.End()) { this.camPolyMode = (Mogre.PolygonMode)Mogre.StringConverter.ParseInt(ni.Value); OnPropertyChanged("CamPolyMode"); } if ((ni = parameters.Find("CamFOV")) != parameters.End()) this.camFOV = Mogre.StringConverter.ParseReal(ni.Value); if ((ni = parameters.Find("Colour")) != parameters.End()) this.colour = Mogre.StringConverter.ParseColourValue(ni.Value); this.compositorStorage.Clear(); for (int cx = 0; cx < 100; ++cx) { string searchstr = "Compositor" + Mogre.StringConverter.ToString(cx); if ((ni = parameters.Find(searchstr + "Name")) != parameters.End()) { CompositorPush compData = new CompositorPush(); compData.Name = ni.Value; ni = parameters.Find(searchstr + "Enabled"); compData.Enabled = Mogre.StringConverter.ParseBool(ni.Value); this.compositorStorage.Add(compData); } else break; } }
/// <summary> /// /// </summary> /// <param name="ent"></param> /// <param name="position"></param> /// <param name="rotation"></param> public virtual void AddEntity(Entity ent, Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="ent"></param> /// <param name="position"></param> /// <param name="orientation"></param> /// <param name="scale"></param> /// <param name="color"></param> public void AddEntity(Entity ent, Vector3 position, Quaternion orientation, Vector3 scale, ColorEx color) { Mesh mesh = ent.Mesh; if (mesh.SharedVertexData != null) throw new Exception("Shared vertex data not allowed"); //For each subentity for (int i = 0; i < ent.SubEntityCount; i++) { //get the subentity SubEntity subEntity = ent.GetSubEntity(i); SubMesh subMesh = subEntity.SubMesh; //Generate a format string that uniquely identifies this material & vertex/index format if (subMesh.vertexData == null) throw new Exception("Submesh vertex data not found!"); string formatStr = GetFormatString(subEntity); //If a batch using an identical format exists... SubBatch batch = null; if (!mSubBatches.TryGetValue(formatStr, out batch)) { batch = new SubBatch(this, subEntity); mSubBatches.Add(formatStr, batch); } //Now add the submesh to the compatible batch batch.AddSubEntity(subEntity, position, orientation, scale, color); }//end for //Update bounding box Matrix4 mat = Matrix4.FromMatrix3(orientation.ToRotationMatrix()); mat.Scale = scale; AxisAlignedBox entBounds = ent.BoundingBox; entBounds.Transform(mat); if (mBoundsUndefinded) { mBounds.Minimum = entBounds.Minimum + position; mBounds.Maximum = entBounds.Maximum + position; mBoundsUndefinded = false; } else { Vector3 min = mBounds.Minimum; Vector3 max = mBounds.Maximum; min.Floor(entBounds.Minimum + position); max.Ceil(entBounds.Maximum + position); mBounds.Minimum = min; mBounds.Maximum = max; } }
/// <summary> /// /// </summary> /// <param name="ent"></param> /// <param name="position"></param> /// <param name="orientation"></param> /// <param name="scale"></param> /// <param name="color"></param> public void AddSubEntity(SubEntity ent, Vector3 position, Quaternion orientation, Vector3 scale, ColorEx color) { Debug.Assert(!mBuild); //Add this submesh to the queue QueuedMesh newMesh = new QueuedMesh(); newMesh.Mesh = ent.SubMesh; newMesh.Postion = position; newMesh.Orientation = orientation; newMesh.Scale = scale; newMesh.Color = color; if (newMesh.Color != ColorEx.White) { mRequireVertexColors = true; //VertexElementType format = Root.Singleton.RenderSystem.Colo throw new NotSupportedException("Please use ColorEx.White for now!"); } mMeshQueue.Add(newMesh); //Increment the vertex/index count so the buffers will have room for this mesh vertexData.vertexCount += ent.SubMesh.vertexData.vertexCount; indexData.indexCount += ent.SubMesh.indexData.indexCount; }
public override void ProcessParameters(Mogre.NameValuePairList parameters) { Mogre.NameValuePairList.Iterator ni; if ((ni = parameters.Find("Name")) != parameters.End()) { this.name = ni.Value; } if ((ni = parameters.Find("Dimensions")) != parameters.End()) { this.dimensions = MogreX.StringConverter.ParseVector4(ni.Value); } if ((ni = parameters.Find("Skies")) != parameters.End()) { this.skies = Mogre.StringConverter.ParseBool(ni.Value); } if ((ni = parameters.Find("Shadows")) != parameters.End()) { this.shadows = Mogre.StringConverter.ParseBool(ni.Value); } if ((ni = parameters.Find("Overlays")) != parameters.End()) { this.overlays = Mogre.StringConverter.ParseBool(ni.Value); } if ((ni = parameters.Find("CamPosition")) != parameters.End()) { this.camPosition = Mogre.StringConverter.ParseVector3(ni.Value); } if ((ni = parameters.Find("CamOrientation")) != parameters.End()) { this.camOrientation = Mogre.StringConverter.ParseQuaternion(ni.Value); } if ((ni = parameters.Find("CamClipDistance")) != parameters.End()) { this.camClipDistance = MogreX.StringConverter.ParseVector2(ni.Value); } if ((ni = parameters.Find("CamPolyMode")) != parameters.End()) { this.camPolyMode = (Mogre.PolygonMode)Mogre.StringConverter.ParseInt(ni.Value); OnPropertyChanged("CamPolyMode"); } if ((ni = parameters.Find("CamFOV")) != parameters.End()) { this.camFOV = Mogre.StringConverter.ParseReal(ni.Value); } if ((ni = parameters.Find("Colour")) != parameters.End()) { this.colour = Mogre.StringConverter.ParseColourValue(ni.Value); } this.compositorStorage.Clear(); for (int cx = 0; cx < 100; ++cx) { string searchstr = "Compositor" + Mogre.StringConverter.ToString(cx); if ((ni = parameters.Find(searchstr + "Name")) != parameters.End()) { CompositorPush compData = new CompositorPush(); compData.Name = ni.Value; ni = parameters.Find(searchstr + "Enabled"); compData.Enabled = Mogre.StringConverter.ParseBool(ni.Value); this.compositorStorage.Add(compData); } else { break; } } }