I am trying to save a single game object (although I want the game object to contain children as well) downloaded from the web. First I do this
var s = JSONLevelSerializer.SaveObjectTree( obj );
PlayerPrefs.SetString( "test", s );
PlayerPrefs.Save();
to save. And later (the next time I click play)
JSONLevelSerializer.LoadObjectTree (PlayerPrefs.GetString ("test"));
It indeed loads back the game object but
with the render turned off
without the original texture
How can I save/load game objects with texture?
Related
I have an object in blender + an HDRI background / environment map. I am using cycles to render the object and I have Blender 2.8.
I would like to take multiple pictures of the rendered object (with its background) so that I end up with multiple views of the object (say, about 5/10).
I have seen some posts out there but they're not quite what I want because they just render in solid mode whereas I actually want the whole render.
I am a newbie with blender and I don't even know where to start with this. Thank you
You can just render multiple pictures by rendering, saving the image then moving the camera and repeating the process again. Or, you could render an animation with the camera moving to different angle and setting the output to an image format.
Project Premise
The idea for my THREE.js game is the have the player navigate though a maze of objects and reach an exit. I need collision detection not just for cubes and spheres, but also models imported from Blender. I thought about using RayCasting but I decided to go with Physi.js.
The Problem
,The idea is to give the camera a "body" so that the player can't pass though wall or other objects like they can when they are just a camera object. However, My "player" object seems to loses all of its Physi.js attributes as soon as I give it THREE.PointerLockControls(player). What I'm doing is creating a Physijs.BoxMesh, the player, and adding the camera to that. After that I pass the "player" object to my setupControls() function.
var geometry = new THREE.BoxGeometry( 500, 500, 500 );
var material = new THREE.MeshPhongMaterial( {color: 0x0000FF} );
player = new Physijs.BoxMesh(geometry, material, 1, {restitution: .9, friction: .1});
scene.add(camera);
scene.add(player);
player.add(camera);
//give player control of THIS mesh.
setupControls(player);
The Controls work as expected, I can control the player mesh with the camera stuck to it creating an FPS view, but I when I do this I can still move though walls and other objects. I've even moved the camera back on the Z position to confirm whats going on and I can see that the player mesh is just passing though objects instead of being hindered or knocking them over.
Solutions?
If I remove setupControls(player), then the Physi.js physics begin to work on the player mesh! It will fall from gravity, bounces around and everything. It looks really cool, but now I can't control it! It seems like I can only have one or the other lol. So does anyone know what I could do to solve this problem? Is what I'm preposing even possible? I'm new to THREE.js so any input is much appreciated!
I'm working on a plug in for petrel in I require drawing lines, polygons on a petrel map window, can it be possible using mouse events?
Yes, you can create a process that takes mouse button clicks in a map window and creates lines or polygons from the input picks provided (MapPickedPoint). The process could create a new polyline object in a folder in the Petrel input tree that would be updated with each pick, or you can create your own custom domain object that is updated with each point pick. If you create a custom domain object you will need to also provide the method to draw the object in the map window.
I'm building an API for myself to do 2D skeletal animation.
I have a Bone class
and a Skeleton class.
The Skeleton creates a root bone and then subsequent bones are added via the Skeleton's add method by providing the parent bone.
What I now want to do is add animation and frames.
What I was thinking of, is a class that can load and interpolate animations. So it would be an object that would load an animation. It would then, at each frame, take in a Skeleton and modify the Skeleton accordingly.
Is this a good design? Should an animation take in a Skeleton, or should a Skeleton take in an animation and apply it onto itself?
It's best to create an Animation that makes use of a Skeleton instead of the opposite. This because, logically speaking, the object Skeleton does not require an Animation to live, but an Animation strongly requires a Skeleton.
So you can couple those elements in the Animation itself. Do not put too much logics in the objects, and try to put it just where necessary.
Presumably every bone has a 2d position/angle and an animation is a collection of frames where each frame is a collection of bone identifiers and position/angles?
Then you might consider something like
public class Skeleton
{
public List<Bone> Bones {get;set;}
public void Animate(Animation animation)
{
foreach(Bone bone in Bones)
{
bone.Displace(animation.Displacements.FirstOrDefault(o=>o.BoneId == bone.BoneID));
}
}
}
I would create an Animation class containing a std::vector<Skeleton> data member that you can use to manipulate individual Skeleton objects on each frame or interpolate across multiple Skeleton objects in the vector from keyframes. Then when you "play" the animation, you merely have to iterate over the vector, calling out each Skeleton object, and pass that to some other function or class that will display the results on-screen (or do whatever else the Skeleton can be useful for, such as warping a mesh, etc.)
Having an animation object will make it much easier to manipulate the frames of the animation, allowing you to remove/replace frames, etc. Otherwise if you try to pile all of this functionality into a Skeleton object, then you're going to find there's a lot of baggage when trying to manipulate individual aspects of the Skeleton separately from the animation sequence (i.e. suppose you need to change the hierarchy of the Skeleton for a segment of frames, etc.? ... that would be very easy if there is a Skeleton on each frame, but not if you have a monolithic Skelton object).
i'm work on a buffer for load very large pictures ( screen size) to single surface.
The idea is to animate a lot of pictures ( more than the video memory can store ) frame by frame.
I have create a code for make a buffer but i have a big problem with the loading time of bitmap.
My code work a this :
I load an array of local bitmap files path.
I (think ) i preload my bitmap datas in memory. I'm using a thread for store a CGImageRef in an NSArray for all my picture ( 40 for moment )
In a second thread, the code look another NSArray for determine if is empty of not, if is empty, i bind my cgimageRef to the video memory by creating textures. ( use sharedgroup for this)
This array store the adress of 20 textures names, and it's use directly by openGL for draw the surface. this array is my (buffer)
When i play my animation, i delete old textures from my "buffer" and my thread ( at point 3) load a new texture.
It's work great, but is really slow, and after few second, the animation lack.
Can you help me for optimise my code ?
Depending on device and iOS version glTexImage is just slow.
With iOS 4 performance was improved so that you can expect decent speed on 2nd gen devices too, and with decent I mean one or two texture uploads per frame...
Anyway:
Use glTexSubImage and reuse already created texture-IDs.
Also, when using glTex(Sub)Image, try to use a texture-ID that wasn't used for rendering in that frame. I mean: add some kind of texture-ID-doublebuffering.
I asume you do all your GL stuff in the same thread, if not change it.