TMesh != TEntity
BlitzMax Forums/MiniB3D Module/TMesh != TEntity
| ||
I'm curious, i'm using camerapick to retrieve a selected entity which it does fine, and it returns TEntity. I then scan through an array of meshes created with the createMesh() command, so these are of type TMesh. I want to compare the two values to match, TMesh extends TEntity, and it does work and all is well - unless I turn on strict compilation. I type like a drunken lout and make more mistakes than Lewis Hamilton in the last 2 races of a season, so I really would preffer to keep strict on. Is there a way around this at all please? |
| ||
Not sure, but wouldn't this work? If TMesh(CameraPick(X,Y)) = MyCreatedMesh Then DoSomething() Edit: I take that back. Just did some testing and found it doesn't work. Although, I still think it's just a matter of casting the types in the right way. Edit2: Actually, it does work! I just forgot to turn on picking for the mesh. Here is a short piece of sample code. SuperStrict Import sidesign.minib3d Graphics3D 800,600 Local MyMesh:TMesh = CreateMesh() Local MySurface:TSurface = CreateSurface(MyMesh) Local Vertex1:Int = AddVertex(MySurface,-1,1,0) Local Vertex2:Int = AddVertex(MySurface,1,1,0) Local Vertex3:Int = AddVertex(MySurface,-1,-1,0) Local Vertex4:Int = AddVertex(MySurface,1,-1,0) AddTriangle(MySurface,Vertex1,Vertex2,Vertex3) AddTriangle(MySurface,Vertex2,Vertex4,vertex3) EntityPickMode MyMesh,2 Local Camera:TCamera = CreateCamera() PositionEntity Camera,0,0,-3 While Not KeyHit(KEY_ESCAPE) And Not AppTerminate() Local PE:TEntity = CameraPick(Camera,MouseX(),MouseY()) If TMesh(PE) = MyMesh TurnEntity camera,0,0,-.1 Print "Hit!" End If RenderWorld Flip Wend |
| ||
Blitz has casting ?! sweet, I never knew. Thank you so much. Mind you it took me over a year to find out it had constructors and destructors ! I turned strict back on, fixed a typo I had not spotted, and for some reason it's not complaining about the TMesh/TEntity conflict any more even though I haven't fixed it yet lolz, oh well, if it complains again I know what to do. Thank you very much. |
| ||
. |